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
5
using
PressureCalculator::Explicit
;
6
7
Explicit::Explicit
(
double
re,
double
soundSpeed,
int
dimension,
double
particleDistance) {
8
this->soundSpeed =
soundSpeed
;
9
this->
n0
=
RefValues
(dimension, particleDistance, re).
n0
;
10
}
11
12
Explicit::~Explicit
() {
13
}
14
15
std::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
}
Particles
A collection of particles.
Definition
particles.hpp:10
Particles::size
int size() const
Get the number of particles.
Definition
particles.cpp:21
PressureCalculator::Explicit
Class for explicit pressure calculation.
Definition
explicit.hpp:14
PressureCalculator::Explicit::~Explicit
~Explicit() override
Definition
explicit.cpp:12
PressureCalculator::Explicit::Explicit
Explicit(double n0, double soundSpeed, int dimension, double particleDistance)
Definition
explicit.cpp:7
PressureCalculator::Explicit::soundSpeed
double soundSpeed
Definition
explicit.hpp:27
PressureCalculator::Explicit::calc
std::vector< double > calc(Particles &particles) override
calculate pressure
Definition
explicit.cpp:15
PressureCalculator::Explicit::n0
double n0
Definition
explicit.hpp:26
RefValues
Struct for reference values of MPS method.
Definition
refvalues.hpp:8
RefValues::n0
double n0
reference value of number density for source term of pressure Poisson equation
Definition
refvalues.hpp:10
explicit.hpp
ParticleType::Ghost
@ Ghost
Ghost particle (outside of the domain, not used for calculation)
refvalues.hpp
src
pressure_calculator
explicit.cpp
Generated by
1.12.0