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