1#ifndef AMREX_ML_CURL_CURL_H_
2#define AMREX_ML_CURL_CURL_H_
3#include <AMReX_Config.H>
6#include <AMReX_MLCurlCurl_K.H>
34 :
public MLLinOpT<Array<MultiFab,3> >
98 [[nodiscard]] std::string
name ()
const override {
99 return std::string(
"curl of curl");
108 bool setUsePCG (
bool flag) {
return std::exchange(m_use_pcg, flag); }
120 const MF* robinbc_a =
nullptr,
121 const MF* robinbc_b =
nullptr,
122 const MF* robinbc_f =
nullptr)
override;
169 void smooth (
int amrlev,
int mglev,
MF& sol,
const MF& rhs,
170 bool skip_fillboundary,
int niter)
const override;
182 const MF* crse_bcdata=
nullptr)
override;
197 const MF* crse_bcdata=
nullptr)
override;
210 [[nodiscard]]
bool isSingular (
int )
const override {
return false; }
222 RT xdoty (
int amrlev,
int mglev,
const MF&
x,
const MF&
y,
bool local)
const override;
231 [[nodiscard]]
RT normInf (
int amrlev,
MF const& mf,
bool local)
const override;
244 [[nodiscard]]
MF make (
int amrlev,
int mglev,
IntVect const& ng)
const override;
245 [[nodiscard]]
MF make (
int amrlev,
int mglev,
IntVect const& ng,
246 MFInfo const& mf_info)
const override;
255 MFInfo const& mf_info)
const override;
261 MFInfo const& mf_info)
const override;
265#if (AMREX_SPACEDIM > 1)
275 void smooth4 (
int amrlev,
int mglev,
MF& sol,
MF const& rhs,
int color)
const;
286 void smooth1D (
int amrlev,
int mglev,
MF& sol,
MF const& rhs,
int color)
const;
297 void compresid (
int amrlev,
int mglev,
MF& resid,
MF const& b)
const;
311 void applyBC (
int amrlev,
int mglev,
MF& in, CurlCurlStateType type)
const;
313 [[nodiscard]]
iMultiFab const& getDotMask (
int amrlev,
int mglev,
int idim)
const;
315 [[nodiscard]] CurlCurlDirichletInfo getDirichletInfo (
int amrlev,
int mglev)
const;
316 [[nodiscard]] CurlCurlSymmetryInfo getSymmetryInfo (
int amrlev,
int mglev)
const;
318 void update_lusolver ();
320 void set_curvilinear_domain_bc ();
321 void clearAlphaMultiFab ();
322 void clearBetaMultiFab ();
326 RT m_alpha = std::numeric_limits<RT>::lowest();
327 RT m_beta = std::numeric_limits<RT>::lowest();
330#if (AMREX_SPACEDIM == 3)
332#elif (AMREX_SPACEDIM == 2)
338 mutable Vector<Vector<Array<std::unique_ptr<iMultiFab>,3>>> m_dotmask;
339 static constexpr int m_ncomp = 1;
340 Vector<Vector<std::unique_ptr<Gpu::DeviceScalar
341 <LUSolver<AMREX_SPACEDIM*2,RT>>>>> m_lusolver;
342 Vector<Vector<Array<std::unique_ptr<MultiFab>,3>>> m_bcoefs;
343 Vector<Vector<Array<std::unique_ptr<MultiFab>,3>>> m_acoefs;
344 bool m_use_pcg =
false;
345 bool m_needs_update =
true;
Array4< Real > fine
Definition AMReX_InterpFaceRegister.cpp:90
Array4< Real const > crse
Definition AMReX_InterpFaceRegister.cpp:92
curl (alpha curl E) + beta E = rhs
Definition AMReX_MLCurlCurl.H:35
void setLevelBC(int amrlev, const MF *levelbcdata, const MF *robinbc_a=nullptr, const MF *robinbc_b=nullptr, const MF *robinbc_f=nullptr) override
Provide level-specific BC data (compatible with MLLinOp interface).
Definition AMReX_MLCurlCurl.cpp:297
void setAlpha(const Vector< MultiFab const * > &a_acoeffs)
Definition AMReX_MLCurlCurl.cpp:134
void preparePrecond() override
Prepare auxiliary data used by the multigrid preconditioner.
Definition AMReX_MLCurlCurl.cpp:918
void restriction(int amrlev, int cmglev, MF &crse, MF &fine) const override
Restrict edge-centered fields from fine to coarse MG level.
Definition AMReX_MLCurlCurl.cpp:304
void setDirichletNodesToZero(int amrlev, int mglev, MF &a_mf) const override
Zero out Dirichlet nodes on (amrlev,mglev) (useful for GMRES).
Definition AMReX_MLCurlCurl.cpp:239
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_MLCurlCurl.cpp:340
bool isSingular(int) const override
Is it singular on AMR level amrlev?
Definition AMReX_MLCurlCurl.H:210
void update() override
Update for reuse.
Definition AMReX_MLCurlCurl.cpp:1310
typename MLLinOpT< MF >::BCType BCType
Definition AMReX_MLCurlCurl.H:39
typename MLLinOpT< MF >::RT RT
Definition AMReX_MLCurlCurl.H:38
void define(const Vector< Geometry > &a_geom, const Vector< BoxArray > &a_grids, const Vector< DistributionMapping > &a_dmap, const LPInfo &a_info=LPInfo(), int a_coord=0)
Bind the operator to the AMR hierarchy.
Definition AMReX_MLCurlCurl.cpp:16
void smooth(int amrlev, int mglev, MF &sol, const MF &rhs, bool skip_fillboundary, int niter) const override
Run the Gauss-Seidel / PCG smoother for niter sweeps.
Definition AMReX_MLCurlCurl.cpp:535
RT normInf(int amrlev, MF const &mf, bool local) const override
Infinity norm helper for vector-valued MultiFabs.
Definition AMReX_MLCurlCurl.cpp:971
void prepareForSolve() override
Finish BC caches, mask updates, and metric setup prior to solves.
Definition AMReX_MLCurlCurl.cpp:912
void averageDownAndSync(Vector< MF > &sol) const override
Average vector fields down the AMR hierarchy and synchronize interfaces using sol.
Definition AMReX_MLCurlCurl.cpp:976
void solutionResidual(int amrlev, MF &resid, MF &x, const MF &b, const MF *crse_bcdata=nullptr) override
Compute residuals using solution BCs.
Definition AMReX_MLCurlCurl.cpp:758
void setScalars(RT a_alpha, RT a_beta) noexcept
Definition AMReX_MLCurlCurl.cpp:56
void make(Vector< Vector< MF > > &mf, IntVect const &ng) const override
Allocate a hierarchy of MF s stored in mf with grow cells ng.
Definition AMReX_MLCurlCurl.cpp:988
void smooth4(int amrlev, int mglev, MF &sol, MF const &rhs, int color) const
One color sweep of the 4-color smoother (2D/3D).
Definition AMReX_MLCurlCurl.cpp:651
IntVect getNGrowVectRestriction() const override
Definition AMReX_MLCurlCurl.H:236
void setBeta(const Vector< Array< MultiFab const *, 3 > > &a_bcoefs)
Definition AMReX_MLCurlCurl.cpp:66
MLCurlCurl()=default
Construct an empty operator; call define() before solving.
std::string name() const override
Definition AMReX_MLCurlCurl.H:98
typename MLLinOpT< MF >::Location Location
Definition AMReX_MLCurlCurl.H:42
void correctionResidual(int amrlev, int mglev, MF &resid, MF &x, const MF &b, BCMode bc_mode, const MF *crse_bcdata=nullptr) override
Compute residuals for correction solves.
Definition AMReX_MLCurlCurl.cpp:767
typename MLLinOpT< MF >::StateMode StateMode
Definition AMReX_MLCurlCurl.H:41
void compresid(int amrlev, int mglev, MF &resid, MF const &b) const
Residual computation helper on (amrlev,mglev).
Definition AMReX_MLCurlCurl.cpp:776
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 curl-curl operator with boundary conditions.
Definition AMReX_MLCurlCurl.cpp:374
MF makeAlias(MF const &mf) const override
Create a shallow alias of mf (no allocation).
Definition AMReX_MLCurlCurl.cpp:1012
RT xdoty(int amrlev, int mglev, const MF &x, const MF &y, bool local) const override
Dot-product helper.
Definition AMReX_MLCurlCurl.cpp:956
bool setUsePCG(bool flag)
Toggle the PCG smoother; returns the previous value.
Definition AMReX_MLCurlCurl.H:108
MF makeCoarseMG(int amrlev, int mglev, IntVect const &ng) const override
Definition AMReX_MLCurlCurl.cpp:1022
bool needsUpdate() const override
Does it need update if it's reused?
Definition AMReX_MLCurlCurl.H:199
typename MLLinOpT< MF >::BCMode BCMode
Definition AMReX_MLCurlCurl.H:40
void prepareRHS(Vector< MF * > const &rhs) const
Definition AMReX_MLCurlCurl.cpp:230
Array< MultiFab, 3 > MF
Definition AMReX_MLCurlCurl.H:37
void applyPhysBC(int amrlev, int mglev, MultiFab &mf, CurlCurlStateType type) const
Apply physical BCs to mf for the chosen state type.
Definition AMReX_MLCurlCurl.cpp:1086
MF makeCoarseAmr(int famrlev, IntVect const &ng) const override
Definition AMReX_MLCurlCurl.cpp:1044
bool isBottomSingular() const override
Is the bottom of the multigrid hierarchy singular?
Definition AMReX_MLCurlCurl.H:211
Abstract base class for multilevel linear operators used by MLMG and the bottom solvers.
Definition AMReX_MLLinOp.H:137
typename FabDataType< MF >::value_type RT
Definition AMReX_MLLinOp.H:148
Boundary helper for MLMG that manages coarse/fine and physical BC metadata.
Definition AMReX_MLMGBndry.H:20
A collection (stored as an array) of FArrayBox objects.
Definition AMReX_MultiFab.H:40
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:29
A Collection of IArrayBoxes.
Definition AMReX_iMultiFab.H:34
std::array< T, N > Array
Definition AMReX_Array.H:31
Definition AMReX_Amr.cpp:50
LinOpBCType
Definition AMReX_LO_BCTYPES.H:27
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:38
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:73