32#ifdef REMORA_USE_NETCDF
33 const int bdy_var_type,
43 const MultiFab& mf_calc)
45 BL_PROFILE_VAR(
"REMORA::FillPatch()",REMORA_FillPatch);
46 amrex::Interpolater* mapper =
nullptr;
48 Box mf_box(mf_to_fill.boxArray()[0]);
49 bool is_2d = mf_box.length(2) == 1;
60 if (lev>0 && fill_set) {
62 mf_box.ixType() == IndexType(IntVect(0,0,0))) {
66 if (mf_box.ixType() == IndexType(IntVect(1,0,0))) {
68 }
else if (mf_box.ixType() == IndexType(IntVect(0,1,0))) {
70 }
else if (mf_box.ixType() == IndexType(IntVect(0,0,1))) {
74 if (mf_box.ixType() == IndexType(IntVect(1,0,0))) {
76 }
else if (mf_box.ixType() == IndexType(IntVect(0,1,0))) {
85 ncomp = mf_to_fill.nComp();
90 if (mf_box.ixType() == IndexType(IntVect(0,0,0)))
92 mapper = &cell_cons_interp;
95 else if (mf_box.ixType() == IndexType(IntVect(1,0,0)))
97 mapper = &face_linear_interp;
100 else if (mf_box.ixType() == IndexType(IntVect(0,1,0)))
102 mapper = &face_linear_interp;
106 mapper = &face_linear_interp;
112 Vector<MultiFab*> fmf = {mfs[lev], mfs[lev]};
113 Vector<Real> ftime = {
t_old[lev],
t_new[lev]};
114 amrex::FillPatchSingleLevel(mf_to_fill, time, fmf, ftime, icomp, icomp, ncomp,
119 Vector<MultiFab*> fmf = {mfs[lev], mfs[lev]};
120 Vector<Real> ftime = {
t_old[lev],
t_new[lev]};
121 Vector<MultiFab*> cmf = {mfs[lev-1], mfs[lev-1]};
122 Vector<Real> ctime = {
t_old[lev-1],
t_new[lev-1]};
124 mfs[lev-1]->FillBoundary(geom[lev-1].periodicity());
125 amrex::FillPatchTwoLevels(mf_to_fill, mf_to_fill.nGrowVect(), IntVect(0,0,0),
126 time, cmf, ctime, fmf, ftime,
127 icomp, icomp, ncomp, geom[lev-1], geom[lev],
134 const bool do_bc=
true;
141 (*
physbcs[lev])(mf_to_fill,*mask,icomp,ncomp,mf_to_fill.nGrowVect(),time,bccomp,n_not_fill,mf_calc,
144#ifdef REMORA_USE_NETCDF
149 fill_from_bdyfiles(mf_to_fill,*mask,time,bccomp,bdy_var_type, icomp,icomp_calc,mf_calc,dt_lev);
153 if ( mf_box.ixType() == IndexType(IntVect(0,0,0)) ) {
154 mf_to_fill.EnforcePeriodicity(geom[lev].periodicity());
158 if ( (mf_box.ixType() == IndexType(IntVect(1,0,0))) ||
159 (mf_box.ixType() == IndexType(IntVect(0,1,0))) )
161 int khi = geom[lev].Domain().bigEnd(2);
162 for (MFIter mfi(mf_to_fill); mfi.isValid(); ++mfi)
164 Box gbx = mfi.growntilebox();
165 gbx.setSmall(2,khi+1);
167 Array4<Real> vel_arr = mf_to_fill.array(mfi);
168 ParallelFor(gbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k)
170 vel_arr(i,j,k) = vel_arr(i,j,khi);
196#ifdef REMORA_USE_NETCDF
208 BL_PROFILE_VAR(
"REMORA::FillPatch()",REMORA_FillPatch);
210 amrex::Interpolater* mapper =
nullptr;
212 Box mf_box(mf_to_fill.boxArray()[0]);
213 bool is_2d = mf_box.length(2) == 1;
222 if (lev>0 && fill_set) {
224 mf_box.ixType() == IndexType(IntVect(0,0,0))) {
228 if (mf_box.ixType() == IndexType(IntVect(1,0,0))) {
230 }
else if (mf_box.ixType() == IndexType(IntVect(0,1,0))) {
232 }
else if (mf_box.ixType() == IndexType(IntVect(0,0,1))) {
236 if (mf_box.ixType() == IndexType(IntVect(1,0,0))) {
238 }
else if (mf_box.ixType() == IndexType(IntVect(0,1,0))) {
247 ncomp = mf_to_fill.nComp();
252 if (mf_box.ixType() == IndexType(IntVect(0,0,0)))
255 mapper = &cell_cons_interp;
257 else if (mf_box.ixType() == IndexType(IntVect(1,0,0)))
260 mapper = &face_linear_interp;
262 else if (mf_box.ixType() == IndexType(IntVect(0,1,0)))
265 mapper = &face_linear_interp;
269 mapper = &face_linear_interp;
274 Vector<MultiFab*> fmf = {mfs[lev], mfs[lev]};
275 Vector<Real> ftime = {
t_old[lev],
t_new[lev]};
276 amrex::FillPatchSingleLevel(mf_to_fill, time, fmf, ftime, icomp, icomp, ncomp,
281 Vector<MultiFab*> fmf = {mfs[lev], mfs[lev]};
282 Vector<Real> ftime = {
t_old[lev],
t_new[lev]};
283 Vector<MultiFab*> cmf = {mfs[lev-1], mfs[lev-1]};
284 Vector<Real> ctime = {
t_old[lev-1],
t_new[lev-1]};
286 mfs[lev-1]->FillBoundary(geom[lev-1].periodicity());
287 amrex::FillPatchTwoLevels(mf_to_fill, mf_to_fill.nGrowVect(), IntVect(0,0,0),
288 time, cmf, ctime, fmf, ftime,
289 icomp, icomp, ncomp, geom[lev-1], geom[lev],
306 const Real teps = (
t_new[lev] -
t_old[lev]) * 1.e-3_rt;
308 if (time >
t_new[lev] - teps && time <
t_new[lev] + teps)
310 for (
int i = 0; i < Vars::NumTypes; ++i) {
315 else if (time >
t_old[lev] - teps && time <
t_old[lev] + teps)
317 for (
int i = 0; i < Vars::NumTypes; ++i) {
322 else if (time >
t_old[lev] && time <
t_new[lev])
326 for (
int i = 0; i < Vars::NumTypes; ++i) {
327 MultiFab* mf_tmp =
new MultiFab(vars_new[lev][i].boxArray(),
328 vars_new[lev][i].DistributionMap(),
329 vars_new[lev][i].nComp(), vars_new[lev][i].nGrowVect());
330 mf_tmp->setVal(0.0_rt);
332 const Real dt_fraction = (time -
t_old[lev]) / (
t_new[lev] -
t_old[lev]);
333 MultiFab::Saxpy(*mf_tmp, 1.0_rt - dt_fraction, vars_old[lev][i], 0, 0, mf_tmp->nComp(), mf_tmp->nGrowVect());
334 MultiFab::Saxpy(*mf_tmp, dt_fraction, vars_new[lev][i], 0, 0, mf_tmp->nComp(), mf_tmp->nGrowVect());
342 amrex::Error(
"Requested data at a time outside the interval [t_old, t_new]");
346 for (
int i = 0; i < Vars::NumTypes; ++i) {
347 data.
get_var(Vars::xvel).FillBoundary(geom[lev].periodicity());
348 data.
get_var(Vars::yvel).FillBoundary(geom[lev].periodicity());
349 data.
get_var(Vars::zvel).FillBoundary(geom[lev].periodicity());
350 data.
get_var(Vars::cons).FillBoundary(geom[lev].periodicity());
371 const int bdy_var_type,
374 const int n_not_fill,
375 const int icomp_calc,
377 const MultiFab& mf_calc)
380 AMREX_ASSERT(lev > 0);
386 ncomp = mf_to_fill->nComp();
391 Box mf_box(mf_to_fill->boxArray()[0]);
394 amrex::Interpolater* mapper =
nullptr;
396 Box box_mf(mf_to_fill->boxArray()[0]);
398 if (box_mf.ixType() == IndexType(IntVect(0,0,0)))
401 mapper = &cell_cons_interp;
404 else if (box_mf.ixType() == IndexType(IntVect(1,0,0)))
407 mapper = &face_linear_interp;
410 else if (box_mf.ixType() == IndexType(IntVect(0,1,0)))
413 mapper = &face_linear_interp;
416 else if (box_mf.ixType() == IndexType(IntVect(0,0,1)))
419 mapper = &face_linear_interp;
422 amrex::Abort(
"Dont recognize this box type in REMORA_FillPatch");
428 Vector<Real> ctime = {cdata.
get_time()};
430 Vector<MultiFab*> cmf = {mf_crse};
431 Vector<Real> ctime = {time};
437#ifdef REMORA_USE_NETCDF
446#ifdef REMORA_USE_NETCDF
453 mf_crse->FillBoundary(geom[lev-1].periodicity());
454 amrex::InterpFromCoarseLevel(*mf_to_fill, mf_to_fill->nGrowVect(), IntVect(0,0,0),
455 *mf_crse, 0, icomp, ncomp, geom[lev-1], geom[lev],
464 (*
physbcs[lev])(*mf_to_fill,*mask,icomp,ncomp,mf_to_fill->nGrowVect(),
465 time,bccomp,n_not_fill,mf_calc,
468#ifdef REMORA_USE_NETCDF
473 fill_from_bdyfiles(*mf_to_fill,*mask,time,bccomp,bdy_var_type, icomp,icomp_calc,mf_calc,dt_lev);
477 if ( mf_box.ixType() == IndexType(IntVect(0,0,0)) ) {
478 mf_to_fill->EnforcePeriodicity(geom[lev].periodicity());
482 if ( (mf_box.ixType() == IndexType(IntVect(1,0,0))) ||
483 (mf_box.ixType() == IndexType(IntVect(0,1,0))) )
485 int khi = geom[lev].Domain().bigEnd(2);
486 for (MFIter mfi(*mf_to_fill); mfi.isValid(); ++mfi)
488 Box gbx = mfi.growntilebox();
489 gbx.setSmall(2,khi+1);
491 Array4<Real> vel_arr = mf_to_fill->array(mfi);
492 ParallelFor(gbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k)
494 vel_arr(i,j,k) = vel_arr(i,j,khi);
511 Box domain(Geom(lev).Domain());
513 int ihi = domain.bigEnd(0);
514 int jhi = domain.bigEnd(1);
515 int khi = domain.bigEnd(2);
518 mf_cc_vel.FillBoundary(geom[lev].periodicity());
521#pragma omp parallel if (Gpu::notInLaunchRegion())
523 for (MFIter mfi(mf_cc_vel, TilingIfNotGPU()); mfi.isValid(); ++mfi)
527 const Box& bx = mfi.tilebox();
528 const Array4<Real>& vel_arr = mf_cc_vel.array(mfi);
530 if (!Geom(lev).isPeriodic(0)) {
532 if (bx.smallEnd(0) <= domain.smallEnd(0)) {
534 ParallelFor(makeSlab(bx,0,0), [=] AMREX_GPU_DEVICE(
int ,
int j,
int k)
noexcept
536 vel_arr(-1,j,k,1) = mult*vel_arr(0,j,k,1);
537 vel_arr(-1,j,k,2) = mult*vel_arr(0,j,k,2);
542 if (bx.bigEnd(0) >= domain.bigEnd(0)) {
544 ParallelFor(makeSlab(bx,0,0), [=] AMREX_GPU_DEVICE(
int ,
int j,
int k)
noexcept
546 vel_arr(ihi+1,j,k,1) = mult*vel_arr(ihi,j,k,1);
547 vel_arr(ihi+1,j,k,2) = mult*vel_arr(ihi,j,k,2);
552 if (!Geom(lev).isPeriodic(1)) {
554 if (bx.smallEnd(1) <= domain.smallEnd(1)) {
556 ParallelFor(makeSlab(bx,1,0), [=] AMREX_GPU_DEVICE(
int i,
int ,
int k)
noexcept
558 vel_arr(i,-1,k,0) = mult*vel_arr(i,0,k,0);
559 vel_arr(i,-1,k,2) = mult*vel_arr(i,0,k,2);
564 if (bx.bigEnd(1) >= domain.bigEnd(1)) {
566 ParallelFor(makeSlab(bx,1,0), [=] AMREX_GPU_DEVICE(
int i,
int ,
int k)
noexcept
568 vel_arr(i,jhi+1,k,0) = mult*vel_arr(i,jhi,k,0);
569 vel_arr(i,jhi+1,k,2) = mult*-vel_arr(i,jhi,k,2);
574 if (!Geom(lev).isPeriodic(2)) {
576 if (bx.smallEnd(2) <= domain.smallEnd(2)) {
578 ParallelFor(makeSlab(bx,2,0), [=] AMREX_GPU_DEVICE(
int i,
int j,
int)
noexcept
580 vel_arr(i,j,-1,0) = mult*vel_arr(i,j,0,0);
581 vel_arr(i,j,-1,1) = mult*vel_arr(i,j,0,1);
586 if (bx.bigEnd(2) >= domain.bigEnd(2)) {
588 ParallelFor(makeSlab(bx,2,0), [=] AMREX_GPU_DEVICE(
int i,
int j,
int)
noexcept
590 vel_arr(i,j,khi+1,0) = mult*vel_arr(i,j,khi,0);
591 vel_arr(i,j,khi+1,1) = mult*vel_arr(i,j,khi,1);
void FillPatch(int lev, amrex::Real time, amrex::MultiFab &mf_to_be_filled, amrex::Vector< amrex::MultiFab * > const &mfs, const int bccomp, const int bdy_var_type=BdyVars::null, const int icomp=0, const bool fill_all=true, const bool fill_set=true, const int n_not_fill=0, const int icomp_calc=0, const amrex::Real dt=amrex::Real(0.0), const amrex::MultiFab &mf_calc=amrex::MultiFab())
Fill a new MultiFab by copying in phi from valid region and filling ghost cells.
void FillCoarsePatch(int lev, amrex::Real time, amrex::MultiFab *mf_fine, amrex::MultiFab *mf_crse, const int bdy_var_type=BdyVars::null, const int icomp=0, const bool fill_all=true, const int n_not_fill=0, const int icomp_calc=0, const amrex::Real dt=amrex::Real(0.0), const amrex::MultiFab &mf_calc=amrex::MultiFab())
fill an entire multifab by interpolating from the coarser level