17 Eigen::Vector3d& gravity,
18 std::unique_ptr<PressureCalculator::Interface>&& pressureCalculator,
19 std::unique_ptr<SurfaceDetector::Interface>&& surfaceDetector
68 particle.pressure = pressures[particle.id];
78 auto pressures = explicitPressureCalculator->calc(
particles);
80 particle.pressure = pressures[particle.id];
88#pragma omp parallel for
93 p.acceleration.setZero();
103#pragma omp parallel for
108 Eigen::Vector3d viscosityTerm = Eigen::Vector3d::Zero();
110 for (
auto& neighbor : pi.neighbors) {
113 if (neighbor.distance < re) {
115 viscosityTerm += (pj.velocity - pi.velocity) * w;
120 pi.acceleration += viscosityTerm;
125#pragma omp parallel for
131 p.acceleration.setZero();
140 for (
auto& neighbor : pi.neighbors) {
147 double invMi = pi.inverseDensity();
149 double mass = 1.0 / (invMi + invMj);
151 Eigen::Vector3d normal = (pj.
position - pi.position).normalized();
152 double relVel = (pj.
velocity - pi.velocity).dot(normal);
153 double impulse = 0.0;
156 pi.velocity -= impulse * invMi * normal;
157 pj.
velocity += impulse * invMj * normal;
160 double positionImpulse = depth * mass;
161 pi.position -= positionImpulse * invMi * normal;
162 pj.
position += positionImpulse * invMj * normal;
172#pragma omp parallel for
174 pi.numberDensity = 0.0;
179 for (
auto& neighbor : pi.neighbors)
185#pragma omp parallel for
187 p.minimumPressure = p.pressure;
194 for (
auto& neighbor : pi.neighbors) {
201 if (neighbor.distance < re) {
202 pi.minimumPressure = std::min(pi.minimumPressure, pj.
pressure);
212#pragma omp parallel for
217 Eigen::Vector3d grad = Eigen::Vector3d::Zero();
218 for (
auto& neighbor : pi.neighbors) {
223 if (neighbor.distance < re) {
226 double dist2 = (pj.
position - pi.position).squaredNorm();
228 ? (pj.
pressure - pi.minimumPressure) / dist2
229 : (pj.
pressure + pi.pressure) / dist2;
230 grad += (pj.
position - pi.position) * pij * w;
234 pi.acceleration -= grad / pi.density;
239#pragma omp parallel for
246 p.acceleration.setZero();
262 cerr <<
"ERROR: Courant number is larger than CFL condition. Courant = " <<
courant << endl;
void setMinimumPressure(const double &re)
set minimum pressure for pressure gradient calculation
void calViscosity(const double &re)
calculate viscosity term of Navier-Stokes equation
std::unique_ptr< PressureCalculator::Interface > pressureCalculator
Interface for pressure calculation.
void moveParticleUsingPressureGradient()
move particles in correction step
Settings settings
Settings for the simulation.
Weight weightGrad
Weight function instance for the gradient calculation.
double courant
Maximum courant number among all particles.
void calPressureGradient(const double &re)
calculate pressure gradient term
RefValues refValuesForLaplacian
Reference values for the simulation ( , )
void moveParticle()
move particles in prediction step
RefValues refValuesForNumberDensity
Reference values for the simulation ( , )
void calCourant()
calculate Courant number
void collision()
calculate collision between particles when they are too close
Eigen::Vector3d gravity
Gravity vector for the simulation.
NeighborSearcher neighborSearcher
Neighbor searcher for neighbor search.
std::unique_ptr< SurfaceDetector::Interface > surfaceDetector
Interface for free surface detection.
void calNumberDensity(const double &re)
calculate number density of each particle
RefValues refValuesForGradient
Reference values for the simulation ( , )
Weight weight
Weight function instance except for gradient calculation.
void calGravity()
calculate gravity term
Particles particles
Particles in the simulation.
Domain domain
Domain of the simulation.
void setNeighbors(Particles &particles)
Class for particle in MPS method.
double inverseDensity() const
calculate inverse of density for collision
Eigen::Vector3d position
position of the particle
double pressure
pressure of the particle
int id
index of the particle
double minimumPressure
minimum pressure of the particle
Eigen::Vector3d velocity
velocity of the particle
ParticleType type
type of the particle
int size() const
Get the number of particles.
Class for explicit pressure calculation.
Struct for reference values of MPS method.
double n0
reference value of number density for source term of pressure Poisson equation
double lambda
coefficient for laplacian
Provides a weight function.
double weightFn(double dis, double re)
Weight function for MPS method.
@ Ghost
Ghost particle (outside of the domain, not used for calculation)
@ DummyWall
Dummy wall particle (pressure is not calculated)
double reMax
Maximum of effective radius.
double collisionDistance
Distance for collision detection.
double particleDistance
Initial distance between particles.
int dim
Dimension of the simulation.
double re_forNumberDensity
Effective radius for number density.
std::string pressureCalculationMethod
Method for pressure calculation.
double kinematicViscosity
Kinematic viscosity.
double cflCondition
CFL condition.
double coefficientOfRestitution
Coefficient of restitution.
double re_forGradient
Effective radius for gradient.
Domain domain
domain of the simulation
double re_forLaplacian
Effective radius for Laplacian.