8#include <yaml-cpp/yaml.h>
14namespace fs = std::filesystem;
40 auto extension = particlesPath.extension();
41 if (extension ==
".csv") {
42 return std::make_unique<ParticlesLoader::Csv>();
43 }
else if (extension ==
".prof") {
44 return std::make_unique<ParticlesLoader::Prof>();
46 cerr <<
"unsupported file format: " << particlesPath.extension() << endl;
58 auto outputFilePath = outputDirectory / inputFilePath.filename();
59 if (fs::exists(outputFilePath)) {
60 cerr <<
"file " << outputFilePath <<
" already exists in the output directory" << endl;
63 fs::copy_file(inputFilePath, outputFilePath);
68 YAML::Node yaml = YAML::LoadFile(settingPath.string());
73 s.
dim = yaml[
"dim"].as<
int>();
75 s.
dt = yaml[
"dt"].as<
double>();
76 s.
endTime = yaml[
"endTime"].as<
double>();
86 s.
gravity[0] = yaml[
"gravity"][0].as<
double>();
87 s.
gravity[1] = yaml[
"gravity"][1].as<
double>();
88 s.
gravity[2] = yaml[
"gravity"][2].as<
double>();
94 yaml[
"surfaceDetection-particleDistribution-threshold"].as<
double>();
102 s.
soundSpeed = yaml[
"soundSpeed"].as<
double>();
115 s.
domain.
xMin = yaml[
"domainMin"][0].as<
double>();
116 s.
domain.
xMax = yaml[
"domainMax"][0].as<
double>();
117 s.
domain.
yMin = yaml[
"domainMin"][1].as<
double>();
118 s.
domain.
yMax = yaml[
"domainMax"][1].as<
double>();
119 s.
domain.
zMin = yaml[
"domainMin"][2].as<
double>();
120 s.
domain.
zMax = yaml[
"domainMax"][2].as<
double>();
126 auto yamlDir = settingPath.parent_path();
127 auto relativeProfPath = yaml[
"particlesPath"].as<std::string>();
128 s.
particlesPath = fs::weakly_canonical(yamlDir / relativeProfPath);
132 if (yaml[
"outputVtkInBinary"]) {
double xMax
maximum x coordinate of the domain
double zMin
minimum z coordinate of the domain
double zMax
maximum z coordinate of the domain
double xMin
minimum x coordinate of the domain
double yMin
minimum y coordinate of the domain
double yMax
maximum y coordinate of the domain
std::unique_ptr< ParticlesLoader::Interface > particlesLoader
std::unique_ptr< ParticlesLoader::Interface > getParticlesLoader(const fs::path &particlesPath)
Get the Particles Loader object according to the input file extension.
void copyInputFileToOutputDirectory(const fs::path &inputFilePath, const fs::path &outputDirectory)
Copy the input file to the output directory.
Input load(const fs::path &settingPath, const fs::path &outputDirectory)
Load the setting file and the particle file.
Settings loadSettingYaml(const fs::path &settingPath)
Struct for settings of calculation.
Eigen::Vector3d gravity
Gravity.
double reMax
Maximum of effective radius.
double outputPeriod
Output period of the simulation.
double soundSpeed
Speed of sound for Explicit method.
double compressibility
Compressibility of the fluid for Implicit method.
double collisionDistance
Distance for collision detection.
int numPhysicalCores
Number of cores to calculate.
double particleDistance
Initial distance between particles.
std::filesystem::path particlesPath
Path for input particle file.
bool outputVtkInBinary
Flag for saving VTK file in binary format.
double endTime
End time of the simulation.
int dim
Dimension of the simulation.
double relaxationCoefficientForPressure
Relaxation coefficient for pressure for Implicit method.
double re_forNumberDensity
Effective radius for number density.
bool surfaceDetection_particleDistribution
flag for free surface detection based on particle distribution
double defaultDensity
default density for fluid and wall particles.
std::string pressureCalculationMethod
Method for pressure calculation.
double surfaceDetection_particleDistribution_threshold
double kinematicViscosity
Kinematic viscosity.
double cflCondition
CFL condition.
double coefficientOfRestitution
Coefficient of restitution.
double surfaceDetection_numberDensity_threshold
threshold ratio of number density for free surface detection
double re_forGradient
Effective radius for gradient.
Domain domain
domain of the simulation
double re_forLaplacian
Effective radius for Laplacian.