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

Adding templating to the MFInterp functions #4328

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
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
35 changes: 21 additions & 14 deletions Src/AmrCore/AMReX_MFInterp_1D_C.H
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

namespace amrex {

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_cons_lin_interp_limit_minmax_llslope (int i, int, int, Array4<Real> const& slope,
Array4<Real const> const& u, int scomp, int ncomp,
void mf_cell_cons_lin_interp_limit_minmax_llslope (int i, int, int, Array4<T> const& slope,
Array4<T const> const& u, int scomp, int ncomp,
Box const& domain, IntVect const& ratio, BCRec const* bc) noexcept
{
Real sfx = Real(1.0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use T here and other places in this function too?

Expand Down Expand Up @@ -35,9 +36,10 @@ void mf_cell_cons_lin_interp_limit_minmax_llslope (int i, int, int, Array4<Real>
amrex::ignore_unused(ratio);
}

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_cons_lin_interp_llslope (int i, int, int, Array4<Real> const& slope,
Array4<Real const> const& u, int scomp, int ncomp,
void mf_cell_cons_lin_interp_llslope (int i, int, int, Array4<T> const& slope,
Array4<T const> const& u, int scomp, int ncomp,
Box const& domain, IntVect const& /*ratio*/, BCRec const* bc) noexcept
{
Real sfx = Real(1.0);
Expand All @@ -62,10 +64,11 @@ void mf_cell_cons_lin_interp_llslope (int i, int, int, Array4<Real> const& slope
}
}

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_cons_lin_interp_mcslope (int i, int /*j*/, int /*k*/, int ns,
Array4<Real> const& slope,
Array4<Real const> const& u, int scomp, int /*ncomp*/,
Array4<T> const& slope,
Array4<T const> const& u, int scomp, int /*ncomp*/,
Box const& domain, IntVect const& ratio,
BCRec const* bc) noexcept
{
Expand Down Expand Up @@ -98,10 +101,11 @@ void mf_cell_cons_lin_interp_mcslope (int i, int /*j*/, int /*k*/, int ns,
slope(i,0,0,ns) = sx * alpha;
}

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_cons_lin_interp (int i, int /*j*/, int /*k*/, int ns,
Array4<Real> const& fine, int fcomp,
Array4<Real const> const& slope, Array4<Real const> const& crse,
Array4<T> const& fine, int fcomp,
Array4<T const> const& slope, Array4<T const> const& crse,
int ccomp, int /*ncomp*/, IntVect const& ratio) noexcept
{
const int ic = amrex::coarsen(i, ratio[0]);
Expand All @@ -110,9 +114,10 @@ void mf_cell_cons_lin_interp (int i, int /*j*/, int /*k*/, int ns,
+ xoff * slope(ic,0,0,ns);
}

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_cons_lin_interp_mcslope_sph (int i, int ns, Array4<Real> const& slope,
Array4<Real const> const& u, int scomp, int /*ncomp*/,
void mf_cell_cons_lin_interp_mcslope_sph (int i, int ns, Array4<T> const& slope,
Array4<T const> const& u, int scomp, int /*ncomp*/,
Box const& domain, IntVect const& ratio,
BCRec const* bc, Real drf, Real rlo) noexcept
{
Expand Down Expand Up @@ -161,9 +166,10 @@ void mf_cell_cons_lin_interp_mcslope_sph (int i, int ns, Array4<Real> const& slo
slope(i,0,0,ns) = sx * alpha;
}

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_cons_lin_interp_sph (int i, int ns, Array4<Real> const& fine, int fcomp,
Array4<Real const> const& slope, Array4<Real const> const& crse,
void mf_cell_cons_lin_interp_sph (int i, int ns, Array4<T> const& fine, int fcomp,
Array4<T const> const& slope, Array4<T const> const& crse,
int ccomp, int /*ncomp*/, IntVect const& ratio, Real drf, Real rlo) noexcept
{
const int ic = amrex::coarsen(i, ratio[0]);
Expand Down Expand Up @@ -202,9 +208,10 @@ void mf_cell_bilin_interp (int i, int, int, int n, Array4<T> const& fine, int fc
crse(ic+sx,0,0,n+ccomp)*(Real(1.0)-wx);
}

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_nodebilin_interp (int i, int, int, int n, Array4<Real> const& fine, int fcomp,
Array4<Real const> const& crse, int ccomp, IntVect const& ratio) noexcept
void mf_nodebilin_interp (int i, int, int, int n, Array4<T> const& fine, int fcomp,
Array4<T const> const& crse, int ccomp, IntVect const& ratio) noexcept
{
int ic = amrex::coarsen(i,ratio[0]);
int ioff = i - ic*ratio[0];
Expand Down
55 changes: 33 additions & 22 deletions Src/AmrCore/AMReX_MFInterp_2D_C.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

namespace amrex {

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_cons_lin_interp_limit_minmax_llslope (int i, int j, int, Array4<Real> const& slope,
Array4<Real const> const& u, int scomp, int ncomp,
void mf_cell_cons_lin_interp_limit_minmax_llslope (int i, int j, int, Array4<T> const& slope,
Array4<T const> const& u, int scomp, int ncomp,
Box const& domain, IntVect const& ratio, BCRec const* bc) noexcept
{
Real sfx = Real(1.0);
Expand Down Expand Up @@ -86,9 +87,10 @@ void mf_cell_cons_lin_interp_limit_minmax_llslope (int i, int j, int, Array4<Rea
}
}

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_cons_lin_interp_llslope (int i, int j, int, Array4<Real> const& slope,
Array4<Real const> const& u, int scomp, int ncomp,
void mf_cell_cons_lin_interp_llslope (int i, int j, int, Array4<T> const& slope,
Array4<T const> const& u, int scomp, int ncomp,
Box const& domain, IntVect const& ratio, BCRec const* bc) noexcept
{
Real sfx = Real(1.0);
Expand Down Expand Up @@ -134,9 +136,11 @@ void mf_cell_cons_lin_interp_llslope (int i, int j, int, Array4<Real> const& slo
}
}


template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_cons_lin_interp_mcslope (int i, int j, int /*k*/, int ns, Array4<Real> const& slope,
Array4<Real const> const& u, int scomp, int ncomp,
void mf_cell_cons_lin_interp_mcslope (int i, int j, int /*k*/, int ns, Array4<T> const& slope,
Array4<T const> const& u, int scomp, int ncomp,
Box const& domain, IntVect const& ratio,
BCRec const* bc) noexcept
{
Expand Down Expand Up @@ -188,9 +192,10 @@ void mf_cell_cons_lin_interp_mcslope (int i, int j, int /*k*/, int ns, Array4<Re
slope(i,j,0,ns+ ncomp) = sy * alpha;
}

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_cons_lin_interp (int i, int j, int /*k*/, int ns, Array4<Real> const& fine, int fcomp,
Array4<Real const> const& slope, Array4<Real const> const& crse,
void mf_cell_cons_lin_interp (int i, int j, int /*k*/, int ns, Array4<T> const& fine, int fcomp,
Array4<T const> const& slope, Array4<T const> const& crse,
int ccomp, int ncomp, IntVect const& ratio) noexcept
{
const int ic = amrex::coarsen(i, ratio[0]);
Expand All @@ -202,9 +207,10 @@ void mf_cell_cons_lin_interp (int i, int j, int /*k*/, int ns, Array4<Real> cons
+ yoff * slope(ic,jc,0,ns+ncomp);
}

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_cons_lin_interp_mcslope_rz (int i, int j, int ns, Array4<Real> const& slope,
Array4<Real const> const& u, int scomp, int ncomp,
void mf_cell_cons_lin_interp_mcslope_rz (int i, int j, int ns, Array4<T> const& slope,
Array4<T const> const& u, int scomp, int ncomp,
Box const& domain, IntVect const& ratio,
BCRec const* bc, Real drf, Real rlo) noexcept
{
Expand Down Expand Up @@ -273,9 +279,10 @@ void mf_cell_cons_lin_interp_mcslope_rz (int i, int j, int ns, Array4<Real> cons
slope(i,j,0,ns+ ncomp) = sy * alpha;
}

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_cons_lin_interp_rz (int i, int j, int ns, Array4<Real> const& fine, int fcomp,
Array4<Real const> const& slope, Array4<Real const> const& crse,
void mf_cell_cons_lin_interp_rz (int i, int j, int ns, Array4<T> const& fine, int fcomp,
Array4<T const> const& slope, Array4<T const> const& crse,
int ccomp, int ncomp, IntVect const& ratio, Real drf, Real rlo) noexcept
{
const int ic = amrex::coarsen(i, ratio[0]);
Expand Down Expand Up @@ -328,9 +335,10 @@ void mf_cell_bilin_interp (int i, int j, int, int n, Array4<T> const& fine, int
crse(ic+sx,jc+sy,0,n+ccomp)*(Real(1.0)-wx)*(Real(1.0)-wy);
}

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_nodebilin_interp (int i, int j, int, int n, Array4<Real> const& fine, int fcomp,
Array4<Real const> const& crse, int ccomp, IntVect const& ratio) noexcept
void mf_nodebilin_interp (int i, int j, int, int n, Array4<T> const& fine, int fcomp,
Array4<T const> const& crse, int ccomp, IntVect const& ratio) noexcept
{
int ic = amrex::coarsen(i,ratio[0]);
int jc = amrex::coarsen(j,ratio[1]);
Expand Down Expand Up @@ -359,10 +367,11 @@ void mf_nodebilin_interp (int i, int j, int, int n, Array4<Real> const& fine, in
}
}

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_quadratic_calcslope (int i, int j, int /*k*/, int n,
Array4<Real const> const& crse, int ccomp,
Array4<Real> const& slope,
Array4<T const> const& crse, int ccomp,
Array4<T> const& slope,
Box const& domain,
BCRec const* bc) noexcept
{
Expand All @@ -380,11 +389,12 @@ void mf_cell_quadratic_calcslope (int i, int j, int /*k*/, int n,
slope(i,j,0,5*n+4) = sxy; // xy
}

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_quadratic_interp (int i, int j, int /*k*/, int n,
Array4<Real> const& fine, int fcomp,
Array4<Real const> const& crse, int ccomp,
Array4<Real const> const& slope,
Array4<T> const& fine, int fcomp,
Array4<T const> const& crse, int ccomp,
Array4<T const> const& slope,
IntVect const& ratio) noexcept
{
int ic = amrex::coarsen(i, ratio[0]);
Expand All @@ -404,11 +414,12 @@ void mf_cell_quadratic_interp (int i, int j, int /*k*/, int n,
+ xoff * yoff * slope(ic,jc,0,5*n+4); // xy
}

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_quadratic_interp_rz (int i, int j, int /*k*/, int n,
Array4<Real> const& fine, int fcomp,
Array4<Real const> const& crse, int ccomp,
Array4<Real const> const& slope,
Array4<T> const& fine, int fcomp,
Array4<T const> const& crse, int ccomp,
Array4<T const> const& slope,
IntVect const& ratio,
GeometryData const& cs_geomdata,
GeometryData const& fn_geomdata) noexcept
Expand Down
37 changes: 22 additions & 15 deletions Src/AmrCore/AMReX_MFInterp_3D_C.H
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

namespace amrex {

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_cons_lin_interp_limit_minmax_llslope (int i, int j, int k, Array4<Real> const& slope,
Array4<Real const> const& u, int scomp, int ncomp,
void mf_cell_cons_lin_interp_limit_minmax_llslope (int i, int j, int k, Array4<T> const& slope,
Array4<T const> const& u, int scomp, int ncomp,
Box const& domain, IntVect const& ratio, BCRec const* bc) noexcept
{
Real sfx = Real(1.0);
Expand Down Expand Up @@ -107,9 +108,10 @@ void mf_cell_cons_lin_interp_limit_minmax_llslope (int i, int j, int k, Array4<R
}
}

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_cons_lin_interp_llslope (int i, int j, int k, Array4<Real> const& slope,
Array4<Real const> const& u, int scomp, int ncomp,
void mf_cell_cons_lin_interp_llslope (int i, int j, int k, Array4<T> const& slope,
Array4<T const> const& u, int scomp, int ncomp,
Box const& domain, IntVect const& ratio, BCRec const* bc) noexcept
{
Real sfx = Real(1.0);
Expand Down Expand Up @@ -174,9 +176,10 @@ void mf_cell_cons_lin_interp_llslope (int i, int j, int k, Array4<Real> const& s
}
}

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_cons_lin_interp_mcslope (int i, int j, int k, int ns, Array4<Real> const& slope,
Array4<Real const> const& u, int scomp, int ncomp,
void mf_cell_cons_lin_interp_mcslope (int i, int j, int k, int ns, Array4<T> const& slope,
Array4<T const> const& u, int scomp, int ncomp,
Box const& domain, IntVect const& ratio,
BCRec const* bc) noexcept
{
Expand Down Expand Up @@ -242,9 +245,10 @@ void mf_cell_cons_lin_interp_mcslope (int i, int j, int k, int ns, Array4<Real>
slope(i,j,k,ns+2*ncomp) = sz * alpha;
}

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_cons_lin_interp (int i, int j, int k, int ns, Array4<Real> const& fine, int fcomp,
Array4<Real const> const& slope, Array4<Real const> const& crse,
void mf_cell_cons_lin_interp (int i, int j, int k, int ns, Array4<T> const& fine, int fcomp,
Array4<T const> const& slope, Array4<T const> const& crse,
int ccomp, int ncomp, IntVect const& ratio) noexcept
{
const int ic = amrex::coarsen(i, ratio[0]);
Expand Down Expand Up @@ -304,9 +308,10 @@ void mf_cell_bilin_interp (int i, int j, int k, int n, Array4<T> const& fine, in
crse(ic+sx,jc+sy,kc+sz,n+ccomp)*(Real(1.0)-wx)*(Real(1.0)-wy)*(Real(1.0)-wz);
}

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_nodebilin_interp (int i, int j, int k, int n, Array4<Real> const& fine, int fcomp,
Array4<Real const> const& crse, int ccomp, IntVect const& ratio) noexcept
void mf_nodebilin_interp (int i, int j, int k, int n, Array4<T> const& fine, int fcomp,
Array4<T const> const& crse, int ccomp, IntVect const& ratio) noexcept
{
int ic = amrex::coarsen(i,ratio[0]);
int jc = amrex::coarsen(j,ratio[1]);
Expand Down Expand Up @@ -367,10 +372,11 @@ void mf_nodebilin_interp (int i, int j, int k, int n, Array4<Real> const& fine,
}
}

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_quadratic_calcslope (int i, int j, int k, int n,
Array4<Real const> const& crse, int ccomp,
Array4<Real> const& slope,
Array4<T const> const& crse, int ccomp,
Array4<T> const& slope,
Box const& domain,
BCRec const* bc) noexcept
{
Expand All @@ -396,11 +402,12 @@ void mf_cell_quadratic_calcslope (int i, int j, int k, int n,
slope(i,j,k,9*n+8) = syz; // yz
}

template<typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void mf_cell_quadratic_interp (int i, int j, int k, int n,
Array4<Real> const& fine, int fcomp,
Array4<Real const> const& crse, int ccomp,
Array4<Real const> const& slope,
Array4<T> const& fine, int fcomp,
Array4<T const> const& crse, int ccomp,
Array4<T const> const& slope,
IntVect const& ratio) noexcept
{
int ic = amrex::coarsen(i, ratio[0]);
Expand Down
Loading