9#include <yaml-cpp/yaml.h>
15namespace fs = std::filesystem;
41 auto extension = particlesPath.extension();
42 if (extension ==
".csv") {
43 return std::make_unique<ParticlesLoader::Csv>();
44 }
else if (extension ==
".prof") {
45 return std::make_unique<ParticlesLoader::Prof>();
46 }
else if (extension ==
".vtu") {
47 return std::make_unique<ParticlesLoader::Vtu>();
49 cerr <<
"unsupported file format: " << particlesPath.extension() << endl;
61 auto outputFilePath = outputDirectory / inputFilePath.filename();
62 if (fs::exists(outputFilePath)) {
63 cerr <<
"file " << outputFilePath <<
" already exists in the output directory" << endl;
66 fs::copy_file(inputFilePath, outputFilePath);
71 YAML::Node yaml = YAML::LoadFile(settingPath.string());
76 YAML::Node comp = yaml[
"computationalConditions"];
77 s.
dim = comp[
"dim"].as<
int>();
79 s.
dt = comp[
"dt"].as<
double>();
80 s.
endTime = comp[
"endTime"].as<
double>();
85 YAML::Node phys = yaml[
"physicalProperties"];
90 YAML::Node grav = yaml[
"gravity"];
91 s.
gravityMethod = grav[
"method"] ? grav[
"method"].as<std::string>() :
"xyz";
93 s.
gravity[0] = grav[
"xyz"][0].as<
double>();
94 s.
gravity[1] = grav[
"xyz"][1].as<
double>();
95 s.
gravity[2] = grav[
"xyz"][2].as<
double>();
97 s.
gNorm = grav[
"normAndAngle"][
"norm"] ? grav[
"normAndAngle"][
"norm"].as<
double>() : 0.0;
98 s.
gAngle = grav[
"normAndAngle"][
"angle"] ? grav[
"normAndAngle"][
"angle"].as<
double>() : 0.0;
100 cerr <<
"unsupported gravity method: " << s.
gravityMethod << endl;
105 YAML::Node surf = yaml[
"surfaceDetection"];
111 YAML::Node press = yaml[
"pressureCalculation"];
113 if (press[
"method"].as<std::string>() ==
"Implicit") {
117 }
else if (press[
"method"].as<std::string>() ==
"Explicit") {
119 s.
soundSpeed = press[
"explicit"][
"soundSpeed"].as<
double>();
121 cerr <<
"unsupported pressure calculation method: " << press[
"method"].as<std::string>() << endl;
126 YAML::Node coll = yaml[
"collision"];
131 YAML::Node re = yaml[
"effectiveRadius"];
138 YAML::Node dom = yaml[
"domain"];
150 YAML::Node io = yaml[
"io"];
151 auto yamlDir = settingPath.parent_path();
152 auto relativeProfPath = io[
"particlesPath"].as<std::string>();
153 s.
particlesPath = fs::weakly_canonical(yamlDir / relativeProfPath);
156 s.
outputVtkInBinary = io[
"outputVtkInBinary"] ? io[
"outputVtkInBinary"].as<
bool>() :
false;
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 vector when using xyz input.
std::string gravityMethod
Method for gravity input.
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.
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.
double gNorm
Norm of gravity when using norm and angle.
bool surfaceDetection_particleDistribution
flag for free surface detection based on particle distribution
double gAngle
Angle of gravity when using norm and angle.
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.