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>
78 void setLevelBC (
int amrlev,
const MF* levelbcdata,
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)
117 void updateSolBC (
int amrlev,
const MF& crse_bcdata)
const;
124 void updateCorBC (
int amrlev,
const MF& crse_bcdata)
const;
138 const MLMGBndryT<MF>* bndry=
nullptr,
bool skip_fillboundary=
false)
const;
185 IntVect const& nghost)
const override;
197 const MF& fine_sol,
const MF& fine_rhs)
override;
210 void apply (
int amrlev,
int mglev, MF& out, MF& in,
BCMode bc_mode,
222 void smooth (
int amrlev,
int mglev, MF& sol,
const MF& rhs,
223 bool skip_fillboundary,
int niter)
const final;
235 const MF* crse_bcdata=
nullptr)
override;
243 void prepareForFluxes (
int amrlev,
const MF* crse_bcdata =
nullptr)
override;
257 BCMode bc_mode,
const MF* crse_bcdata=
nullptr) final;
272 void reflux (
int crse_amrlev,
273 MF& res, const MF& crse_sol, const MF&,
274 MF&, MF& fine_sol, const MF&) const final;
283 void compFlux (
int amrlev, const
Array<MF*,AMREX_SPACEDIM>& fluxes,
284 MF& sol,
Location loc) const override;
293 void compGrad (
int amrlev, const
Array<MF*,AMREX_SPACEDIM>& grad,
294 MF& sol,
Location loc) const override;
321 MF const& rhs) const override;
346 RT xdoty (
int amrlev,
int mglev, const MF&
x, const MF&
y,
bool local) const final;
367 virtual
void Fapply (
int amrlev,
int mglev, MF& out, const MF& in) const = 0;
368 virtual
void Fsmooth (
int amrlev,
int mglev, MF& sol, const MF& rhs,
int redblack) const = 0;
370 const
Array<
FAB*,AMREX_SPACEDIM>& flux,
371 const
FAB& sol,
Location loc,
int face_only=0) const = 0;
382 const
Array<MF*,AMREX_SPACEDIM>& ,
393 RT normInf (
int amrlev, MF
const& mf,
bool local)
const override;
409 void avgDownResAmr (
int clev, MF& cres, MF
const& fres)
const override;
455 void setLOBndryConds (
const Geometry& geom,
const Real* dx,
469 const BCTuple& bndryConds (
const MFIter& mfi,
int icomp)
const noexcept {
470 return bcond[mfi][icomp];
472 const RealTuple& bndryLocs (
const MFIter& mfi,
int icomp)
const noexcept {
473 return bcloc[mfi][icomp];
502 void defineAuxData ();
505 void computeVolInv ()
const;
508 int m_interpbndry_halfwidth = 2;
527 Box const& box() const noexcept {
return bx; }
534 Array4<int const> mlo;
535 Array4<int const> mhi;
546 Box const& box() const noexcept {
return bx; }
555 Array4<int const> mlo;
556 Array4<int const> mhi;
567 Box const& box() const noexcept {
return bx; }
571template <
typename MF>
572MLCellLinOpT<MF>::BndryCondLoc::BndryCondLoc (
const BoxArray& ba,
573 const DistributionMapping& dm,
578 bctl_dv(bctl.local_size()*ncomp),
581 auto* dp = bctl_dv.data();
582 for (MFIter mfi(bcloc); mfi.isValid(); ++mfi) {
583 bcond[mfi].resize(ncomp);
584 bcloc[mfi].resize(ncomp);
590template <
typename MF>
592MLCellLinOpT<MF>::BndryCondLoc::
593setLOBndryConds (
const Geometry& geom,
const Real* dx,
594 const Vector<Array<BCType,AMREX_SPACEDIM> >& lobc,
595 const Vector<Array<BCType,AMREX_SPACEDIM> >& hibc,
597 const Array<Real,AMREX_SPACEDIM>& domain_bloc_lo,
598 const Array<Real,AMREX_SPACEDIM>& domain_bloc_hi,
601 const Box& domain = geom.Domain();
606 for (MFIter mfi(bcloc); mfi.isValid(); ++mfi)
608 const Box& bx = mfi.validbox();
609 for (
int icomp = 0; icomp < m_ncomp; ++icomp) {
610 RealTuple & bloc = bcloc[mfi][icomp];
611 BCTuple & bctag = bcond[mfi][icomp];
613 lobc[icomp], hibc[icomp],
614 dx, ratio, interior_bloc,
615 domain_bloc_lo, domain_bloc_hi,
616 geom.isPeriodicArray(),
621 Gpu::PinnedVector<GpuArray<BCTL,2*AMREX_SPACEDIM> > hv;
622 hv.reserve(bctl_dv.size());
623 for (MFIter mfi(bctl); mfi.isValid(); ++mfi)
625 for (
int icomp = 0; icomp < m_ncomp; ++icomp) {
626 GpuArray<BCTL,2*AMREX_SPACEDIM> tmp;
627 for (
int m = 0; m < 2*AMREX_SPACEDIM; ++m) {
628 tmp[m].type = bcond[mfi][icomp][m];
629 tmp[m].location = bcloc[mfi][icomp][m];
631 hv.push_back(std::move(tmp));
640template <
typename MF>
646template <
typename MF>
659template <
typename MF>
665 m_undrrelxr.resize(this->m_num_amr_levels);
666 m_maskvals.resize(this->m_num_amr_levels);
667 m_fluxreg.resize(this->m_num_amr_levels-1);
668 m_norm_fine_mask.resize(this->m_num_amr_levels-1);
669 m_bc_tags.resize(this->m_num_amr_levels);
671 const int ncomp = this->getNComp();
673 for (
int amrlev = 0; amrlev < this->m_num_amr_levels; ++amrlev)
675 m_undrrelxr[amrlev].resize(this->m_num_mg_levels[amrlev]);
676 m_bc_tags[amrlev].resize(this->m_num_mg_levels[amrlev]);
677 for (
int mglev = 0; mglev < this->m_num_mg_levels[amrlev]; ++mglev)
679 m_undrrelxr[amrlev][mglev].define(this->m_grids[amrlev][mglev],
680 this->m_dmap[amrlev][mglev],
685 for (
int amrlev = 0; amrlev < this->m_num_amr_levels; ++amrlev)
687 m_maskvals[amrlev].resize(this->m_num_mg_levels[amrlev]);
688 for (
int mglev = 0; mglev < this->m_num_mg_levels[amrlev]; ++mglev)
690 for (OrientationIter oitr; oitr; ++oitr)
692 const Orientation face = oitr();
694 const int extent = this->isCrossStencil() ? 0 : 1;
695 m_maskvals[amrlev][mglev][face].define(this->m_grids[amrlev][mglev],
696 this->m_dmap[amrlev][mglev],
697 this->m_geom[amrlev][mglev],
698 face, 0, ngrow, extent, 1,
true);
703 for (
int amrlev = 0; amrlev < this->m_num_amr_levels-1; ++amrlev)
705 const IntVect ratio{this->AMRRefRatioVect(amrlev)};
706 m_fluxreg[amrlev].define(this->m_grids[amrlev+1][0],
707 this->m_grids[amrlev][0],
708 this->m_dmap[amrlev+1][0],
709 this->m_dmap[amrlev][0],
710 this->m_geom[amrlev+1][0],
711 this->m_geom[amrlev][0],
712 ratio, amrlev+1, ncomp);
713 m_fluxreg[amrlev].setDeterministic(this->info.deterministic);
714 m_norm_fine_mask[amrlev] = std::make_unique<iMultiFab>
715 (
makeFineMask(this->m_grids[amrlev][0], this->m_dmap[amrlev][0],
716 this->m_grids[amrlev+1][0],
720#if (AMREX_SPACEDIM != 3)
721 m_has_metric_term = !this->m_geom[0][0].IsCartesian() && this->info.has_metric_term;
725template <
typename MF>
727MLCellLinOpT<MF>::defineBC ()
731 const int ncomp = this->getNComp();
733 m_bndry_sol.resize(this->m_num_amr_levels);
734 m_crse_sol_br.resize(this->m_num_amr_levels);
736 m_bndry_cor.resize(this->m_num_amr_levels);
737 m_crse_cor_br.resize(this->m_num_amr_levels);
739 m_robin_bcval.resize(this->m_num_amr_levels);
741 for (
int amrlev = 0; amrlev < this->m_num_amr_levels; ++amrlev)
743 m_bndry_sol[amrlev] = std::make_unique<MLMGBndryT<MF>>(this->m_grids[amrlev][0],
744 this->m_dmap[amrlev][0],
746 this->m_geom[amrlev][0]);
749 for (
int amrlev = 1; amrlev < this->m_num_amr_levels; ++amrlev)
751 const int in_rad = 0;
752 const int out_rad = 1;
753 const int extent_rad = 2;
754 const IntVect crse_ratio = this->AMRRefRatioVect(amrlev-1);
755 BoxArray cba = this->m_grids[amrlev][0];
756 cba.coarsen(crse_ratio);
757 m_crse_sol_br[amrlev] = std::make_unique<BndryRegisterT<MF>>
758 (cba, this->m_dmap[amrlev][0], in_rad, out_rad, extent_rad, ncomp);
761 for (
int amrlev = 1; amrlev < this->m_num_amr_levels; ++amrlev)
763 const int in_rad = 0;
764 const int out_rad = 1;
765 const int extent_rad = 2;
766 const IntVect crse_ratio = this->AMRRefRatioVect(amrlev-1);
767 BoxArray cba = this->m_grids[amrlev][0];
768 cba.coarsen(crse_ratio);
769 m_crse_cor_br[amrlev] = std::make_unique<BndryRegisterT<MF>>
770 (cba, this->m_dmap[amrlev][0], in_rad, out_rad, extent_rad, ncomp);
771 m_crse_cor_br[amrlev]->setVal(RT(0.0));
775 for (
int amrlev = 1; amrlev < this->m_num_amr_levels; ++amrlev)
777 m_bndry_cor[amrlev] = std::make_unique<MLMGBndryT<MF>>
778 (this->m_grids[amrlev][0], this->m_dmap[amrlev][0], ncomp, this->m_geom[amrlev][0]);
779 MF bc_data(this->m_grids[amrlev][0], this->m_dmap[amrlev][0], ncomp, 1);
782 m_bndry_cor[amrlev]->setBndryValues(*m_crse_cor_br[amrlev], 0, bc_data, 0, 0, ncomp,
783 this->AMRRefRatioVect(amrlev-1),
785 m_interpbndry_halfwidth);
787 Vector<Array<LinOpBCType,AMREX_SPACEDIM> > bclohi
788 (ncomp,Array<LinOpBCType,AMREX_SPACEDIM>{{
AMREX_D_DECL(BCType::Dirichlet,
790 BCType::Dirichlet)}});
791 m_bndry_cor[amrlev]->setLOBndryConds(bclohi, bclohi, this->AMRRefRatioVect(amrlev-1),
RealVect{});
794 m_bcondloc.resize(this->m_num_amr_levels);
795 for (
int amrlev = 0; amrlev < this->m_num_amr_levels; ++amrlev)
797 m_bcondloc[amrlev].resize(this->m_num_mg_levels[amrlev]);
798 for (
int mglev = 0; mglev < this->m_num_mg_levels[amrlev]; ++mglev)
800 m_bcondloc[amrlev][mglev] = std::make_unique<BndryCondLoc>(this->m_grids[amrlev][mglev],
801 this->m_dmap[amrlev][mglev],
807template <
typename MF>
810 const MF* robinbc_b,
const MF* robinbc_f)
816 const int ncomp = this->getNComp();
820 if (this->hasHiddenDimension()) { ng[this->hiddenDirection()] = 0; }
821 if (a_levelbcdata ==
nullptr) {
822 zero.define(this->m_grids[amrlev][0], this->m_dmap[amrlev][0], ncomp, ng);
827 const MF& bcdata = (a_levelbcdata ==
nullptr) ?
zero : *a_levelbcdata;
833 if (this->needsCoarseDataForBC())
836 if (this->hasHiddenDimension()) {
837 int hidden_dir = this->hiddenDirection();
840 br_ref_ratio = this->m_coarse_data_crse_ratio.
allGT(0) ? this->m_coarse_data_crse_ratio :
IntVect(2);
841 if (this->m_crse_sol_br[amrlev] ==
nullptr && br_ref_ratio.
allGT(0))
843 const int in_rad = 0;
844 const int out_rad = 1;
845 const int extent_rad = 2;
846 const IntVect crse_ratio = br_ref_ratio;
847 BoxArray cba = this->m_grids[amrlev][0];
849 this->m_crse_sol_br[amrlev] = std::make_unique<BndryRegisterT<MF>>
850 (cba, this->m_dmap[amrlev][0], in_rad, out_rad, extent_rad, ncomp);
852 if (this->m_coarse_data_for_bc !=
nullptr) {
855 this->m_crse_sol_br[amrlev]->copyFrom(*(this->m_coarse_data_for_bc), 0, 0, 0, ncomp,
856 this->m_geom[0][0].periodicity(
cbx));
858 this->m_crse_sol_br[amrlev]->setVal(
RT(0.0));
860 this->m_bndry_sol[amrlev]->setBndryValues(*(this->m_crse_sol_br[amrlev]), 0,
861 bcdata, 0, 0, ncomp, br_ref_ratio,
863 this->m_interpbndry_halfwidth);
864 br_ref_ratio = this->m_coarse_data_crse_ratio;
868 this->m_bndry_sol[amrlev]->setPhysBndryValues(bcdata,0,0,ncomp);
874 this->m_bndry_sol[amrlev]->setPhysBndryValues(bcdata,0,0,ncomp);
875 br_ref_ratio = this->AMRRefRatioVect(amrlev-1);
879 this->m_bndry_sol[amrlev]->setLOBndryConds(this->m_lobc, this->m_hibc, br_ref_ratio,
880 this->m_coarse_bc_loc, crse_fine_bc_type);
882 const Real* dx = this->m_geom[amrlev][0].CellSize();
883 for (
int mglev = 0; mglev < this->m_num_mg_levels[amrlev]; ++mglev)
885 this->m_bcondloc[amrlev][mglev]->setLOBndryConds(this->m_geom[amrlev][mglev], dx,
886 this->m_lobc, this->m_hibc,
887 br_ref_ratio, this->m_coarse_bc_loc,
888 this->m_domain_bloc_lo, this->m_domain_bloc_hi,
892 if (this->hasRobinBC()) {
893 AMREX_ASSERT(robinbc_a !=
nullptr && robinbc_b !=
nullptr && robinbc_f !=
nullptr);
894 this->m_robin_bcval[amrlev] = std::make_unique<MF>(this->m_grids[amrlev][0],
895 this->m_dmap[amrlev][0],
897 const Box& domain = this->m_geom[amrlev][0].Domain();
901#pragma omp parallel if (Gpu::notInLaunchRegion())
903 for (
MFIter mfi(*(this->m_robin_bcval[amrlev]), mfi_info); mfi.
isValid(); ++mfi) {
904 Box const& vbx = mfi.validbox();
908 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
911 bool outside_domain_lo = !(domain.
contains(blo));
912 bool outside_domain_hi = !(domain.
contains(bhi));
913 if ((!outside_domain_lo) && (!outside_domain_hi)) {
continue; }
914 for (
int icomp = 0; icomp < ncomp; ++icomp) {
915 Array4<RT> const& rbc = (*(this->m_robin_bcval[amrlev]))[mfi].array(icomp*3);
920 rbc(i,j,k,0) = ra(i,j,k,icomp);
921 rbc(i,j,k,1) = rb(i,j,k,icomp);
922 rbc(i,j,k,2) = rf(i,j,k,icomp);
929 rbc(i,j,k,0) = ra(i,j,k,icomp);
930 rbc(i,j,k,1) = rb(i,j,k,icomp);
931 rbc(i,j,k,2) = rf(i,j,k,icomp);
940template <
typename MF>
947template <
typename MF>
954 const int ncomp = this->getNComp();
955 m_crse_sol_br[amrlev]->copyFrom(crse_bcdata, 0, 0, 0, ncomp,
956 this->m_geom[amrlev-1][0].periodicity());
957 m_bndry_sol[amrlev]->updateBndryValues(*m_crse_sol_br[amrlev], 0, 0, ncomp,
958 this->AMRRefRatioVect(amrlev-1),
960 m_interpbndry_halfwidth);
963template <
typename MF>
969 const int ncomp = this->getNComp();
970 m_crse_cor_br[amrlev]->copyFrom(crse_bcdata, 0, 0, 0, ncomp,
971 this->m_geom[amrlev-1][0].periodicity());
972 m_bndry_cor[amrlev]->updateBndryValues(*m_crse_cor_br[amrlev], 0, 0, ncomp,
973 this->AMRRefRatioVect(amrlev-1),
975 m_interpbndry_halfwidth);
978template <
typename MF>
985 BL_ASSERT(mglev == 0 || bc_mode == BCMode::Homogeneous);
986 BL_ASSERT(bndry !=
nullptr || bc_mode == BCMode::Homogeneous);
988 const int ncomp = this->getNComp();
989 const int cross = isCrossStencil();
990 const int tensorop = isTensorOp();
991 if (!skip_fillboundary) {
992 in.FillBoundary(0, ncomp, this->m_geom[amrlev][mglev].periodicity(), cross);
995 int flagbc = bc_mode == BCMode::Inhomogeneous;
996 const int imaxorder = this->maxorder;
998 const Real* dxinv = this->m_geom[amrlev][mglev].InvCellSize();
999 const RT dxi =
static_cast<RT>(dxinv[0]);
1000 const RT dyi = (AMREX_SPACEDIM >= 2) ?
static_cast<RT>(dxinv[1]) :
RT(1.0);
1001 const RT dzi = (AMREX_SPACEDIM == 3) ?
static_cast<RT>(dxinv[2]) :
RT(1.0);
1003 const auto& maskvals = m_maskvals[amrlev][mglev];
1004 const auto& bcondloc = *m_bcondloc[amrlev][mglev];
1007 const auto& foo = foofab.const_array();
1013 "non-cross stencil not support for gpu");
1015 const int hidden_direction = this->hiddenDirection();
1020 if (! m_bc_tags[amrlev][mglev].is_defined()) {
1022 tags.reserve(in.local_size()*2*AMREX_SPACEDIM*ncomp);
1024 const Box& vbx = mfi.validbox();
1025 const auto & bdlv = bcondloc.bndryLocs(mfi);
1026 const auto & bdcv = bcondloc.bndryConds(mfi);
1028 const int local_index = mfi.LocalIndex();
1030 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
1031 if (idim != hidden_direction) {
1034 for (
int icomp = 0; icomp < ncomp; ++icomp) {
1036 maskvals[olo].const_array(mfi),
1039 bdcv[icomp][olo], vbx.
length(idim),
1040 icomp, olo, local_index
1043 maskvals[ohi].const_array(mfi),
1046 bdcv[icomp][ohi], vbx.
length(idim),
1047 icomp, ohi, local_index
1053 m_bc_tags[amrlev][mglev].define(tags);
1060 bndry_arrays[ori] = (bndry !=
nullptr) ?
1064 auto inma = in.arrays();
1068 const auto& bcval = bndry_arrays[tag.face][tag.local_index];
1069 const int side = tag.face.faceDir();
1070 if (tag.face.coordDir() == 0) {
1071 mllinop_apply_bc_x(side, i, j, k, tag.blen, inma[tag.local_index],
1072 tag.mask, tag.bctype, tag.bcloc, bcval,
1073 imaxorder, dxi, flagbc, tag.comp);
1075#if (AMREX_SPACEDIM > 1)
1077#
if (AMREX_SPACEDIM > 2)
1078 if (tag.face.coordDir() == 1)
1081 mllinop_apply_bc_y(side, i, j, k, tag.blen, inma[tag.local_index],
1082 tag.mask, tag.bctype, tag.bcloc, bcval,
1083 imaxorder, dyi, flagbc, tag.comp);
1085#if (AMREX_SPACEDIM > 2)
1087 mllinop_apply_bc_z(side, i, j, k, tag.blen, inma[tag.local_index],
1088 tag.mask, tag.bctype, tag.bcloc, bcval,
1089 imaxorder, dzi, flagbc, tag.comp);
1096 if (cross || tensorop)
1099#pragma omp parallel if (Gpu::notInLaunchRegion())
1103 const Box& vbx = mfi.validbox();
1104 const auto& iofab = in.array(mfi);
1106 const auto & bdlv = bcondloc.bndryLocs(mfi);
1107 const auto & bdcv = bcondloc.bndryConds(mfi);
1109 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim)
1111 if (hidden_direction == idim) {
continue; }
1116 const int blen = vbx.
length(idim);
1117 const auto& mlo = maskvals[olo].array(mfi);
1118 const auto& mhi = maskvals[ohi].array(mfi);
1119 const auto& bvlo = (bndry !=
nullptr) ? bndry->
bndryValues(olo).const_array(mfi) : foo;
1120 const auto& bvhi = (bndry !=
nullptr) ? bndry->
bndryValues(ohi).const_array(mfi) : foo;
1121 for (
int icomp = 0; icomp < ncomp; ++icomp) {
1122 const BoundCond bctlo = bdcv[icomp][olo];
1123 const BoundCond bcthi = bdcv[icomp][ohi];
1124 const RT bcllo = bdlv[icomp][olo];
1125 const RT bclhi = bdlv[icomp][ohi];
1127 mllinop_apply_bc_x(0, blo, blen, iofab, mlo,
1129 imaxorder, dxi, flagbc, icomp);
1130 mllinop_apply_bc_x(1, bhi, blen, iofab, mhi,
1132 imaxorder, dxi, flagbc, icomp);
1133 }
else if (idim == 1) {
1134 mllinop_apply_bc_y(0, blo, blen, iofab, mlo,
1136 imaxorder, dyi, flagbc, icomp);
1137 mllinop_apply_bc_y(1, bhi, blen, iofab, mhi,
1139 imaxorder, dyi, flagbc, icomp);
1141 mllinop_apply_bc_z(0, blo, blen, iofab, mlo,
1143 imaxorder, dzi, flagbc, icomp);
1144 mllinop_apply_bc_z(1, bhi, blen, iofab, mhi,
1146 imaxorder, dzi, flagbc, icomp);
1155 amrex::Abort(
"amrex_mllinop_apply_bc not available when BL_NO_FORT=TRUE");
1157 if constexpr (std::is_same_v<Real,RT>) {
1163 const Box& vbx = mfi.validbox();
1165 const auto & bdlv = bcondloc.bndryLocs(mfi);
1166 const auto & bdcv = bcondloc.bndryConds(mfi);
1169 const BCTuple & bdc = bdcv[0];
1179 const auto& fsfab = (bndry !=
nullptr) ? bndry->
bndryValues(ori)[mfi] : foofab;
1181 const Mask& m = maskvals[ori][mfi];
1188 imaxorder, dxinv, flagbc, ncomp, cross);
1198template <
typename MF>
1202 const Box& dombx = this->m_geom[0].back().Domain();
1204 const BoxArray& old_ba = this->m_grids[0].back();
1205 const int N = old_ba.
size();
1208 for (
int i = 0; i < N; ++i)
1219#if (AMREX_SPACEDIM == 3)
1220 for (
int kk = 0; kk < nblks[2]; ++kk) {
1222#if (AMREX_SPACEDIM >= 2)
1223 for (
int jj = 0; jj < nblks[1]; ++jj) {
1225 for (
int ii = 0; ii < nblks[0]; ++ii)
1232#if (AMREX_SPACEDIM >= 2)
1235#if (AMREX_SPACEDIM == 3)
1240 std::sort(bv.begin(), bv.end());
1241 bv.erase(std::unique(bv.begin(), bv.end()), bv.end());
1248template <
typename MF>
1252 const int ncomp = this->getNComp();
1253 IntVect ratio = (amrlev > 0) ?
IntVect(2) : this->mg_coarsen_ratio_vec[cmglev-1];
1257template <
typename MF>
1261 const int ncomp = this->getNComp();
1263 Dim3 ratio3 = {.
x = 2, .y = 2, .z = 2};
1264 IntVect ratio = (amrlev > 0) ?
IntVect(2) : this->mg_coarsen_ratio_vec[fmglev];
1266 ratio3.
y = ratio[1];,
1267 ratio3.
z = ratio[2];);
1271 auto const& finema =
fine.arrays();
1272 auto const& crsema =
crse.const_arrays();
1279 finema[box_no](i,j,k,n) += crsema[box_no](ic,jc,kc,n);
1288#pragma omp parallel if (Gpu::notInLaunchRegion())
1292 const Box& bx = mfi.tilebox();
1300 ffab(i,j,k,n) += cfab(ic,jc,kc,n);
1306template <
typename MF>
1310 const int ncomp = this->getNComp();
1312 const Geometry& crse_geom = this->Geom(amrlev,fmglev+1);
1313 const IntVect refratio = (amrlev > 0) ?
IntVect(2) : this->mg_coarsen_ratio_vec[fmglev];
1328 cfine.
define(cba,
fine.DistributionMap(), ncomp, ng);
1329 cfine.setVal(
RT(0.0));
1334 bool isEB =
fine.hasEBFabFactory();
1345#pragma omp parallel if (Gpu::notInLaunchRegion())
1349 const Box& bx = mfi.tilebox();
1350 const auto& ff =
fine.array(mfi);
1351 const auto& cc = cmf->array(mfi);
1356 const auto& flag = (*flags)[mfi];
1363 mlmg_eb_cc_interp_r<2>(tbx, ff, cc, flg, ncomp);
1374 const bool call_lincc =
true;
1378#if (AMREX_SPACEDIM == 3)
1379 if (this->hasHiddenDimension()) {
1380 Box const& bx_2d = this->compactify(bx);
1381 auto const& ff_2d = this->compactify(ff);
1382 auto const& cc_2d = this->compactify(cc);
1385 TwoD::mlmg_lin_cc_interp_r2(tbx, ff_2d, cc_2d, ncomp);
1392 mlmg_lin_cc_interp_r2(tbx, ff, cc, ncomp);
1399template <
typename MF>
1404 const int ncomp = this->getNComp();
1405 const IntVect refratioV = this->AMRRefRatioVect(famrlev-1);
1408 const int refratio = refratioV.
max();
1411 const auto *factory =
dynamic_cast<EBFArrayBoxFactory const*
>(this->Factory(famrlev));
1418#pragma omp parallel if (Gpu::notInLaunchRegion())
1422 const Box& bx = mfi.tilebox();
1423 auto const& ff =
fine.array(mfi);
1424 auto const& cc =
crse.const_array(mfi);
1429 const auto& flag = (*flags)[mfi];
1439 mlmg_eb_cc_interp_r<2>(tbx, ff, cc, flg, ncomp);
1447 mlmg_eb_cc_interp_r<4>(tbx, ff, cc, flg, ncomp);
1452 amrex::Abort(
"mlmg_eb_cc_interp: only refratio 2 and 4 are supported");
1463 const bool call_lincc =
true;
1467#if (AMREX_SPACEDIM == 3)
1468 if (this->hasHiddenDimension()) {
1469 Box const& bx_2d = this->compactify(bx);
1470 auto const& ff_2d = this->compactify(ff);
1471 auto const& cc_2d = this->compactify(cc);
1477 TwoD::mlmg_lin_cc_interp_r2(tbx, ff_2d, cc_2d, ncomp);
1485 TwoD::mlmg_lin_cc_interp_r4(tbx, ff_2d, cc_2d, ncomp);
1490 amrex::Abort(
"mlmg_lin_cc_interp: only refratio 2 and 4 are supported");
1500 mlmg_lin_cc_interp_r2(tbx, ff, cc, ncomp);
1508 mlmg_lin_cc_interp_r4(tbx, ff, cc, ncomp);
1513 amrex::Abort(
"mlmg_lin_cc_interp: only refratio 2 and 4 are supported");
1520template <
typename MF>
1523 const MF& fine_sol,
const MF& fine_rhs)
1525 const auto amrrr = this->AMRRefRatioVect(camrlev);
1526 const int ncomp = this->getNComp();
1531template <
typename MF>
1537 applyBC(amrlev, mglev, in, bc_mode, s_mode, bndry);
1538 Fapply(amrlev, mglev, out, in);
1541template <
typename MF>
1544 bool skip_fillboundary,
int niter)
const
1547 for (
int i = 0; i < niter; ++i) {
1548 for (
int redblack = 0; redblack < 2; ++redblack)
1550 applyBC(amrlev, mglev, sol, BCMode::Homogeneous, StateMode::Solution,
1551 nullptr, skip_fillboundary);
1552 Fsmooth(amrlev, mglev, sol, rhs, redblack);
1553 skip_fillboundary =
false;
1558template <
typename MF>
1561 const MF* crse_bcdata)
1563 BL_PROFILE(
"MLCellLinOp::solutionResidual()");
1564 const int ncomp = this->getNComp();
1565 if (crse_bcdata !=
nullptr) {
1566 updateSolBC(amrlev, *crse_bcdata);
1568 const int mglev = 0;
1569 apply(amrlev, mglev, resid,
x, BCMode::Inhomogeneous, StateMode::Solution,
1570 m_bndry_sol[amrlev].
get());
1573 MF::Xpay(resid,
RT(-1.0), b, 0, 0, ncomp,
IntVect(0));
1576template <
typename MF>
1580 if (crse_bcdata !=
nullptr) {
1581 updateSolBC(amrlev, *crse_bcdata);
1585template <
typename MF>
1588 BCMode bc_mode,
const MF* crse_bcdata)
1590 BL_PROFILE(
"MLCellLinOp::correctionResidual()");
1591 const int ncomp = this->getNComp();
1592 if (bc_mode == BCMode::Inhomogeneous)
1597 updateCorBC(amrlev, *crse_bcdata);
1599 apply(amrlev, mglev, resid,
x, BCMode::Inhomogeneous, StateMode::Correction,
1600 m_bndry_cor[amrlev].
get());
1605 apply(amrlev, mglev, resid,
x, BCMode::Homogeneous, StateMode::Correction,
nullptr);
1608 MF::Xpay(resid,
Real(-1.0), b, 0, 0, ncomp,
IntVect(0));
1611template <
typename MF>
1614 MF&, MF& fine_sol,
const MF&)
const
1618 auto& fluxreg = m_fluxreg[crse_amrlev];
1621 const int ncomp = this->getNComp();
1623 const int fine_amrlev = crse_amrlev+1;
1626 const Real* crse_dx = this->m_geom[crse_amrlev][0].CellSize();
1627 const Real* fine_dx = this->m_geom[fine_amrlev][0].CellSize();
1629 const int mglev = 0;
1630 applyBC(fine_amrlev, mglev, fine_sol, BCMode::Inhomogeneous, StateMode::Solution,
1631 m_bndry_sol[fine_amrlev].
get());
1637#pragma omp parallel if (Gpu::notInLaunchRegion())
1646 if (fluxreg.CrseHasWork(mfi))
1648 const Box& tbx = mfi.tilebox();
1652 FFlux(crse_amrlev, mfi, pflux, crse_sol[mfi], Location::FaceCentroid);
1653 fluxreg.CrseAdd(mfi, cpflux, crse_dx, dt,
RunOn::Gpu);
1663 if (fluxreg.FineHasWork(mfi))
1665 const Box& tbx = mfi.tilebox();
1666 const int face_only =
true;
1670 FFlux(fine_amrlev, mfi, pflux, fine_sol[mfi], Location::FaceCentroid, face_only);
1671 fluxreg.FineAdd(mfi, cpflux, fine_dx, dt,
RunOn::Gpu);
1676 fluxreg.Reflux(res);
1677 this->applyOverset(crse_amrlev, res);
1680template <
typename MF>
1687 const int mglev = 0;
1688 const int ncomp = this->getNComp();
1689 applyBC(amrlev, mglev, sol, BCMode::Inhomogeneous, StateMode::Solution,
1690 m_bndry_sol[amrlev].
get());
1696#pragma omp parallel if (Gpu::notInLaunchRegion())
1703 const Box& tbx = mfi.tilebox();
1707 FFlux(amrlev, mfi, pflux, sol[mfi], loc);
1708 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
1709 const Box& nbx = mfi.nodaltilebox(idim);
1710 auto const& dst = fluxes[idim]->array(mfi);
1711 auto const& src = pflux[idim]->const_array();
1714 dst(i,j,k,n) = src(i,j,k,n);
1721template <
typename MF>
1728 if (sol.nComp() > 1) {
1729 amrex::Abort(
"MLCellLinOp::compGrad called, but only works for single-component solves");
1732 const int mglev = 0;
1733 applyBC(amrlev, mglev, sol, BCMode::Inhomogeneous, StateMode::Solution,
1734 m_bndry_sol[amrlev].
get());
1736 const int ncomp = this->getNComp();
1738 AMREX_D_TERM(
const RT dxi =
static_cast<RT>(this->m_geom[amrlev][mglev].InvCellSize(0));,
1739 const RT dyi =
static_cast<RT>(this->m_geom[amrlev][mglev].InvCellSize(1));,
1740 const RT dzi =
static_cast<RT>(this->m_geom[amrlev][mglev].InvCellSize(2)););
1742#pragma omp parallel if (Gpu::notInLaunchRegion())
1747 const Box& ybx = mfi.nodaltilebox(1);,
1748 const Box& zbx = mfi.nodaltilebox(2););
1749 const auto& s = sol.array(mfi);
1751 const auto& gy = grad[1]->array(mfi);,
1752 const auto& gz = grad[2]->array(mfi););
1756 gx(i,j,k,n) = dxi*(s(i,j,k,n) - s(i-1,j,k,n));
1758#if (AMREX_SPACEDIM >= 2)
1761 gy(i,j,k,n) = dyi*(s(i,j,k,n) - s(i,j-1,k,n));
1764#if (AMREX_SPACEDIM == 3)
1767 gz(i,j,k,n) = dzi*(s(i,j,k,n) - s(i,j,k-1,n));
1772 addInhomogNeumannFlux(amrlev, grad, sol,
false);
1775template <
typename MF>
1780#if (AMREX_SPACEDIM != 3)
1781 if (!m_has_metric_term) {
return; }
1783 const int ncomp = rhs.nComp();
1785 bool cc = rhs.ixType().cellCentered(0);
1787 const Geometry& geom = this->m_geom[amrlev][mglev];
1789 const RT probxlo =
static_cast<RT>(geom.
ProbLo(0));
1792#pragma omp parallel if (Gpu::notInLaunchRegion())
1796 const Box& tbx = mfi.tilebox();
1797 auto const& rhsarr = rhs.array(mfi);
1798#if (AMREX_SPACEDIM == 1)
1802 RT rc = probxlo + (i+
RT(0.5))*dx;
1803 rhsarr(i,j,k,n) *= rc*rc;
1808 RT re = probxlo + i*dx;
1809 rhsarr(i,j,k,n) *= re*re;
1812#elif (AMREX_SPACEDIM == 2)
1816 RT rc = probxlo + (i+
RT(0.5))*dx;
1817 rhsarr(i,j,k,n) *= rc;
1822 RT re = probxlo + i*dx;
1823 rhsarr(i,j,k,n) *= re;
1831template <
typename MF>
1836#if (AMREX_SPACEDIM != 3)
1837 if (!m_has_metric_term) {
return; }
1839 const int ncomp = rhs.nComp();
1841 bool cc = rhs.ixType().cellCentered(0);
1843 const Geometry& geom = this->m_geom[amrlev][mglev];
1845 const RT probxlo =
static_cast<RT>(geom.
ProbLo(0));
1848#pragma omp parallel if (Gpu::notInLaunchRegion())
1852 const Box& tbx = mfi.tilebox();
1853 auto const& rhsarr = rhs.array(mfi);
1854#if (AMREX_SPACEDIM == 1)
1858 RT rcinv =
RT(1.0)/(probxlo + (i+
RT(0.5))*dx);
1859 rhsarr(i,j,k,n) *= rcinv*rcinv;
1864 RT re = probxlo + i*dx;
1865 RT reinv = (re==
RT(0.0)) ?
RT(0.0) :
RT(1.)/re;
1866 rhsarr(i,j,k,n) *= reinv*reinv;
1869#elif (AMREX_SPACEDIM == 2)
1873 RT rcinv =
RT(1.0)/(probxlo + (i+
RT(0.5))*dx);
1874 rhsarr(i,j,k,n) *= rcinv;
1879 RT re = probxlo + i*dx;
1880 RT reinv = (re==
RT(0.0)) ?
RT(0.0) :
RT(1.)/re;
1881 rhsarr(i,j,k,n) *= reinv;
1889template <
typename MF>
1896 const int ncomp = this->getNComp();
1900 const auto *factory =
dynamic_cast<EBFArrayBoxFactory const*
>(this->Factory(amrlev,mglev));
1901 if (factory && !factory->isAllRegular())
1903 if constexpr (std::is_same<MF,MultiFab>()) {
1904 const MultiFab& vfrac = factory->getVolFrac();
1905 for (
int c = 0; c < ncomp; ++c) {
1907 * m_volinv[amrlev][mglev];
1910 amrex::Abort(
"TODO: MLMG with EB only works with MultiFab");
1916 for (
int c = 0; c < ncomp; ++c) {
1917 offset[c] = rhs.sum(c,
IntVect(0),
true) * m_volinv[amrlev][mglev];
1926template <
typename MF>
1931 const int ncomp = this->getNComp();
1932 for (
int c = 0; c < ncomp; ++c) {
1933 rhs.plus(-
offset[c], c, 1);
1936 if (!rhs.isAllRegular()) {
1937 if constexpr (std::is_same<MF,MultiFab>()) {
1940 amrex::Abort(
"amrex::EB_set_covered only works with MultiFab");
1946template <
typename MF>
1950 BL_PROFILE(
"MLCellLinOp::prepareForSolve()");
1952 const int imaxorder = this->maxorder;
1953 const int ncomp = this->getNComp();
1954 const int hidden_direction = this->hiddenDirection();
1955 for (
int amrlev = 0; amrlev < this->m_num_amr_levels; ++amrlev)
1957 for (
int mglev = 0; mglev < this->m_num_mg_levels[amrlev]; ++mglev)
1959 const auto& bcondloc = *m_bcondloc[amrlev][mglev];
1960 const auto& maskvals = m_maskvals[amrlev][mglev];
1962 const RT dxi =
static_cast<RT>(this->m_geom[amrlev][mglev].InvCellSize(0));
1963 const RT dyi =
static_cast<RT>((AMREX_SPACEDIM >= 2) ? this->m_geom[amrlev][mglev].InvCellSize(1) :
Real(1.0));
1964 const RT dzi =
static_cast<RT>((AMREX_SPACEDIM == 3) ? this->m_geom[amrlev][mglev].InvCellSize(2) :
Real(1.0));
1966 auto& undrrelxr = this->m_undrrelxr[amrlev][mglev];
1967 MF foo(this->m_grids[amrlev][mglev], this->m_dmap[amrlev][mglev], ncomp, 0,
MFInfo().SetAlloc(
false));
1970 const auto *factory =
dynamic_cast<EBFArrayBoxFactory const*
>(this->m_factory[amrlev][mglev].get());
1972 (factory) ? &(factory->getMultiEBCellFlagFab()) :
nullptr;
1973 auto area = (factory) ? factory->getAreaFrac()
1981 if (factory && !factory->isAllRegular()) {
1982#if defined(AMREX_USE_CUDA) && defined(_WIN32)
1983 if (!std::is_same<MF,MultiFab>()) {
1985 if constexpr (!std::is_same<MF,MultiFab>()) {
1987 amrex::Abort(
"MLCellLinOp with EB only works with MultiFab");
1990 tags.reserve(foo.local_size()*AMREX_SPACEDIM*ncomp);
1994 const Box& vbx = mfi.validbox();
1996 const auto & bdlv = bcondloc.bndryLocs(mfi);
1997 const auto & bdcv = bcondloc.bndryConds(mfi);
2001 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim)
2008 for (
int icomp = 0; icomp < ncomp; ++icomp) {
2009 tags.emplace_back(MLMGPSEBTag<RT>{undrrelxr[olo].array(mfi),
2010 undrrelxr[ohi].array(mfi),
2012 maskvals[olo].const_array(mfi),
2013 maskvals[ohi].const_array(mfi),
2014 bdlv[icomp][olo], bdlv[icomp][ohi],
2016 bdcv[icomp][olo], bdcv[icomp][ohi],
2017 vbx.
length(idim), icomp, idim});
2024 [=]
AMREX_GPU_DEVICE (
int i,
int j,
int k, MLMGPSEBTag<RT>
const& tag)
noexcept
2029 mllinop_comp_interp_coef0_x_eb
2030 (0, i , j, k, tag.blen, tag.flo, tag.mlo, tag.ap,
2031 tag.bctlo, tag.bcllo, imaxorder, dxi, tag.comp);
2032 mllinop_comp_interp_coef0_x_eb
2033 (1, i+tag.blen+1, j, k, tag.blen, tag.fhi, tag.mhi, tag.ap,
2034 tag.bcthi, tag.bclhi, imaxorder, dxi, tag.comp);
2036#if (AMREX_SPACEDIM > 1)
2038#
if (AMREX_SPACEDIM > 2)
2042 mllinop_comp_interp_coef0_y_eb
2043 (0, i, j , k, tag.blen, tag.flo, tag.mlo, tag.ap,
2044 tag.bctlo, tag.bcllo, imaxorder, dyi, tag.comp);
2045 mllinop_comp_interp_coef0_y_eb
2046 (1, i, j+tag.blen+1, k, tag.blen, tag.fhi, tag.mhi, tag.ap,
2047 tag.bcthi, tag.bclhi, imaxorder, dyi, tag.comp);
2049#if (AMREX_SPACEDIM > 2)
2051 mllinop_comp_interp_coef0_z_eb
2052 (0, i, j, k , tag.blen, tag.flo, tag.mlo, tag.ap,
2053 tag.bctlo, tag.bcllo, imaxorder, dzi, tag.comp);
2054 mllinop_comp_interp_coef0_z_eb
2055 (1, i, j, k+tag.blen+1, tag.blen, tag.fhi, tag.mhi, tag.ap,
2056 tag.bcthi, tag.bclhi, imaxorder, dzi, tag.comp);
2063 mllinop_comp_interp_coef0_x
2064 (0, i , j, k, tag.blen, tag.flo, tag.mlo,
2065 tag.bctlo, tag.bcllo, imaxorder, dxi, tag.comp);
2066 mllinop_comp_interp_coef0_x
2067 (1, i+tag.blen+1, j, k, tag.blen, tag.fhi, tag.mhi,
2068 tag.bcthi, tag.bclhi, imaxorder, dxi, tag.comp);
2070#if (AMREX_SPACEDIM > 1)
2072#if (AMREX_SPACEDIM > 2)
2076 mllinop_comp_interp_coef0_y
2077 (0, i, j , k, tag.blen, tag.flo, tag.mlo,
2078 tag.bctlo, tag.bcllo, imaxorder, dyi, tag.comp);
2079 mllinop_comp_interp_coef0_y
2080 (1, i, j+tag.blen+1, k, tag.blen, tag.fhi, tag.mhi,
2081 tag.bcthi, tag.bclhi, imaxorder, dyi, tag.comp);
2083#if (AMREX_SPACEDIM > 2)
2085 mllinop_comp_interp_coef0_z
2086 (0, i, j, k , tag.blen, tag.flo, tag.mlo,
2087 tag.bctlo, tag.bcllo, imaxorder, dzi, tag.comp);
2088 mllinop_comp_interp_coef0_z
2089 (1, i, j, k+tag.blen+1, tag.blen, tag.fhi, tag.mhi,
2090 tag.bcthi, tag.bclhi, imaxorder, dzi, tag.comp);
2101 tags.reserve(foo.local_size()*AMREX_SPACEDIM*ncomp);
2105 const Box& vbx = mfi.validbox();
2107 const auto & bdlv = bcondloc.bndryLocs(mfi);
2108 const auto & bdcv = bcondloc.bndryConds(mfi);
2110 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim)
2112 if (idim != hidden_direction) {
2115 for (
int icomp = 0; icomp < ncomp; ++icomp) {
2116 tags.emplace_back(MLMGPSTag<RT>{undrrelxr[olo].array(mfi),
2117 undrrelxr[ohi].array(mfi),
2118 maskvals[olo].const_array(mfi),
2119 maskvals[ohi].const_array(mfi),
2120 bdlv[icomp][olo], bdlv[icomp][ohi],
2122 bdcv[icomp][olo], bdcv[icomp][ohi],
2123 vbx.
length(idim), icomp, idim});
2130 [=]
AMREX_GPU_DEVICE (
int i,
int j,
int k, MLMGPSTag<RT>
const& tag)
noexcept
2134 mllinop_comp_interp_coef0_x
2135 (0, i , j, k, tag.blen, tag.flo, tag.mlo,
2136 tag.bctlo, tag.bcllo, imaxorder, dxi, tag.comp);
2137 mllinop_comp_interp_coef0_x
2138 (1, i+tag.blen+1, j, k, tag.blen, tag.fhi, tag.mhi,
2139 tag.bcthi, tag.bclhi, imaxorder, dxi, tag.comp);
2141#if (AMREX_SPACEDIM > 1)
2143#
if (AMREX_SPACEDIM > 2)
2147 mllinop_comp_interp_coef0_y
2148 (0, i, j , k, tag.blen, tag.flo, tag.mlo,
2149 tag.bctlo, tag.bcllo, imaxorder, dyi, tag.comp);
2150 mllinop_comp_interp_coef0_y
2151 (1, i, j+tag.blen+1, k, tag.blen, tag.fhi, tag.mhi,
2152 tag.bcthi, tag.bclhi, imaxorder, dyi, tag.comp);
2154#if (AMREX_SPACEDIM > 2)
2156 mllinop_comp_interp_coef0_z
2157 (0, i, j, k , tag.blen, tag.flo, tag.mlo,
2158 tag.bctlo, tag.bcllo, imaxorder, dzi, tag.comp);
2159 mllinop_comp_interp_coef0_z
2160 (1, i, j, k+tag.blen+1, tag.blen, tag.fhi, tag.mhi,
2161 tag.bcthi, tag.bclhi, imaxorder, dzi, tag.comp);
2175 const Box& vbx = mfi.validbox();
2177 const auto & bdlv = bcondloc.bndryLocs(mfi);
2178 const auto & bdcv = bcondloc.bndryConds(mfi);
2183 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim)
2185 if (idim == hidden_direction) {
continue; }
2190 const int blen = vbx.
length(idim);
2191 const auto& mlo = maskvals[olo].array(mfi);
2192 const auto& mhi = maskvals[ohi].array(mfi);
2193 const auto& flo = undrrelxr[olo].array(mfi);
2194 const auto& fhi = undrrelxr[ohi].array(mfi);
2195 for (
int icomp = 0; icomp < ncomp; ++icomp) {
2196 const BoundCond bctlo = bdcv[icomp][olo];
2197 const BoundCond bcthi = bdcv[icomp][ohi];
2198 const auto bcllo = bdlv[icomp][olo];
2199 const auto bclhi = bdlv[icomp][ohi];
2202 if constexpr (!std::is_same<MF,MultiFab>()) {
2203 amrex::Abort(
"MLCellLinOp with EB only works with MultiFab");
2205 auto const& ap = area[idim]->const_array(mfi);
2207 mllinop_comp_interp_coef0_x_eb
2208 (0, blo, blen, flo, mlo, ap, bctlo, bcllo,
2209 imaxorder, dxi, icomp);
2210 mllinop_comp_interp_coef0_x_eb
2211 (1, bhi, blen, fhi, mhi, ap, bcthi, bclhi,
2212 imaxorder, dxi, icomp);
2213 }
else if (idim == 1) {
2214 mllinop_comp_interp_coef0_y_eb
2215 (0, blo, blen, flo, mlo, ap, bctlo, bcllo,
2216 imaxorder, dyi, icomp);
2217 mllinop_comp_interp_coef0_y_eb
2218 (1, bhi, blen, fhi, mhi, ap, bcthi, bclhi,
2219 imaxorder, dyi, icomp);
2221 mllinop_comp_interp_coef0_z_eb
2222 (0, blo, blen, flo, mlo, ap, bctlo, bcllo,
2223 imaxorder, dzi, icomp);
2224 mllinop_comp_interp_coef0_z_eb
2225 (1, bhi, blen, fhi, mhi, ap, bcthi, bclhi,
2226 imaxorder, dzi, icomp);
2233 mllinop_comp_interp_coef0_x
2234 (0, blo, blen, flo, mlo, bctlo, bcllo,
2235 imaxorder, dxi, icomp);
2236 mllinop_comp_interp_coef0_x
2237 (1, bhi, blen, fhi, mhi, bcthi, bclhi,
2238 imaxorder, dxi, icomp);
2239 }
else if (idim == 1) {
2240 mllinop_comp_interp_coef0_y
2241 (0, blo, blen, flo, mlo, bctlo, bcllo,
2242 imaxorder, dyi, icomp);
2243 mllinop_comp_interp_coef0_y
2244 (1, bhi, blen, fhi, mhi, bcthi, bclhi,
2245 imaxorder, dyi, icomp);
2247 mllinop_comp_interp_coef0_z
2248 (0, blo, blen, flo, mlo, bctlo, bcllo,
2249 imaxorder, dzi, icomp);
2250 mllinop_comp_interp_coef0_z
2251 (1, bhi, blen, fhi, mhi, bcthi, bclhi,
2252 imaxorder, dzi, icomp);
2263template <
typename MF>
2268 const int ncomp = this->getNComp();
2277template <
typename MF>
2281 const int ncomp = this->getNComp();
2284 for (
int ilev = 0; ilev < this->NAMRLevels()-1; ++ilev) {
2285 result +=
amrex::Dot(*m_norm_fine_mask[ilev], *
x[ilev], 0, *
y[ilev], 0, ncomp, nghost,
true);
2288 *
y[this->NAMRLevels()-1], 0, ncomp, nghost,
true);
2293template <
typename MF>
2297 const int ncomp = this->getNComp();
2300 for (
int ilev = 0; ilev < this->NAMRLevels()-1; ++ilev) {
2301 result +=
amrex::Dot(*m_norm_fine_mask[ilev], *
x[ilev], 0, ncomp, nghost,
true);
2303 result +=
amrex::Dot(*
x[this->NAMRLevels()-1], 0, ncomp, nghost,
true);
2305 return std::sqrt(result);
2308template <
typename MF>
2312 if (!m_volinv.empty()) {
return; }
2314 m_volinv.resize(this->m_num_amr_levels);
2315 for (
int amrlev = 0; amrlev < this->m_num_amr_levels; ++amrlev) {
2316 m_volinv[amrlev].resize(this->NMGLevels(amrlev));
2321 auto f = [&] (
int amrlev,
int mglev) {
2323 const auto *factory =
dynamic_cast<EBFArrayBoxFactory const*
>(this->Factory(amrlev,mglev));
2324 if (factory && !factory->isAllRegular())
2326 if constexpr (std::is_same<MF,MultiFab>()) {
2327 const auto& vfrac = factory->getVolFrac();
2328 m_volinv[amrlev][mglev] = vfrac.sum(0,
true);
2330 amrex::Abort(
"MLCellLinOp with EB only works with MultiFab");
2337 ? this->compactify(this->Geom(amrlev,mglev).Domain()).d_numPts()
2338 : this->m_grids[amrlev][mglev].d_numPts();
2340 m_volinv[amrlev][mglev] = RT(1.0 / npts);
2347 int mgbottom = this->NMGLevels(0)-1;
2352 const auto *factory =
dynamic_cast<EBFArrayBoxFactory const*
>(this->Factory(0,0));
2353 if (factory && !factory->isAllRegular())
2355 ParallelAllReduce::Sum<RT>({m_volinv[0][0], m_volinv[0][mgbottom]},
2357 temp1 = RT(1.0)/m_volinv[0][0];
2358 temp2 = RT(1.0)/m_volinv[0][mgbottom];
2362 temp1 = m_volinv[0][0];
2363 temp2 = m_volinv[0][mgbottom];
2365 m_volinv[0][0] = temp1;
2366 m_volinv[0][mgbottom] = temp2;
2370template <
typename MF>
2374 const int ncomp = this->getNComp();
2375 const int finest_level = this->NAMRLevels() - 1;
2378 const auto *factory =
dynamic_cast<EBFArrayBoxFactory const*
>(this->Factory(amrlev));
2379 if (factory && !factory->isAllRegular()) {
2380#if defined(AMREX_USE_CUDA) && defined(_WIN32)
2381 if (!std::is_same<MF,MultiFab>()) {
2383 if constexpr (!std::is_same<MF,MultiFab>()) {
2385 amrex::Abort(
"MLCellLinOpT with EB only works with MultiFab");
2387 const MultiFab& vfrac = factory->getVolFrac();
2388 if (amrlev == finest_level) {
2398 return std::abs(ma[box_no](i,j,k,n)
2399 *vfrac_ma[box_no](i,j,k));
2405#pragma omp parallel reduction(max:norm)
2408 Box const& bx = mfi.tilebox();
2409 auto const& fab = mf.const_array(mfi);
2413 norm = std::max(
norm, std::abs(fab(i,j,k,n)*v(i,j,k)));
2420 auto const& ma = mf.const_arrays();
2421 auto const& mask_ma = m_norm_fine_mask[amrlev]->const_arrays();
2428 if (mask_ma[box_no](i,j,k)) {
2429 return std::abs(ma[box_no](i,j,k,n)
2430 *vfrac_ma[box_no](i,j,k));
2439#pragma omp parallel reduction(max:norm)
2442 Box const& bx = mfi.tilebox();
2443 auto const& fab = mf.const_array(mfi);
2444 auto const&
mask = m_norm_fine_mask[amrlev]->const_array(mfi);
2449 norm = std::max(
norm, std::abs(fab(i,j,k,n)*v(i,j,k)));
2459 if (amrlev == finest_level) {
2462 norm = mf.norminf(*m_norm_fine_mask[amrlev], 0, ncomp,
IntVect(0),
true);
2470template <
typename MF>
2474 int ncomp = this->getNComp();
2475 for (
int falev = this->NAMRLevels()-1; falev > 0; --falev)
2478 if (!sol[falev].isAllRegular()) {
2479 if constexpr (std::is_same<MF,MultiFab>()) {
2482 amrex::Abort(
"EB_average_down only works with MultiFab");
2492template <
typename MF>
2497 if (!fres.isAllRegular()) {
2498 if constexpr (std::is_same<MF,MultiFab>()) {
2500 this->AMRRefRatioVect(clev));
2502 amrex::Abort(
"EB_average_down only works with MultiFab");
2508 this->AMRRefRatioVect(clev));
2512template <
typename MF>
2516 this->m_precond_mode =
true;
2518 if (m_bndry_sol_zero.empty()) {
2519 m_bndry_sol_zero.resize(m_bndry_sol.size());
2520 const int ncomp = this->getNComp();
2521 for (
int amrlev = 0; amrlev < this->m_num_amr_levels; ++amrlev) {
2522 m_bndry_sol_zero[amrlev] = std::make_unique<MLMGBndryT<MF>>
2523 (this->m_grids[amrlev][0],
2524 this->m_dmap[amrlev][0],
2526 this->m_geom[amrlev][0]);
2528 std::swap(m_bndry_sol, m_bndry_sol_zero);
2529 MF
const* coarse_data_for_bc_save = this->m_coarse_data_for_bc;
2530 this->m_coarse_data_for_bc =
nullptr;
2531 for (
int amrlev = 0; amrlev < this->m_num_amr_levels; ++amrlev) {
2532 this->setLevelBC(amrlev,
nullptr);
2534 this->m_coarse_data_for_bc = coarse_data_for_bc_save;
2536 std::swap(m_bndry_sol, m_bndry_sol_zero);
2540template <
typename MF>
2544 this->m_precond_mode =
false;
2545 std::swap(m_bndry_sol, m_bndry_sol_zero);
#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:551
#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:124
#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
Array4< int const > offset
Definition AMReX_HypreMLABecLap.cpp:1129
Box cbx
Definition AMReX_HypreMLABecLap.cpp:1131
Array4< Real > fine
Definition AMReX_InterpFaceRegister.cpp:90
Array4< int const > mask
Definition AMReX_InterpFaceRegister.cpp:93
Array4< Real const > crse
Definition AMReX_InterpFaceRegister.cpp:92
#define AMREX_LOOP_4D(bx, ncomp, i, j, k, n, block)
Definition AMReX_Loop.nolint.H:16
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:676
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:672
Long size() const noexcept
Return the number of boxes in the BoxArray.
Definition AMReX_BoxArray.H:753
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
This static member function returns a constant reference to an object of type BoxND representing the ...
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:51
Definition AMReX_EBFabFactory.H:32
An Array of FortranArrayBox(FAB)-like Objects.
Definition AMReX_FabArray.H:344
MultiArray4< typename FabArray< FAB >::value_type const > const_arrays() const noexcept
Definition AMReX_FabArray.H:647
Array4< typename FabArray< FAB >::value_type const > const_array(const MFIter &mfi) const noexcept
Definition AMReX_FabArray.H:585
Definition AMReX_FabFactory.H:50
Rectangular problem domain geometry.
Definition AMReX_Geometry.H:75
Periodicity periodicity() const noexcept
Definition AMReX_Geometry.H:361
const Real * ProbLo() const noexcept
Returns the lo end of the problem domain in each dimension.
Definition AMReX_Geometry.H:184
GPU-compatible tuple.
Definition AMReX_Tuple.H:98
__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:517
__host__ __device__ IntVectND & setVal(int i, int val) noexcept
Set i'th coordinate of IntVectND to val.
Definition AMReX_IntVect.H:373
__host__ static __device__ constexpr IntVectND< dim > TheCellVector() noexcept
This static member function returns a reference to a constant IntVectND object, all of whose dim argu...
Definition AMReX_IntVect.H:810
__host__ __device__ constexpr int max() const noexcept
maximum (no absolute values) value
Definition AMReX_IntVect.H:313
An InterpBndryData object adds to a BndryData object the ability to manipulate and set the data store...
Definition AMReX_InterpBndryData.H:45
static constexpr int IBD_max_order_DEF
Definition AMReX_InterpBndryData.H:126
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:172
Definition AMReX_MLCellLinOp.H:31
virtual void Fsmooth(int amrlev, int mglev, MF &sol, const MF &rhs, int redblack) const =0
Vector< RT > getSolvabilityOffset(int amrlev, int mglev, MF const &rhs) const override
Compute the average offset needed to enforce solvability constraints.
Definition AMReX_MLCellLinOp.H:1891
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:1522
void averageDownAndSync(Vector< MF > &sol) const override
Average the solution hierarchy down (fine-to-coarse) and sync.
Definition AMReX_MLCellLinOp.H:2472
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:1200
Vector< YAFluxRegisterT< MF > > m_fluxreg
Definition AMReX_MLCellLinOp.H:496
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:980
void updateSolBC(int amrlev, const MF &crse_bcdata) const
Refresh stored solution BC data from coarse inputs.
Definition AMReX_MLCellLinOp.H:949
Vector< std::unique_ptr< MLMGBndryT< MF > > > m_bndry_sol
Definition AMReX_MLCellLinOp.H:436
MLCellLinOpT< MF > & operator=(const MLCellLinOpT< MF > &)=delete
void compGrad(int amrlev, const Array< MF *, 3 > &grad, MF &sol, Location loc) const override
Compute directional gradients of the solution.
Definition AMReX_MLCellLinOp.H:1723
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:2494
void reflux(int crse_amrlev, MF &res, const MF &crse_sol, const MF &, MF &, MF &fine_sol, const MF &) const final
Reflux fine-level fluxes into the coarse residual.
Definition AMReX_MLCellLinOp.H:1613
RT dotProductPrecond(Vector< MF const * > const &x, Vector< MF const * > const &y) const final
Dot product over the composite AMR hierarchy, excluding cells covered by finer levels (used when the ...
Definition AMReX_MLCellLinOp.H:2279
virtual void Fapply(int amrlev, int mglev, MF &out, const MF &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:2542
void update() override
Update for reuse.
Definition AMReX_MLCellLinOp.H:942
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:1587
MLCellLinOpT(const MLCellLinOpT< MF > &)=delete
typename MLLinOpT< MF >::BCMode BCMode
Definition AMReX_MLCellLinOp.H:38
void smooth(int amrlev, int mglev, MF &sol, const MF &rhs, bool skip_fillboundary, int niter) const final
Perform niter smoothing iterations on the supplied residual equation.
Definition AMReX_MLCellLinOp.H:1543
RT normInf(int amrlev, MF const &mf, bool local) const override
Infinity norm helper used by solvers and diagnostics.
Definition AMReX_MLCellLinOp.H:2372
virtual bool isCrossStencil() const
Whether the stencil is the cross shape.
Definition AMReX_MLCellLinOp.H:107
void updateCorBC(int amrlev, const MF &crse_bcdata) const
Refresh stored correction BC data from coarse inputs.
Definition AMReX_MLCellLinOp.H:965
Array< RT, 2 *3 > RealTuple
Definition AMReX_MLCellLinOp.H:447
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:1259
RT xdoty(int amrlev, int mglev, const MF &x, const MF &y, bool local) const final
Dot product helper.
Definition AMReX_MLCellLinOp.H:2265
Array< BoundCond, 2 *3 > BCTuple
Definition AMReX_MLCellLinOp.H:448
void prepareForSolve() override
Prepare multilevel metadata before MLMG iterates (coefficients, BC caches, etc.).
Definition AMReX_MLCellLinOp.H:1948
void unapplyMetricTerm(int amrlev, int mglev, MF &rhs) const final
Remove metric scaling previously applied to the RHS.
Definition AMReX_MLCellLinOp.H:1833
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:1533
void applyMetricTerm(int amrlev, int mglev, MF &rhs) const final
Multiply the RHS by metric terms appropriate for curvilinear coordinates.
Definition AMReX_MLCellLinOp.H:1777
Vector< std::unique_ptr< BndryRegisterT< MF > > > m_crse_cor_br
Definition AMReX_MLCellLinOp.H:440
RT norm2Precond(Vector< MF const * > const &x) const final
L2 norm over the composite AMR hierarchy, excluding cells covered by finer levels (used when the oper...
Definition AMReX_MLCellLinOp.H:2295
void beginPrecondBC() override
Called when the operator starts being used as a preconditioner.
Definition AMReX_MLCellLinOp.H:2514
Vector< Vector< std::unique_ptr< BndryCondLoc > > > m_bcondloc
Definition AMReX_MLCellLinOp.H:486
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:1250
void setGaussSeidel(bool flag) noexcept
Toggle Gauss–Seidel smoothing in place of Jacobi relaxation.
Definition AMReX_MLCellLinOp.H:104
Vector< std::unique_ptr< MF > > m_robin_bcval
Definition AMReX_MLCellLinOp.H:423
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:648
~MLCellLinOpT() override=default
virtual bool isTensorOp() const
Whether this operator is a tensor solve.
Definition AMReX_MLCellLinOp.H:109
void setInterpBndryHalfWidth(int w)
Control how many cells the interpolation boundary stencil spans.
Definition AMReX_MLCellLinOp.H:430
Vector< Vector< BndryRegisterT< MF > > > m_undrrelxr
Definition AMReX_MLCellLinOp.H:489
MLCellLinOpT()
Definition AMReX_MLCellLinOp.H:641
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:1308
void fixSolvabilityByOffset(int amrlev, int mglev, MF &rhs, Vector< RT > const &offset) const override
Apply solvability offsets to the RHS (subtracting the average).
Definition AMReX_MLCellLinOp.H:1928
Vector< std::unique_ptr< MLMGBndryT< MF > > > m_bndry_cor
Definition AMReX_MLCellLinOp.H:439
void compFlux(int amrlev, const Array< MF *, 3 > &fluxes, MF &sol, Location loc) const override
Compute face-centered fluxes from the supplied solution.
Definition AMReX_MLCellLinOp.H:1682
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:1578
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:1560
bool m_has_metric_term
Definition AMReX_MLCellLinOp.H:434
bool m_use_gauss_seidel
Definition AMReX_MLCellLinOp.H:498
Vector< std::unique_ptr< MLMGBndryT< MF > > > m_bndry_sol_zero
Definition AMReX_MLCellLinOp.H:442
Vector< std::unique_ptr< BndryRegisterT< MF > > > m_crse_sol_br
Definition AMReX_MLCellLinOp.H:437
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:1401
virtual void addInhomogNeumannFlux(int, const Array< MF *, 3 > &, MF const &, bool) const
Optional hook for adding inhomogeneous Neumann contributions.
Definition AMReX_MLCellLinOp.H:381
Vector< std::unique_ptr< iMultiFab > > m_norm_fine_mask
Definition AMReX_MLCellLinOp.H:494
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:809
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:492
virtual void FFlux(int amrlev, const MFIter &mfi, const Array< FAB *, 3 > &flux, const FAB &sol, Location loc, int face_only=0) const =0
Abstract base class for multilevel linear operators used by MLMG and the bottom solvers.
Definition AMReX_MLLinOp.H:137
virtual bool needsUpdate() const
Does it need update if it's reused?
Definition AMReX_MLLinOp.H:332
virtual void update()
Update for reuse.
Definition AMReX_MLLinOp.H:334
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:1056
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
Dynamically allocated vector for trivially copyable data.
Definition AMReX_PODVector.H:308
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:79
__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:1848
__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:1817
__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:1582
__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:1469
__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:1880
__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:1548
__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:1326
std::array< T, N > Array
Definition AMReX_Array.H:31
Arena * The_Async_Arena()
Definition AMReX_Arena.cpp:830
void Sum(Gpu::DeviceVector< T > &v, MPI_Comm comm)
Definition AMReX_GpuParallelReduce.H:34
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:310
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:259
__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:359
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:652
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:1609
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:252
LinOpBCType
Definition AMReX_LO_BCTYPES.H:27
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
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:38
RealVectND< 3 > RealVect
Definition AMReX_ParmParse.H:37
bool TilingIfNotGPU() noexcept
Definition AMReX_MFIter.H:12
void Abort(const std::string &msg)
Print a fatal-error message to stderr and abort execution.
Definition AMReX.cpp:241
__host__ __device__ constexpr int get(IntVectND< dim > const &iv) noexcept
Get I'th element of IntVectND<dim>
Definition AMReX_IntVect.H:1334
A multidimensional array accessor.
Definition AMReX_Array4.H:288
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
Definition AMReX_FabDataType.H:10
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:51
StateMode
Definition AMReX_MLLinOp.H:118
BCMode
Definition AMReX_MLLinOp.H:117
Location
Definition AMReX_MLLinOp.H:119
FabArray memory allocation information.
Definition AMReX_FabArray.H:68
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:156
Struct for holding types.
Definition AMReX_TypeList.H:13