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 amrex::FillPatchTwoLevels(mf_to_fill, time, cmf, ctime, fmf, ftime,
125 icomp, icomp, ncomp, geom[lev-1], geom[lev],
131 const bool do_bc=
true;
138 (*
physbcs[lev])(mf_to_fill,*mask,icomp,ncomp,mf_to_fill.nGrowVect(),time,bccomp,n_not_fill,mf_calc,
141#ifdef REMORA_USE_NETCDF
146 fill_from_bdyfiles(mf_to_fill,*mask,time,bccomp,bdy_var_type, icomp,icomp_calc,mf_calc,dt_lev);
150 if ( mf_box.ixType() == IndexType(IntVect(0,0,0)) ) {
151 mf_to_fill.EnforcePeriodicity(geom[lev].periodicity());
155 if ( (mf_box.ixType() == IndexType(IntVect(1,0,0))) ||
156 (mf_box.ixType() == IndexType(IntVect(0,1,0))) )
158 int khi = geom[lev].Domain().bigEnd(2);
159 for (MFIter mfi(mf_to_fill); mfi.isValid(); ++mfi)
161 Box gbx = mfi.growntilebox();
162 gbx.setSmall(2,khi+1);
164 Array4<Real> vel_arr = mf_to_fill.array(mfi);
165 ParallelFor(gbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k)
167 vel_arr(i,j,k) = vel_arr(i,j,khi);
193#ifdef REMORA_USE_NETCDF
205 BL_PROFILE_VAR(
"REMORA::FillPatch()",REMORA_FillPatch);
207 amrex::Interpolater* mapper =
nullptr;
209 Box mf_box(mf_to_fill.boxArray()[0]);
210 bool is_2d = mf_box.length(2) == 1;
219 if (lev>0 && fill_set) {
221 mf_box.ixType() == IndexType(IntVect(0,0,0))) {
225 if (mf_box.ixType() == IndexType(IntVect(1,0,0))) {
227 }
else if (mf_box.ixType() == IndexType(IntVect(0,1,0))) {
229 }
else if (mf_box.ixType() == IndexType(IntVect(0,0,1))) {
233 if (mf_box.ixType() == IndexType(IntVect(1,0,0))) {
235 }
else if (mf_box.ixType() == IndexType(IntVect(0,1,0))) {
244 ncomp = mf_to_fill.nComp();
249 if (mf_box.ixType() == IndexType(IntVect(0,0,0)))
252 mapper = &cell_cons_interp;
254 else if (mf_box.ixType() == IndexType(IntVect(1,0,0)))
257 mapper = &face_linear_interp;
259 else if (mf_box.ixType() == IndexType(IntVect(0,1,0)))
262 mapper = &face_linear_interp;
266 mapper = &face_linear_interp;
271 Vector<MultiFab*> fmf = {mfs[lev], mfs[lev]};
272 Vector<Real> ftime = {
t_old[lev],
t_new[lev]};
273 amrex::FillPatchSingleLevel(mf_to_fill, time, fmf, ftime, icomp, icomp, ncomp,
278 Vector<MultiFab*> fmf = {mfs[lev], mfs[lev]};
279 Vector<Real> ftime = {
t_old[lev],
t_new[lev]};
280 Vector<MultiFab*> cmf = {mfs[lev-1], mfs[lev-1]};
281 Vector<Real> ctime = {
t_old[lev-1],
t_new[lev-1]};
283 amrex::FillPatchTwoLevels(mf_to_fill, time, cmf, ctime, fmf, ftime,
284 0, icomp, ncomp, geom[lev-1], geom[lev],
300 const Real teps = (
t_new[lev] -
t_old[lev]) * 1.e-3_rt;
302 if (time >
t_new[lev] - teps && time <
t_new[lev] + teps)
304 for (
int i = 0; i < Vars::NumTypes; ++i) {
309 else if (time >
t_old[lev] - teps && time <
t_old[lev] + teps)
311 for (
int i = 0; i < Vars::NumTypes; ++i) {
316 else if (time >
t_old[lev] && time <
t_new[lev])
320 for (
int i = 0; i < Vars::NumTypes; ++i) {
321 MultiFab* mf_tmp =
new MultiFab(vars_new[lev][i].boxArray(),
322 vars_new[lev][i].DistributionMap(),
323 vars_new[lev][i].nComp(), vars_new[lev][i].nGrowVect());
324 mf_tmp->setVal(0.0_rt);
326 const Real dt_fraction = (time -
t_old[lev]) / (
t_new[lev] -
t_old[lev]);
327 MultiFab::Saxpy(*mf_tmp, 1.0_rt - dt_fraction, vars_old[lev][i], 0, 0, mf_tmp->nComp(), mf_tmp->nGrowVect());
328 MultiFab::Saxpy(*mf_tmp, dt_fraction, vars_new[lev][i], 0, 0, mf_tmp->nComp(), mf_tmp->nGrowVect());
336 amrex::Error(
"Requested data at a time outside the interval [t_old, t_new]");
340 for (
int i = 0; i < Vars::NumTypes; ++i) {
341 data.
get_var(Vars::xvel).FillBoundary(geom[lev].periodicity());
342 data.
get_var(Vars::yvel).FillBoundary(geom[lev].periodicity());
343 data.
get_var(Vars::zvel).FillBoundary(geom[lev].periodicity());
344 data.
get_var(Vars::cons).FillBoundary(geom[lev].periodicity());
369 AMREX_ASSERT(lev > 0);
373 ncomp = mf_to_fill->nComp();
379 amrex::Interpolater* mapper =
nullptr;
381 Box box_mf(mf_to_fill->boxArray()[0]);
383 if (box_mf.ixType() == IndexType(IntVect(0,0,0)))
386 mapper = &cell_cons_interp;
388 else if (box_mf.ixType() == IndexType(IntVect(1,0,0)))
391 mapper = &face_linear_interp;
393 else if (box_mf.ixType() == IndexType(IntVect(0,1,0)))
396 mapper = &face_linear_interp;
398 else if (box_mf.ixType() == IndexType(IntVect(0,0,1)))
401 mapper = &face_linear_interp;
403 amrex::Abort(
"Dont recognize this box type in REMORA_FillPatch");
409 Vector<Real> ctime = {cdata.
get_time()};
411 Vector<MultiFab*> cmf = {mf_crse};
412 Vector<Real> ctime = {time};
418#ifdef REMORA_USE_NETCDF
427#ifdef REMORA_USE_NETCDF
437 amrex::InterpFromCoarseLevel(*mf_to_fill, time, *mf_crse, 0, icomp, ncomp, geom[lev-1], geom[lev],
452 Box domain(Geom(lev).Domain());
454 int ihi = domain.bigEnd(0);
455 int jhi = domain.bigEnd(1);
456 int khi = domain.bigEnd(2);
459 mf_cc_vel.FillBoundary(geom[lev].periodicity());
462#pragma omp parallel if (Gpu::notInLaunchRegion())
464 for (MFIter mfi(mf_cc_vel, TilingIfNotGPU()); mfi.isValid(); ++mfi)
468 const Box& bx = mfi.tilebox();
469 const Array4<Real>& vel_arr = mf_cc_vel.array(mfi);
471 if (!Geom(lev).isPeriodic(0)) {
473 if (bx.smallEnd(0) <= domain.smallEnd(0)) {
475 ParallelFor(makeSlab(bx,0,0), [=] AMREX_GPU_DEVICE(
int ,
int j,
int k)
noexcept
477 vel_arr(-1,j,k,1) = mult*vel_arr(0,j,k,1);
478 vel_arr(-1,j,k,2) = mult*vel_arr(0,j,k,2);
483 if (bx.bigEnd(0) >= domain.bigEnd(0)) {
485 ParallelFor(makeSlab(bx,0,0), [=] AMREX_GPU_DEVICE(
int ,
int j,
int k)
noexcept
487 vel_arr(ihi+1,j,k,1) = mult*vel_arr(ihi,j,k,1);
488 vel_arr(ihi+1,j,k,2) = mult*vel_arr(ihi,j,k,2);
493 if (!Geom(lev).isPeriodic(1)) {
495 if (bx.smallEnd(1) <= domain.smallEnd(1)) {
497 ParallelFor(makeSlab(bx,1,0), [=] AMREX_GPU_DEVICE(
int i,
int ,
int k)
noexcept
499 vel_arr(i,-1,k,0) = mult*vel_arr(i,0,k,0);
500 vel_arr(i,-1,k,2) = mult*vel_arr(i,0,k,2);
505 if (bx.bigEnd(1) >= domain.bigEnd(1)) {
507 ParallelFor(makeSlab(bx,1,0), [=] AMREX_GPU_DEVICE(
int i,
int ,
int k)
noexcept
509 vel_arr(i,jhi+1,k,0) = mult*vel_arr(i,jhi,k,0);
510 vel_arr(i,jhi+1,k,2) = mult*-vel_arr(i,jhi,k,2);
515 if (!Geom(lev).isPeriodic(2)) {
517 if (bx.smallEnd(2) <= domain.smallEnd(2)) {
519 ParallelFor(makeSlab(bx,2,0), [=] AMREX_GPU_DEVICE(
int i,
int j,
int)
noexcept
521 vel_arr(i,j,-1,0) = mult*vel_arr(i,j,0,0);
522 vel_arr(i,j,-1,1) = mult*vel_arr(i,j,0,1);
527 if (bx.bigEnd(2) >= domain.bigEnd(2)) {
529 ParallelFor(makeSlab(bx,2,0), [=] AMREX_GPU_DEVICE(
int i,
int j,
int)
noexcept
531 vel_arr(i,j,khi+1,0) = mult*vel_arr(i,j,khi,0);
532 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.