MPS-Basic
Loading...
Searching...
No Matches
PressureCalculator::Explicit Class Reference

Class for explicit pressure calculation. More...

#include <explicit.hpp>

Inheritance diagram for PressureCalculator::Explicit:
Collaboration diagram for PressureCalculator::Explicit:

Public Member Functions

std::vector< double > calc (Particles &particles) override
 calculate pressure
 
 ~Explicit () override
 
 Explicit (double n0, double soundSpeed, int dimension, double particleDistance)
 
- Public Member Functions inherited from PressureCalculator::Interface
virtual ~Interface ()
 destructor
 

Private Attributes

double n0
 
double soundSpeed
 

Detailed Description

Class for explicit pressure calculation.

This class calculates pressure explicitly.

Definition at line 14 of file explicit.hpp.

Constructor & Destructor Documentation

◆ ~Explicit()

Explicit::~Explicit ( )
override

Definition at line 12 of file explicit.cpp.

12 {
13}

◆ Explicit()

Explicit::Explicit ( double n0,
double soundSpeed,
int dimension,
double particleDistance )

Definition at line 7 of file explicit.cpp.

7 {
9 this->n0 = RefValues(dimension, particleDistance, re).n0;
10}
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

Member Function Documentation

◆ calc()

std::vector< double > Explicit::calc ( Particles & particles)
overridevirtual

calculate pressure

Parameters
particlesparticles

Implements PressureCalculator::Interface.

Definition at line 15 of file explicit.cpp.

15 {
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}
int size() const
Get the number of particles.
Definition particles.cpp:21
@ Ghost
Ghost particle (outside of the domain, not used for calculation)
Here is the call graph for this function:

Member Data Documentation

◆ n0

double PressureCalculator::Explicit::n0
private

Definition at line 26 of file explicit.hpp.

◆ soundSpeed

double PressureCalculator::Explicit::soundSpeed
private

Definition at line 27 of file explicit.hpp.


The documentation for this class was generated from the following files: