1 #ifndef AMREX_EB_FLUXREGISTER_3D_C_H_
2 #define AMREX_EB_FLUXREGISTER_3D_C_H_
3 #include <AMReX_Config.H>
13 Real dtdx, Real dtdy, Real dtdz,
int ncomp)
16 && vfrac(i,j,k) > Real(1.e-14))
18 Real volinv = Real(1.0)/vfrac(i,j,k);
21 Real tmp = dtdx*ax(i,j,k)*volinv;
22 for (
int n = 0; n < ncomp; ++n) {
23 d(i,j,k,n) -= tmp*fx(i,j,k,n);
26 Real tmp = dtdx*ax(i+1,j,k)*volinv;
27 for (
int n = 0; n < ncomp; ++n) {
28 d(i,j,k,n) += tmp*fx(i+1,j,k,n);
33 Real tmp = dtdy*ay(i,j,k)*volinv;
34 for (
int n = 0; n < ncomp; ++n) {
35 d(i,j,k,n) -= tmp*fy(i,j,k,n);
38 Real tmp = dtdy*ay(i,j+1,k)*volinv;
39 for (
int n = 0; n < ncomp; ++n) {
40 d(i,j,k,n) += tmp*fy(i,j+1,k,n);
45 Real tmp = dtdz*az(i,j,k)*volinv;
46 for (
int n = 0; n < ncomp; ++n) {
47 d(i,j,k,n) -= tmp*fz(i,j,k,n);
50 Real tmp = dtdz*az(i,j,k+1)*volinv;
51 for (
int n = 0; n < ncomp; ++n) {
52 d(i,j,k,n) += tmp*fz(i,j,k+1,n);
60 Dim3 const& ratio, Real small) noexcept
62 Real cvol = Real(0.0);
63 for (
int kk = k*ratio.z; kk < (k+1)*ratio.z; ++kk) {
64 for (
int jj = j*ratio.y; jj < (j+1)*ratio.y; ++jj) {
65 for (
int ii = i*ratio.x; ii < (i+1)*ratio.x; ++ii) {
66 cvol += vfrac(ii,jj,kk);
70 return (cvol > small) ? Real(1.0)/cvol : Real(0.0);
75 Array4<Real const>
const&
f, Array4<Real const>
const& vfrac,
76 Array4<Real const>
const& a, Real fac, Dim3
const& ratio)
78 int ii = (i+1)*ratio.x;
80 for (
int kk = k*ratio.z; kk < (k+1)*ratio.z; ++kk) {
81 for (
int jj = j*ratio.y; jj < (j+1)*ratio.y; ++jj) {
82 if (
f.contains(ii,jj,kk)) {
83 fa +=
f(ii,jj,kk,n) * a(ii,jj,kk);
94 Array4<Real const>
const&
f, Array4<Real const>
const& vfrac,
95 Array4<Real const>
const& a, Real fac, Dim3
const& ratio)
99 for (
int kk = k*ratio.z; kk < (k+1)*ratio.z; ++kk) {
100 for (
int jj = j*ratio.y; jj < (j+1)*ratio.y; ++jj) {
101 if (
f.contains(ii,jj,kk)) {
102 fa +=
f(ii,jj,kk,n) * a(ii,jj,kk);
113 Array4<Real const>
const&
f, Array4<Real const>
const& vfrac,
114 Array4<Real const>
const& a, Real fac, Dim3
const& ratio)
116 int jj = (j+1)*ratio.y;
118 for (
int kk = k*ratio.z; kk < (k+1)*ratio.z; ++kk) {
119 for (
int ii = i*ratio.x; ii < (i+1)*ratio.x; ++ii) {
120 if (
f.contains(ii,jj,kk)) {
121 fa +=
f(ii,jj,kk,n) * a(ii,jj,kk);
132 Array4<Real const>
const&
f, Array4<Real const>
const& vfrac,
133 Array4<Real const>
const& a, Real fac, Dim3
const& ratio)
137 for (
int kk = k*ratio.z; kk < (k+1)*ratio.z; ++kk) {
138 for (
int ii = i*ratio.x; ii < (i+1)*ratio.x; ++ii) {
139 if (
f.contains(ii,jj,kk)) {
140 fa +=
f(ii,jj,kk,n) * a(ii,jj,kk);
154 int kk = (k+1)*ratio.
z;
156 for (
int jj = j*ratio.
y; jj < (j+1)*ratio.
y; ++jj) {
157 for (
int ii = i*ratio.
x; ii < (i+1)*ratio.
x; ++ii) {
158 if (
f.contains(ii,jj,kk)) {
159 fa +=
f(ii,jj,kk,n) * a(ii,jj,kk);
175 for (
int jj = j*ratio.
y; jj < (j+1)*ratio.
y; ++jj) {
176 for (
int ii = i*ratio.
x; ii < (i+1)*ratio.
x; ++ii) {
177 if (
f.contains(ii,jj,kk)) {
178 fa +=
f(ii,jj,kk,n) * a(ii,jj,kk);
189 Array4<Real const>
const& dm, Array4<Real const>
const& vfrac,
190 Dim3
const& ratio, Real threshold)
192 Real dmtot = Real(0.0);
193 for (
int kk = k*ratio.z; kk < (k+1)*ratio.z; ++kk) {
194 for (
int jj = j*ratio.y; jj < (j+1)*ratio.y; ++jj) {
195 for (
int ii = i*ratio.x; ii < (i+1)*ratio.x; ++ii) {
196 if (dmbx.contains(
IntVect(ii,jj,kk))) {
197 dmtot += dm(ii,jj,kk,n);
209 Array4<Real const>
const& s, Array4<int const>
const& amrflg,
210 Array4<EBCellFlag const>
const& ebflg, Array4<Real const>
const& vfrac)
214 auto flag = ebflg(i,j,k);
215 if (flag.isRegular())
217 if (bx.contains(
IntVect(i,j,k)))
222 else if (flag.isSingleValued())
224 Real dm = s(i,j,k,n) * vfrac(i,j,k);
225 if (bx.contains(
IntVect(i,j,k))) {
229 Real wtot = Real(0.0);
230 for (
int kk = -1; kk <= 1; ++kk) {
231 for (
int jj = -1; jj <= 1; ++jj) {
232 for (
int ii = -1; ii <= 1; ++ii) {
233 if ((ii != 0 || jj != 0 || kk != 0) && flag.isConnected(ii,jj,kk)) {
234 wtot += vfrac(i+ii,j+jj,k+kk);
238 Real drho = dm * ((Real(1.0)-vfrac(i,j,k))/wtot);
239 for (
int kk = -1; kk <= 1; ++kk) {
240 for (
int jj = -1; jj <= 1; ++jj) {
241 for (
int ii = -1; ii <= 1; ++ii) {
242 if ((ii != 0 || jj != 0 || kk != 0) && flag.isConnected(ii,jj,kk)) {
243 if (bx.contains(
IntVect(i+ii,j+jj,k+kk))) {
254 Array4<Real const>
const& s, Array4<int const>
const& msk, Dim3 ratio)
259 if (msk(ic,jc,kc) == 1) {
260 d(i,j,k,n) += s(ic,jc,kc,n);
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
constexpr int amrex_yafluxreg_fine_cell
Definition: AMReX_YAFluxRegister_K.H:8
constexpr int amrex_yafluxreg_crse_fine_boundary_cell
Definition: AMReX_YAFluxRegister_K.H:7
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void Add(T *const sum, T const value) noexcept
Definition: AMReX_GpuAtomic.H:619
static int f(amrex::Real t, N_Vector y_data, N_Vector y_rhs, void *user_data)
Definition: AMReX_SundialsIntegrator.H:44
Definition: AMReX_Amr.cpp:49
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void eb_rereflux_to_fine(int i, int j, int, int n, Array4< Real > const &d, Array4< Real const > const &s, Array4< int const > const &msk, Dim3 ratio)
Definition: AMReX_EBFluxRegister_2D_C.H:194
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void eb_flux_reg_fineadd_va_xlo(int i, int j, int k, int n, Array4< Real > const &d, Array4< Real const > const &f, Array4< Real const > const &vfrac, Array4< Real const > const &a, Real fac, Dim3 const &ratio)
Definition: AMReX_EBFluxRegister_2D_C.H:60
BoxND< AMREX_SPACEDIM > Box
Definition: AMReX_BaseFwd.H:27
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void eb_flux_reg_fineadd_va_zlo(int i, int j, int k, int n, Array4< Real > const &d, Array4< Real const > const &f, Array4< Real const > const &vfrac, Array4< Real const > const &a, Real fac, Dim3 const &ratio)
Definition: AMReX_EBFluxRegister_3D_C.H:150
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void eb_flux_reg_fineadd_va_yhi(int i, int j, int k, int n, Array4< Real > const &d, Array4< Real const > const &f, Array4< Real const > const &vfrac, Array4< Real const > const &a, Real fac, Dim3 const &ratio)
Definition: AMReX_EBFluxRegister_2D_C.H:114
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real eb_flux_reg_cvol(int i, int j, Array4< Real const > const &vfrac, Dim3 const &ratio, Real threshold) noexcept
Definition: AMReX_EBFluxRegister_2D_C.H:46
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void eb_flux_reg_fineadd_dm(int i, int j, int k, int n, Box const &dmbx, Array4< Real > const &d, Array4< Real const > const &dm, Array4< Real const > const &vfrac, Dim3 const &ratio, Real threshold)
Definition: AMReX_EBFluxRegister_2D_C.H:132
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void eb_flux_reg_fineadd_va_ylo(int i, int j, int k, int n, Array4< Real > const &d, Array4< Real const > const &f, Array4< Real const > const &vfrac, Array4< Real const > const &a, Real fac, Dim3 const &ratio)
Definition: AMReX_EBFluxRegister_2D_C.H:96
IntVectND< AMREX_SPACEDIM > IntVect
Definition: AMReX_BaseFwd.H:30
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void eb_flux_reg_fineadd_va_xhi(int i, int j, int k, int n, Array4< Real > const &d, Array4< Real const > const &f, Array4< Real const > const &vfrac, Array4< Real const > const &a, Real fac, Dim3 const &ratio)
Definition: AMReX_EBFluxRegister_2D_C.H:78
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void eb_rereflux_from_crse(int i, int j, int k, int n, Box const &bx, Array4< Real > const &d, Array4< Real const > const &s, Array4< int const > const &amrflg, Array4< EBCellFlag const > const &ebflg, Array4< Real const > const &vfrac)
Definition: AMReX_EBFluxRegister_2D_C.H:151
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > coarsen(const BoxND< dim > &b, int ref_ratio) noexcept
Coarsen BoxND by given (positive) refinement ratio. NOTE: if type(dir) = CELL centered: lo <- lo/rati...
Definition: AMReX_Box.H:1304
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void eb_flux_reg_fineadd_va_zhi(int i, int j, int k, int n, Array4< Real > const &d, Array4< Real const > const &f, Array4< Real const > const &vfrac, Array4< Real const > const &a, Real fac, Dim3 const &ratio)
Definition: AMReX_EBFluxRegister_3D_C.H:169
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void eb_flux_reg_crseadd_va(int i, int j, int k, Array4< Real > const &d, Array4< int const > const &flag, Array4< Real const > const &fx, Array4< Real const > const &fy, Array4< Real const > const &vfrac, Array4< Real const > const &ax, Array4< Real const > const &ay, Real dtdx, Real dtdy, int ncomp)
Definition: AMReX_EBFluxRegister_2D_C.H:8
Definition: AMReX_Array4.H:61
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T * ptr(int i, int j, int k) const noexcept
Definition: AMReX_Array4.H:149
Definition: AMReX_Dim3.H:12
int x
Definition: AMReX_Dim3.H:12
int z
Definition: AMReX_Dim3.H:12
int y
Definition: AMReX_Dim3.H:12