12 double relaxationCoefficient,
13 double compressibility,
14 double n0_forNumberDensity,
15 double n0_forLaplacian,
17 double reForLaplacian,
18 double reForNumberDensity
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;
57 std::vector<double> pressureStdVec(pressure.data(), pressure.data() + pressure.size());
58 return pressureStdVec;
79#pragma omp parallel for
80 for (
auto& pi : particles) {
81 if (dirichletBoundaryCondition.
contains(pi.id)) {
85 sourceTerm[pi.id] = gamma * (1.0 / (
dt *
dt)) * ((pi.numberDensity - n0) / n0);
105 for (
auto& pi : particles) {
106 if (dirichletBoundaryCondition.
contains(pi.id)) {
113 double coefficient_ii = 0.0;
114 for (
auto& neighbor : pi.neighbors) {
115 auto& pj = particles[neighbor.id];
120 if (neighbor.distance < re) {
121 double coefficient_ij = a *
weight(neighbor.distance, re) / pi.density;
123 coefficient_ii += coefficient_ij;
A collection of particles.
int size() const
Get the number of particles.
Dirichlet boundary condition.
double value(int id) const
Get the boundary condition value.
bool contains(int id) const
Check if the boundary condition contains the particle.
Class for setting up and solving pressure Poisson equation.
double relaxationCoefficient
double reForNumberDensity
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.
std::vector< double > solve()
Solve pressure Poisson equation.
PressurePoissonEquation()=default
void setup(const Particles &particles, const DirichletBoundaryCondition &dirichletBoundaryCondition)
Setup pressure Poisson equation.
void setMatrixTriplets(const Particles &particles, const DirichletBoundaryCondition &dirichletBoundaryCondition)
Set the matrix triplets for the pressure Poisson equation.
Eigen::VectorXd sourceTerm
Source term for pressure Poisson equation.
std::vector< Eigen::Triplet< double > > matrixTriplets
Triplets for coefficient matrix.
double n0_forNumberDensity
double weight(double dis, double re)
Wight function for MPS method presented by Koshizuka and Oka, 1996