MPS-Basic
Loading...
Searching...
No Matches
explicit.cpp
Go to the documentation of this file.
1#include "explicit.hpp"
2
3#include "../refvalues.hpp"
4
6
7Explicit::Explicit(double re, double soundSpeed, int dimension, double particleDistance) {
8 this->soundSpeed = soundSpeed;
9 this->n0 = RefValues(dimension, particleDistance, re).n0;
10}
11
14
15std::vector<double> Explicit::calc(Particles& particles) {
16 std::vector<double> pressure;
17 pressure.resize(particles.size());
18
19#pragma omp parallel for
20 for (const auto& pi : particles) {
21 if (pi.type == ParticleType::Ghost) {
22 pressure[pi.id] = 0;
23 } else {
24 auto ni = pi.numberDensity;
25 auto c = this->soundSpeed;
26 auto rho = pi.density;
27
28 if (ni > n0) {
29 pressure[pi.id] = c * c * rho * (ni - n0) / n0;
30 } else {
31 pressure[pi.id] = 0;
32 }
33 }
34 }
35
36 return pressure;
37}
A collection of particles.
Definition particles.hpp:10
int size() const
Get the number of particles.
Definition particles.cpp:21
Class for explicit pressure calculation.
Definition explicit.hpp:14
Explicit(double n0, double soundSpeed, int dimension, double particleDistance)
Definition explicit.cpp:7
std::vector< double > calc(Particles &particles) override
calculate pressure
Definition explicit.cpp:15
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
@ Ghost
Ghost particle (outside of the domain, not used for calculation)