Class for setting up and solving pressure Poisson equation.
More...
#include <pressure_poisson_equation.hpp>
Class for setting up and solving pressure Poisson equation.
Definition at line 14 of file pressure_poisson_equation.hpp.
◆ PressurePoissonEquation() [1/2]
PressureCalculator::PressurePoissonEquation::PressurePoissonEquation |
( |
| ) |
|
|
default |
◆ PressurePoissonEquation() [2/2]
PressurePoissonEquation::PressurePoissonEquation |
( |
int | dimension, |
|
|
double | dt, |
|
|
double | relaxationCoefficient, |
|
|
double | compressibility, |
|
|
double | n0_forNumberDensity, |
|
|
double | n0_forLaplacian, |
|
|
double | lambda0, |
|
|
double | reForLaplacian, |
|
|
double | reForNumberDensity ) |
Definition at line 9 of file pressure_poisson_equation.cpp.
19 {
29}
double relaxationCoefficient
double reForNumberDensity
double n0_forNumberDensity
◆ setup()
Setup pressure Poisson equation.
- Parameters
-
particles | Particles |
isPressureUpdateTarget | Function that gets a particle and returns true if the particle is a target for pressure update |
Definition at line 31 of file pressure_poisson_equation.cpp.
33 {
35
40}
int size() const
Get the number of particles.
void setSourceTerm(const Particles &particles, const DirichletBoundaryCondition &dirichletBoundaryCondition)
Set the source term for the pressure Poisson equation.
Eigen::SparseMatrix< double, Eigen::RowMajor > coefficientMatrix
Coefficient matrix for pressure Poisson equation.
void setMatrixTriplets(const Particles &particles, const DirichletBoundaryCondition &dirichletBoundaryCondition)
Set the matrix triplets for the pressure Poisson equation.
std::vector< Eigen::Triplet< double > > matrixTriplets
Triplets for coefficient matrix.
◆ solve()
std::vector< double > PressurePoissonEquation::solve |
( |
| ) |
|
Solve pressure Poisson equation.
- Returns
- Calculated pressure. The size of the vector is the same as the number of particles.
Definition at line 42 of file pressure_poisson_equation.cpp.
42 {
43 using std::cerr;
44 using std::endl;
45
46 Eigen::BiCGSTAB<Eigen::SparseMatrix<double, Eigen::RowMajor>> solver;
48 Eigen::VectorXd pressure = solver.solve(
sourceTerm);
49 if (solver.info() != Eigen::Success) {
50 cerr << "Pressure calculation failed." << endl;
51 std::exit(-1);
52 }
53
54
55
56
57 std::vector<double> pressureStdVec(pressure.data(), pressure.data() + pressure.size());
58 return pressureStdVec;
59}
Eigen::VectorXd sourceTerm
Source term for pressure Poisson equation.
◆ resetEquation()
void PressurePoissonEquation::resetEquation |
( |
| ) |
|
|
private |
◆ setSourceTerm()
Set the source term for the pressure Poisson equation.
- Parameters
-
particles | Particles |
isPressureUpdateTarget | Function that gets a particle and returns true if the particle is a target for pressure update |
Definition at line 73 of file pressure_poisson_equation.cpp.
75 {
78
79#pragma omp parallel for
80 for (auto& pi : particles) {
81 if (dirichletBoundaryCondition.contains(pi.id)) {
82
83 sourceTerm[pi.id] = dirichletBoundaryCondition.value(pi.id);
84 } else {
85 sourceTerm[pi.id] = gamma * (1.0 / (
dt *
dt)) * ((pi.numberDensity - n0) / n0);
86 }
87 }
88}
◆ setMatrixTriplets()
Set the matrix triplets for the pressure Poisson equation.
Coefficient matrix is a sparse matrix and made by triplets. Triplets are the elements of the matrix that are not zero and represented by the row index, column index, and the value of the element. This function sets the triplets for the pressure Poisson equation.
- Parameters
-
particles | Particles |
isPressureUpdateTarget | Function that gets a particle and returns true if the particle is a target for pressure update |
Definition at line 99 of file pressure_poisson_equation.cpp.
101 {
104
105 for (auto& pi : particles) {
106 if (dirichletBoundaryCondition.contains(pi.id)) {
107
108
110 continue;
111 }
112
113 double coefficient_ii = 0.0;
114 for (auto& neighbor : pi.neighbors) {
115 auto& pj = particles[neighbor.id];
117 continue;
118 }
119
120 if (neighbor.distance < re) {
121 double coefficient_ij = a *
weight(neighbor.distance, re) / pi.density;
123 coefficient_ii += coefficient_ij;
124 }
125 }
128 }
129}
double weight(double dis, double re)
Wight function for MPS method presented by Koshizuka and Oka, 1996
◆ dimension
int PressureCalculator::PressurePoissonEquation::dimension |
|
private |
◆ dt
double PressureCalculator::PressurePoissonEquation::dt |
|
private |
◆ relaxationCoefficient
double PressureCalculator::PressurePoissonEquation::relaxationCoefficient |
|
private |
◆ compressibility
double PressureCalculator::PressurePoissonEquation::compressibility |
|
private |
◆ n0_forNumberDensity
double PressureCalculator::PressurePoissonEquation::n0_forNumberDensity |
|
private |
◆ n0_forLaplacian
double PressureCalculator::PressurePoissonEquation::n0_forLaplacian |
|
private |
◆ lambda0
double PressureCalculator::PressurePoissonEquation::lambda0 |
|
private |
◆ reForLaplacian
double PressureCalculator::PressurePoissonEquation::reForLaplacian |
|
private |
◆ reForNumberDensity
double PressureCalculator::PressurePoissonEquation::reForNumberDensity |
|
private |
◆ particlesCount
size_t PressureCalculator::PressurePoissonEquation::particlesCount |
|
private |
◆ matrixTriplets
std::vector<Eigen::Triplet<double> > PressureCalculator::PressurePoissonEquation::matrixTriplets |
|
private |
◆ coefficientMatrix
Eigen::SparseMatrix<double, Eigen::RowMajor> PressureCalculator::PressurePoissonEquation::coefficientMatrix |
|
private |
◆ sourceTerm
Eigen::VectorXd PressureCalculator::PressurePoissonEquation::sourceTerm |
|
private |
The documentation for this class was generated from the following files: