4#ifdef REMORA_USE_PARTICLES
7#include <AMReX_Particles.H>
9struct REMORAParticlesIntIdxAoS
17struct REMORAParticlesRealIdxAoS
24struct REMORAParticlesIntIdxSoA
31struct REMORAParticlesRealIdxSoA
42namespace REMORAParticleInitializations
45 const std::string init_box_uniform =
"box";
48namespace REMORAParticleNames
50 const std::string tracers =
"tracer_particles";
51 const std::string hydro =
"hydro_particles";
54struct REMORAParticlesAssignor
58 amrex::IntVect operator() ( P
const& p,
59 amrex::GpuArray<amrex::Real,AMREX_SPACEDIM>
const& plo,
60 amrex::GpuArray<amrex::Real,AMREX_SPACEDIM>
const& dxi,
61 const amrex::Box& domain )
const noexcept
64 AMREX_D_DECL(
int(amrex::Math::floor((p.pos(0)-plo[0])*dxi[0])),
65 int(amrex::Math::floor((p.pos(1)-plo[1])*dxi[1])),
66 p.idata(REMORAParticlesIntIdxAoS::k) ) );
67 iv[0] += domain.smallEnd()[0];
68 iv[1] += domain.smallEnd()[1];
74AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
75void update_location_idata ( P& a_p,
76 amrex::GpuArray<amrex::Real,AMREX_SPACEDIM>
const& a_plo,
77 amrex::GpuArray<amrex::Real,AMREX_SPACEDIM>
const& a_dxi,
78 const amrex::Array4<amrex::Real const>& a_height_arr )
80 amrex::IntVect iv(
int(amrex::Math::floor((a_p.pos(0)-a_plo[0])*a_dxi[0])),
81 int(amrex::Math::floor((a_p.pos(1)-a_plo[1])*a_dxi[1])),
82 a_p.idata(REMORAParticlesIntIdxAoS::k) );
85 amrex::Real lx = (a_p.pos(0)-a_plo[0])*a_dxi[0] -
static_cast<amrex::Real
>(iv[0]);
86 amrex::Real ly = (a_p.pos(1)-a_plo[1])*a_dxi[1] -
static_cast<amrex::Real
>(iv[1]);
87 auto zlo = a_height_arr(iv[0] ,iv[1] ,iv[2] ) * (1.0-lx) * (1.0-ly) +
88 a_height_arr(iv[0]+1,iv[1] ,iv[2] ) * lx * (1.0-ly) +
89 a_height_arr(iv[0] ,iv[1]+1,iv[2] ) * (1.0-lx) * ly +
90 a_height_arr(iv[0]+1,iv[1]+1,iv[2] ) * lx * ly;
91 auto zhi = a_height_arr(iv[0] ,iv[1] ,iv[2]+1) * (1.0-lx) * (1.0-ly) +
92 a_height_arr(iv[0]+1,iv[1] ,iv[2]+1) * lx * (1.0-ly) +
93 a_height_arr(iv[0] ,iv[1]+1,iv[2]+1) * (1.0-lx) * ly +
94 a_height_arr(iv[0]+1,iv[1]+1,iv[2]+1) * lx * ly;
96 if (a_p.pos(2) > zhi) {
97 a_p.idata(REMORAParticlesIntIdxAoS::k) += 1;
98 }
else if (a_p.pos(2) <= zlo) {
99 a_p.idata(REMORAParticlesIntIdxAoS::k) -= 1;
104class REMORAPC :
public amrex::ParticleContainer< REMORAParticlesRealIdxAoS::ncomps,
105 REMORAParticlesIntIdxAoS::ncomps,
106 REMORAParticlesRealIdxSoA::ncomps,
107 REMORAParticlesIntIdxSoA::ncomps,
108 amrex::DefaultAllocator,
109 REMORAParticlesAssignor >
114 REMORAPC ( amrex::ParGDBBase* a_gdb,
115 const std::string& a_name =
"particles" )
116 :
amrex::ParticleContainer< REMORAParticlesRealIdxAoS::ncomps,
117 REMORAParticlesIntIdxAoS::ncomps,
118 REMORAParticlesRealIdxSoA::ncomps,
119 REMORAParticlesIntIdxSoA::ncomps,
120 amrex::DefaultAllocator,
121 REMORAParticlesAssignor> (a_gdb)
123 BL_PROFILE(
"REMORAPCPC::REMORAPC()");
129 REMORAPC (
const amrex::Geometry& a_geom,
130 const amrex::DistributionMapping& a_dmap,
131 const amrex::BoxArray& a_ba,
132 const std::string& a_name =
"particles" )
133 :
amrex::ParticleContainer< REMORAParticlesRealIdxAoS::ncomps,
134 REMORAParticlesIntIdxAoS::ncomps,
135 REMORAParticlesRealIdxSoA::ncomps,
136 REMORAParticlesIntIdxSoA::ncomps,
137 amrex::DefaultAllocator,
138 REMORAParticlesAssignor> ( a_geom, a_dmap, a_ba )
140 BL_PROFILE(
"REMORAPCPC::REMORAPC()");
146 virtual void InitializeParticles (
const std::unique_ptr<amrex::MultiFab>& a_ptr =
nullptr);
149 virtual void EvolveParticles (
int lev,
151 amrex::Vector<amrex::MultiFab const*>& a_flow_vel,
152 const amrex::Vector<std::unique_ptr<amrex::MultiFab>>& );
155 virtual amrex::Vector<std::string> varNames ()
const
157 BL_PROFILE(
"REMORAPCPC::varNames()");
158 return {AMREX_D_DECL(
"xvel",
"yvel",
"zvel"),
"mass"};
162 virtual amrex::Vector<std::string> meshPlotVarNames ()
const
164 BL_PROFILE(
"REMORAPCPC::varNames()");
165 return {
"mass_density"};
169 virtual void AdvectWithFlow (
int lev,
171 amrex::Vector<amrex::MultiFab const*>&,
172 const std::unique_ptr<amrex::MultiFab>& );
175 virtual void massDensity ( amrex::MultiFab&,
const int&,
const int& a_comp = 0)
const;
178 virtual void computeMeshVar(
const std::string& a_var_name,
179 amrex::MultiFab& a_mf,
180 const int a_lev)
const
182 if (a_var_name ==
"mass_density") {
183 massDensity( a_mf, a_lev );
190 inline void setAdvectWithFlow (
bool a_flag)
192 BL_PROFILE(
"REMORAPCPC::setAdvectWithFlow()");
193 m_advect_w_flow = a_flag;
200 void initializeParticlesUniformDistributionInBox (
const std::unique_ptr<amrex::MultiFab>& a_ptr,
201 const amrex::RealBox& particle_box);
205 bool m_advect_w_flow;
207 amrex::RealBox m_particle_box;
211 std::string m_initialization_type;
215 virtual void readInputs ();
219 bool place_randomly_in_cells;