1#ifndef AMREX_ML_CELL_LINOP_H_
2#define AMREX_ML_CELL_LINOP_H_
3#include <AMReX_Config.H>
9#include <AMReX_MLLinOp_K.H>
10#include <AMReX_MLMG_K.H>
79 const MF* robinbc_a =
nullptr,
80 const MF* robinbc_b =
nullptr,
81 const MF* robinbc_f =
nullptr) final;
84 requires (!std::same_as<MF,AMF>)
86 const AMF* robinbc_a =
nullptr,
87 const AMF* robinbc_b =
nullptr,
88 const AMF* robinbc_f =
nullptr)
145 const MLMGBndryT<MF>* bndry=
nullptr,
bool skip_fillboundary=
false)
const;
158 void restriction (
int amrlev,
int cmglev, MF& crse, MF& fine)
const override;
169 void interpolation (
int amrlev,
int fmglev, MF& fine,
const MF& crse)
const override;
180 void interpAssign (
int amrlev,
int fmglev, MF& fine, MF& crse)
const override;
192 IntVect const& nghost)
const override;
204 const MF& fine_sol,
const MF& fine_rhs)
override;
217 void apply (
int amrlev,
int mglev, MF& out, MF& in,
BCMode bc_mode,
229 void smooth (
int amrlev,
int mglev, MF& sol,
const MF& rhs,
230 bool skip_fillboundary,
int niter)
const override;
242 const MF* crse_bcdata=
nullptr)
override;
264 BCMode bc_mode,
const MF* crse_bcdata=
nullptr) final;
280 MF& res, const MF& crse_sol, const MF&,
281 MF&, MF& fine_sol, const MF&) const final;
291 MF& sol,
Location loc) const override;
301 MF& sol,
Location loc) const override;
328 MF const& rhs) const override;
338 Vector<
RT> const& offset) const override;
353 RT xdoty (
int amrlev,
int mglev, const MF&
x, const MF&
y,
bool local) const final;
374 virtual
void Fapply (
int amrlev,
int mglev, MF& out, const MF& in) const = 0;
375 virtual
void Fsmooth (
int amrlev,
int mglev, MF& sol, const MF& rhs,
int redblack) const = 0;
377 const
Array<
FAB*,AMREX_SPACEDIM>& flux,
378 const
FAB& sol,
Location loc,
int face_only=0) const = 0;
389 const
Array<MF*,AMREX_SPACEDIM>& ,
400 RT normInf (
int amrlev, MF
const& mf,
bool local)
const override;
438 m_interpbndry_halfwidth = w;
475 void setLOBndryConds (
const Geometry& geom,
const Real* dx,
489 const BCTuple& bndryConds (
const MFIter& mfi,
int icomp)
const noexcept {
490 return bcond[mfi][icomp];
492 const RealTuple& bndryLocs (
const MFIter& mfi,
int icomp)
const noexcept {
493 return bcloc[mfi][icomp];
522 void defineAuxData ();
525 void computeVolInv ()
const;
528 int m_interpbndry_halfwidth = 2;
547 Box const& box() const noexcept {
return bx; }
554 Array4<int const> mlo;
555 Array4<int const> mhi;
566 Box const& box() const noexcept {
return bx; }
575 Array4<int const> mlo;
576 Array4<int const> mhi;
587 Box const& box() const noexcept {
return bx; }
591template <
typename MF>
598 bctl_dv(bctl.local_size()*ncomp),
601 auto* dp = bctl_dv.data();
602 for (MFIter mfi(bcloc); mfi.isValid(); ++mfi) {
603 bcond[mfi].resize(ncomp);
604 bcloc[mfi].resize(ncomp);
610template <
typename MF>
621 const Box& domain = geom.Domain();
628 const Box& bx = mfi.validbox();
629 for (
int icomp = 0; icomp < m_ncomp; ++icomp) {
630 RealTuple & bloc = bcloc[mfi][icomp];
631 BCTuple & bctag = bcond[mfi][icomp];
633 lobc[icomp], hibc[icomp],
634 dx, ratio, interior_bloc,
635 domain_bloc_lo, domain_bloc_hi,
636 geom.isPeriodicArray(),
642 hv.reserve(bctl_dv.size());
645 for (
int icomp = 0; icomp < m_ncomp; ++icomp) {
647 for (
int m = 0; m < 2*AMREX_SPACEDIM; ++m) {
648 tmp[m].type = bcond[mfi][icomp][m];
649 tmp[m].location = bcloc[mfi][icomp][m];
651 hv.push_back(std::move(tmp));
660template <
typename MF>
666template <
typename MF>
676 "MLCellLinOp: anisotropic coarsening is not supported");
682template <
typename MF>
684MLCellLinOpT<MF>::defineAuxData ()
688 m_undrrelxr.resize(this->m_num_amr_levels);
689 m_maskvals.resize(this->m_num_amr_levels);
690 m_fluxreg.resize(this->m_num_amr_levels-1);
691 m_norm_fine_mask.resize(this->m_num_amr_levels-1);
692 m_bc_tags.resize(this->m_num_amr_levels);
694 const int ncomp = this->getNComp();
696 for (
int amrlev = 0; amrlev < this->m_num_amr_levels; ++amrlev)
698 m_undrrelxr[amrlev].resize(this->m_num_mg_levels[amrlev]);
699 m_bc_tags[amrlev].resize(this->m_num_mg_levels[amrlev]);
700 for (
int mglev = 0; mglev < this->m_num_mg_levels[amrlev]; ++mglev)
702 m_undrrelxr[amrlev][mglev].define(this->m_grids[amrlev][mglev],
703 this->m_dmap[amrlev][mglev],
708 for (
int amrlev = 0; amrlev < this->m_num_amr_levels; ++amrlev)
710 m_maskvals[amrlev].resize(this->m_num_mg_levels[amrlev]);
711 for (
int mglev = 0; mglev < this->m_num_mg_levels[amrlev]; ++mglev)
717 const int extent = this->isCrossStencil() ? 0 : 1;
718 m_maskvals[amrlev][mglev][face].define(this->m_grids[amrlev][mglev],
719 this->m_dmap[amrlev][mglev],
720 this->m_geom[amrlev][mglev],
721 face, 0, ngrow, extent, 1,
true);
726 for (
int amrlev = 0; amrlev < this->m_num_amr_levels-1; ++amrlev)
728 const IntVect ratio{this->AMRRefRatioVect(amrlev)};
729 m_fluxreg[amrlev].define(this->m_grids[amrlev+1][0],
730 this->m_grids[amrlev][0],
731 this->m_dmap[amrlev+1][0],
732 this->m_dmap[amrlev][0],
733 this->m_geom[amrlev+1][0],
734 this->m_geom[amrlev][0],
735 ratio, amrlev+1, ncomp);
736 m_fluxreg[amrlev].setDeterministic(this->info.deterministic);
737 m_norm_fine_mask[amrlev] = std::make_unique<iMultiFab>
738 (
makeFineMask(this->m_grids[amrlev][0], this->m_dmap[amrlev][0],
739 this->m_grids[amrlev+1][0],
743#if (AMREX_SPACEDIM != 3)
744 m_has_metric_term = !this->m_geom[0][0].IsCartesian() && this->info.has_metric_term;
748template <
typename MF>
750MLCellLinOpT<MF>::defineBC ()
754 const int ncomp = this->getNComp();
756 m_bndry_sol.resize(this->m_num_amr_levels);
757 m_crse_sol_br.resize(this->m_num_amr_levels);
759 m_bndry_cor.resize(this->m_num_amr_levels);
760 m_crse_cor_br.resize(this->m_num_amr_levels);
762 m_robin_bcval.resize(this->m_num_amr_levels);
764 for (
int amrlev = 0; amrlev < this->m_num_amr_levels; ++amrlev)
766 m_bndry_sol[amrlev] = std::make_unique<MLMGBndryT<MF>>(this->m_grids[amrlev][0],
767 this->m_dmap[amrlev][0],
769 this->m_geom[amrlev][0]);
772 for (
int amrlev = 1; amrlev < this->m_num_amr_levels; ++amrlev)
774 const int in_rad = 0;
775 const int out_rad = 1;
776 const int extent_rad = 2;
777 const IntVect crse_ratio = this->AMRRefRatioVect(amrlev-1);
778 BoxArray cba = this->m_grids[amrlev][0];
780 m_crse_sol_br[amrlev] = std::make_unique<BndryRegisterT<MF>>
781 (cba, this->m_dmap[amrlev][0], in_rad, out_rad, extent_rad, ncomp);
784 for (
int amrlev = 1; amrlev < this->m_num_amr_levels; ++amrlev)
786 const int in_rad = 0;
787 const int out_rad = 1;
788 const int extent_rad = 2;
789 const IntVect crse_ratio = this->AMRRefRatioVect(amrlev-1);
790 BoxArray cba = this->m_grids[amrlev][0];
792 m_crse_cor_br[amrlev] = std::make_unique<BndryRegisterT<MF>>
793 (cba, this->m_dmap[amrlev][0], in_rad, out_rad, extent_rad, ncomp);
794 m_crse_cor_br[amrlev]->setVal(RT(0.0));
798 for (
int amrlev = 1; amrlev < this->m_num_amr_levels; ++amrlev)
800 m_bndry_cor[amrlev] = std::make_unique<MLMGBndryT<MF>>
801 (this->m_grids[amrlev][0], this->m_dmap[amrlev][0], ncomp, this->m_geom[amrlev][0]);
802 MF bc_data(this->m_grids[amrlev][0], this->m_dmap[amrlev][0], ncomp, 1);
805 m_bndry_cor[amrlev]->setBndryValues(*m_crse_cor_br[amrlev], 0, bc_data, 0, 0, ncomp,
806 this->AMRRefRatioVect(amrlev-1),
808 m_interpbndry_halfwidth);
813 BCType::Dirichlet)}});
814 m_bndry_cor[amrlev]->setLOBndryConds(bclohi, bclohi, this->AMRRefRatioVect(amrlev-1),
RealVect{});
817 m_bcondloc.resize(this->m_num_amr_levels);
818 for (
int amrlev = 0; amrlev < this->m_num_amr_levels; ++amrlev)
820 m_bcondloc[amrlev].resize(this->m_num_mg_levels[amrlev]);
821 for (
int mglev = 0; mglev < this->m_num_mg_levels[amrlev]; ++mglev)
823 m_bcondloc[amrlev][mglev] = std::make_unique<BndryCondLoc>(this->m_grids[amrlev][mglev],
824 this->m_dmap[amrlev][mglev],
830template <
typename MF>
833 const MF* robinbc_b,
const MF* robinbc_f)
845 AMREX_ASSERT(robinbc_a !=
nullptr && robinbc_b !=
nullptr);
846 fMultiFab ra(robinbc_a->boxArray(), robinbc_a->DistributionMap(),
847 robinbc_a->nComp(), robinbc_a->nGrowVect());
848 fMultiFab rb(robinbc_b->boxArray(), robinbc_b->DistributionMap(),
849 robinbc_b->nComp(), robinbc_b->nGrowVect());
850 fMultiFab rf(robinbc_b->boxArray(), robinbc_b->DistributionMap(),
851 robinbc_b->nComp(), robinbc_b->nGrowVect());
857 rb[mfi].template mult<RunOn::Device>(lambda, rb[mfi].box(), 0, rb.
nComp());
861 this->
m_sp_linop->setLevelBC(amrlev,
nullptr, &ra, &rb, &rf);
863 this->
m_sp_linop->setLevelBC(amrlev,
nullptr);
870 if (a_levelbcdata ==
nullptr) {
871 zero.define(this->m_grids[amrlev][0], this->m_dmap[amrlev][0], ncomp, ng);
876 const MF& bcdata = (a_levelbcdata ==
nullptr) ?
zero : *a_levelbcdata;
892 const int in_rad = 0;
893 const int out_rad = 1;
894 const int extent_rad = 2;
895 const IntVect crse_ratio = br_ref_ratio;
896 BoxArray cba = this->m_grids[amrlev][0];
898 this->
m_crse_sol_br[amrlev] = std::make_unique<BndryRegisterT<MF>>
899 (cba, this->m_dmap[amrlev][0], in_rad, out_rad, extent_rad, ncomp);
905 this->
m_geom[0][0].periodicity(cbx));
910 bcdata, 0, 0, ncomp, br_ref_ratio,
912 this->m_interpbndry_halfwidth);
917 this->
m_bndry_sol[amrlev]->setPhysBndryValues(bcdata,0,0,ncomp);
923 this->
m_bndry_sol[amrlev]->setPhysBndryValues(bcdata,0,0,ncomp);
931 const Real* dx = this->
m_geom[amrlev][0].CellSize();
932 for (
int mglev = 0; mglev < this->m_num_mg_levels[amrlev]; ++mglev)
934 this->
m_bcondloc[amrlev][mglev]->setLOBndryConds(this->
m_geom[amrlev][mglev], dx,
939 m_bc_tags[amrlev][mglev].undefine();
945 AMREX_ASSERT(robinbc_a !=
nullptr && robinbc_b !=
nullptr && robinbc_f !=
nullptr);
946 this->
m_robin_bcval[amrlev] = std::make_unique<MF>(this->m_grids[amrlev][0],
947 this->m_dmap[amrlev][0],
949 const Box& domain = this->
m_geom[amrlev][0].Domain();
953#pragma omp parallel if (Gpu::notInLaunchRegion())
956 Box const& vbx = mfi.validbox();
960 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
963 bool outside_domain_lo = !(domain.
contains(blo));
964 bool outside_domain_hi = !(domain.
contains(bhi));
965 if ((!outside_domain_lo) && (!outside_domain_hi)) {
continue; }
966 for (
int icomp = 0; icomp < ncomp; ++icomp) {
972 rbc(i,j,k,0) = ra(i,j,k,icomp);
973 rbc(i,j,k,1) = rb(i,j,k,icomp);
974 rbc(i,j,k,2) = rf(i,j,k,icomp);
981 rbc(i,j,k,0) = ra(i,j,k,icomp);
982 rbc(i,j,k,1) = rb(i,j,k,icomp);
983 rbc(i,j,k,2) = rf(i,j,k,icomp);
992template <
typename MF>
999template <
typename MF>
1006 const int ncomp = this->
getNComp();
1007 m_crse_sol_br[amrlev]->copyFrom(crse_bcdata, 0, 0, 0, ncomp,
1008 this->
m_geom[amrlev-1][0].periodicity());
1012 m_interpbndry_halfwidth);
1015template <
typename MF>
1021 const int ncomp = this->
getNComp();
1022 m_crse_cor_br[amrlev]->copyFrom(crse_bcdata, 0, 0, 0, ncomp,
1023 this->
m_geom[amrlev-1][0].periodicity());
1027 m_interpbndry_halfwidth);
1030template <
typename MF>
1037 BL_ASSERT(mglev == 0 || bc_mode == BCMode::Homogeneous);
1038 BL_ASSERT(bndry !=
nullptr || bc_mode == BCMode::Homogeneous);
1040 const int ncomp = this->
getNComp();
1043 if (!skip_fillboundary) {
1044 in.FillBoundary(0, ncomp, this->
m_geom[amrlev][mglev].periodicity(), cross);
1047 int flagbc = bc_mode == BCMode::Inhomogeneous;
1048 const int imaxorder = this->
maxorder;
1050 const Real* dxinv = this->
m_geom[amrlev][mglev].InvCellSize();
1051 const RT dxi =
static_cast<RT>(dxinv[0]);
1052 const RT dyi = (AMREX_SPACEDIM >= 2) ?
static_cast<RT>(dxinv[1]) :
RT(1.0);
1053 const RT dzi = (AMREX_SPACEDIM == 3) ?
static_cast<RT>(dxinv[2]) :
RT(1.0);
1055 const auto& maskvals =
m_maskvals[amrlev][mglev];
1056 const auto& bcondloc = *
m_bcondloc[amrlev][mglev];
1059 const auto& foo = foofab.const_array();
1065 "non-cross stencil not support for gpu");
1072 if (! m_bc_tags[amrlev][mglev].is_defined()) {
1074 tags.reserve(in.local_size()*2*AMREX_SPACEDIM*ncomp);
1076 const Box& vbx = mfi.validbox();
1077 const auto & bdlv = bcondloc.bndryLocs(mfi);
1078 const auto & bdcv = bcondloc.bndryConds(mfi);
1080 const int local_index = mfi.LocalIndex();
1082 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
1083 if (idim != hidden_direction) {
1086 for (
int icomp = 0; icomp < ncomp; ++icomp) {
1088 maskvals[olo].const_array(mfi),
1091 bdcv[icomp][olo], vbx.
length(idim),
1092 icomp, olo, local_index
1095 maskvals[ohi].const_array(mfi),
1098 bdcv[icomp][ohi], vbx.
length(idim),
1099 icomp, ohi, local_index
1105 m_bc_tags[amrlev][mglev].define(tags);
1112 bndry_arrays[ori] = (bndry !=
nullptr) ?
1116 auto inma = in.arrays();
1120 const auto& bcval = bndry_arrays[tag.face][tag.local_index];
1121 const int side = tag.face.faceDir();
1122 if (tag.face.coordDir() == 0) {
1123 mllinop_apply_bc_x(side, i, j, k, tag.blen, inma[tag.local_index],
1124 tag.mask, tag.bctype, tag.bcloc, bcval,
1125 imaxorder, dxi, flagbc, tag.comp);
1127#if (AMREX_SPACEDIM > 1)
1129#if (AMREX_SPACEDIM > 2)
1130 if (tag.face.coordDir() == 1)
1133 mllinop_apply_bc_y(side, i, j, k, tag.blen, inma[tag.local_index],
1134 tag.mask, tag.bctype, tag.bcloc, bcval,
1135 imaxorder, dyi, flagbc, tag.comp);
1137#if (AMREX_SPACEDIM > 2)
1139 mllinop_apply_bc_z(side, i, j, k, tag.blen, inma[tag.local_index],
1140 tag.mask, tag.bctype, tag.bcloc, bcval,
1141 imaxorder, dzi, flagbc, tag.comp);
1148 if (cross || tensorop)
1151#pragma omp parallel if (Gpu::notInLaunchRegion())
1155 const Box& vbx = mfi.validbox();
1156 const auto& iofab = in.array(mfi);
1158 const auto & bdlv = bcondloc.bndryLocs(mfi);
1159 const auto & bdcv = bcondloc.bndryConds(mfi);
1161 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim)
1163 if (hidden_direction == idim) {
continue; }
1168 const int blen = vbx.
length(idim);
1169 const auto& mlo = maskvals[olo].array(mfi);
1170 const auto& mhi = maskvals[ohi].array(mfi);
1171 const auto& bvlo = (bndry !=
nullptr) ? bndry->
bndryValues(olo).const_array(mfi) : foo;
1172 const auto& bvhi = (bndry !=
nullptr) ? bndry->
bndryValues(ohi).const_array(mfi) : foo;
1173 for (
int icomp = 0; icomp < ncomp; ++icomp) {
1174 const BoundCond bctlo = bdcv[icomp][olo];
1175 const BoundCond bcthi = bdcv[icomp][ohi];
1176 const RT bcllo = bdlv[icomp][olo];
1177 const RT bclhi = bdlv[icomp][ohi];
1179 mllinop_apply_bc_x(0, blo, blen, iofab, mlo,
1181 imaxorder, dxi, flagbc, icomp);
1182 mllinop_apply_bc_x(1, bhi, blen, iofab, mhi,
1184 imaxorder, dxi, flagbc, icomp);
1185 }
else if (idim == 1) {
1186 mllinop_apply_bc_y(0, blo, blen, iofab, mlo,
1188 imaxorder, dyi, flagbc, icomp);
1189 mllinop_apply_bc_y(1, bhi, blen, iofab, mhi,
1191 imaxorder, dyi, flagbc, icomp);
1193 mllinop_apply_bc_z(0, blo, blen, iofab, mlo,
1195 imaxorder, dzi, flagbc, icomp);
1196 mllinop_apply_bc_z(1, bhi, blen, iofab, mhi,
1198 imaxorder, dzi, flagbc, icomp);
1207 amrex::Abort(
"amrex_mllinop_apply_bc not available when BL_NO_FORT=TRUE");
1209 if constexpr (std::is_same_v<Real,RT>) {
1215 const Box& vbx = mfi.validbox();
1217 const auto & bdlv = bcondloc.bndryLocs(mfi);
1218 const auto & bdcv = bcondloc.bndryConds(mfi);
1221 const BCTuple & bdc = bdcv[0];
1231 const auto& fsfab = (bndry !=
nullptr) ? bndry->
bndryValues(ori)[mfi] : foofab;
1233 const Mask& m = maskvals[ori][mfi];
1240 imaxorder, dxinv, flagbc, ncomp, cross);
1250template <
typename MF>
1254 const Box& dombx = this->
m_geom[0].back().Domain();
1256 const BoxArray& old_ba = this->m_grids[0].back();
1257 const int N = old_ba.
size();
1260 for (
int i = 0; i < N; ++i)
1271#if (AMREX_SPACEDIM == 3)
1272 for (
int kk = 0; kk < nblks[2]; ++kk) {
1274#if (AMREX_SPACEDIM >= 2)
1275 for (
int jj = 0; jj < nblks[1]; ++jj) {
1277 for (
int ii = 0; ii < nblks[0]; ++ii)
1284#if (AMREX_SPACEDIM >= 2)
1287#if (AMREX_SPACEDIM == 3)
1292 std::sort(bv.begin(), bv.end());
1293 bv.erase(std::unique(bv.begin(), bv.end()), bv.end());
1300template <
typename MF>
1304 const int ncomp = this->
getNComp();
1312template <
typename MF>
1316 const int ncomp = this->
getNComp();
1318 Dim3 ratio3 = {.x = 2, .y = 2, .z = 2};
1322 ratio3.
y = ratio[1];,
1323 ratio3.
z = ratio[2];);
1327 auto const& finema = fine.arrays();
1328 auto const& crsema = crse.const_arrays();
1335 finema[box_no](i,j,k,n) += crsema[box_no](ic,jc,kc,n);
1344#pragma omp parallel if (Gpu::notInLaunchRegion())
1348 const Box& bx = mfi.tilebox();
1356 ffab(i,j,k,n) += cfab(ic,jc,kc,n);
1362template <
typename MF>
1366 const int ncomp = this->
getNComp();
1368 const Geometry& crse_geom = this->
Geom(amrlev,fmglev+1);
1371 const IntVect ng = crse.nGrowVect();
1379 crse.setBndry(
RT(0.0));
1388 cfine.setBndry(
RT(0.0));
1393 bool isEB = fine.hasEBFabFactory();
1404#pragma omp parallel if (Gpu::notInLaunchRegion())
1408 const Box& bx = mfi.tilebox();
1409 const auto& ff = fine.array(mfi);
1410 const auto& cc = cmf->array(mfi);
1415 const auto& flag = (*flags)[mfi];
1422 mlmg_eb_cc_interp_r<2>(tbx, ff, cc, flg, ncomp);
1433 const bool call_lincc =
true;
1437#if (AMREX_SPACEDIM == 3)
1444 TwoD::mlmg_lin_cc_interp_r2(tbx, ff_2d, cc_2d, ncomp);
1451 mlmg_lin_cc_interp_r2(tbx, ff, cc, ncomp);
1458template <
typename MF>
1463 const int ncomp = this->
getNComp();
1467 const int refratio = refratioV.
max();
1477#pragma omp parallel if (Gpu::notInLaunchRegion())
1481 const Box& bx = mfi.tilebox();
1482 auto const& ff = fine.array(mfi);
1483 auto const& cc = crse.const_array(mfi);
1488 const auto& flag = (*flags)[mfi];
1498 mlmg_eb_cc_interp_r<2>(tbx, ff, cc, flg, ncomp);
1506 mlmg_eb_cc_interp_r<4>(tbx, ff, cc, flg, ncomp);
1511 amrex::Abort(
"mlmg_eb_cc_interp: only refratio 2 and 4 are supported");
1522 const bool call_lincc =
true;
1526#if (AMREX_SPACEDIM == 3)
1536 TwoD::mlmg_lin_cc_interp_r2(tbx, ff_2d, cc_2d, ncomp);
1544 TwoD::mlmg_lin_cc_interp_r4(tbx, ff_2d, cc_2d, ncomp);
1549 amrex::Abort(
"mlmg_lin_cc_interp: only refratio 2 and 4 are supported");
1559 mlmg_lin_cc_interp_r2(tbx, ff, cc, ncomp);
1567 mlmg_lin_cc_interp_r4(tbx, ff, cc, ncomp);
1572 amrex::Abort(
"mlmg_lin_cc_interp: only refratio 2 and 4 are supported");
1579template <
typename MF>
1582 const MF& fine_sol,
const MF& fine_rhs)
1585 const int ncomp = this->
getNComp();
1590template <
typename MF>
1596 applyBC(amrlev, mglev, in, bc_mode, s_mode, bndry);
1597 Fapply(amrlev, mglev, out, in);
1600template <
typename MF>
1603 bool skip_fillboundary,
int niter)
const
1606 for (
int i = 0; i < niter; ++i) {
1607 for (
int redblack = 0; redblack < 2; ++redblack)
1609 applyBC(amrlev, mglev, sol, BCMode::Homogeneous, StateMode::Solution,
1610 nullptr, skip_fillboundary);
1611 Fsmooth(amrlev, mglev, sol, rhs, redblack);
1612 skip_fillboundary =
false;
1617template <
typename MF>
1620 const MF* crse_bcdata)
1622 BL_PROFILE(
"MLCellLinOp::solutionResidual()");
1623 const int ncomp = this->
getNComp();
1624 if (crse_bcdata !=
nullptr) {
1627 const int mglev = 0;
1628 apply(amrlev, mglev, resid,
x, BCMode::Inhomogeneous, StateMode::Solution,
1632 MF::Xpay(resid,
RT(-1.0), b, 0, 0, ncomp,
IntVect(0));
1635template <
typename MF>
1639 if (crse_bcdata !=
nullptr) {
1644template <
typename MF>
1647 BCMode bc_mode,
const MF* crse_bcdata)
1649 BL_PROFILE(
"MLCellLinOp::correctionResidual()");
1650 const int ncomp = this->
getNComp();
1651 if (bc_mode == BCMode::Inhomogeneous)
1658 apply(amrlev, mglev, resid,
x, BCMode::Inhomogeneous, StateMode::Correction,
1664 apply(amrlev, mglev, resid,
x, BCMode::Homogeneous, StateMode::Correction,
nullptr);
1667 MF::Xpay(resid,
Real(-1.0), b, 0, 0, ncomp,
IntVect(0));
1670template <
typename MF>
1673 MF&, MF& fine_sol,
const MF&)
const
1680 const int ncomp = this->
getNComp();
1682 const int fine_amrlev = crse_amrlev+1;
1685 const Real* crse_dx = this->
m_geom[crse_amrlev][0].CellSize();
1686 const Real* fine_dx = this->
m_geom[fine_amrlev][0].CellSize();
1688 const int mglev = 0;
1689 applyBC(fine_amrlev, mglev, fine_sol, BCMode::Inhomogeneous, StateMode::Solution,
1696#pragma omp parallel if (Gpu::notInLaunchRegion())
1705 if (fluxreg.CrseHasWork(mfi))
1707 const Box& tbx = mfi.tilebox();
1711 FFlux(crse_amrlev, mfi, pflux, crse_sol[mfi], Location::FaceCentroid);
1712 fluxreg.CrseAdd(mfi, cpflux, crse_dx, dt,
RunOn::Gpu);
1722 if (fluxreg.FineHasWork(mfi))
1724 const Box& tbx = mfi.tilebox();
1725 const int face_only =
true;
1729 FFlux(fine_amrlev, mfi, pflux, fine_sol[mfi], Location::FaceCentroid, face_only);
1730 fluxreg.FineAdd(mfi, cpflux, fine_dx, dt,
RunOn::Gpu);
1735 fluxreg.Reflux(res);
1739template <
typename MF>
1746 const int mglev = 0;
1747 const int ncomp = this->
getNComp();
1748 applyBC(amrlev, mglev, sol, BCMode::Inhomogeneous, StateMode::Solution,
1755#pragma omp parallel if (Gpu::notInLaunchRegion())
1762 const Box& tbx = mfi.tilebox();
1766 FFlux(amrlev, mfi, pflux, sol[mfi], loc);
1767 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
1768 const Box& nbx = mfi.nodaltilebox(idim);
1769 auto const& dst = fluxes[idim]->array(mfi);
1770 auto const& src = pflux[idim]->const_array();
1773 dst(i,j,k,n) = src(i,j,k,n);
1780template <
typename MF>
1787 if (sol.nComp() > 1) {
1788 amrex::Abort(
"MLCellLinOp::compGrad called, but only works for single-component solves");
1791 const int mglev = 0;
1792 applyBC(amrlev, mglev, sol, BCMode::Inhomogeneous, StateMode::Solution,
1795 const int ncomp = this->
getNComp();
1798 const RT dyi =
static_cast<RT>(this->
m_geom[amrlev][mglev].InvCellSize(1));,
1799 const RT dzi =
static_cast<RT>(this->
m_geom[amrlev][mglev].InvCellSize(2)););
1801#pragma omp parallel if (Gpu::notInLaunchRegion())
1806 const Box& ybx = mfi.nodaltilebox(1);,
1807 const Box& zbx = mfi.nodaltilebox(2););
1808 const auto& s = sol.array(mfi);
1810 const auto& gy = grad[1]->array(mfi);,
1811 const auto& gz = grad[2]->array(mfi););
1815 gx(i,j,k,n) = dxi*(s(i,j,k,n) - s(i-1,j,k,n));
1817#if (AMREX_SPACEDIM >= 2)
1820 gy(i,j,k,n) = dyi*(s(i,j,k,n) - s(i,j-1,k,n));
1823#if (AMREX_SPACEDIM == 3)
1826 gz(i,j,k,n) = dzi*(s(i,j,k,n) - s(i,j,k-1,n));
1834template <
typename MF>
1839#if (AMREX_SPACEDIM != 3)
1842 const int ncomp = rhs.nComp();
1844 bool cc = rhs.ixType().cellCentered(0);
1848 const RT probxlo =
static_cast<RT>(geom.
ProbLo(0));
1851#pragma omp parallel if (Gpu::notInLaunchRegion())
1855 const Box& tbx = mfi.tilebox();
1856 auto const& rhsarr = rhs.array(mfi);
1857#if (AMREX_SPACEDIM == 1)
1861 RT rc = probxlo + (
RT(i)+
RT(0.5))*dx;
1862 rhsarr(i,j,k,n) *= rc*rc;
1867 RT re = probxlo +
RT(i)*dx;
1868 rhsarr(i,j,k,n) *= re*re;
1871#elif (AMREX_SPACEDIM == 2)
1875 RT rc = probxlo + (
RT(i)+
RT(0.5))*dx;
1876 rhsarr(i,j,k,n) *= rc;
1881 RT re = probxlo +
RT(i)*dx;
1882 rhsarr(i,j,k,n) *= re;
1890template <
typename MF>
1895#if (AMREX_SPACEDIM != 3)
1898 const int ncomp = rhs.nComp();
1900 bool cc = rhs.ixType().cellCentered(0);
1904 const RT probxlo =
static_cast<RT>(geom.
ProbLo(0));
1907#pragma omp parallel if (Gpu::notInLaunchRegion())
1911 const Box& tbx = mfi.tilebox();
1912 auto const& rhsarr = rhs.array(mfi);
1913#if (AMREX_SPACEDIM == 1)
1917 RT rcinv =
RT(1.0)/(probxlo + (
RT(i)+
RT(0.5))*dx);
1918 rhsarr(i,j,k,n) *= rcinv*rcinv;
1923 RT re = probxlo +
RT(i)*dx;
1924 RT reinv = (re==
RT(0.0)) ?
RT(0.0) :
RT(1.)/re;
1925 rhsarr(i,j,k,n) *= reinv*reinv;
1928#elif (AMREX_SPACEDIM == 2)
1932 RT rcinv =
RT(1.0)/(probxlo + (
RT(i)+
RT(0.5))*dx);
1933 rhsarr(i,j,k,n) *= rcinv;
1938 RT re = probxlo +
RT(i)*dx;
1939 RT reinv = (re==
RT(0.0)) ?
RT(0.0) :
RT(1.)/re;
1940 rhsarr(i,j,k,n) *= reinv;
1948template <
typename MF>
1955 const int ncomp = this->
getNComp();
1960 if (factory && !factory->isAllRegular())
1962 if constexpr (std::is_same<MF,MultiFab>()) {
1963 const MultiFab& vfrac = factory->getVolFrac();
1964 for (
int c = 0; c < ncomp; ++c) {
1966 * m_volinv[amrlev][mglev];
1969 amrex::Abort(
"TODO: MLMG with EB only works with MultiFab");
1975 for (
int c = 0; c < ncomp; ++c) {
1976 offset[c] = rhs.sum(c,
IntVect(0),
true) * m_volinv[amrlev][mglev];
1985template <
typename MF>
1990 const int ncomp = this->
getNComp();
1991 for (
int c = 0; c < ncomp; ++c) {
1992 rhs.plus(-offset[c], c, 1);
1995 if (!rhs.isAllRegular()) {
1996 if constexpr (std::is_same<MF,MultiFab>()) {
1999 amrex::Abort(
"amrex::EB_set_covered only works with MultiFab");
2005template <
typename MF>
2009 BL_PROFILE(
"MLCellLinOp::prepareForSolve()");
2011 const int imaxorder = this->
maxorder;
2012 const int ncomp = this->
getNComp();
2014 for (
int amrlev = 0; amrlev < this->m_num_amr_levels; ++amrlev)
2016 for (
int mglev = 0; mglev < this->m_num_mg_levels[amrlev]; ++mglev)
2018 const auto& bcondloc = *
m_bcondloc[amrlev][mglev];
2019 const auto& maskvals =
m_maskvals[amrlev][mglev];
2021 const RT dxi =
static_cast<RT>(this->
m_geom[amrlev][mglev].InvCellSize(0));
2022 const RT dyi =
static_cast<RT>((AMREX_SPACEDIM >= 2) ? this->
m_geom[amrlev][mglev].InvCellSize(1) :
Real(1.0));
2023 const RT dzi =
static_cast<RT>((AMREX_SPACEDIM == 3) ? this->
m_geom[amrlev][mglev].InvCellSize(2) :
Real(1.0));
2025 auto& undrrelxr = this->
m_undrrelxr[amrlev][mglev];
2026 MF foo(this->m_grids[amrlev][mglev], this->m_dmap[amrlev][mglev], ncomp, 0,
MFInfo().SetAlloc(
false));
2031 (factory) ? &(factory->getMultiEBCellFlagFab()) :
nullptr;
2032 auto area = (factory) ? factory->getAreaFrac()
2040 if (factory && !factory->isAllRegular()) {
2041#if defined(AMREX_USE_CUDA) && defined(_WIN32)
2042 if (!std::is_same<MF,MultiFab>()) {
2044 if constexpr (!std::is_same<MF,MultiFab>()) {
2046 amrex::Abort(
"MLCellLinOp with EB only works with MultiFab");
2049 tags.reserve(foo.local_size()*AMREX_SPACEDIM*ncomp);
2053 const Box& vbx = mfi.validbox();
2055 const auto & bdlv = bcondloc.bndryLocs(mfi);
2056 const auto & bdcv = bcondloc.bndryConds(mfi);
2060 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim)
2067 for (
int icomp = 0; icomp < ncomp; ++icomp) {
2068 tags.emplace_back(MLMGPSEBTag<RT>{undrrelxr[olo].array(mfi),
2069 undrrelxr[ohi].array(mfi),
2071 maskvals[olo].const_array(mfi),
2072 maskvals[ohi].const_array(mfi),
2073 bdlv[icomp][olo], bdlv[icomp][ohi],
2075 bdcv[icomp][olo], bdcv[icomp][ohi],
2076 vbx.
length(idim), icomp, idim});
2083 [=]
AMREX_GPU_DEVICE (
int i,
int j,
int k, MLMGPSEBTag<RT>
const& tag)
noexcept
2088 mllinop_comp_interp_coef0_x_eb
2089 (0, i , j, k, tag.blen, tag.flo, tag.mlo, tag.ap,
2090 tag.bctlo, tag.bcllo, imaxorder, dxi, tag.comp);
2091 mllinop_comp_interp_coef0_x_eb
2092 (1, i+tag.blen+1, j, k, tag.blen, tag.fhi, tag.mhi, tag.ap,
2093 tag.bcthi, tag.bclhi, imaxorder, dxi, tag.comp);
2095#if (AMREX_SPACEDIM > 1)
2097#if (AMREX_SPACEDIM > 2)
2101 mllinop_comp_interp_coef0_y_eb
2102 (0, i, j , k, tag.blen, tag.flo, tag.mlo, tag.ap,
2103 tag.bctlo, tag.bcllo, imaxorder, dyi, tag.comp);
2104 mllinop_comp_interp_coef0_y_eb
2105 (1, i, j+tag.blen+1, k, tag.blen, tag.fhi, tag.mhi, tag.ap,
2106 tag.bcthi, tag.bclhi, imaxorder, dyi, tag.comp);
2108#if (AMREX_SPACEDIM > 2)
2110 mllinop_comp_interp_coef0_z_eb
2111 (0, i, j, k , tag.blen, tag.flo, tag.mlo, tag.ap,
2112 tag.bctlo, tag.bcllo, imaxorder, dzi, tag.comp);
2113 mllinop_comp_interp_coef0_z_eb
2114 (1, i, j, k+tag.blen+1, tag.blen, tag.fhi, tag.mhi, tag.ap,
2115 tag.bcthi, tag.bclhi, imaxorder, dzi, tag.comp);
2122 mllinop_comp_interp_coef0_x
2123 (0, i , j, k, tag.blen, tag.flo, tag.mlo,
2124 tag.bctlo, tag.bcllo, imaxorder, dxi, tag.comp);
2125 mllinop_comp_interp_coef0_x
2126 (1, i+tag.blen+1, j, k, tag.blen, tag.fhi, tag.mhi,
2127 tag.bcthi, tag.bclhi, imaxorder, dxi, tag.comp);
2129#if (AMREX_SPACEDIM > 1)
2131#if (AMREX_SPACEDIM > 2)
2135 mllinop_comp_interp_coef0_y
2136 (0, i, j , k, tag.blen, tag.flo, tag.mlo,
2137 tag.bctlo, tag.bcllo, imaxorder, dyi, tag.comp);
2138 mllinop_comp_interp_coef0_y
2139 (1, i, j+tag.blen+1, k, tag.blen, tag.fhi, tag.mhi,
2140 tag.bcthi, tag.bclhi, imaxorder, dyi, tag.comp);
2142#if (AMREX_SPACEDIM > 2)
2144 mllinop_comp_interp_coef0_z
2145 (0, i, j, k , tag.blen, tag.flo, tag.mlo,
2146 tag.bctlo, tag.bcllo, imaxorder, dzi, tag.comp);
2147 mllinop_comp_interp_coef0_z
2148 (1, i, j, k+tag.blen+1, tag.blen, tag.fhi, tag.mhi,
2149 tag.bcthi, tag.bclhi, imaxorder, dzi, tag.comp);
2160 tags.reserve(foo.local_size()*AMREX_SPACEDIM*ncomp);
2164 const Box& vbx = mfi.validbox();
2166 const auto & bdlv = bcondloc.bndryLocs(mfi);
2167 const auto & bdcv = bcondloc.bndryConds(mfi);
2169 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim)
2171 if (idim != hidden_direction) {
2174 for (
int icomp = 0; icomp < ncomp; ++icomp) {
2175 tags.emplace_back(MLMGPSTag<RT>{undrrelxr[olo].array(mfi),
2176 undrrelxr[ohi].array(mfi),
2177 maskvals[olo].const_array(mfi),
2178 maskvals[ohi].const_array(mfi),
2179 bdlv[icomp][olo], bdlv[icomp][ohi],
2181 bdcv[icomp][olo], bdcv[icomp][ohi],
2182 vbx.
length(idim), icomp, idim});
2189 [=]
AMREX_GPU_DEVICE (
int i,
int j,
int k, MLMGPSTag<RT>
const& tag)
noexcept
2193 mllinop_comp_interp_coef0_x
2194 (0, i , j, k, tag.blen, tag.flo, tag.mlo,
2195 tag.bctlo, tag.bcllo, imaxorder, dxi, tag.comp);
2196 mllinop_comp_interp_coef0_x
2197 (1, i+tag.blen+1, j, k, tag.blen, tag.fhi, tag.mhi,
2198 tag.bcthi, tag.bclhi, imaxorder, dxi, tag.comp);
2200#if (AMREX_SPACEDIM > 1)
2202#if (AMREX_SPACEDIM > 2)
2206 mllinop_comp_interp_coef0_y
2207 (0, i, j , k, tag.blen, tag.flo, tag.mlo,
2208 tag.bctlo, tag.bcllo, imaxorder, dyi, tag.comp);
2209 mllinop_comp_interp_coef0_y
2210 (1, i, j+tag.blen+1, k, tag.blen, tag.fhi, tag.mhi,
2211 tag.bcthi, tag.bclhi, imaxorder, dyi, tag.comp);
2213#if (AMREX_SPACEDIM > 2)
2215 mllinop_comp_interp_coef0_z
2216 (0, i, j, k , tag.blen, tag.flo, tag.mlo,
2217 tag.bctlo, tag.bcllo, imaxorder, dzi, tag.comp);
2218 mllinop_comp_interp_coef0_z
2219 (1, i, j, k+tag.blen+1, tag.blen, tag.fhi, tag.mhi,
2220 tag.bcthi, tag.bclhi, imaxorder, dzi, tag.comp);
2234 const Box& vbx = mfi.validbox();
2236 const auto & bdlv = bcondloc.bndryLocs(mfi);
2237 const auto & bdcv = bcondloc.bndryConds(mfi);
2242 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim)
2244 if (idim == hidden_direction) {
continue; }
2249 const int blen = vbx.
length(idim);
2250 const auto& mlo = maskvals[olo].array(mfi);
2251 const auto& mhi = maskvals[ohi].array(mfi);
2252 const auto& flo = undrrelxr[olo].array(mfi);
2253 const auto& fhi = undrrelxr[ohi].array(mfi);
2254 for (
int icomp = 0; icomp < ncomp; ++icomp) {
2255 const BoundCond bctlo = bdcv[icomp][olo];
2256 const BoundCond bcthi = bdcv[icomp][ohi];
2257 const auto bcllo = bdlv[icomp][olo];
2258 const auto bclhi = bdlv[icomp][ohi];
2261 if constexpr (!std::is_same<MF,MultiFab>()) {
2262 amrex::Abort(
"MLCellLinOp with EB only works with MultiFab");
2264 auto const& ap = area[idim]->const_array(mfi);
2266 mllinop_comp_interp_coef0_x_eb
2267 (0, blo, blen, flo, mlo, ap, bctlo, bcllo,
2268 imaxorder, dxi, icomp);
2269 mllinop_comp_interp_coef0_x_eb
2270 (1, bhi, blen, fhi, mhi, ap, bcthi, bclhi,
2271 imaxorder, dxi, icomp);
2272 }
else if (idim == 1) {
2273 mllinop_comp_interp_coef0_y_eb
2274 (0, blo, blen, flo, mlo, ap, bctlo, bcllo,
2275 imaxorder, dyi, icomp);
2276 mllinop_comp_interp_coef0_y_eb
2277 (1, bhi, blen, fhi, mhi, ap, bcthi, bclhi,
2278 imaxorder, dyi, icomp);
2280 mllinop_comp_interp_coef0_z_eb
2281 (0, blo, blen, flo, mlo, ap, bctlo, bcllo,
2282 imaxorder, dzi, icomp);
2283 mllinop_comp_interp_coef0_z_eb
2284 (1, bhi, blen, fhi, mhi, ap, bcthi, bclhi,
2285 imaxorder, dzi, icomp);
2292 mllinop_comp_interp_coef0_x
2293 (0, blo, blen, flo, mlo, bctlo, bcllo,
2294 imaxorder, dxi, icomp);
2295 mllinop_comp_interp_coef0_x
2296 (1, bhi, blen, fhi, mhi, bcthi, bclhi,
2297 imaxorder, dxi, icomp);
2298 }
else if (idim == 1) {
2299 mllinop_comp_interp_coef0_y
2300 (0, blo, blen, flo, mlo, bctlo, bcllo,
2301 imaxorder, dyi, icomp);
2302 mllinop_comp_interp_coef0_y
2303 (1, bhi, blen, fhi, mhi, bcthi, bclhi,
2304 imaxorder, dyi, icomp);
2306 mllinop_comp_interp_coef0_z
2307 (0, blo, blen, flo, mlo, bctlo, bcllo,
2308 imaxorder, dzi, icomp);
2309 mllinop_comp_interp_coef0_z
2310 (1, bhi, blen, fhi, mhi, bcthi, bclhi,
2311 imaxorder, dzi, icomp);
2326template <
typename MF>
2331 const int ncomp = this->
getNComp();
2340template <
typename MF>
2344 const int ncomp = this->
getNComp();
2347 for (
int ilev = 0; ilev < this->
NAMRLevels()-1; ++ilev) {
2351 *
y[this->
NAMRLevels()-1], 0, ncomp, nghost,
true);
2356template <
typename MF>
2360 const int ncomp = this->
getNComp();
2363 for (
int ilev = 0; ilev < this->
NAMRLevels()-1; ++ilev) {
2368 return std::sqrt(result);
2371template <
typename MF>
2373MLCellLinOpT<MF>::computeVolInv ()
const
2375 if (!m_volinv.empty()) {
return; }
2377 m_volinv.resize(this->m_num_amr_levels);
2378 for (
int amrlev = 0; amrlev < this->m_num_amr_levels; ++amrlev) {
2379 m_volinv[amrlev].resize(this->NMGLevels(amrlev));
2384 auto f = [&] (
int amrlev,
int mglev) {
2386 const auto *factory =
dynamic_cast<EBFArrayBoxFactory const*
>(this->Factory(amrlev,mglev));
2387 if (factory && !factory->isAllRegular())
2389 if constexpr (std::is_same<MF,MultiFab>()) {
2390 const auto& vfrac = factory->getVolFrac();
2391 m_volinv[amrlev][mglev] = vfrac.sum(0,
true);
2393 amrex::Abort(
"MLCellLinOp with EB only works with MultiFab");
2400 ? this->compactify(this->Geom(amrlev,mglev).Domain()).d_numPts()
2401 : this->m_grids[amrlev][mglev].d_numPts();
2403 m_volinv[amrlev][mglev] = RT(1.0 / npts);
2410 int mgbottom = this->NMGLevels(0)-1;
2416 if (factory && !factory->isAllRegular())
2420 temp1 = RT(1.0)/m_volinv[0][0];
2421 temp2 = RT(1.0)/m_volinv[0][mgbottom];
2425 temp1 = m_volinv[0][0];
2426 temp2 = m_volinv[0][mgbottom];
2428 m_volinv[0][0] = temp1;
2429 m_volinv[0][mgbottom] = temp2;
2433template <
typename MF>
2437 const int ncomp = this->
getNComp();
2438 const int finest_level = this->
NAMRLevels() - 1;
2442 if (factory && !factory->isAllRegular()) {
2443#if defined(AMREX_USE_CUDA) && defined(_WIN32)
2444 if (!std::is_same<MF,MultiFab>()) {
2446 if constexpr (!std::is_same<MF,MultiFab>()) {
2448 amrex::Abort(
"MLCellLinOpT with EB only works with MultiFab");
2450 const MultiFab& vfrac = factory->getVolFrac();
2452 Math::detail::AbsNanToInf<Real>
const absinf{};
2453 if (amrlev == finest_level) {
2456 auto const& ma = mf.const_arrays();
2463 Real const vf = vfrac_ma[box_no](i,j,k);
2464 return (vf >
Real(0)) ? absinf(ma[box_no](i,j,k,n))*vf :
Real(0);
2470#pragma omp parallel reduction(max:norm)
2473 Box const& bx = mfi.tilebox();
2474 auto const& fab = mf.const_array(mfi);
2478 if (v(i,j,k) >
Real(0)) {
2479 norm = std::max(
norm, absinf(fab(i,j,k,n))*v(i,j,k));
2487 auto const& ma = mf.const_arrays();
2495 if (mask_ma[box_no](i,j,k)) {
2496 Real const vf = vfrac_ma[box_no](i,j,k);
2497 return (vf >
Real(0)) ? absinf(ma[box_no](i,j,k,n))*vf :
Real(0);
2506#pragma omp parallel reduction(max:norm)
2509 Box const& bx = mfi.tilebox();
2510 auto const& fab = mf.const_array(mfi);
2515 if (mask(i,j,k) && v(i,j,k) >
Real(0)) {
2516 norm = std::max(
norm, absinf(fab(i,j,k,n))*v(i,j,k));
2526 if (amrlev == finest_level) {
2537template <
typename MF>
2542 for (
int falev = this->
NAMRLevels()-1; falev > 0; --falev)
2545 if (!sol[falev].isAllRegular()) {
2546 if constexpr (std::is_same<MF,MultiFab>()) {
2549 amrex::Abort(
"EB_average_down only works with MultiFab");
2559template <
typename MF>
2564 if (!fres.isAllRegular()) {
2565 if constexpr (std::is_same<MF,MultiFab>()) {
2569 amrex::Abort(
"EB_average_down only works with MultiFab");
2579template <
typename MF>
2587 const int ncomp = this->
getNComp();
2588 for (
int amrlev = 0; amrlev < this->m_num_amr_levels; ++amrlev) {
2590 (this->m_grids[amrlev][0],
2591 this->m_dmap[amrlev][0],
2593 this->
m_geom[amrlev][0]);
2598 for (
int amrlev = 0; amrlev < this->m_num_amr_levels; ++amrlev) {
2607template <
typename MF>
2616#ifdef AMREX_MLMG_HAS_FLOAT
#define BL_TO_FORTRAN_BOX(x)
Definition AMReX_ArrayLim.H:51
#define BL_TO_FORTRAN_ANYD(x)
Definition AMReX_ArrayLim.H:44
#define BL_PROFILE(a)
Definition AMReX_BLProfiler.H:593
#define AMREX_ALWAYS_ASSERT_WITH_MESSAGE(EX, MSG)
Definition AMReX_BLassert.H:49
#define BL_ASSERT(EX)
Definition AMReX_BLassert.H:39
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
#define AMREX_ALWAYS_ASSERT(EX)
Definition AMReX_BLassert.H:50
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:123
#define AMREX_HOST_DEVICE_PARALLEL_FOR_3D(...)
Definition AMReX_GpuLaunchMacrosC.nolint.H:110
#define AMREX_GPU_LAUNCH_HOST_DEVICE_LAMBDA_RANGE(TN, TI, block)
Definition AMReX_GpuLaunchMacrosC.nolint.H:4
#define AMREX_HOST_DEVICE_PARALLEL_FOR_4D(...)
Definition AMReX_GpuLaunchMacrosC.nolint.H:111
#define AMREX_GPU_DEVICE
Definition AMReX_GpuQualifiers.H:18
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
#define AMREX_LOOP_4D(bx, ncomp, i, j, k, n, block)
void amrex_mllinop_apply_bc(const int *lo, const int *hi, amrex_real *phi, const int *philo, const int *phihi, const int *mask, const int *mlo, const int *mhi, int cdir, int bct, amrex_real bcl, const amrex_real *bcval, const int *blo, const int *bhi, int maxorder, const amrex_real *dxinv, int inhomog, int nc, int cross)
#define AMREX_D_TERM(a, b, c)
Definition AMReX_SPACE.H:172
#define AMREX_D_DECL(a, b, c)
Definition AMReX_SPACE.H:171
Yet-another flux register for refluxing.
const FabSetT< MF > & bndryValues(Orientation face) const noexcept
Access the boundary values stored on orientation face.
Definition AMReX_BndryData.H:93
Maintain an identifier for boundary condition types.
Definition AMReX_BoundCond.H:25
Reference-counted collection of Boxes.
Definition AMReX_BoxArray.H:681
void define(const Box &bx)
Initialize the BoxArray from a single box.
Definition AMReX_BoxArray.cpp:352
BoxArray & coarsen(int refinement_ratio)
Coarsen each Box in the BoxArray by refinement_ratio.
Definition AMReX_BoxArray.cpp:685
Long size() const noexcept
Return the number of boxes in the BoxArray.
Definition AMReX_BoxArray.H:758
A list of Boxes sharing a common IndexType.
Definition AMReX_BoxList.H:109
__host__ __device__ BoxND & setBig(const IntVectND< dim > &bg) noexcept
Redefine the big end of the BoxND.
Definition AMReX_Box.H:516
__host__ __device__ IntVectND< dim > length() const noexcept
Return the length of the BoxND.
Definition AMReX_Box.H:167
__host__ __device__ bool contains(const IntVectND< dim > &p) const noexcept
Return true if argument is contained within BoxND.
Definition AMReX_Box.H:233
__host__ __device__ IntVectND< dim > size() const noexcept
Return the length of the BoxND.
Definition AMReX_Box.H:160
__host__ __device__ BoxND & coarsen(int ref_ratio) noexcept
Coarsen BoxND by given (positive) refinement ratio. NOTE: if type(dir) = CELL centered: lo <- lo/rati...
Definition AMReX_Box.H:754
__host__ __device__ BoxND & refine(int ref_ratio) noexcept
Refine BoxND by given (positive) refinement ratio. NOTE: if type(dir) = CELL centered: lo <- lo*ratio...
Definition AMReX_Box.H:730
__host__ static __device__ BoxND TheUnitBox() noexcept
Definition AMReX_Box.H:783
__host__ __device__ const IntVectND< dim > & smallEnd() const &noexcept
Return the inclusive lower bound of the box.
Definition AMReX_Box.H:124
const Real * CellSize() const noexcept
Returns the cellsize for each coordinate direction.
Definition AMReX_CoordSys.H:79
Calculates the distribution of FABs to MPI processes.
Definition AMReX_DistributionMapping.H:55
Definition AMReX_EBFabFactory.H:32
IntVect nGrowVect() const noexcept
Definition AMReX_FabArrayBase.H:85
int nComp() const noexcept
Return number of variables (aka components) associated with each point.
Definition AMReX_FabArrayBase.H:88
An Array of FortranArrayBox(FAB)-like Objects.
Definition AMReX_FabArray.H:383
void LocalCopy(FabArray< SFAB > const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
Perform local copy of FabArray data.
Definition AMReX_FabArray.H:2333
MultiArray4< typename FabArray< FAB >::value_type const > const_arrays() const noexcept
Read-only convenience wrapper equivalent to arrays() const.
Definition AMReX_FabArray.H:759
void setVal(value_type val)
Set all components in the entire region of each FAB to val.
Definition AMReX_FabArray.H:3068
Array4< typename FabArray< FAB >::value_type const > const_array(const MFIter &mfi) const noexcept
Synonym for array(const MFIter&) that highlights read-only semantics.
Definition AMReX_FabArray.H:677
Abstract factory interface for creating, aliasing, and destroying FAB objects.
Definition AMReX_FabFactory.H:73
Rectangular problem domain geometry.
Definition AMReX_Geometry.H:87
Periodicity periodicity() const noexcept
Return the Periodicity based on the length of the domain.
Definition AMReX_Geometry.H:426
const Real * ProbLo() const noexcept
Returns the lo end of the problem domain in each dimension.
Definition AMReX_Geometry.H:210
GPU-compatible tuple.
Definition AMReX_Tuple.H:104
__host__ __device__ constexpr bool allGT(const IntVectND< dim > &rhs) const noexcept
Returns true if this is greater than argument for all components. NOTE: This is NOT a strict weak ord...
Definition AMReX_IntVect.H:524
__host__ static __device__ constexpr IntVectND< dim > TheCellVector() noexcept
Definition AMReX_IntVect.H:839
__host__ __device__ constexpr int max() const noexcept
maximum (no absolute values) value
Definition AMReX_IntVect.H:320
static constexpr int IBD_max_order_DEF
Definition AMReX_InterpBndryData.H:143
a one-thingy-per-box distributed object
Definition AMReX_LayoutData.H:13
Iterator for looping ever tiles and boxes of amrex::FabArray based containers.
Definition AMReX_MFIter.H:88
bool isValid() const noexcept
Is the iterator valid i.e. is it associated with a FAB?
Definition AMReX_MFIter.H:176
Definition AMReX_MLCellLinOp.H:31
virtual void Fsmooth(int amrlev, int mglev, MultiFab &sol, const MultiFab &rhs, int redblack) const=0
Vector< RT > getSolvabilityOffset(int amrlev, int mglev, MultiFab const &rhs) const override
void averageDownSolutionRHS(int camrlev, MF &crse_sol, MF &crse_rhs, const MF &fine_sol, const MF &fine_rhs) override
Average fine solution/RHS onto the next coarser AMR level.
Definition AMReX_MLCellLinOp.H:1581
void averageDownAndSync(Vector< MF > &sol) const override
Average the solution hierarchy down (fine-to-coarse) and sync.
Definition AMReX_MLCellLinOp.H:2539
void smooth(int amrlev, int mglev, MF &sol, const MF &rhs, bool skip_fillboundary, int niter) const override
Perform niter smoothing iterations on the supplied residual equation.
Definition AMReX_MLCellLinOp.H:1602
BoxArray makeNGrids(int grid_size) const
Helper that builds a BoxArray for NSolve with boxes no larger than the requested grid_size.
Definition AMReX_MLCellLinOp.H:1252
Vector< YAFluxRegisterT< MultiFab > > m_fluxreg
Definition AMReX_MLCellLinOp.H:516
virtual void applyBC(int amrlev, int mglev, MF &in, BCMode bc_mode, StateMode s_mode, const MLMGBndryT< MF > *bndry=nullptr, bool skip_fillboundary=false) const
Apply physical BCs (optionally skipping FillBoundary).
Definition AMReX_MLCellLinOp.H:1032
void updateSolBC(int amrlev, const MF &crse_bcdata) const
Refresh stored solution BC data from coarse inputs.
Definition AMReX_MLCellLinOp.H:1001
Vector< std::unique_ptr< MLMGBndryT< MultiFab > > > m_bndry_sol
Definition AMReX_MLCellLinOp.H:456
MLCellLinOpT< MF > & operator=(const MLCellLinOpT< MF > &)=delete
void compGrad(int amrlev, const Array< MultiFab *, 3 > &grad, MultiFab &sol, Location loc) const override
void avgDownResAmr(int clev, MF &cres, MF const &fres) const override
Average a residual from a fine AMR level to its coarse parent.
Definition AMReX_MLCellLinOp.H:2561
void reflux(int crse_amrlev, MultiFab &res, const MultiFab &crse_sol, const MultiFab &, MultiFab &, MultiFab &fine_sol, const MultiFab &) const final
RT dotProductPrecond(Vector< MultiFab const * > const &x, Vector< MultiFab const * > const &y) const final
virtual void Fapply(int amrlev, int mglev, MultiFab &out, const MultiFab &in) const=0
typename FabDataType< MF >::value_type RT
Definition AMReX_MLCellLinOp.H:35
void endPrecondBC() override
Called when the operator stops being used as a preconditioner.
Definition AMReX_MLCellLinOp.H:2609
void update() override
Update for reuse.
Definition AMReX_MLCellLinOp.H:994
LinOpBCType BCType
Definition AMReX_MLCellLinOp.H:37
void correctionResidual(int amrlev, int mglev, MF &resid, MF &x, const MF &b, BCMode bc_mode, const MF *crse_bcdata=nullptr) final
Compute the correction residual with optional coarse data.
Definition AMReX_MLCellLinOp.H:1646
MLCellLinOpT(const MLCellLinOpT< MF > &)=delete
typename MLLinOpT< MF >::BCMode BCMode
Definition AMReX_MLCellLinOp.H:38
RT normInf(int amrlev, MF const &mf, bool local) const override
Infinity norm helper used by solvers and diagnostics.
Definition AMReX_MLCellLinOp.H:2435
virtual bool isCrossStencil() const
Whether the stencil is the cross shape.
Definition AMReX_MLCellLinOp.H:114
void updateCorBC(int amrlev, const MF &crse_bcdata) const
Refresh stored correction BC data from coarse inputs.
Definition AMReX_MLCellLinOp.H:1017
Array< RT, 2 *3 > RealTuple
Definition AMReX_MLCellLinOp.H:467
void interpolation(int amrlev, int fmglev, MF &fine, const MF &crse) const override
Add the prolongation of coarse data onto the fine grid (fine += prolong(crse)).
Definition AMReX_MLCellLinOp.H:1314
RT xdoty(int amrlev, int mglev, const MultiFab &x, const MultiFab &y, bool local) const final
Array< BoundCond, 2 *3 > BCTuple
Definition AMReX_MLCellLinOp.H:468
void prepareForSolve() override
void unapplyMetricTerm(int amrlev, int mglev, MultiFab &rhs) const final
void apply(int amrlev, int mglev, MF &out, MF &in, BCMode bc_mode, StateMode s_mode, const MLMGBndryT< MF > *bndry=nullptr) const override
Apply the linear operator with boundary conditions.
Definition AMReX_MLCellLinOp.H:1592
void applyMetricTerm(int amrlev, int mglev, MultiFab &rhs) const final
Vector< std::unique_ptr< BndryRegisterT< MultiFab > > > m_crse_cor_br
Definition AMReX_MLCellLinOp.H:460
RT norm2Precond(Vector< MultiFab const * > const &x) const final
void beginPrecondBC() override
Called when the operator starts being used as a preconditioner.
Definition AMReX_MLCellLinOp.H:2581
Vector< Vector< std::unique_ptr< BndryCondLoc > > > m_bcondloc
Definition AMReX_MLCellLinOp.H:506
void restriction(int amrlev, int cmglev, MF &crse, MF &fine) const override
Restrict a fine-grid field onto its coarse counterpart.
Definition AMReX_MLCellLinOp.H:1302
void setGaussSeidel(bool flag) noexcept
Toggle Gauss–Seidel smoothing in place of Jacobi relaxation.
Definition AMReX_MLCellLinOp.H:104
Vector< std::unique_ptr< MultiFab > > m_robin_bcval
Definition AMReX_MLCellLinOp.H:430
void define(const Vector< Geometry > &a_geom, const Vector< BoxArray > &a_grids, const Vector< DistributionMapping > &a_dmap, const LPInfo &a_info=LPInfo(), const Vector< FabFactory< FAB > const * > &a_factory={})
Bind the operator to an AMR hierarchy.
Definition AMReX_MLCellLinOp.H:668
~MLCellLinOpT() override=default
virtual bool isTensorOp() const
Whether this operator is a tensor solve.
Definition AMReX_MLCellLinOp.H:116
void setInterpBndryHalfWidth(int w)
Control how many cells the interpolation boundary stencil spans.
Definition AMReX_MLCellLinOp.H:437
Vector< Vector< BndryRegisterT< MultiFab > > > m_undrrelxr
Definition AMReX_MLCellLinOp.H:509
MLCellLinOpT()
Definition AMReX_MLCellLinOp.H:661
MLCellLinOpT(MLCellLinOpT< MF > &&)=delete
typename FabDataType< MF >::fab_type FAB
Definition AMReX_MLCellLinOp.H:34
void interpAssign(int amrlev, int fmglev, MF &fine, MF &crse) const override
Overwrite fine data with the prolongation of coarse data (fine = prolong(crse)).
Definition AMReX_MLCellLinOp.H:1364
void fixSolvabilityByOffset(int amrlev, int mglev, MultiFab &rhs, Vector< RT > const &offset) const override
Vector< std::unique_ptr< MLMGBndryT< MultiFab > > > m_bndry_cor
Definition AMReX_MLCellLinOp.H:459
void compFlux(int amrlev, const Array< MultiFab *, 3 > &fluxes, MultiFab &sol, Location loc) const override
typename MLLinOpT< MF >::Location Location
Definition AMReX_MLCellLinOp.H:40
void prepareForFluxes(int amrlev, const MF *crse_bcdata=nullptr) override
Ensure BC caches are ready for flux computations (e.g., getFluxes).
Definition AMReX_MLCellLinOp.H:1637
void solutionResidual(int amrlev, MF &resid, MF &x, const MF &b, const MF *crse_bcdata=nullptr) override
Compute the residual resid = b - A(x) using solution boundary data.
Definition AMReX_MLCellLinOp.H:1619
bool m_has_metric_term
Definition AMReX_MLCellLinOp.H:454
bool m_use_gauss_seidel
Definition AMReX_MLCellLinOp.H:518
Vector< std::unique_ptr< MLMGBndryT< MultiFab > > > m_bndry_sol_zero
Definition AMReX_MLCellLinOp.H:462
Vector< std::unique_ptr< BndryRegisterT< MultiFab > > > m_crse_sol_br
Definition AMReX_MLCellLinOp.H:457
void interpolationAmr(int famrlev, MF &fine, const MF &crse, IntVect const &nghost) const override
Prolong AMR-level data during FMG initialization.
Definition AMReX_MLCellLinOp.H:1460
virtual void addInhomogNeumannFlux(int, const Array< MultiFab *, 3 > &, MultiFab const &, bool) const
Definition AMReX_MLCellLinOp.H:388
Vector< std::unique_ptr< iMultiFab > > m_norm_fine_mask
Definition AMReX_MLCellLinOp.H:514
void spCopySettings() override
Definition AMReX_MLCellLinOp.H:447
typename MLLinOpT< MF >::StateMode StateMode
Definition AMReX_MLCellLinOp.H:39
void setLevelBC(int amrlev, const MF *levelbcdata, const MF *robinbc_a=nullptr, const MF *robinbc_b=nullptr, const MF *robinbc_f=nullptr) final
Provide per-level inhomogeneous boundary data.
Definition AMReX_MLCellLinOp.H:832
bool needsUpdate() const override
Does it need update if it's reused?
Definition AMReX_MLCellLinOp.H:93
Vector< Vector< Array< MultiMask, 2 *3 > > > m_maskvals
Definition AMReX_MLCellLinOp.H:512
virtual void FFlux(int amrlev, const MFIter &mfi, const Array< FAB *, 3 > &flux, const FAB &sol, Location loc, int face_only=0) const=0
const MF * m_coarse_data_for_bc
Definition AMReX_MLLinOp.H:1039
Vector< Vector< std::unique_ptr< FabFactory< FAB > > > > m_factory
Definition AMReX_MLLinOp.H:1010
int NAMRLevels() const noexcept
Return the number of AMR levels.
Definition AMReX_MLLinOp.H:951
IntVect m_ixtype
Definition AMReX_MLLinOp.H:998
RealVect m_coarse_bc_loc
Definition AMReX_MLLinOp.H:1038
virtual bool needsUpdate() const
Does it need update if it's reused?
Definition AMReX_MLLinOp.H:390
virtual void applyOverset(int amrlev, MF &rhs) const
Overset-only hook for zeroing regions covered by masks.
Definition AMReX_MLLinOp.H:647
FabFactory< FAB > const * Factory(int amr_lev, int mglev=0) const noexcept
Definition AMReX_MLLinOp.H:1209
LinOpEnumType::StateMode StateMode
Definition AMReX_MLLinOp.H:173
Array< Real, 3 > m_domain_bloc_hi
Definition AMReX_MLLinOp.H:1033
virtual void spCopySettings()
Definition AMReX_MLLinOp.H:1165
bool hasRobinBC() const noexcept
Definition AMReX_MLLinOp.H:2061
Vector< Array< BCType, 3 > > m_hibc
Definition AMReX_MLLinOp.H:966
virtual int getNComp() const
Return number of components.
Definition AMReX_MLLinOp.H:385
IntVect m_coarse_data_crse_ratio
Definition AMReX_MLLinOp.H:1037
Vector< Array< BCType, 3 > > m_hibc_orig
Definition AMReX_MLLinOp.H:970
bool needsCoarseDataForBC() const noexcept
Needs coarse data for bc?
Definition AMReX_MLLinOp.H:249
virtual void update()
Update for reuse.
Definition AMReX_MLLinOp.H:392
Vector< Array< BCType, 3 > > m_lobc_orig
Definition AMReX_MLLinOp.H:969
bool m_precond_mode
Definition AMReX_MLLinOp.H:1042
bool hasHiddenDimension() const noexcept
Definition AMReX_MLLinOp.H:1293
virtual bool supportsAnisotropicCoarsening() const
True if the operator supports MG levels coarsened in any subset of directions. Then MLMG coarsens str...
Definition AMReX_MLLinOp.H:823
const Geometry & Geom(int amr_lev, int mglev=0) const noexcept
Geometry accessor for (amr_lev,mglev).
Definition AMReX_MLLinOp.H:962
int hiddenDirection() const noexcept
Definition AMReX_MLLinOp.H:1294
Vector< Array< BCType, 3 > > m_lobc
Definition AMReX_MLLinOp.H:965
Vector< Vector< Geometry > > m_geom
first Vector is for amr level and second is mg level
Definition AMReX_MLLinOp.H:1007
Box compactify(Box const &b) const noexcept
Definition AMReX_MLLinOp.H:2068
Real m_sp_length_scale
Definition AMReX_MLLinOp.H:1065
int maxorder
Definition AMReX_MLLinOp.H:986
void define(const Vector< Geometry > &a_geom, const Vector< BoxArray > &a_grids, const Vector< DistributionMapping > &a_dmap, const LPInfo &a_info, const Vector< FabFactory< FAB > const * > &a_factory, bool eb_limit_coarsening=true)
Initialize the operator hierarchy on a set of AMR levels.
Definition AMReX_MLLinOp.H:1356
Vector< IntVect > mg_coarsen_ratio_vec
Definition AMReX_MLLinOp.H:1004
LinOpEnumType::Location Location
Definition AMReX_MLLinOp.H:174
LinOpEnumType::BCMode BCMode
Definition AMReX_MLLinOp.H:172
static constexpr bool mixed_precision_capable
Definition AMReX_MLLinOp.H:1047
LinOpBCType m_coarse_fine_bc_type
Definition AMReX_MLLinOp.H:1036
Array< Real, 3 > m_domain_bloc_lo
Definition AMReX_MLLinOp.H:1032
std::unique_ptr< MLLinOpT< fMultiFab > > m_sp_linop
Definition AMReX_MLLinOp.H:1053
friend class MLLinOpT
Definition AMReX_MLLinOp.H:159
IntVect AMRRefRatioVect(int amr_lev) const noexcept
Return AMR refinement ratio as IntVect (1 in hidden direction).
Definition AMReX_MLLinOp.H:1203
int m_num_amr_levels
Definition AMReX_MLLinOp.H:992
Boundary helper for MLMG that manages coarse/fine and physical BC metadata.
Definition AMReX_MLMGBndry.H:20
static void setBoxBC(RealTuple &bloc, BCTuple &bctag, const Box &bx, const Box &domain, const Array< LinOpBCType, 3 > &lo, const Array< LinOpBCType, 3 > &hi, const Real *dx, IntVect const &ratio, const RealVect &interior_bloc, const Array< Real, 3 > &domain_bloc_lo, const Array< Real, 3 > &domain_bloc_hi, const GpuArray< int, 3 > &is_periodic, LinOpBCType a_crse_fine_bc_type)
Helper that sets up BC tuples for a single box.
Definition AMReX_MLMGBndry.H:163
Definition AMReX_Mask.H:33
A collection (stored as an array) of FArrayBox objects.
Definition AMReX_MultiFab.H:40
An Iterator over the Orientation of Faces of a Box.
Definition AMReX_Orientation.H:135
Encapsulation of the Orientation of the Faces of a Box.
Definition AMReX_Orientation.H:29
@ low
Definition AMReX_Orientation.H:34
@ high
Definition AMReX_Orientation.H:34
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:29
Checks if a type is amrex::MultiFab-like (i.e., FabArray<FAB>, where FAB is a BaseFabType).
Definition AMReX_Concepts.H:26
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:80
ArrayND< T, 4, true > Array4
Convenient alias for a 4D ArrayND with three spatial dimensions plus a component dimension.
Definition AMReX_Array4.H:1352
@ singlevalued
No multivalued cells; not entirely regular or covered.
Definition AMReX_FabFactory.H:30
@ covered
Every cell in the region is covered.
Definition AMReX_FabFactory.H:28
@ regular
Every cell in the region is regular.
Definition AMReX_FabFactory.H:29
__host__ __device__ BoxND< dim > adjCellHi(const BoxND< dim > &b, int dir, int len=1) noexcept
Return the BoxND of length len adjacent to b on the high end along coordinate direction dir.
Definition AMReX_Box.H:1850
__host__ __device__ BoxND< dim > adjCellLo(const BoxND< dim > &b, int dir, int len=1) noexcept
Return the BoxND of length len adjacent to b on the low end along coordinate direction dir.
Definition AMReX_Box.H:1819
__host__ __device__ BoxND< dim > surroundingNodes(const BoxND< dim > &b, int dir) noexcept
Return a BoxND with NODE based coordinates in direction dir that encloses BoxND b.
Definition AMReX_Box.H:1584
__host__ __device__ BoxND< dim > coarsen(const BoxND< dim > &b, int ref_ratio) noexcept
Return a copy of b coarsened by the isotropic ratio ref_ratio.
Definition AMReX_Box.H:1471
__host__ __device__ BoxND< dim > adjCell(const BoxND< dim > &b, Orientation face, int len=1) noexcept
Similar to adjCellLo and adjCellHi except that it operates on the given face of BoxND b.
Definition AMReX_Box.H:1882
__host__ __device__ BoxND< dim > shift(const BoxND< dim > &b, int dir, int nzones) noexcept
Return a copy of b shifted by nzones cells in direction dir.
Definition AMReX_Box.H:1550
__host__ __device__ BoxND< dim > grow(const BoxND< dim > &b, int i) noexcept
Return a copy of b grown uniformly by i cells in every direction.
Definition AMReX_Box.H:1328
PODVector< T, PinnedArenaAllocator< T > > PinnedVector
A PODVector that uses the pinned memory arena.
Definition AMReX_GpuContainers.H:48
std::array< T, N > Array
Definition AMReX_Array.H:31
PODVector< T, ArenaAllocator< T > > DeviceVector
A PODVector that uses the standard memory Arena. Note that the memory might or might not be managed d...
Definition AMReX_GpuContainers.H:24
Arena * The_Async_Arena()
Definition AMReX_Arena.cpp:849
void Sum(Gpu::DeviceVector< T > &v, MPI_Comm comm)
Definition AMReX_GpuParallelReduce.H:37
void Max(KeyValuePair< K, V > &vi, MPI_Comm comm)
Definition AMReX_ParallelReduce.H:133
void copyAsync(HostToDevice, InIter begin, InIter end, OutIter result) noexcept
A host-to-device copy routine. Note this is just a wrapper around memcpy, so it assumes contiguous st...
Definition AMReX_GpuContainers.H:228
static constexpr HostToDevice hostToDevice
Definition AMReX_GpuContainers.H:105
void streamSynchronize() noexcept
Definition AMReX_GpuDevice.H:329
bool inLaunchRegion() noexcept
Definition AMReX_GpuControl.H:88
bool notInLaunchRegion() noexcept
Definition AMReX_GpuControl.H:89
bool inNoSyncRegion() noexcept
Definition AMReX_GpuControl.H:148
MPI_Comm CommunicatorSub() noexcept
sub-communicator for current frame
Definition AMReX_ParallelContext.H:70
Definition AMReX_Amr.cpp:50
__host__ __device__ void ignore_unused(const Ts &...)
No-op helper that marks variables as intentionally unused.
Definition AMReX.H:273
__host__ __device__ T norm(const GpuComplex< T > &a_z) noexcept
Return the norm (magnitude squared) of a complex number.
Definition AMReX_GpuComplex.H:349
ReduceData< Ts... >::Type ParReduce(TypeList< Ops... > operation_list, TypeList< Ts... > type_list, FabArray< FAB > const &fa, IntVect const &nghost, F &&f)
Parallel reduce for MultiFab/FabArray. The reduce result is local and it's the user's responsibility ...
Definition AMReX_ParReduce.H:48
void average_down(const MultiFab &S_fine, MultiFab &S_crse, const Geometry &fgeom, const Geometry &cgeom, int scomp, int ncomp, int rr)
Definition AMReX_MultiFabUtil.cpp:360
@ zero
Definition AMReX.H:560
@ Gpu
Definition AMReX_GpuControl.H:65
iMultiFab makeFineMask(const BoxArray &cba, const DistributionMapping &cdm, const BoxArray &fba, const IntVect &ratio, int crse_value, int fine_value, MFInfo const &info)
Definition AMReX_MultiFabUtil.cpp:655
void EB_set_covered(MultiFab &mf, Real val)
Fill all covered cells with a single value val.
Definition AMReX_EBMultiFabUtil.cpp:21
FAB::value_type Dot(FabArray< FAB > const &x, int xcomp, FabArray< FAB > const &y, int ycomp, int ncomp, IntVect const &nghost, bool local=false)
Compute dot products of two FabArrays.
Definition AMReX_FabArrayUtility.H:1906
void ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition AMReX_CTOParallelForImpl.H:202
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:35
bool isMFIterSafe(const FabArrayBase &x, const FabArrayBase &y)
Definition AMReX_MFIter.H:256
LinOpBCType
Definition AMReX_LO_BCTYPES.H:27
@ Robin
Definition AMReX_LO_BCTYPES.H:36
@ Dirichlet
Definition AMReX_LO_BCTYPES.H:29
void EB_average_down(const MultiFab &S_fine, MultiFab &S_crse, const MultiFab &vol_fine, const MultiFab &vfrac_fine, int scomp, int ncomp, const IntVect &ratio)
Volume-weighted average-down from fine to coarse using EB volume fractions.
Definition AMReX_EBMultiFabUtil.cpp:336
@ y
Definition AMReX_Orientation.H:14
@ x
Definition AMReX_Orientation.H:14
FabArray< BaseFab< float > > fMultiFab
Definition AMReX_MultiFab.H:19
bool TilingIfNotGPU() noexcept
Definition AMReX_MFIter.H:12
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:38
void Abort(const std::string &msg)
Print a fatal-error message to stderr and abort execution.
Definition AMReX.cpp:239
RealVectND< 3 > RealVect
Definition AMReX_ParmParse.H:40
MLCellLinOpT< MultiFab > MLCellLinOp
Definition AMReX_MLCellLinOp.H:2620
__host__ __device__ constexpr int get(IntVectND< dim > const &iv) noexcept
Get the Idx-th element of IntVectND<dim>.
Definition AMReX_IntVect.H:1367
A simple struct holding 3 int values for a 3D index.
Definition AMReX_Dim3.H:24
int x
Definition AMReX_Dim3.H:24
int z
Definition AMReX_Dim3.H:24
int y
Definition AMReX_Dim3.H:24
Type trait specialized for MultiFab-like types and their containers.
Definition AMReX_FabDataType.H:16
Fixed-size array that can be used on GPU.
Definition AMReX_Array.H:52
Configuration knobs for multilevel linear operators (grid agglomeration, metrics, etc....
Definition AMReX_MLLinOp.H:54
FabArray memory allocation information.
Definition AMReX_FabArray.H:73
Definition AMReX_MFIter.H:20
MFItInfo & SetDynamic(bool f) noexcept
Definition AMReX_MFIter.H:43
MFItInfo & EnableTiling(const IntVect &ts=FabArrayBase::mfiter_tile_size) noexcept
Definition AMReX_MFIter.H:31
Definition AMReX_MLCellLinOp.H:26
Definition AMReX_FabArray.H:195
Struct for holding types.
Definition AMReX_TypeList.H:13