Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up interpolation routines in AMReX_TracerParticle_mod_K.H and AMReX_Particle_mod_K.H #3679

Merged
merged 19 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Src/Particle/AMReX_ParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -1180,11 +1180,6 @@ public:
Vector<std::unique_ptr<MultiFab> >& mf_to_be_filled,
int lev_min, int ncomp, int finest_level, int ngrow=2) const;

void Interpolate (Vector<std::unique_ptr<MultiFab> >& mesh_data,
int lev_min, int lev_max);

void InterpolateSingleLevel (MultiFab& mesh_data, int lev);

void AssignCellDensitySingleLevel (int rho_index, MultiFab& mf, int level,
int ncomp=1, int particle_lvl_offset = 0) const;

Expand Down
50 changes: 0 additions & 50 deletions Src/Particle/AMReX_ParticleContainerI.H
Original file line number Diff line number Diff line change
Expand Up @@ -2481,56 +2481,6 @@ AssignCellDensitySingleLevel (int rho_index,
}
}

template <typename ParticleType, int NArrayReal, int NArrayInt,
template<class> class Allocator, class CellAssignor>
void
ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>::Interpolate (Vector<std::unique_ptr<MultiFab> >& mesh_data,
int lev_min, int lev_max)
{
BL_PROFILE("ParticleContainer::Interpolate()");
for (int lev = lev_min; lev <= lev_max; ++lev) {
InterpolateSingleLevel(*mesh_data[lev], lev);
}
}

template <typename ParticleType, int NArrayReal, int NArrayInt,
template<class> class Allocator, class CellAssignor>
void
ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>::
InterpolateSingleLevel (MultiFab& mesh_data, int lev)
{
BL_PROFILE("ParticleContainer::InterpolateSingleLevel()");

if (mesh_data.nGrow() < 1) {
amrex::Error("Must have at least one ghost cell when in InterpolateSingleLevel");
}

const Geometry& gm = Geom(lev);
const auto plo = gm.ProbLoArray();
const auto dxi = gm.InvCellSizeArray();

using ParIter = ParIter_impl<ParticleType, NArrayReal, NArrayInt, Allocator>;

#ifdef AMREX_USE_OMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
#endif
for (ParIter pti(*this, lev); pti.isValid(); ++pti)
{
auto& particles = pti.GetArrayOfStructs();
auto ptd = pti.GetParticleTile().getParticleTileData();
FArrayBox& fab = mesh_data[pti];
const auto fabarr = fab.array();
const Long np = particles.numParticles();

int nComp = fab.nComp();
AMREX_FOR_1D( np, i,
{
auto p = make_particle<ParticleType>{}(ptd,i);
amrex_interpolate_cic(p, nComp, fabarr, plo, dxi);
});
}
}

template <typename ParticleType, int NArrayReal, int NArrayInt,
template<class> class Allocator, class CellAssignor>
void
Expand Down
74 changes: 0 additions & 74 deletions Src/Particle/AMReX_Particle_mod_K.H
Original file line number Diff line number Diff line change
Expand Up @@ -233,80 +233,6 @@ void amrex_deposit_particle_dx_cic (P const& p, int nc, amrex::Array4<amrex::Rea
#endif
}

template <typename P>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void amrex_interpolate_cic (P const& p, int nc, amrex::Array4<amrex::Real const> const& acc,
amrex::GpuArray<amrex::Real,AMREX_SPACEDIM> const& plo,
amrex::GpuArray<amrex::Real,AMREX_SPACEDIM> const& dxi)
{
#if (AMREX_SPACEDIM == 1)
amrex::Real lx = (p.pos(0) - plo[0]) * dxi[0] + Real(0.5);

int i = static_cast<int>(amrex::Math::floor(lx));

amrex::Real xint = lx - static_cast<Real>(i);

amrex::Real sx[] = {Real(1.0)-xint, xint};

for (int comp=0; comp < nc; ++comp) {
for (int ii = 0; ii <= 1; ++ii) {
amrex::Real acceleration = sx[ii]*acc(i+ii-1,0,0,comp);
amrex::ignore_unused(acceleration);
}
}
#elif (AMREX_SPACEDIM == 2)
amrex::Real lx = (p.pos(0) - plo[0]) * dxi[0] + Real(0.5);
amrex::Real ly = (p.pos(1) - plo[1]) * dxi[1] + Real(0.5);

int i = static_cast<int>(amrex::Math::floor(lx));
int j = static_cast<int>(amrex::Math::floor(ly));

amrex::Real xint = lx - static_cast<Real>(i);
amrex::Real yint = ly - static_cast<Real>(j);

amrex::Real sx[] = {Real(1.0)-xint, xint};
amrex::Real sy[] = {Real(1.0)-yint, yint};

for (int comp=0; comp < nc; ++comp) {
for (int jj = 0; jj <= 1; ++jj) {
for (int ii = 0; ii <= 1; ++ii) {
amrex::Real acceleration = sx[ii]*sy[jj]*acc(i+ii-1,j+jj-1,0,comp);
amrex::ignore_unused(acceleration);
}
}
}
#elif (AMREX_SPACEDIM == 3)
amrex::Real lx = (p.pos(0) - plo[0]) * dxi[0] + Real(0.5);
amrex::Real ly = (p.pos(1) - plo[1]) * dxi[1] + Real(0.5);
amrex::Real lz = (p.pos(2) - plo[2]) * dxi[2] + Real(0.5);

int i = static_cast<int>(amrex::Math::floor(lx));
int j = static_cast<int>(amrex::Math::floor(ly));
int k = static_cast<int>(amrex::Math::floor(lz));

amrex::Real xint = lx - static_cast<Real>(i);
amrex::Real yint = ly - static_cast<Real>(j);
amrex::Real zint = lz - static_cast<Real>(k);

amrex::Real sx[] = {Real(1.0)-xint, xint};
amrex::Real sy[] = {Real(1.0)-yint, yint};
amrex::Real sz[] = {Real(1.0)-zint, zint};

for (int comp=0; comp < nc; ++comp) {
for (int kk = 0; kk <= 1; ++kk) {
for (int jj = 0; jj <= 1; ++jj) {
for (int ii = 0; ii <= 1; ++ii) {
amrex::Real acceleration = sx[ii]*sy[jj]*sz[kk]*acc(i+ii-1,j+jj-1,k+kk-1,comp);
amrex::ignore_unused(acceleration);
}
}
}
}
#else
amrex::Abort("Not implemented.");
#endif
}

}

#endif
Loading