30 const DiffusionType difftype,
const amrex::Real dt,
bool mesh_mapping)
32 amrex::Real factor = 0.0;
47 amrex::Abort(
"Invalid diffusion type");
52 auto fstate = std::is_same<Scheme, fvm::Godunov>::value
60 if (field.in_uniform_space() && mesh_mapping) {
61 field.to_stretched_space();
64 if (field_old.in_uniform_space() && mesh_mapping) {
65 field_old.to_stretched_space();
74 Field const* mesh_detJ =
78 for (
int lev = 0; lev < nlevels; ++lev) {
80#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
82 for (amrex::MFIter mfi(field(lev)); mfi.isValid(); ++mfi) {
83 const auto& bx = mfi.tilebox();
84 auto fld = field(lev).array(mfi);
85 const auto fld_o = field_old(lev).const_array(mfi);
86 const auto rho_o = den_old(lev).const_array(mfi);
87 const auto rho = den_new(lev).const_array(mfi);
88 const auto src = src_term(lev).const_array(mfi);
89 const auto diff = diff_term(lev).const_array(mfi);
90 const auto ddt_o = conv_term(lev).const_array(mfi);
91 const auto imask = mask_cell(lev).const_array(mfi);
92 amrex::Array4<amrex::Real const> detJ =
93 mesh_mapping ? ((*mesh_detJ)(lev).const_array(mfi))
94 : amrex::Array4<amrex::Real const>();
96 if (PDE::multiply_rho) {
101 [=] AMREX_GPU_DEVICE(
102 int i,
int j,
int k,
int n)
noexcept {
104 mesh_mapping ? (detJ(i, j, k)) : 1.0;
107 rho_o(i, j, k) * det_j * fld_o(i, j, k, n) +
108 static_cast<amrex::Real
>(imask(i, j, k)) * dt *
110 det_j * src(i, j, k, n) +
111 factor * diff(i, j, k, n));
113 fld(i, j, k, n) /= rho(i, j, k);
116 fld(i, j, k, n) /= det_j;
122 [=] AMREX_GPU_DEVICE(
123 int i,
int j,
int k,
int n)
noexcept {
125 mesh_mapping ? (detJ(i, j, k)) : 1.0;
128 det_j * fld_o(i, j, k, n) +
129 static_cast<amrex::Real
>(imask(i, j, k)) * dt *
131 det_j * src(i, j, k, n) +
132 factor * diff(i, j, k, n));
135 fld(i, j, k, n) /= det_j;
150 const DiffusionType difftype,
const amrex::Real dt,
bool mesh_mapping)
152 amrex::Real ofac = 0.0;
153 amrex::Real nfac = 0.0;
171 amrex::Abort(
"Invalid diffusion type");
178 if (field.in_uniform_space() && mesh_mapping) {
179 field.to_stretched_space();
182 if (field_old.in_uniform_space() && mesh_mapping) {
183 field_old.to_stretched_space();
194 Field const* mesh_detJ =
198 for (
int lev = 0; lev < nlevels; ++lev) {
200#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
202 for (amrex::MFIter mfi(field(lev)); mfi.isValid(); ++mfi) {
203 const auto& bx = mfi.tilebox();
204 auto fld = field(lev).array(mfi);
205 const auto fld_o = field_old(lev).const_array(mfi);
206 const auto rho_o = den_old(lev).const_array(mfi);
207 const auto rho = den_new(lev).const_array(mfi);
208 const auto src = src_term(lev).const_array(mfi);
209 const auto diff = diff_term(lev).const_array(mfi);
210 const auto ddt = conv_term(lev).const_array(mfi);
211 const auto diff_o = diff_term_old(lev).const_array(mfi);
212 const auto ddt_o = conv_term_old(lev).const_array(mfi);
213 const auto imask = mask_cell(lev).const_array(mfi);
214 amrex::Array4<amrex::Real const> detJ =
215 mesh_mapping ? ((*mesh_detJ)(lev).const_array(mfi))
216 : amrex::Array4<amrex::Real const>();
218 if (PDE::multiply_rho) {
223 [=] AMREX_GPU_DEVICE(
224 int i,
int j,
int k,
int n)
noexcept {
226 mesh_mapping ? (detJ(i, j, k)) : 1.0;
229 rho_o(i, j, k) * det_j * fld_o(i, j, k, n) +
230 static_cast<amrex::Real
>(imask(i, j, k)) * dt *
232 (ddt_o(i, j, k, n) + ddt(i, j, k, n)) +
233 ofac * diff_o(i, j, k, n) +
234 nfac * diff(i, j, k, n) +
235 det_j * src(i, j, k, n));
237 fld(i, j, k, n) /= rho(i, j, k);
240 fld(i, j, k, n) /= det_j;
246 [=] AMREX_GPU_DEVICE(
247 int i,
int j,
int k,
int n)
noexcept {
249 mesh_mapping ? (detJ(i, j, k)) : 1.0;
252 det_j * fld_o(i, j, k, n) +
253 static_cast<amrex::Real
>(imask(i, j, k)) * dt *
255 (ddt_o(i, j, k, n) + ddt(i, j, k, n)) +
256 ofac * diff_o(i, j, k, n) +
257 nfac * diff(i, j, k, n) +
258 det_j * src(i, j, k, n));
261 fld(i, j, k, n) /= det_j;