Skip to content

Commit

Permalink
Convert rfface to C++
Browse files Browse the repository at this point in the history
  • Loading branch information
maxpkatz committed Oct 15, 2023
1 parent f8446cd commit 2463070
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 135 deletions.
2 changes: 0 additions & 2 deletions Source/radiation/Make.package
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ CEXE_headers += filt_prim.H

FEXE_headers += RAD_F.H

ca_F90EXE_sources += RAD_$(DIM)D.F90

CEXE_sources += trace_ppm_rad.cpp

ca_F90EXE_sources += rad_params.F90
Expand Down
29 changes: 0 additions & 29 deletions Source/radiation/RAD_1D.F90

This file was deleted.

38 changes: 0 additions & 38 deletions Source/radiation/RAD_2D.F90

This file was deleted.

56 changes: 0 additions & 56 deletions Source/radiation/RAD_3D.F90

This file was deleted.

4 changes: 0 additions & 4 deletions Source/radiation/RAD_F.H
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@ extern "C" {
BL_FORT_FAB_ARG_3D(state),
BL_FORT_FAB_ARG_3D(kappar));

void rfface(BL_FORT_FAB_ARG(fine),
BL_FORT_FAB_ARG(crse),
const int& idim, const int* irat);

void FORT_RADBNDRY2(amrex::Real* bf, ARLIM_P(blo), ARLIM_P(bhi),
int* tfab, ARLIM_P(dlo), ARLIM_P(dhi),
const amrex::Real* dx, const amrex::Real* xlo, const amrex::Real& time);
Expand Down
12 changes: 6 additions & 6 deletions Source/radiation/Radiation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2100,17 +2100,17 @@ void Radiation::deferred_sync(int level, MultiFab& rhs, int indx)
for (FabSetIter fsi(ref_sync_flux[lo_face]);
fsi.isValid(); ++fsi) {

rfface(BL_TO_FORTRAN(ref_sync_flux[lo_face][fsi]),
BL_TO_FORTRAN_N(crse_sync_flux[lo_face][fsi], indx),
dir, ref_rat.getVect());
rfface(ref_sync_flux[lo_face][fsi].array(),
crse_sync_flux[lo_face][fsi].array(indx),
dir, ref_rat);
}

for (FabSetIter fsi(ref_sync_flux[hi_face]);
fsi.isValid(); ++fsi) {

rfface(BL_TO_FORTRAN(ref_sync_flux[hi_face][fsi]),
BL_TO_FORTRAN_N(crse_sync_flux[hi_face][fsi], indx),
dir, ref_rat.getVect());
rfface(ref_sync_flux[hi_face][fsi].array(),
crse_sync_flux[hi_face][fsi].array(indx),
dir, ref_rat);
}
}

Expand Down
69 changes: 69 additions & 0 deletions Source/radiation/rad_util.H
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,73 @@ amrex::Real kavg(Real a, Real b, Real d, int opt)
return k;
}

AMREX_INLINE
void rfface (Array4<Real> const fine,
Array4<Real const> const crse,
int idim, const IntVect& irat)
{
const Dim3 flo = amrex::lbound(fine);
const Dim3 fhi = amrex::ubound(fine);

const Dim3 clo = amrex::lbound(crse);
const Dim3 chi = amrex::ubound(crse);

Real ifac = 1.0_rt;
Real jfac = 1.0_rt;
Real kfac = 1.0_rt;
Real rfac = 1.0_rt;

if (idim == 0) {
#if AMREX_SPACEDIM >= 2
jfac = irat[1];
#endif
#if AMREX_SPACEDIM == 3
kfac = irat[2];
#endif

Real rfac = jfac * kfac;

int i = flo.x;
for (int k = flo.z; k <= fhi.z; ++k) {
for (int j = flo.y; j <= fhi.y; ++j) {
fine(i,j,k) = crse(clo.x, j / jfac, k / kfac) / rfac;
}
}
}
else if (idim == 1) {
#if AMREX_SPACEDIM >= 2
ifac = irat[0];
#endif
#if AMREX_SPACEDIM == 3
kfac = irat[2];
#endif

rfac = ifac * kfac;

int j = flo.y;
for (int k = flo.z; k <= fhi.z; ++k) {
for (int i = flo.x; i <= fhi.x; ++i) {
fine(i,j,k) = crse(i / ifac, clo.y, k / kfac) / rfac;
}
}
}
else {
#if AMREX_SPACEDIM >= 2
ifac = irat[0];
#endif
#if AMREX_SPACEDIM == 3
jfac = irat[1];
#endif

rfac = ifac * jfac;

int k = flo.z;
for (int j = flo.y; j <= fhi.y; ++j) {
for (int i = flo.x; i <= fhi.x; ++i) {
fine(i,j,k) = crse(i / ifac, j / jfac, clo.z) / rfac;
}
}
}
}

#endif

0 comments on commit 2463070

Please sign in to comment.