Skip to content

Commit

Permalink
for CUDA compile
Browse files Browse the repository at this point in the history
  • Loading branch information
asalmgren committed Nov 13, 2023
1 parent eb2c775 commit 13ada79
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Source/ERF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ ERF::AverageDownTo (int crse_lev, int scomp, int ncomp) // NOLINT
{
AMREX_ALWAYS_ASSERT(solverChoice.coupling_type == CouplingType::TwoWay ||
solverChoice.coupling_type == CouplingType::Mixed);

for (int var_idx = 0; var_idx < Vars::NumTypes; ++var_idx) {
const BoxArray& ba(vars_new[crse_lev][var_idx].boxArray());
if (ba[0].type() == IntVect::TheZeroVector())
Expand All @@ -1277,16 +1277,17 @@ ERF::AverageDownTo (int crse_lev, int scomp, int ncomp) // NOLINT
const Box& bx = mfi.tilebox();
const Array4< Real> cons_arr = vars_new[lev][Vars::cons].array(mfi);
const Array4<const Real> mapfac_arr = mapfac_m[lev]->const_array(mfi);
int l_scomp = scomp;
if (solverChoice.use_terrain) {
const Array4<const Real> detJ_arr = detJ_cc[lev]->const_array(mfi);
ParallelFor(bx, ncomp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept
{
cons_arr(i,j,k,scomp+n) *= detJ_arr(i,j,k) / (mapfac_arr(i,j,0)*mapfac_arr(i,j,0));
cons_arr(i,j,k,l_scomp+n) *= detJ_arr(i,j,k) / (mapfac_arr(i,j,0)*mapfac_arr(i,j,0));
});
} else {
ParallelFor(bx, ncomp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept
{
cons_arr(i,j,k,scomp+n) /= (mapfac_arr(i,j,0)*mapfac_arr(i,j,0));
cons_arr(i,j,k,l_scomp+n) /= (mapfac_arr(i,j,0)*mapfac_arr(i,j,0));
});
}
} // mfi
Expand All @@ -1306,12 +1307,12 @@ ERF::AverageDownTo (int crse_lev, int scomp, int ncomp) // NOLINT
const Array4<const Real> detJ_arr = detJ_cc[lev]->const_array(mfi);
ParallelFor(bx, ncomp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept
{
cons_arr(i,j,k,scomp+n) *= (mapfac_arr(i,j,0)*mapfac_arr(i,j,0)) / detJ_arr(i,j,k);
cons_arr(i,j,k,l_scomp+n) *= (mapfac_arr(i,j,0)*mapfac_arr(i,j,0)) / detJ_arr(i,j,k);
});
} else {
ParallelFor(bx, ncomp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept
{
cons_arr(i,j,k,scomp+n) *= (mapfac_arr(i,j,0)*mapfac_arr(i,j,0));
cons_arr(i,j,k,l_scomp+n) *= (mapfac_arr(i,j,0)*mapfac_arr(i,j,0));
});
}
} // mfi
Expand Down

0 comments on commit 13ada79

Please sign in to comment.