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>
117 for (
int i = 0; i < nmodels; i++)
126 std::string name =
"model" + std::to_string(i + 1);
135 value.
models.push_back(tmp_model);
147 if (nmodels > 1 && pp.
contains(
"ic.type"))
151 if (type ==
"ellipse") value.
ic_eta =
new IC::Ellipse(value.geom, pp,
"ic.ellipse");
152 else if (type ==
"constant") value.
ic_eta =
new IC::Constant(value.geom, pp,
"ic.constant");
153 else if (type ==
"voronoi") value.
ic_eta =
new IC::Voronoi(value.geom, pp,
"ic.voronoi");
154 else if (type ==
"bmp") value.
ic_eta =
new IC::BMP(value.geom, pp,
"ic.bmp");
155 else if (type ==
"png") value.
ic_eta =
new IC::PNG(value.geom, pp,
"ic.png");
156 else if (type ==
"expression") value.
ic_eta =
new IC::Expression(value.geom, pp,
"ic.expression");
157 else if (type ==
"psread") value.
ic_eta =
new IC::PSRead(value.geom, pp,
"ic.psread");
172 if (type ==
"ellipse") value.
ic_psi =
new IC::Ellipse(value.geom, pp,
"psi.ic.ellipse");
173 else if (type ==
"constant") value.
ic_psi =
new IC::Constant(value.geom, pp,
"psi.ic.constant");
174 else if (type ==
"expression") value.
ic_psi =
new IC::Expression(value.geom, pp,
"psi.ic.expression");
175 else if (type ==
"psread") value.
ic_psi =
new IC::PSRead(value.geom, pp,
"psi.ic.psread");
176 else if (type ==
"png") value.
ic_psi =
new IC::PNG(value.geom, pp,
"psi.ic.png");
193 pp_query(
"trac_normal.ic.type", type);
213 else eta_mf[lev]->setVal(1.0);
225 for (
int lev = 0; lev <= finest_level; ++lev)
228 psi_mf[lev]->FillBoundary();
229 amrex::Box domain = this->geom[lev].Domain();
230 domain.convert(amrex::IntVect::TheNodeVector());
233 for (MFIter mfi(*
model_mf[lev],
false); mfi.isValid(); ++mfi)
235 amrex::Box bx = mfi.grownnodaltilebox();
238 amrex::Array4<Set::Vector>
const& rhs =
rhs_mf[lev]->array(mfi);
239 amrex::Array4<const Set::Scalar>
const& psi =
psi_mf[lev]->array(mfi);
240 amrex::Array4<const Set::Scalar>
const& trac_normal =
trac_normal_mf[lev]->array(mfi);
242 amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) {
244 rhs(i,j,k) = trac_normal(i,j,k) * grad;
251 if (a_step > 0)
return;
253 for (
int lev = 0; lev <= finest_level; ++lev)
255 eta_mf[lev]->FillBoundary();
257 amrex::Box domain = this->geom[lev].Domain();
258 domain.convert(amrex::IntVect::TheNodeVector());
262 for (MFIter mfi(*
model_mf[lev],
false); mfi.isValid(); ++mfi)
264 amrex::Box bx = mfi.grownnodaltilebox();
267 amrex::Array4<MODEL>
const& model =
model_mf[lev]->array(mfi);
268 amrex::Array4<const Set::Scalar>
const& eta =
eta_mf[lev]->array(mfi);
270 amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) {
271 model(i, j, k) = MODEL::Zero();
272 for (
unsigned int n = 0; n <
models.size(); n++)
273 model(i, j, k) += eta(i, j, k, n) *
models[n];
281 for (MFIter mfi(*
model_mf[lev],
false); mfi.isValid(); ++mfi)
283 amrex::Box bx = mfi.grownnodaltilebox() & domain;
284 amrex::Array4<MODEL>
const& model = this->
model_mf[lev]->array(mfi);
285 const Dim3 lo = amrex::lbound(domain), hi = amrex::ubound(domain);
287 amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k)
289 if (i==lo.x && j==lo.y)
290 model(i,j,k) = 0.5*(model(i+1,j,k)+model(i,j+1,k));
291 else if (i==lo.x && j==hi.y)
292 model(i,j,k) = 0.5*(model(i+1,j,k)+model(i,j-1,k));
293 else if (i==hi.x && j==lo.y)
294 model(i,j,k) = 0.5*(model(i-1,j,k)+model(i,j+1,k));
295 else if (i==hi.x && j==hi.y)
296 model(i,j,k) = 0.5*(model(i-1,j,k)+model(i,j-1,k));
299 model(i,j,k) = model(i+1,j,k);
301 model(i,j,k) = model(i-1,j,k);
303 model(i,j,k) = model(i,j+1,k);
305 model(i,j,k) = model(i,j-1,k);
321 for (amrex::MFIter mfi(*
eta_mf[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi)
323 amrex::Box bx = mfi.nodaltilebox();
324 amrex::Array4<char>
const& tags = a_tags.array(mfi);
325 amrex::Array4<Set::Scalar>
const& eta =
eta_mf[lev]->array(mfi);
326 amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k)
329 for (
int n = 0; n <
eta_mf[lev]->nComp(); n++)
333 tags(i, j, k) = amrex::TagBox::SET;
338 amrex::Array4<Set::Scalar>
const& psi =
psi_mf[lev]->array(mfi);
339 amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k)
345 tags(i, j, k) = amrex::TagBox::SET;