REMORA
Regional Modeling of Oceans Refined Adaptively
Loading...
Searching...
No Matches
REMORA_PC_Utils.cpp
Go to the documentation of this file.
1#ifdef REMORA_USE_PARTICLES
2
3#include <AMReX_ParticleInterpolators.H>
4#include <REMORA_Constants.H>
5#include <REMORA_PC.H>
6
7using namespace amrex;
8
9/**
10 * @param a_mf Multifab to calculate over
11 * @param a_lev level to calculate on
12 * @param a_comp component to calculate
13 */
14void REMORAPC::massDensity ( MultiFab& a_mf,
15 const int& a_lev,
16 const int& a_comp ) const
17{
18 BL_PROFILE("REMORAPC::massDensity()");
19
20 AMREX_ASSERT(OK());
21 AMREX_ASSERT(numParticlesOutOfRange(*this, 0) == 0);
22
23 const auto& geom = Geom(a_lev);
24 const auto plo = geom.ProbLoArray();
25 const auto dxi = geom.InvCellSizeArray();
26
27 const Real inv_cell_volume = dxi[0]*dxi[1]*dxi[2];
28 a_mf.setVal(0.0);
29
30 ParticleToMesh( *this, a_mf, a_lev,
31 [=] AMREX_GPU_DEVICE ( const REMORAPC::ParticleTileType::ConstParticleTileDataType& ptd,
32 int i, Array4<Real> const& rho)
33 {
34 auto p = ptd.m_aos[i];
35 ParticleInterpolator::Linear interp(p, plo, dxi);
36 interp.ParticleToMesh ( p, rho, 0, a_comp, 1,
37 [=] AMREX_GPU_DEVICE ( const REMORAPC::ParticleType&, int)
38 {
39 auto mass = ptd.m_rdata[REMORAParticlesRealIdxSoA::mass][i];
40 return mass*inv_cell_volume;
41 });
42 });
43
44 return;
45}
46
47#endif