MPS-Basic
Loading...
Searching...
No Matches
distribution.cpp
Go to the documentation of this file.
1#include "distribution.hpp"
2
3#include <Eigen/Dense>
4
6
7bool Distribution::isFreeSurface(const Particles& particles, const Particle& particle) {
8 // main: surface, sub: surface -> surface (true)
9 // main: surface, sub: inner -> inner (false)
10 // main: inner, sub: surface -> inner (false)
11 // main: inner, sub: inner -> inner (false)
12 if (mainDetection(particles, particle)) {
13 return subDetection(particles, particle);
14 } else {
15 return false;
16 }
17}
18
23bool Distribution::mainDetection(const Particles& particles, const Particle& particle) {
25}
26
31bool Distribution::subDetection(const Particles& particles, const Particle& particle) {
32 if (particle.neighbors.empty()) {
33 // If the particle has no neighbors, it is considered to be a free surface.
34 return true;
35 }
36
37 Eigen::Vector3d rij_sum = Eigen::Vector3d::Zero();
38 for (auto& neighbor : particle.neighbors) {
39 auto& pj = particles[neighbor.id];
40
41 rij_sum += pj.position - particle.position;
42 }
43
45
46 if (abs(rij_sum.x()) > threshold) {
47 return true;
48
49 } else if (abs(rij_sum.y()) > threshold) {
50 return true;
51
52 } else if (abs(rij_sum.z()) > threshold) {
53 return true;
54
55 } else {
56 return false;
57 }
58}
59
61 double n0, double particleDistance, double distributionThresholdRatio, double numberDensityThresholdRatio
62)
63 : n0(n0), particleDistance(particleDistance), distributionThresholdRatio(distributionThresholdRatio),
64 numberDensityThresholdRatio(numberDensityThresholdRatio) {
65}
66
Class for particle in MPS method.
Definition particle.hpp:47
Eigen::Vector3d position
position of the particle
Definition particle.hpp:55
double numberDensity
number density of the particle
Definition particle.hpp:59
std::vector< Neighbor > neighbors
neighbors of the particle
Definition particle.hpp:66
A collection of particles.
Definition particles.hpp:10
Detects free surface based on number density and assists evaluation by particle distribution.
double distributionThresholdRatio
Threshold ratio for particle distribution.
bool mainDetection(const Particles &particles, const Particle &particle)
Main detection based on number density.
double particleDistance
Particle distance.
double numberDensityThresholdRatio
Threshold ratio for number density.
bool subDetection(const Particles &particles, const Particle &particle)
Sub detection based on particle distribution.
double n0
Reference value for number density.
bool isFreeSurface(const Particles &particles, const Particle &particle) override
Whether the particle is on the free surface.
Distribution(double n0, double particleDistance, double distributionThresholdRatio, double numberDensityThresholdRatio)