15 #include "../coordinates/coordinates.hpp"
16 #include "../debugger/debugger.hpp"
17 #include "../hydro/hydro.hpp"
18 #include "../hydro/srcterms/hydro_srcterms.hpp"
19 #include "../math/interpolation.h"
20 #include "../mesh/mesh.hpp"
23 SimpleCloudParticles::SimpleCloudParticles(MeshBlock *pmb, ParameterInput *pin,
25 : Particles(pmb, pin, name, 2) {
27 pmb->pdebug->Enter(
"SimpleCloudParticles");
28 std::stringstream &msg = pmb->pdebug->msg;
29 msg <<
"- first category is " << name +
" cloud" << std::endl
30 <<
"- second category is " << name +
" precipitation" << std::endl;
35 Real mu = pin->GetReal(
"particles", name +
".mu");
36 Real cc = pin->GetReal(
"particles", name +
".cc");
46 void SimpleCloudParticles::ExchangeHydro(std::vector<MaterialPoint> &mp,
49 MeshBlock *pmb = pmy_block;
50 pmb->pdebug->Call(
"SimpleCloudParticles::ExchangeHydro-" + myname);
51 std::stringstream &msg = pmb->pdebug->msg;
53 Mesh *pm = pmb->pmy_mesh;
62 Real g1 = pmb->phydro->hsrc.GetG1();
63 Real g2 = pmb->phydro->hsrc.GetG2();
64 Real g3 = pmb->phydro->hsrc.GetG3();
66 int f = pm->f2 + pm->f3;
67 for (std::vector<MaterialPoint>::iterator q = mp.begin(); q != mp.end();
73 interpnf(&q->v1, loc + 2 - f, v1.data(), xcenter_.data() + 2 - f,
74 dims_.data() + 2 - f, 1 + f);
76 interpnf(&q->v2, loc + 2 - f, v2.data(), xcenter_.data() + 2 - f,
77 dims_.data() + 2 - f, 1 + f);
81 interpnf(&q->v3, loc + 2 - f, v3.data(), xcenter_.data() + 2 - f,
82 dims_.data() + 2 - f, 1 + f);
86 if (std::isnan(q->v1) || std::isnan(q->v2) || std::isnan(q->v3)) {
87 msg <<
"### FATAL ERROR in SimpleCloudParticle::ExchangeHydro. Particles "
88 << myname <<
" velocity is nan" << std::endl;
89 msg <<
"id = " << q->id << std::endl
90 <<
"type = " << q->type << std::endl
91 <<
"x1 = " << q->x1 << std::endl
92 <<
"x2 = " << q->x2 << std::endl
93 <<
"x3 = " << q->x3 << std::endl
94 <<
"v1 = " << q->v1 << std::endl
95 <<
"v2 = " << q->v2 << std::endl
96 <<
"v3 = " << q->v3 << std::endl;
97 Real k =
locate(xcenter_.data(), q->x3, dims_[0]);
98 Real
j =
locate(xcenter_.data() + dims_[0], q->x2, dims_[1]);
99 Real i =
locate(xcenter_.data() + dims_[0] + dims_[1], q->x1, dims_[2]);
100 std::cout << i <<
" " << pcoord->x1v(i) <<
" " << pcoord->x1v(i + 1)
102 std::cout <<
j <<
" " << pcoord->x2v(
j) <<
" " << pcoord->x2v(
j + 1)
104 std::cout << k <<
" " << pcoord->x3v(k) <<
" " << pcoord->x3v(k + 1);
109 if (q->type == 1) q->v1 += -10.;
113 k =
locate(xface_.data(), q->x3, dims_[0] + 1);
114 j =
locate(xface_.data() + dims_[0] + 1, q->x2, dims_[1] + 1);
115 i =
locate(xface_.data() + dims_[0] + dims_[1] + 2, q->x1, dims_[2] + 1);
117 Real src = dt * q->rho;
118 du(IM1, k,
j, i) += src * g1;
119 du(IM2, k,
j, i) += src * g2;
120 du(IM3, k,
j, i) += src * g3;
121 du(IEN, k,
j, i) += src * (g1 * q->v1 + g2 * q->v2 + g3 * q->v3);
125 pmb->pdebug->CheckConservation(
"du", du, pmb->is, pmb->ie, pmb->js, pmb->je,
128 pmb->pdebug->Leave();
void interpnf(double *val, double const *coor, double const *data, double const *axis, size_t const *len, int ndim)
int locate(double const *xx, double x, int n)