Block-Structured AMR Software Framework
AMReX_MLTensorOp.H
Go to the documentation of this file.
1 #ifndef AMREX_ML_TENSOR_OP_H_
2 #define AMREX_ML_TENSOR_OP_H_
3 #include <AMReX_Config.H>
4 
6 #include <AMReX_Array.H>
7 
8 namespace amrex {
9 
10 // Tensor solver for high Reynolds flows with small gradient in viscosity.
11 // The system it solves is
12 //
13 // alpha a v - beta div dot tau = rhs
14 //
15 // where tau = eta [grad v + (grad v)^T] + (kappa-(2/3)eta) (div v) I.
16 // Here eta and kappa are shear and bulk viscosity, and I is identity tensor.
17 //
18 // The user needs to provide `a` by `setACoeffs`, eta by `setShearViscosity`,
19 // and kappa by `setBulkViscosity`. If `setBulkViscosity` is not called,
20 // kappa is set to zero.
21 //
22 // The scalars alpha and beta can be set with `setScalar(Real, Real)`. If
23 // they are not set, their default value is 1.
24 
26  : public MLABecLaplacian
27 {
28 public:
29 
30  MLTensorOp ();
31  MLTensorOp (const Vector<Geometry>& a_geom,
32  const Vector<BoxArray>& a_grids,
33  const Vector<DistributionMapping>& a_dmap,
34  const LPInfo& a_info = LPInfo(),
35  const Vector<FabFactory<FArrayBox> const*>& a_factory = {});
36  MLTensorOp (const Vector<Geometry>& a_geom,
37  const Vector<BoxArray>& a_grids,
38  const Vector<DistributionMapping>& a_dmap,
39  const Vector<iMultiFab const*>& a_overset_mask, // 1: unknown, 0: known
40  const LPInfo& a_info = LPInfo(),
41  const Vector<FabFactory<FArrayBox> const*>& a_factory = {});
42  ~MLTensorOp () override = default;
43 
44  MLTensorOp (const MLTensorOp&) = delete;
45  MLTensorOp (MLTensorOp&&) = delete;
46  MLTensorOp& operator= (const MLTensorOp&) = delete;
48 
49  void define (const Vector<Geometry>& a_geom,
50  const Vector<BoxArray>& a_grids,
51  const Vector<DistributionMapping>& a_dmap,
52  const LPInfo& a_info = LPInfo(),
53  const Vector<FabFactory<FArrayBox> const*>& a_factory = {});
54 
55  void define (const Vector<Geometry>& a_geom,
56  const Vector<BoxArray>& a_grids,
57  const Vector<DistributionMapping>& a_dmap,
58  const Vector<iMultiFab const*>& a_overset_mask,
59  const LPInfo& a_info = LPInfo(),
60  const Vector<FabFactory<FArrayBox> const*>& a_factory = {});
61 
62  void setShearViscosity (int amrlev, const Array<MultiFab const*,AMREX_SPACEDIM>& eta);
63  void setShearViscosity (int amrlev, Real eta);
64  void setBulkViscosity (int amrlev, const Array<MultiFab const*,AMREX_SPACEDIM>& kappa);
65  void setBulkViscosity (int amrlev, Real kappa);
66 
67  [[nodiscard]] int getNComp () const final { return AMREX_SPACEDIM; }
68 
69  [[nodiscard]] bool isCrossStencil () const final { return false; }
70  [[nodiscard]] bool isTensorOp () const final { return true; }
71 
72  [[nodiscard]] bool needsUpdate () const final {
74  }
75  void update () final {
76  amrex::Abort("MLTensorOp: update TODO");
77  }
78 
79  void prepareForSolve () final;
80  [[nodiscard]] bool isSingular (int /*armlev*/) const final { return false; }
81  [[nodiscard]] bool isBottomSingular () const final { return false; }
82 
83  void apply (int amrlev, int mglev, MultiFab& out, MultiFab& in, BCMode bc_mode,
84  StateMode s_mode, const MLMGBndry* bndry=nullptr) const final;
85 
86  void compFlux (int amrlev, const Array<MultiFab*,AMREX_SPACEDIM>& fluxes,
87  MultiFab& sol, Location loc) const override;
88 
89  void compVelGrad (int amrlev, const Array<MultiFab*,AMREX_SPACEDIM>& fluxes,
90  MultiFab& sol, Location loc) const;
91 
92  void setBCoeffs (int amrlev, const Array<MultiFab const*,AMREX_SPACEDIM>& beta) = delete;
93 
94 protected:
95 
96  bool m_needs_update = true;
97 
98  bool m_has_kappa = false;
99  Vector<Vector<Array<MultiFab,AMREX_SPACEDIM> > > m_kappa;
100 
101 public: // for cuda
102 
103  void applyBCTensor (int amrlev, int mglev, MultiFab& vel,
104  BCMode bc_mode, StateMode s_mode, const MLMGBndry* bndry
105  ) const;
106 };
107 
108 }
109 
110 #endif
Definition: AMReX_MLABecLaplacian.H:15
typename MLLinOpT< MF >::Location Location
Definition: AMReX_MLABecLaplacian.H:22
bool needsUpdate() const override
Does it need update if it's reused?
Definition: AMReX_MLABecLaplacian.H:149
typename MLLinOpT< MF >::BCMode BCMode
Definition: AMReX_MLCellLinOp.H:28
typename MLLinOpT< MF >::StateMode StateMode
Definition: AMReX_MLCellLinOp.H:29
Definition: AMReX_MLMGBndry.H:12
Definition: AMReX_MLTensorOp.H:27
bool isTensorOp() const final
Definition: AMReX_MLTensorOp.H:70
void update() final
Update for reuse.
Definition: AMReX_MLTensorOp.H:75
bool m_has_kappa
Definition: AMReX_MLTensorOp.H:98
bool m_needs_update
Definition: AMReX_MLTensorOp.H:96
MLTensorOp(MLTensorOp &&)=delete
bool isBottomSingular() const final
Is the bottom of MG singular?
Definition: AMReX_MLTensorOp.H:81
void compVelGrad(int amrlev, const Array< MultiFab *, AMREX_SPACEDIM > &fluxes, MultiFab &sol, Location loc) const
Definition: AMReX_MLTensorOp_grad.cpp:133
MLTensorOp & operator=(const MLTensorOp &)=delete
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< FArrayBox > const * > &a_factory={})
Definition: AMReX_MLTensorOp.cpp:39
MLTensorOp(const MLTensorOp &)=delete
~MLTensorOp() override=default
void setBulkViscosity(int amrlev, const Array< MultiFab const *, AMREX_SPACEDIM > &kappa)
Definition: AMReX_MLTensorOp.cpp:108
bool needsUpdate() const final
Does it need update if it's reused?
Definition: AMReX_MLTensorOp.H:72
bool isSingular(int) const final
Is it singular on given AMR level?
Definition: AMReX_MLTensorOp.H:80
void prepareForSolve() final
Definition: AMReX_MLTensorOp.cpp:128
Vector< Vector< Array< MultiFab, AMREX_SPACEDIM > > > m_kappa
Definition: AMReX_MLTensorOp.H:99
void compFlux(int amrlev, const Array< MultiFab *, AMREX_SPACEDIM > &fluxes, MultiFab &sol, Location loc) const override
Definition: AMReX_MLTensorOp_grad.cpp:7
bool isCrossStencil() const final
Definition: AMReX_MLTensorOp.H:69
void apply(int amrlev, int mglev, MultiFab &out, MultiFab &in, BCMode bc_mode, StateMode s_mode, const MLMGBndry *bndry=nullptr) const final
Definition: AMReX_MLTensorOp.cpp:200
int getNComp() const final
Return number of components.
Definition: AMReX_MLTensorOp.H:67
MLTensorOp()
Definition: AMReX_MLTensorOp.cpp:12
void setBCoeffs(int amrlev, const Array< MultiFab const *, AMREX_SPACEDIM > &beta)=delete
void setShearViscosity(int amrlev, const Array< MultiFab const *, AMREX_SPACEDIM > &eta)
Definition: AMReX_MLTensorOp.cpp:96
void applyBCTensor(int amrlev, int mglev, MultiFab &vel, BCMode bc_mode, StateMode s_mode, const MLMGBndry *bndry) const
Definition: AMReX_MLTensorOp.cpp:336
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_Amr.cpp:49
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition: AMReX.cpp:225
std::array< T, N > Array
Definition: AMReX_Array.H:24
Definition: AMReX_MLLinOp.H:35