Canoe
Comprehensive Atmosphere N' Ocean Engine
nbody_inbound.cpp
Go to the documentation of this file.
1 
4 // Athena++ headers
5 #include <athena/athena.hpp>
6 #include <athena/coordinates/coordinates.hpp>
7 #include <athena/hydro/hydro.hpp>
8 #include <athena/mesh/mesh.hpp>
9 
10 // climath
11 #include <climath/interpolation.h> // interpn
12 
13 // particle
14 #include "particle_data.hpp"
15 #include "particles.hpp"
16 
17 void ParticleBase::SetVelocitiesFromHydro(Hydro const *phydro,
18  Coordinates const *pcoord) {
19  AthenaArray<Real> v1, v2, v3;
20  Real loc[3];
21 
22  v1.InitWithShallowSlice(const_cast<AthenaArray<Real> &>(phydro->w), 4, IM1,
23  1);
24  v2.InitWithShallowSlice(const_cast<AthenaArray<Real> &>(phydro->w), 4, IM2,
25  1);
26  v3.InitWithShallowSlice(const_cast<AthenaArray<Real> &>(phydro->w), 4, IM3,
27  1);
28 
29  auto pm = pmy_block_->pmy_mesh;
30 
31  // loop over particles
32  for (auto &q : pc) {
33  loc[0] = q.x3;
34  loc[1] = q.x2;
35  loc[2] = q.x1;
36 
37  int f = pm->f2 + pm->f3;
38  // interpolate Eulerian velocity to particle velocity
39  interpn(&q.v1, loc + 2 - f, v1.data(), pcoord->GetCellCoords() + 2 - f,
40  pcoord->GetDimensions() + 2 - f, 1 + f, 1);
41 
42  if (pm->f2) {
43  interpn(&q.v2, loc + 2 - f, v2.data(), pcoord->GetCellCoords() + 2 - f,
44  pcoord->GetDimensions() + 2 - f, 1 + f, 1);
45  } else {
46  q.v2 = 0.;
47  }
48 
49  if (pm->f3) {
50  interpn(&q.v3, loc + 2 - f, v3.data(), pcoord->GetCellCoords() + 2 - f,
51  pcoord->GetDimensions() + 2 - f, 1 + f, 1);
52  } else {
53  q.v3 = 0.;
54  }
55  }
56 }
ParticleContainer pc
Definition: particles.hpp:39
void SetVelocitiesFromHydro(Hydro const *phydro, Coordinates const *pcoord)
MeshBlock const * pmy_block_
pointer to parent MeshBlock
Definition: particles.hpp:82
void interpn(double *val, double const *coor, double const *data, double const *axis, size_t const *len, int ndim, int nval)
Definition: interpn.c:12