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, WeightType weightType) {
10 assert(dim == 2 || dim == 3);
11 assert(particleDistance < re);
12
13 this->weight = Weight(weightType);
14
15 int iZ_start = -4;
16 int iZ_end = 5;
17 if (dim == 2) {
18 iZ_start = 0;
19 iZ_end = 1;
20 }
21
22 this->n0 = 0.0;
23 this->lambda = 0.0;
24 for (int iX = -4; iX < 5; iX++) {
25 for (int iY = -4; iY < 5; iY++) {
26 for (int iZ = iZ_start; iZ < iZ_end; iZ++) {
27 if (((iX == 0) && (iY == 0)) && (iZ == 0))
28 continue;
29
30 double xj = particleDistance * (double) (iX);
31 double yj = particleDistance * (double) (iY);
32 double zj = particleDistance * (double) (iZ);
33 double dis2 = xj * xj + yj * yj + zj * zj;
34 double dis = sqrt(dis2);
35 n0 += weight.weightFn(dis, re);
36 lambda += dis2 * weight.weightFn(dis, re);
37 }
38 }
39 }
40 this->lambda /= this->n0;
41}
Weight weight
weight function instance
Definition refvalues.hpp:26
RefValues()=default
double n0
reference value of number density for source term of pressure Poisson equation
Definition refvalues.hpp:11
double lambda
coefficient for laplacian
Definition refvalues.hpp:12
Provides a weight function.
Definition weight.hpp:15
double weightFn(double dis, double re)
Weight function for MPS method.
Definition weight.cpp:10
WeightType
Definition weight.hpp:5