MPS-Basic
Loading...
Searching...
No Matches
mps_factory.cpp
Go to the documentation of this file.
1#include "mps_factory.hpp"
2
8
10
12 RefValues refValuesForNumberDensity(
13 input.settings.dim,
16 );
17
18 std::unique_ptr<SurfaceDetector::Interface> surfaceDetector;
20 surfaceDetector.reset(new SurfaceDetector::Distribution(
21 refValuesForNumberDensity.n0,
25 ));
26 } else {
27 surfaceDetector.reset(new SurfaceDetector::NumberDensity(
29 refValuesForNumberDensity.n0
30 ));
31 }
32
33 std::unique_ptr<DirichletBoundaryConditionGenerator::Interface> DirichletBoundaryConditionGenerator;
35 new DirichletBoundaryConditionGenerator::FreeSurface(std::move(surfaceDetector))
36 );
37
38 std::unique_ptr<PressureCalculator::Interface> pressureCalculator;
39 if (input.settings.pressureCalculationMethod == "Implicit") {
40 pressureCalculator.reset(new PressureCalculator::Implicit(
41 input.settings.dim,
45 input.settings.dt,
49 ));
50 } else if (input.settings.pressureCalculationMethod == "Explicit") {
51 pressureCalculator.reset(new PressureCalculator::Explicit(
53 input.settings.soundSpeed,
54 input.settings.dim,
56 ));
57 } else {
58 std::cerr << "Invalid pressure calculation method: " << input.settings.pressureCalculationMethod << std::endl;
59 std::cerr << "Please select either Implicit or Explicit." << std::endl;
60 std::exit(-1);
61 }
62
63 return MPS(input, std::move(pressureCalculator), std::move(surfaceDetector));
64}
static MPS create(const Input &input)
MPS simulation class.
Definition mps.hpp:25
Dirichlet Boundary Condition Generator that sets the free surface pressure to 0.
Class for explicit pressure calculation.
Definition explicit.hpp:14
Class for implicit pressure calculation.
Definition implicit.hpp:21
Struct for reference values of MPS method.
Definition refvalues.hpp:8
double n0
reference value of number density for source term of pressure Poisson equation
Definition refvalues.hpp:10
Detects free surface based on number density and assists evaluation by particle distribution.
Detects free surface based on the number density.
Represents the input data for MPS simulation.
Definition input.hpp:12
Settings settings
Settings for the simulation.
Definition input.hpp:13
double soundSpeed
Speed of sound for Explicit method.
Definition settings.hpp:47
double compressibility
Compressibility of the fluid for Implicit method.
Definition settings.hpp:44
double particleDistance
Initial distance between particles.
Definition settings.hpp:18
int dim
Dimension of the simulation.
Definition settings.hpp:17
double relaxationCoefficientForPressure
Relaxation coefficient for pressure for Implicit method.
Definition settings.hpp:45
double re_forNumberDensity
Effective radius for number density.
Definition settings.hpp:54
bool surfaceDetection_particleDistribution
flag for free surface detection based on particle distribution
Definition settings.hpp:38
std::string pressureCalculationMethod
Method for pressure calculation.
Definition settings.hpp:42
double surfaceDetection_particleDistribution_threshold
Definition settings.hpp:39
double surfaceDetection_numberDensity_threshold
threshold ratio of number density for free surface detection
Definition settings.hpp:36
double dt
Time step.
Definition settings.hpp:19
double re_forLaplacian
Effective radius for Laplacian.
Definition settings.hpp:56