diff --git a/Source/radiation/Make.package b/Source/radiation/Make.package index eb9eb54a20..3e0f97669b 100644 --- a/Source/radiation/Make.package +++ b/Source/radiation/Make.package @@ -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 diff --git a/Source/radiation/RAD_1D.F90 b/Source/radiation/RAD_1D.F90 deleted file mode 100644 index b960b07211..0000000000 --- a/Source/radiation/RAD_1D.F90 +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -module rad_module - - use amrex_fort_module, only : rt => amrex_real - implicit none - - real(rt) , parameter :: tiny = 1.e-50_rt - real(rt) , parameter :: BIGKR = 1.e25_rt - -contains - -subroutine rfface(fine, & - DIMS(fbox), & - crse, & - DIMS(cbox), & - idim, irat) bind(C, name="rfface") - use amrex_fort_module, only : rt => amrex_real - implicit none - integer :: DIMDEC(fbox) - integer :: DIMDEC(cbox) - real(rt) :: fine(DIMV(fbox)) - real(rt) :: crse(DIMV(cbox)) - integer :: idim, irat(0:0) - fine(fbox_l1) = crse(cbox_l1) -end subroutine rfface - -end module rad_module diff --git a/Source/radiation/RAD_2D.F90 b/Source/radiation/RAD_2D.F90 deleted file mode 100644 index 936db98070..0000000000 --- a/Source/radiation/RAD_2D.F90 +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include - -module rad_module - - use amrex_fort_module, only : rt => amrex_real - implicit none - - real(rt) , parameter :: tiny = 1.e-50_rt - real(rt) , parameter :: BIGKR = 1.e25_rt - -contains - -subroutine rfface(fine, & - DIMS(fbox), & - crse, & - DIMS(cbox), & - idim, irat) bind(C, name="rfface") - - use amrex_fort_module, only : rt => amrex_real - integer :: DIMDEC(fbox) - integer :: DIMDEC(cbox) - real(rt) :: fine(DIMV(fbox)) - real(rt) :: crse(DIMV(cbox)) - integer :: idim, irat(0:1) - integer :: i, j - if (idim == 0) then - do j = fbox_l2, fbox_h2 - fine(fbox_l1,j) = crse(cbox_l1, j/irat(1)) / irat(1) - enddo - else - do i = fbox_l1, fbox_h1 - fine(i,fbox_l2) = crse(i/irat(0), cbox_l2) / irat(0) - enddo - endif -end subroutine rfface - -end module rad_module diff --git a/Source/radiation/RAD_3D.F90 b/Source/radiation/RAD_3D.F90 deleted file mode 100644 index 5b0f3dd71a..0000000000 --- a/Source/radiation/RAD_3D.F90 +++ /dev/null @@ -1,56 +0,0 @@ -#include -#include - -module rad_module - - use amrex_fort_module, only : rt => amrex_real - implicit none - - real(rt) , parameter :: tiny = 1.e-50_rt - real(rt) , parameter :: BIGKR = 1.e25_rt - -contains - -! The following routines implement metric terms in 2D and are included -! in the 3D source only to enable the code to link. - -subroutine rfface(fine, & - DIMS(fbox), & - crse, & - DIMS(cbox), & - idim, irat) bind(C, name="rfface") - - use amrex_fort_module, only : rt => amrex_real - integer :: DIMDEC(fbox) - integer :: DIMDEC(cbox) - real(rt) :: fine(DIMV(fbox)) - real(rt) :: crse(DIMV(cbox)) - integer :: idim, irat(0:2) - integer :: i, j, k - integer :: rfac - if (idim == 0) then - rfac = irat(1) * irat(2) - do k = fbox_l3, fbox_h3 - do j = fbox_l2, fbox_h2 - fine(fbox_l1,j,k) = crse(cbox_l1, j/irat(1), k/irat(2)) / rfac - enddo - enddo - else if (idim == 1) then - rfac = irat(0) * irat(2) - do k = fbox_l3, fbox_h3 - do i = fbox_l1, fbox_h1 - fine(i,fbox_l2,k) = crse(i/irat(0), cbox_l2, k/irat(2)) / rfac - enddo - enddo - else - rfac = irat(0) * irat(1) - do j = fbox_l2, fbox_h2 - do i = fbox_l1, fbox_h1 - fine(i,j,fbox_l3) = crse(i/irat(0), j/irat(1), cbox_l3) / rfac - enddo - enddo - endif -end subroutine rfface - -end module rad_module - diff --git a/Source/radiation/RAD_F.H b/Source/radiation/RAD_F.H index 3b6e374ba0..ef85a7ba73 100644 --- a/Source/radiation/RAD_F.H +++ b/Source/radiation/RAD_F.H @@ -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); diff --git a/Source/radiation/Radiation.cpp b/Source/radiation/Radiation.cpp index d2eb374b1b..5534bc61b6 100644 --- a/Source/radiation/Radiation.cpp +++ b/Source/radiation/Radiation.cpp @@ -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); } } diff --git a/Source/radiation/rad_util.H b/Source/radiation/rad_util.H index 7c6f32c12c..e97ec127b7 100644 --- a/Source/radiation/rad_util.H +++ b/Source/radiation/rad_util.H @@ -295,4 +295,73 @@ amrex::Real kavg(Real a, Real b, Real d, int opt) return k; } +AMREX_INLINE +void rfface (Array4 const fine, + Array4 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