32#ifdef REMORA_USE_NETCDF
33 const int bdy_var_type,
41#ifdef REMORA_USE_NETCDF
48 const MultiFab& mf_calc)
50 BL_PROFILE_VAR(
"REMORA::FillPatch()",REMORA_FillPatch);
51 amrex::Interpolater* mapper =
nullptr;
53 Box mf_box(mf_to_fill.boxArray()[0]);
54 bool is_2d = mf_box.length(2) == 1;
65 if (lev>0 && fill_set) {
67 mf_box.ixType() == IndexType(IntVect(0,0,0))) {
71 if (mf_box.ixType() == IndexType(IntVect(1,0,0))) {
73 }
else if (mf_box.ixType() == IndexType(IntVect(0,1,0))) {
75 }
else if (mf_box.ixType() == IndexType(IntVect(0,0,1))) {
79 if (mf_box.ixType() == IndexType(IntVect(1,0,0))) {
81 }
else if (mf_box.ixType() == IndexType(IntVect(0,1,0))) {
90 ncomp = mf_to_fill.nComp();
95 if (mf_box.ixType() == IndexType(IntVect(0,0,0)))
97 mapper = &cell_cons_interp;
100 else if (mf_box.ixType() == IndexType(IntVect(1,0,0)))
102 mapper = &face_cons_linear_interp;
105 else if (mf_box.ixType() == IndexType(IntVect(0,1,0)))
107 mapper = &face_cons_linear_interp;
111 mapper = &face_cons_linear_interp;
117 Vector<MultiFab*> fmf = {mfs[lev], mfs[lev]};
118 Vector<Real> ftime = {
t_old[lev],
t_new[lev]};
119 amrex::FillPatchSingleLevel(mf_to_fill, time, fmf, ftime, icomp, icomp, ncomp,
124 Vector<MultiFab*> fmf = {mfs[lev], mfs[lev]};
125 Vector<Real> ftime = {
t_old[lev],
t_new[lev]};
126 Vector<MultiFab*> cmf = {mfs[lev-1], mfs[lev-1]};
127 Vector<Real> ctime = {
t_old[lev-1],
t_new[lev-1]};
129 mfs[lev-1]->FillBoundary(geom[lev-1].periodicity());
130 amrex::FillPatchTwoLevels(mf_to_fill, mf_to_fill.nGrowVect(), IntVect(0,0,0),
131 time, cmf, ctime, fmf, ftime,
132 icomp, icomp, ncomp, geom[lev-1], geom[lev],
139 const bool do_bc=
true;
146 (*
physbcs[lev])(mf_to_fill,*mask,icomp,ncomp,mf_to_fill.nGrowVect(),time,bccomp,n_not_fill,mf_calc,
149#ifdef REMORA_USE_NETCDF
153 fill_from_bdyfiles(lev, mf_to_fill,*mask,time,bccomp,bdy_var_type, icomp,icomp_calc,mf_calc,dt_lev);
157 if ( mf_box.ixType() == IndexType(IntVect(0,0,0)) ) {
158 mf_to_fill.EnforcePeriodicity(geom[lev].periodicity());
162 if ( (mf_box.ixType() == IndexType(IntVect(1,0,0))) ||
163 (mf_box.ixType() == IndexType(IntVect(0,1,0))) )
165 int khi = geom[lev].Domain().bigEnd(2);
166 for (MFIter mfi(mf_to_fill); mfi.isValid(); ++mfi)
168 Box gbx = mfi.growntilebox();
169 gbx.setSmall(2,khi+1);
171 Array4<Real> vel_arr = mf_to_fill.array(mfi);
172 ParallelFor(gbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k)
174 vel_arr(i,j,k) = vel_arr(i,j,khi);
200#ifdef REMORA_USE_NETCDF
212 BL_PROFILE_VAR(
"REMORA::FillPatchNoBC()",REMORA_FillPatch);
214 amrex::Interpolater* mapper =
nullptr;
216 Box mf_box(mf_to_fill.boxArray()[0]);
217 bool is_2d = mf_box.length(2) == 1;
226 if (lev>0 && fill_set) {
228 mf_box.ixType() == IndexType(IntVect(0,0,0))) {
232 if (mf_box.ixType() == IndexType(IntVect(1,0,0))) {
234 }
else if (mf_box.ixType() == IndexType(IntVect(0,1,0))) {
236 }
else if (mf_box.ixType() == IndexType(IntVect(0,0,1))) {
240 if (mf_box.ixType() == IndexType(IntVect(1,0,0))) {
242 }
else if (mf_box.ixType() == IndexType(IntVect(0,1,0))) {
251 ncomp = mf_to_fill.nComp();
256 if (mf_box.ixType() == IndexType(IntVect(0,0,0)))
259 mapper = &cell_cons_interp;
261 else if (mf_box.ixType() == IndexType(IntVect(1,0,0)))
264 mapper = &face_cons_linear_interp;
266 else if (mf_box.ixType() == IndexType(IntVect(0,1,0)))
269 mapper = &face_cons_linear_interp;
273 mapper = &face_cons_linear_interp;
278 Vector<MultiFab*> fmf = {mfs[lev], mfs[lev]};
279 Vector<Real> ftime = {
t_old[lev],
t_new[lev]};
280 amrex::FillPatchSingleLevel(mf_to_fill, time, fmf, ftime, icomp, icomp, ncomp,
285 Vector<MultiFab*> fmf = {mfs[lev], mfs[lev]};
286 Vector<Real> ftime = {
t_old[lev],
t_new[lev]};
287 Vector<MultiFab*> cmf = {mfs[lev-1], mfs[lev-1]};
288 Vector<Real> ctime = {
t_old[lev-1],
t_new[lev-1]};
290 mfs[lev-1]->FillBoundary(geom[lev-1].periodicity());
291 amrex::FillPatchTwoLevels(mf_to_fill, mf_to_fill.nGrowVect(), IntVect(0,0,0),
292 time, cmf, ctime, fmf, ftime,
293 icomp, icomp, ncomp, geom[lev-1], geom[lev],
310 const Real teps = (
t_new[lev] -
t_old[lev]) * 1.e-3_rt;
312 if (time >
t_new[lev] - teps && time <
t_new[lev] + teps)
314 for (
int i = 0; i < Vars::NumTypes; ++i) {
319 else if (time >
t_old[lev] - teps && time <
t_old[lev] + teps)
321 for (
int i = 0; i < Vars::NumTypes; ++i) {
326 else if (time >
t_old[lev] && time <
t_new[lev])
330 for (
int i = 0; i < Vars::NumTypes; ++i) {
331 MultiFab* mf_tmp =
new MultiFab(vars_new[lev][i].boxArray(),
332 vars_new[lev][i].DistributionMap(),
333 vars_new[lev][i].nComp(), vars_new[lev][i].nGrowVect());
334 mf_tmp->setVal(0.0_rt);
336 const Real dt_fraction = (time -
t_old[lev]) / (
t_new[lev] -
t_old[lev]);
337 MultiFab::Saxpy(*mf_tmp, 1.0_rt - dt_fraction, vars_old[lev][i], 0, 0, mf_tmp->nComp(), mf_tmp->nGrowVect());
338 MultiFab::Saxpy(*mf_tmp, dt_fraction, vars_new[lev][i], 0, 0, mf_tmp->nComp(), mf_tmp->nGrowVect());
346 amrex::Error(
"Requested data at a time outside the interval [t_old, t_new]");
350 for (
int i = 0; i < Vars::NumTypes; ++i) {
351 data.
get_var(Vars::xvel).FillBoundary(geom[lev].periodicity());
352 data.
get_var(Vars::yvel).FillBoundary(geom[lev].periodicity());
353 data.
get_var(Vars::zvel).FillBoundary(geom[lev].periodicity());
354 data.
get_var(Vars::cons).FillBoundary(geom[lev].periodicity());
380 const int bdy_var_type,
383 const int n_not_fill,
384 const int icomp_calc,
386 const MultiFab& mf_calc) {
387 amrex::Interpolater* mapper = &pc_interp;
389 fill_all, n_not_fill, icomp_calc, dt_lev, mf_calc, mapper);
414 const int bdy_var_type,
417 const int n_not_fill,
418 const int icomp_calc,
420 const MultiFab& mf_calc) {
421 amrex::Interpolater* mapper =
nullptr;
423 fill_all, n_not_fill, icomp_calc, dt_lev, mf_calc, mapper);
447#ifdef REMORA_USE_NETCDF
448 const int bdy_var_type,
454 const int n_not_fill,
455#ifdef REMORA_USE_NETCDF
456 const int icomp_calc,
462 const MultiFab& mf_calc,
463 amrex::Interpolater* mapper)
466 AMREX_ASSERT(lev > 0);
468 MultiFab* mask =
nullptr;
472 ncomp = mf_to_fill->nComp();
477 Box box_mf(mf_to_fill->boxArray()[0]);
479 if (box_mf.ixType() == IndexType(IntVect(0,0,0)))
483 else if (box_mf.ixType() == IndexType(IntVect(1,0,0)))
487 else if (box_mf.ixType() == IndexType(IntVect(0,1,0)))
491 else if (box_mf.ixType() == IndexType(IntVect(0,0,1)))
495 amrex::Abort(
"Dont recognize this box type in REMORA_FillPatch");
498 if (mapper ==
nullptr) {
499 if (box_mf.ixType() == IndexType(IntVect(0,0,0)))
501 mapper = &cell_cons_interp;
503 else if (box_mf.ixType() == IndexType(IntVect(1,0,0)))
505 mapper = &face_cons_linear_interp;
507 else if (box_mf.ixType() == IndexType(IntVect(0,1,0)))
509 mapper = &face_cons_linear_interp;
511 else if (box_mf.ixType() == IndexType(IntVect(0,0,1)))
513 mapper = &face_cons_linear_interp;
515 amrex::Abort(
"Dont recognize this box type in REMORA_FillPatch");
522 Vector<Real> ctime = {cdata.
get_time()};
524 Vector<MultiFab*> cmf = {mf_crse};
525 Vector<Real> ctime = {time};
531#ifdef REMORA_USE_NETCDF
532 ,ic_type,bdy_data_xlo,bdy_data_xhi,
540#ifdef REMORA_USE_NETCDF
541 ,ic_type,bdy_data_xlo,bdy_data_xhi,
548 mf_crse->FillBoundary(geom[lev-1].periodicity());
549 amrex::InterpFromCoarseLevel(*mf_to_fill, mf_to_fill->nGrowVect(), IntVect(0,0,0),
550 *mf_crse, 0, icomp, ncomp, geom[lev-1], geom[lev],
559 (*
physbcs[lev])(*mf_to_fill,*mask,icomp,ncomp,mf_to_fill->nGrowVect(),
560 time,bccomp,n_not_fill,mf_calc,
563#ifdef REMORA_USE_NETCDF
567 fill_from_bdyfiles(lev, *mf_to_fill,*mask,time,bccomp,bdy_var_type, icomp,icomp_calc,mf_calc,dt_lev);
571 if ( box_mf.ixType() == IndexType(IntVect(0,0,0)) ) {
572 mf_to_fill->EnforcePeriodicity(geom[lev].periodicity());
576 if ( (box_mf.ixType() == IndexType(IntVect(1,0,0))) ||
577 (box_mf.ixType() == IndexType(IntVect(0,1,0))) )
579 int khi = geom[lev].Domain().bigEnd(2);
580 for (MFIter mfi(*mf_to_fill); mfi.isValid(); ++mfi)
582 Box gbx = mfi.growntilebox();
583 gbx.setSmall(2,khi+1);
585 Array4<Real> vel_arr = mf_to_fill->array(mfi);
586 ParallelFor(gbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k)
588 vel_arr(i,j,k) = vel_arr(i,j,khi);
606 Box domain(Geom(lev).Domain());
608 int ihi = domain.bigEnd(0);
609 int jhi = domain.bigEnd(1);
610 int khi = domain.bigEnd(2);
613 mf_cc_vel.FillBoundary(geom[lev].periodicity());
616#pragma omp parallel if (Gpu::notInLaunchRegion())
618 for (MFIter mfi(mf_cc_vel, TilingIfNotGPU()); mfi.isValid(); ++mfi)
622 const Box& bx = mfi.tilebox();
623 const Array4<Real>& vel_arr = mf_cc_vel.array(mfi);
625 if (!Geom(lev).isPeriodic(0)) {
627 if (bx.smallEnd(0) <= domain.smallEnd(0)) {
629 ParallelFor(makeSlab(bx,0,0), [=] AMREX_GPU_DEVICE(
int ,
int j,
int k)
noexcept
631 vel_arr(-1,j,k,1) = mult*vel_arr(0,j,k,1);
632 vel_arr(-1,j,k,2) = mult*vel_arr(0,j,k,2);
637 if (bx.bigEnd(0) >= domain.bigEnd(0)) {
639 ParallelFor(makeSlab(bx,0,0), [=] AMREX_GPU_DEVICE(
int ,
int j,
int k)
noexcept
641 vel_arr(ihi+1,j,k,1) = mult*vel_arr(ihi,j,k,1);
642 vel_arr(ihi+1,j,k,2) = mult*vel_arr(ihi,j,k,2);
647 if (!Geom(lev).isPeriodic(1)) {
649 if (bx.smallEnd(1) <= domain.smallEnd(1)) {
651 ParallelFor(makeSlab(bx,1,0), [=] AMREX_GPU_DEVICE(
int i,
int ,
int k)
noexcept
653 vel_arr(i,-1,k,0) = mult*vel_arr(i,0,k,0);
654 vel_arr(i,-1,k,2) = mult*vel_arr(i,0,k,2);
659 if (bx.bigEnd(1) >= domain.bigEnd(1)) {
661 ParallelFor(makeSlab(bx,1,0), [=] AMREX_GPU_DEVICE(
int i,
int ,
int k)
noexcept
663 vel_arr(i,jhi+1,k,0) = mult*vel_arr(i,jhi,k,0);
664 vel_arr(i,jhi+1,k,2) = mult*-vel_arr(i,jhi,k,2);
669 if (!Geom(lev).isPeriodic(2)) {
671 if (bx.smallEnd(2) <= domain.smallEnd(2)) {
673 ParallelFor(makeSlab(bx,2,0), [=] AMREX_GPU_DEVICE(
int i,
int j,
int)
noexcept
675 vel_arr(i,j,-1,0) = mult*vel_arr(i,j,0,0);
676 vel_arr(i,j,-1,1) = mult*vel_arr(i,j,0,1);
681 if (bx.bigEnd(2) >= domain.bigEnd(2)) {
683 ParallelFor(makeSlab(bx,2,0), [=] AMREX_GPU_DEVICE(
int i,
int j,
int)
noexcept
685 vel_arr(i,j,khi+1,0) = mult*vel_arr(i,j,khi,0);
686 vel_arr(i,j,khi+1,1) = mult*vel_arr(i,j,khi,1);
void FillCoarsePatchPC(int lev, amrex::Real time, amrex::MultiFab *mf_fine, amrex::MultiFab *mf_crse, const int bccomp, 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 using the piecewise constant interpol...
amrex::Vector< amrex::BCRec > domain_bcs_type
vector (over BCVars) of BCRecs
amrex::Vector< REMORAFillPatcher > FPr_v
Vector over levels of FillPatchers for v (3D)
void FillCoarsePatch(int lev, amrex::Real time, amrex::MultiFab *mf_fine, amrex::MultiFab *mf_crse, const int bccomp, 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
amrex::GpuArray< amrex::GpuArray< REMORA_BC, AMREX_SPACEDIM *2 >, BCVars::NumTypes > phys_bc_type
Array holding the "physical" boundary condition types (e.g. "inflow")
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskr
land/sea mask at cell centers (2D)
amrex::Vector< REMORAFillPatcher > FPr_u
Vector over levels of FillPatchers for u (3D)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_msku
land/sea mask at x-faces (2D)
void FillPatchNoBC(int lev, amrex::Real time, amrex::MultiFab &mf_to_be_filled, amrex::Vector< amrex::MultiFab * > const &mfs, const int bdy_var_type=BdyVars::null, const int icomp=0, const bool fill_all=true, const bool fill_set=true)
Fill a new MultiFab by copying in phi from valid region and filling ghost cells without applying boun...
amrex::Real bdy_time_interval
Interval between boundary data times.
amrex::Vector< REMORAFillPatcher > FPr_vbar
Vector over levels of FillPatchers for vbar (2D)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskv
land/sea mask at y-faces (2D)
amrex::Vector< std::unique_ptr< REMORAPhysBCFunct > > physbcs
Vector (over level) of functors to apply physical boundary conditions.
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 FillBdyCCVels(int lev, amrex::MultiFab &mf_cc_vel)
Fill the physical boundary conditions for cell-centered velocity (diagnostic only)
void fill_from_bdyfiles(int lev, amrex::MultiFab &mf_to_fill, const amrex::MultiFab &mf_mask, const amrex::Real time, const int bccomp, const int bdy_var_type, const int icomp_to_fill, const int icomp_calc=0, const amrex::MultiFab &mf_calc=amrex::MultiFab(), const amrex::Real=amrex::Real(0.0))
Fill boundary data from netcdf file.
TimeInterpolatedData GetDataAtTime(int lev, amrex::Real time)
utility to copy in data from old and/or new state into another multifab
amrex::Vector< REMORAFillPatcher > FPr_c
Vector over levels of FillPatchers for scalars.
amrex::Vector< REMORAFillPatcher > FPr_w
Vector over levels of FillPatchers for w.
amrex::Vector< amrex::Real > t_new
new time at each level
static SolverChoice solverChoice
Container for algorithmic choices.
int cf_set_width
Width for fixing values at coarse-fine interface.
void FillCoarsePatchMap(int lev, amrex::Real time, amrex::MultiFab *mf_fine, amrex::MultiFab *mf_crse, const int bccomp, 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(), amrex::Interpolater *mapper=nullptr)
fill an entire multifab by interpolating from the coarser level, explicitly specifying interpolator t...
amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NCONS+8 > m_bc_extdir_vals
Array holding the Dirichlet values at walls which need them.
amrex::Vector< REMORAFillPatcher > FPr_ubar
Vector over levels of FillPatchers for ubar (2D)
amrex::Vector< amrex::Real > t_old
old time at each level
amrex::Gpu::DeviceVector< amrex::BCRec > domain_bcs_type_d
GPU vector (over BCVars) of BCRecs.
bool boundary_from_netcdf
void set_time(amrex::Real time)
void add_var(amrex::MultiFab *var_data, int own_data)
amrex::MultiFab & get_var(int var_idx)