1 #ifndef AMREX_MULTIFAB_UTIL_1D_C_H_
2 #define AMREX_MULTIFAB_UTIL_1D_C_H_
3 #include <AMReX_Config.H>
17 int cccomp,
int ndcomp) noexcept
19 cc(i,0,0,n+cccomp) = Real(0.5)*(nd(i,0,0,n+ndcomp)+nd(i+1,0,0,n+ndcomp));
28 cc(i,0,0,cccomp) = Ex(i,0,0);
31 template <
typename CT,
typename FT>
38 const int coord_type = gd.Coord();
44 cc(i,0,0,cccomp) = CT(0.5) * CT( fx(i,0,0) + fx(i+1,0,0) );
49 const Real problo = gd.ProbLo(0);
50 const Real dx = gd.CellSize(0);
51 Real rlo = problo + i*dx;
52 Real rhi = problo + (i+1)*dx;
53 Real rcen = Real(0.5)*(rlo+rhi);
54 cc(i,0,0,cccomp) = CT(Real(0.5) * ( rlo*fx(i,0,0) + rhi*fx(i+1,0,0) ) / rcen);
59 const Real problo = gd.ProbLo(0);
60 const Real dx = gd.CellSize(0);
61 Real rlo = problo + i*dx;
62 Real rhi = problo + (i+1)*dx;
63 Real rcen = Real(0.5)*(rlo+rhi);
64 cc(i,0,0,cccomp) = CT(Real(0.5) * ( rlo*rlo*fx(i,0,0) + rhi*rhi*fx(i+1,0,0) ) / (rcen*rcen));
78 GeometryData const& gd,
bool use_harmonic_averaging) noexcept
80 if (xbx.contains(i,0,0)) {
81 const int coord_type = gd.Coord();
86 if (use_harmonic_averaging)
88 if (cc(i-1,0,0,n) == Real(0.0) || cc(i,0,0,n) == Real(0.0)) {
89 fx(i,0,0,n) = Real(0.0);
91 fx(i,0,0,n) = Real(2.0) / ( Real(1.0) / cc(i-1,0,0,n) + Real(1.0) / cc(i,0,0,n) );
94 fx(i,0,0,n) = Real(0.5)*(cc(i-1,0,0,n) + cc(i,0,0,n));
100 const Real problo = gd.ProbLo(0);
101 const Real dx = gd.CellSize(0);
103 Real rlo = problo + (i-Real(0.5))*dx;
104 Real rhi = problo + (i+Real(0.5))*dx;
105 Real rcen = Real(0.5)*(rlo+rhi);
106 fx(i,0,0,n) = Real(0.5)*(rlo*cc(i-1,0,0,n) + rhi*cc(i,0,0,n)) / rcen;
111 const Real problo = gd.ProbLo(0);
112 const Real dx = gd.CellSize(0);
114 Real rlo = problo + (i-Real(0.5))*dx;
115 Real rhi = problo + (i+Real(0.5))*dx;
116 Real rcen = Real(0.5)*(rlo+rhi);
117 fx(i,0,0,n) = Real(0.5)*(rlo*rlo*cc(i-1,0,0,n) + rhi*rhi*cc(i,0,0,n)) / (rcen*rcen);
128 template <
typename T>
132 int ccomp,
int fcomp,
int ncomp,
133 IntVect const& ratio,
int ) noexcept
135 const auto clo =
lbound(bx);
136 const auto chi =
ubound(bx);
138 const int facx = ratio[0];
140 for (
int n = 0; n < ncomp; ++n) {
141 for (
int i = clo.x; i <= chi.x; ++i) {
142 crse(i,0,0,n+ccomp) =
fine(facx*i,0,0,n+fcomp);
147 template <
typename T>
151 int ccomp,
int fcomp,
IntVect const& ratio,
int ) noexcept
153 crse(i,0,0,n+ccomp) =
fine(ratio[0]*i,0,0,n+fcomp);
159 int ccomp,
int fcomp,
int ncomp,
160 IntVect const& ratio,
int ) noexcept
162 const auto clo =
lbound(bx);
163 const auto chi =
ubound(bx);
165 const int facx = ratio[0];
166 Real facInv = Real(1.)/facx;
168 for (
int n = 0; n < ncomp; ++n) {
169 for (
int i = clo.x; i <= chi.x; ++i) {
171 for (
int iref = 0; iref < facx; ++iref) {
172 c +=
fine(facx*i+iref,0,0,n+fcomp);
174 crse(i,0,0,n+ccomp) = c * facInv;
182 int ccomp,
int fcomp,
IntVect const& ratio,
int ) noexcept
184 const int facx = ratio[0];
185 const Real facInv = Real(1.)/facx;
187 for (
int iref = 0; iref < facx; ++iref) {
188 c +=
fine(facx*i+iref,0,0,n+fcomp);
190 crse(i,0,0,n+ccomp) = c * facInv;
193 template <
typename T>
197 int ccomp,
int fcomp,
int ncomp,
200 const auto clo =
lbound(bx);
201 const auto chi =
ubound(bx);
203 const int facx = ratio[0];
204 const T
volfrac = T(1.0)/T(facx);
206 for (
int n = 0; n < ncomp; ++n) {
207 for (
int i = clo.x; i <= chi.x; ++i) {
210 for (
int iref = 0; iref < facx; ++iref) {
211 c +=
fine(ii+iref,0,0,n+fcomp);
218 template <
typename T>
222 int ccomp,
int fcomp,
IntVect const& ratio) noexcept
224 const int facx = ratio[0];
225 const T
volfrac = T(1.0)/T(facx);
226 const int ii = i*facx;
228 for (
int iref = 0; iref < facx; ++iref) {
229 c +=
fine(ii+iref,0,0,n+fcomp);
234 template <
typename T>
239 int ccomp,
int fcomp,
IntVect const& ratio) noexcept
241 const int facx = ratio[0];
242 const int ii = i*facx;
244 for (
int iref = 0; iref < facx; ++iref) {
245 cv += fv(ii+iref,0,0);
246 cd +=
fine(ii+iref,0,0,fcomp+n)*fv(ii+iref,0,0);
248 crse(i,0,0,ccomp+n) = cd/cv;
251 template <
typename T>
255 int ccomp,
int fcomp,
int ncomp,
258 const auto clo =
lbound(bx);
259 const auto chi =
ubound(bx);
261 const int facx = ratio[0];
263 for (
int n = 0; n < ncomp; ++n) {
265 for (
int i = clo.x; i <= chi.x; ++i) {
266 crse(i,0,0,n+ccomp) =
fine(i*facx,0,0,n+fcomp);
275 int ccomp,
int fcomp,
IntVect const& ratio) noexcept
277 crse(i,0,0,n+ccomp) =
fine(i*ratio[0],0,0,n+fcomp);
286 const auto lo =
lbound(bx);
287 const auto hi =
ubound(bx);
288 const Real dxi = dxinv[0];
290 for (
int n = 0; n < divu.ncomp; ++n) {
292 for (
int i = lo.x; i <= hi.x; ++i) {
293 divu(i,0,0,n) = dxi * (u(i+1,0,0,n)-u(i,0,0,n));
304 const auto lo =
lbound(bx);
305 const auto hi =
ubound(bx);
306 const Real dxi = dxinv[0];
309 for (
int i = lo.x; i <= hi.x; ++i) {
310 grad(i,0,0) = dxi * (u(i+1,0,0)-u(i,0,0));
#define AMREX_PRAGMA_SIMD
Definition: AMReX_Extension.H:80
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
Array4< Real > fine
Definition: AMReX_InterpFaceRegister.cpp:90
Array4< Real const > crse
Definition: AMReX_InterpFaceRegister.cpp:92
Definition: AMReX_Amr.cpp:49
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void amrex_avg_fc_to_cc(int i, int, int, Array4< CT > const &cc, Array4< FT const > const &fx, int cccomp, GeometryData const &gd) noexcept
Definition: AMReX_MultiFabUtil_1D_C.H:33
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void amrex_avgdown_faces(Box const &bx, Array4< T > const &crse, Array4< T const > const &fine, int ccomp, int fcomp, int ncomp, IntVect const &ratio, int) noexcept
Definition: AMReX_MultiFabUtil_1D_C.H:130
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void amrex_avg_cc_to_fc(int i, int, int, int n, Box const &xbx, Array4< Real > const &fx, Array4< Real const > const &cc, GeometryData const &gd, bool use_harmonic_averaging) noexcept
Definition: AMReX_MultiFabUtil_1D_C.H:75
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 ubound(Array4< T > const &a) noexcept
Definition: AMReX_Array4.H:315
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 lbound(Array4< T > const &a) noexcept
Definition: AMReX_Array4.H:308
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void amrex_avgdown_with_vol(int i, int, int, int n, Array4< T > const &crse, Array4< T const > const &fine, Array4< T const > const &fv, int ccomp, int fcomp, IntVect const &ratio) noexcept
Definition: AMReX_MultiFabUtil_1D_C.H:236
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void amrex_avg_nd_to_cc(int i, int, int, int n, Array4< Real > const &cc, Array4< Real const > const &nd, int cccomp, int ndcomp) noexcept
Definition: AMReX_MultiFabUtil_1D_C.H:14
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void amrex_avgdown_edges(Box const &bx, Array4< Real > const &crse, Array4< Real const > const &fine, int ccomp, int fcomp, int ncomp, IntVect const &ratio, int) noexcept
Definition: AMReX_MultiFabUtil_1D_C.H:157
AMREX_GPU_HOST_DEVICE void amrex_compute_divergence(Box const &bx, Array4< Real > const &divu, Array4< Real const > const &u, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MultiFabUtil_1D_C.H:282
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void amrex_avg_eg_to_cc(int i, int, int, Array4< Real > const &cc, Array4< Real const > const &Ex, int cccomp) noexcept
Definition: AMReX_MultiFabUtil_1D_C.H:23
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void amrex_avgdown(Box const &bx, Array4< T > const &crse, Array4< T const > const &fine, int ccomp, int fcomp, int ncomp, IntVect const &ratio) noexcept
Definition: AMReX_MultiFabUtil_1D_C.H:195
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void amrex_avgdown_nodes(Box const &bx, Array4< T > const &crse, Array4< T const > const &fine, int ccomp, int fcomp, int ncomp, IntVect const &ratio) noexcept
Definition: AMReX_MultiFabUtil_1D_C.H:253
AMREX_GPU_HOST_DEVICE void amrex_compute_gradient(Box const &bx, Array4< Real > const &grad, Array4< Real const > const &u, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MultiFabUtil_1D_C.H:300
Definition: AMReX_Array4.H:61
Definition: AMReX_Geometry.H:25