Block-Structured AMR Software Framework
AMReX_MLNodeTensorLaplacian.H
Go to the documentation of this file.
1 #ifndef AMREX_MLNODETENSORLAPLACIAN_H_
2 #define AMREX_MLNODETENSORLAPLACIAN_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_MLNodeLinOp.H>
6 
7 namespace amrex {
8 
9 // del dot (sigma grad phi) = rhs
10 // where phi and rhs are nodal multifab, and sigma is a tensor constant.
11 // It is assumed that tensor is symmetric tensor of rank AMREX_SPACEDIM.
12 // Only periodic and Dirichlet are supported.
13 
15  : public MLNodeLinOp
16 {
17 public:
18 
19 #if (AMREX_SPACEDIM == 2)
20  static constexpr int nelems = 3; // number of unique elements in sigma
21 #else
22  static constexpr int nelems = 6;
23 #endif
24 
25  MLNodeTensorLaplacian () = default;
27  const Vector<BoxArray>& a_grids,
28  const Vector<DistributionMapping>& a_dmap,
29  const LPInfo& a_info = LPInfo());
30  ~MLNodeTensorLaplacian () override = default;
31 
36 
37  // The user can set the tensor by calling either setSigma or setBeta.
38  // For 2d, a_sigma contains components xx, xy, and yy.
39  // For 3d, a_sigma contains components xx, xy, xz, yy, yz, and zz.
40  void setSigma (Array<Real,nelems> const& a_sigma) noexcept;
41  // sigma = I - beta beta^T.
42  void setBeta (Array<Real,AMREX_SPACEDIM> const& a_beta) noexcept;
43 
44  void define (const Vector<Geometry>& a_geom,
45  const Vector<BoxArray>& a_grids,
46  const Vector<DistributionMapping>& a_dmap,
47  const LPInfo& a_info = LPInfo());
48 
49  [[nodiscard]] std::string name () const override { return std::string("MLNodeTensorLaplacian"); }
50 
51  void restriction (int amrlev, int cmglev, MultiFab& crse, MultiFab& fine) const final;
52  void interpolation (int amrlev, int fmglev, MultiFab& fine, const MultiFab& crse) const final;
53  void averageDownSolutionRHS (int camrlev, MultiFab& crse_sol, MultiFab& crse_rhs,
54  const MultiFab& fine_sol, const MultiFab& fine_rhs) final;
55 
56  void reflux (int crse_amrlev,
57  MultiFab& res, const MultiFab& crse_sol, const MultiFab& crse_rhs,
58  MultiFab& fine_res, MultiFab& fine_sol, const MultiFab& fine_rhs) const final;
59 
60  void smooth (int amrlev, int mglev, MultiFab& sol, const MultiFab& rhs,
61  bool skip_fillboundary=false) const final;
62 
63  void prepareForSolve () final;
64  void Fapply (int amrlev, int mglev, MultiFab& out, const MultiFab& in) const final;
65  void Fsmooth (int amrlev, int mglev, MultiFab& sol, const MultiFab& rhs) const final;
66  void normalize (int amrlev, int mglev, MultiFab& mf) const final;
67 
68  void fixUpResidualMask (int amrlev, iMultiFab& resmsk) final;
69 
70 #if defined(AMREX_USE_HYPRE) && (AMREX_SPACEDIM > 1)
71  void fillIJMatrix (MFIter const& mfi,
73  Array4<int const> const& lid,
74  HypreNodeLap::Int* ncols,
75  HypreNodeLap::Int* cols,
76  Real* mat) const override;
77 
78  void fillRHS (MFIter const& mfi,
79  Array4<int const> const& lid,
80  Real* rhs,
81  Array4<Real const> const& bfab) const override;
82 #endif
83 
84 private:
85 
86  GpuArray<Real,nelems> scaledSigma (int amrlev, int mglev) const noexcept;
87 
89  mutable int m_redblack = 0;
90 };
91 
92 }
93 
94 #endif
Array4< Real > fine
Definition: AMReX_InterpFaceRegister.cpp:90
Array4< Real const > crse
Definition: AMReX_InterpFaceRegister.cpp:92
HYPRE_Int Int
Definition: AMReX_HypreNodeLap.H:36
Definition: AMReX_MFIter.H:57
Definition: AMReX_MLNodeLinOp.H:16
Definition: AMReX_MLNodeTensorLaplacian.H:16
MLNodeTensorLaplacian(MLNodeTensorLaplacian &&)=delete
static constexpr int nelems
Definition: AMReX_MLNodeTensorLaplacian.H:22
std::string name() const override
Definition: AMReX_MLNodeTensorLaplacian.H:49
GpuArray< Real, nelems > scaledSigma(int amrlev, int mglev) const noexcept
Definition: AMReX_MLNodeTensorLaplacian.cpp:42
MLNodeTensorLaplacian(const MLNodeTensorLaplacian &)=delete
int m_redblack
Definition: AMReX_MLNodeTensorLaplacian.H:89
void define(const Vector< Geometry > &a_geom, const Vector< BoxArray > &a_grids, const Vector< DistributionMapping > &a_dmap, const LPInfo &a_info=LPInfo())
Definition: AMReX_MLNodeTensorLaplacian.cpp:64
MLNodeTensorLaplacian & operator=(const MLNodeTensorLaplacian &)=delete
void normalize(int amrlev, int mglev, MultiFab &mf) const final
Definition: AMReX_MLNodeTensorLaplacian.cpp:269
void Fapply(int amrlev, int mglev, MultiFab &out, const MultiFab &in) const final
Definition: AMReX_MLNodeTensorLaplacian.cpp:204
GpuArray< Real, nelems > m_sigma
Definition: AMReX_MLNodeTensorLaplacian.H:88
void interpolation(int amrlev, int fmglev, MultiFab &fine, const MultiFab &crse) const final
Definition: AMReX_MLNodeTensorLaplacian.cpp:129
void Fsmooth(int amrlev, int mglev, MultiFab &sol, const MultiFab &rhs) const final
Definition: AMReX_MLNodeTensorLaplacian.cpp:243
~MLNodeTensorLaplacian() override=default
void setSigma(Array< Real, nelems > const &a_sigma) noexcept
Definition: AMReX_MLNodeTensorLaplacian.cpp:17
void prepareForSolve() final
Definition: AMReX_MLNodeTensorLaplacian.cpp:194
void averageDownSolutionRHS(int camrlev, MultiFab &crse_sol, MultiFab &crse_rhs, const MultiFab &fine_sol, const MultiFab &fine_rhs) final
Definition: AMReX_MLNodeTensorLaplacian.cpp:173
void reflux(int crse_amrlev, MultiFab &res, const MultiFab &crse_sol, const MultiFab &crse_rhs, MultiFab &fine_res, MultiFab &fine_sol, const MultiFab &fine_rhs) const final
Definition: AMReX_MLNodeTensorLaplacian.cpp:186
void restriction(int amrlev, int cmglev, MultiFab &crse, MultiFab &fine) const final
Definition: AMReX_MLNodeTensorLaplacian.cpp:82
void fixUpResidualMask(int amrlev, iMultiFab &resmsk) final
Definition: AMReX_MLNodeTensorLaplacian.cpp:275
void setBeta(Array< Real, AMREX_SPACEDIM > const &a_beta) noexcept
Definition: AMReX_MLNodeTensorLaplacian.cpp:23
void smooth(int amrlev, int mglev, MultiFab &sol, const MultiFab &rhs, bool skip_fillboundary=false) const final
Definition: AMReX_MLNodeTensorLaplacian.cpp:227
A collection (stored as an array) of FArrayBox objects.
Definition: AMReX_MultiFab.H:38
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition: AMReX_Vector.H:27
Definition: AMReX_iMultiFab.H:32
Definition: AMReX_Amr.cpp:49
std::array< T, N > Array
Definition: AMReX_Array.H:24
Definition: AMReX_Array4.H:61
Definition: AMReX_MLLinOp.H:35