16 #include "../coordinates/coordinates.hpp"
17 #include "../debugger/debugger.hpp"
18 #include "../globals.hpp"
24 void Particles::Particulate(std::vector<MaterialPoint> &mp,
26 MeshBlock *pmb = pmy_block;
27 pmb->pdebug->Call(
"Particles::Particulate-" + myname);
31 std::vector<MaterialPoint> mpb;
33 for (
int t = 0; t < u.GetDim4(); ++t)
34 for (
int k = pmb->ks; k <= pmb->ke; ++k)
35 for (
int j = pmb->js; j <= pmb->je; ++
j)
36 for (
int i = pmb->is; i <= pmb->ie; ++i) {
41 Real delta_u = u(t, k,
j, i) - u1_(t, k,
j, i);
44 MaterialPoint *pc = pcell_(t, k,
j, i);
45 while (pc !=
nullptr) {
57 Real drho = 0., sum = 0.;
58 pc = pcell_(t, k,
j, i);
72 for (
int n = 0; n < n0 - nmax_per_cell_; ++n) {
83 pcell_(t, k,
j, i) = pc;
84 while (pc !=
nullptr) {
93 Real avg = delta_u / seeds_per_cell_;
95 int num =
std::min(nmax_per_cell_ - nparts, seeds_per_cell_);
97 std::string str = myname + std::to_string(t) +
98 std::to_string(pmb->gid) + std::to_string(i) +
99 std::to_string(
j) + std::to_string(k) +
't' +
100 std::to_string(pmb->pmy_mesh->time) +
'n';
101 for (
int n = 0; n < num; ++n) {
103 p.id = std::abs((
int)std::hash<std::string>{}(
104 str + std::to_string(n))) %
107 p.time = pmb->pmy_mesh->time;
108 p.x1 = pco->x1f(i) + (1. * rand() / RAND_MAX) * pco->dx1f(i);
109 p.x2 = pco->x2f(
j) + (1. * rand() / RAND_MAX) * pco->dx2f(
j);
110 p.x3 = pco->x3f(k) + (1. * rand() / RAND_MAX) * pco->dx3f(k);
119 pc = pcell_(t, k,
j, i);
120 for (
int n = 0; n < seeds_per_cell_ - num; ++n) {
125 }
else if (delta_u < 0.) {
126 Real avg = std::abs(delta_u) / nparts;
127 pc = pcell_(t, k,
j, i);
132 for (
int n = 0; n < nparts; ++n) {
139 avg = std::abs(delta_u) / (nparts - n - 1);
148 std::stringstream msg;
165 for (std::vector<MaterialPoint>::iterator it = mpb.begin(); it != mpb.end();
170 pmb->pdebug->CheckParticleConservation(cnames_, mp);
173 pmb->pdebug->Leave();
double min(double x1, double x2, double x3)