59 #ifndef INTEGRATOR_MECHANICS_H
60 #define INTEGRATOR_MECHANICS_H
67 #include "AMReX_ParallelDescriptor.H"
68 #include "AMReX_ParmParse.H"
89 #include "Numeric/Stencil.H"
95 #include "Operator/Operator.H"
100 template<
class MODEL>
118 for (
int i = 0; i < nmodels; i++)
127 std::string name =
"model" + std::to_string(i + 1);
136 value.
models.push_back(tmp_model);
148 if (nmodels > 1 && pp.
contains(
"ic.type"))
177 if (pp.
contains(
"trac_normal.ic.type"))
197 else eta_mf[lev]->setVal(1.0);
209 for (
int lev = 0; lev <= finest_level; ++lev)
212 psi_mf[lev]->FillBoundary();
213 amrex::Box domain = this->geom[lev].Domain();
214 domain.convert(amrex::IntVect::TheNodeVector());
217 for (MFIter mfi(*
model_mf[lev],
false); mfi.isValid(); ++mfi)
219 amrex::Box bx = mfi.grownnodaltilebox();
222 amrex::Array4<Set::Vector>
const& rhs =
rhs_mf[lev]->array(mfi);
223 amrex::Array4<const Set::Scalar>
const& psi =
psi_mf[lev]->array(mfi);
224 amrex::Array4<const Set::Scalar>
const& trac_normal =
trac_normal_mf[lev]->array(mfi);
226 amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) {
228 rhs(i,j,k) = trac_normal(i,j,k) * grad;
235 if (a_step > 0)
return;
237 for (
int lev = 0; lev <= finest_level; ++lev)
239 eta_mf[lev]->FillBoundary();
241 amrex::Box domain = this->geom[lev].Domain();
242 domain.convert(amrex::IntVect::TheNodeVector());
246 for (MFIter mfi(*
model_mf[lev],
false); mfi.isValid(); ++mfi)
248 amrex::Box bx = mfi.grownnodaltilebox();
251 amrex::Array4<MODEL>
const& model =
model_mf[lev]->array(mfi);
252 amrex::Array4<const Set::Scalar>
const& eta =
eta_mf[lev]->array(mfi);
254 amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) {
255 model(i, j, k) = MODEL::Zero();
256 for (
unsigned int n = 0; n <
models.size(); n++)
257 model(i, j, k) += eta(i, j, k, n) *
models[n];
265 for (MFIter mfi(*
model_mf[lev],
false); mfi.isValid(); ++mfi)
267 amrex::Box bx = mfi.grownnodaltilebox() & domain;
268 amrex::Array4<MODEL>
const& model = this->
model_mf[lev]->array(mfi);
269 const Dim3 lo = amrex::lbound(domain), hi = amrex::ubound(domain);
271 amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k)
273 if (i==lo.x && j==lo.y)
274 model(i,j,k) = 0.5*(model(i+1,j,k)+model(i,j+1,k));
275 else if (i==lo.x && j==hi.y)
276 model(i,j,k) = 0.5*(model(i+1,j,k)+model(i,j-1,k));
277 else if (i==hi.x && j==lo.y)
278 model(i,j,k) = 0.5*(model(i-1,j,k)+model(i,j+1,k));
279 else if (i==hi.x && j==hi.y)
280 model(i,j,k) = 0.5*(model(i-1,j,k)+model(i,j-1,k));
283 model(i,j,k) = model(i+1,j,k);
285 model(i,j,k) = model(i-1,j,k);
287 model(i,j,k) = model(i,j+1,k);
289 model(i,j,k) = model(i,j-1,k);
305 for (amrex::MFIter mfi(*
eta_mf[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi)
307 amrex::Box bx = mfi.nodaltilebox();
308 amrex::Array4<char>
const& tags = a_tags.array(mfi);
309 amrex::Array4<Set::Scalar>
const& eta =
eta_mf[lev]->array(mfi);
310 amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k)
313 for (
int n = 0; n <
eta_mf[lev]->nComp(); n++)
317 tags(i, j, k) = amrex::TagBox::SET;
322 amrex::Array4<Set::Scalar>
const& psi =
psi_mf[lev]->array(mfi);
323 amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k)
329 tags(i, j, k) = amrex::TagBox::SET;