Block-Structured AMR Software Framework
AMReX_MLEBTensorOp.H
Go to the documentation of this file.
1 #ifndef AMREX_ML_EB_TENSOROP_H_
2 #define AMREX_ML_EB_TENSOROP_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_MLEBABecLap.H>
6 
7 namespace amrex {
8 
9 // Tensor solver for high Reynolds flows with small gradient in viscosity.
10 // The system it solves is
11 //
12 // alpha a v - beta div dot tau = rhs
13 //
14 // where tau = eta [grad v + (grad v)^T] + (kappa-(2/3)eta) (div v) I.
15 // Here eta and kappa are shear and bulk viscosity, and I is identity tensor.
16 //
17 // The user needs to provide `a` by `setACoeffs`, eta by `setShearViscosity`,
18 // and kappa by `setBulkViscosity`. If `setBulkViscosity` is not called,
19 // kappa is set to zero. The user must also call `setEBShearViscosity` to set
20 // viscosity on EB. Optionally, `setEBBulkViscosity` can be used to set
21 // bulk viscosity on EB.
22 //
23 // The scalars alpha and beta can be set with `setScalar(Real, Real)`. If
24 // they are not set, their default value is 1.
25 
27  : public MLEBABecLap
28 {
29 public:
30 
31  MLEBTensorOp ();
32  MLEBTensorOp (const Vector<Geometry>& a_geom,
33  const Vector<BoxArray>& a_grids,
34  const Vector<DistributionMapping>& a_dmap,
35  const LPInfo& a_info,
36  const Vector<EBFArrayBoxFactory const*>& a_factory);
37 
38  ~MLEBTensorOp () override;
39 
40  MLEBTensorOp (const MLEBTensorOp&) = delete;
41  MLEBTensorOp (MLEBTensorOp&&) = delete;
44 
45  void define (const Vector<Geometry>& a_geom,
46  const Vector<BoxArray>& a_grids,
47  const Vector<DistributionMapping>& a_dmap,
48  const LPInfo& a_info,
49  const Vector<EBFArrayBoxFactory const*>& a_factory);
50 
51  void setShearViscosity (int amrlev, const Array<MultiFab const*,AMREX_SPACEDIM>& eta,
52  Location a_beta_loc);
53  void setShearViscosity (int amrlev, Real eta);
54 
55  void setBulkViscosity (int amrlev, const Array<MultiFab const*,AMREX_SPACEDIM>& kappa);
56  void setBulkViscosity (int amrlev, Real kappa);
57 
58  void setEBShearViscosity (int amrlev, MultiFab const& eta);
59  void setEBShearViscosity (int amrlev, Real eta);
60  void setEBShearViscosityWithInflow (int amrlev, MultiFab const& eta, MultiFab const& eb_vel);
61 
62  void setEBBulkViscosity (int amrlev, MultiFab const& kappa);
63  void setEBBulkViscosity (int amrlev, Real kappa);
64 
65  [[nodiscard]] int getNComp () const final { return AMREX_SPACEDIM; }
66 
67  [[nodiscard]] bool isCrossStencil () const final { return false; }
68  [[nodiscard]] bool isTensorOp () const final { return true; }
69 
70  [[nodiscard]] bool needsUpdate () const final {
72  }
73  void update () final {
74  amrex::Abort("MLEBTensorOp: update TODO");
75  }
76 
77  void prepareForSolve () final;
78  [[nodiscard]] bool isSingular (int /*armlev*/) const final { return false; }
79  [[nodiscard]] bool isBottomSingular () const final { return false; }
80 
81  void apply (int amrlev, int mglev, MultiFab& out, MultiFab& in, BCMode bc_mode,
82  StateMode s_mode, const MLMGBndry* bndry=nullptr) const final;
83  void compFlux (int amrlev, const Array<MultiFab*,AMREX_SPACEDIM>& fluxes,
84  MultiFab& sol, Location loc) const override;
85 
86  void compVelGrad (int amrlev, const Array<MultiFab*,AMREX_SPACEDIM>& grads,
87  MultiFab& sol, Location loc) const;
88 
89  void setBCoeffs (int amrlev, const Array<MultiFab const*,AMREX_SPACEDIM>& beta,
90  Location a_beta_loc) = delete;
91  void setEBDirichlet (int amrlev, const MultiFab& phi, const MultiFab& beta) = delete;
92  void setEBHomogDirichlet (int amrlev, const MultiFab& beta) = delete;
93 
94 protected:
95 
96  bool m_needs_update = true;
97 
98  bool m_has_kappa = false;
99  bool m_has_eb_kappa = false;
100  Vector<Vector<Array<MultiFab,AMREX_SPACEDIM> > > m_kappa;
102  mutable Vector<Vector<Array<MultiFab,AMREX_SPACEDIM> > > m_tauflux;
103 
104 public: // for cuda
105 
106  void applyBCTensor (int amrlev, int mglev, MultiFab& vel,
107  BCMode bc_mode, StateMode s_mode, const MLMGBndry* bndry) const;
108  void compCrossTerms(int amrlev, int mglev, MultiFab const& mf,
109  const MLMGBndry* bndry) const;
110 };
111 
112 }
113 
114 #endif
115 
116 // add ghost cells to kappa
typename MLLinOpT< MF >::Location Location
Definition: AMReX_MLCellABecLap.H:19
typename MLLinOpT< MF >::BCMode BCMode
Definition: AMReX_MLCellLinOp.H:28
typename MLLinOpT< MF >::StateMode StateMode
Definition: AMReX_MLCellLinOp.H:29
Definition: AMReX_MLEBABecLap.H:16
bool needsUpdate() const override
Does it need update if it's reused?
Definition: AMReX_MLEBABecLap.H:67
Definition: AMReX_MLEBTensorOp.H:28
void apply(int amrlev, int mglev, MultiFab &out, MultiFab &in, BCMode bc_mode, StateMode s_mode, const MLMGBndry *bndry=nullptr) const final
Definition: AMReX_MLEBTensorOp.cpp:200
bool m_needs_update
Definition: AMReX_MLEBTensorOp.H:96
MLEBTensorOp(MLEBTensorOp &&)=delete
void prepareForSolve() final
Definition: AMReX_MLEBTensorOp.cpp:139
Vector< Vector< Array< MultiFab, AMREX_SPACEDIM > > > m_kappa
Definition: AMReX_MLEBTensorOp.H:100
bool m_has_kappa
Definition: AMReX_MLEBTensorOp.H:98
bool needsUpdate() const final
Does it need update if it's reused?
Definition: AMReX_MLEBTensorOp.H:70
void setBulkViscosity(int amrlev, const Array< MultiFab const *, AMREX_SPACEDIM > &kappa)
Definition: AMReX_MLEBTensorOp.cpp:87
void setEBBulkViscosity(int amrlev, MultiFab const &kappa)
Definition: AMReX_MLEBTensorOp.cpp:123
void compVelGrad(int amrlev, const Array< MultiFab *, AMREX_SPACEDIM > &grads, MultiFab &sol, Location loc) const
Definition: AMReX_MLEBTensorOp.cpp:613
bool isCrossStencil() const final
Definition: AMReX_MLEBTensorOp.H:67
void setEBHomogDirichlet(int amrlev, const MultiFab &beta)=delete
~MLEBTensorOp() override
void setShearViscosity(int amrlev, const Array< MultiFab const *, AMREX_SPACEDIM > &eta, Location a_beta_loc)
Definition: AMReX_MLEBTensorOp.cpp:74
void setBCoeffs(int amrlev, const Array< MultiFab const *, AMREX_SPACEDIM > &beta, Location a_beta_loc)=delete
void applyBCTensor(int amrlev, int mglev, MultiFab &vel, BCMode bc_mode, StateMode s_mode, const MLMGBndry *bndry) const
Definition: AMReX_MLEBTensorOp_bc.cpp:8
void compFlux(int amrlev, const Array< MultiFab *, AMREX_SPACEDIM > &fluxes, MultiFab &sol, Location loc) const override
Definition: AMReX_MLEBTensorOp.cpp:502
void compCrossTerms(int amrlev, int mglev, MultiFab const &mf, const MLMGBndry *bndry) const
Definition: AMReX_MLEBTensorOp.cpp:291
void setEBShearViscosity(int amrlev, MultiFab const &eta)
Definition: AMReX_MLEBTensorOp.cpp:105
void setEBDirichlet(int amrlev, const MultiFab &phi, const MultiFab &beta)=delete
int getNComp() const final
Return number of components.
Definition: AMReX_MLEBTensorOp.H:65
void update() final
Update for reuse.
Definition: AMReX_MLEBTensorOp.H:73
Vector< Vector< MultiFab > > m_eb_kappa
Definition: AMReX_MLEBTensorOp.H:101
Vector< Vector< Array< MultiFab, AMREX_SPACEDIM > > > m_tauflux
Definition: AMReX_MLEBTensorOp.H:102
bool isBottomSingular() const final
Is the bottom of MG singular?
Definition: AMReX_MLEBTensorOp.H:79
void define(const Vector< Geometry > &a_geom, const Vector< BoxArray > &a_grids, const Vector< DistributionMapping > &a_dmap, const LPInfo &a_info, const Vector< EBFArrayBoxFactory const * > &a_factory)
Definition: AMReX_MLEBTensorOp.cpp:32
MLEBTensorOp & operator=(const MLEBTensorOp &)=delete
void setEBShearViscosityWithInflow(int amrlev, MultiFab const &eta, MultiFab const &eb_vel)
Definition: AMReX_MLEBTensorOp.cpp:117
MLEBTensorOp()
Definition: AMReX_MLEBTensorOp.cpp:14
bool isSingular(int) const final
Is it singular on given AMR level?
Definition: AMReX_MLEBTensorOp.H:78
bool m_has_eb_kappa
Definition: AMReX_MLEBTensorOp.H:99
bool isTensorOp() const final
Definition: AMReX_MLEBTensorOp.H:68
MLEBTensorOp(const MLEBTensorOp &)=delete
Definition: AMReX_MLMGBndry.H:12
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