MPS-Basic
Loading...
Searching...
No Matches
refvalues.cpp
Go to the documentation of this file.
1#include "refvalues.hpp"
2
3#include "weight.hpp"
4
5#include <cassert>
6#include <cmath>
7#include <utility>
8
9RefValues::RefValues(int dim, double particleDistance, double re) {
10 assert(dim == 2 || dim == 3);
11 assert(particleDistance < re);
12 int iZ_start = -4;
13 int iZ_end = 5;
14 if (dim == 2) {
15 iZ_start = 0;
16 iZ_end = 1;
17 }
18
19 this->n0 = 0.0;
20 this->lambda = 0.0;
21 for (int iX = -4; iX < 5; iX++) {
22 for (int iY = -4; iY < 5; iY++) {
23 for (int iZ = iZ_start; iZ < iZ_end; iZ++) {
24 if (((iX == 0) && (iY == 0)) && (iZ == 0))
25 continue;
26
27 double xj = particleDistance * (double) (iX);
28 double yj = particleDistance * (double) (iY);
29 double zj = particleDistance * (double) (iZ);
30 double dis2 = xj * xj + yj * yj + zj * zj;
31 double dis = sqrt(dis2);
32 n0 += weight(dis, re);
33 lambda += dis2 * weight(dis, re);
34 }
35 }
36 }
37 this->lambda /= this->n0;
38}
RefValues()=default
double n0
reference value of number density for source term of pressure Poisson equation
Definition refvalues.hpp:10
double lambda
coefficient for laplacian
Definition refvalues.hpp:11
double weight(double dis, double re)
Wight function for MPS method presented by Koshizuka and Oka, 1996
Definition weight.cpp:5