Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
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
7namespace amrex {
8
16// Tensor solver for high Reynolds flows with small gradient in viscosity.
17// The system it solves is
18//
19// alpha a v - beta div dot tau = rhs
20//
21// where tau = eta [grad v + (grad v)^T] + (kappa-(2/3)eta) (div v) I.
22// Here eta and kappa are shear and bulk viscosity, and I is identity tensor.
23//
24// The user needs to provide `a` by `setACoeffs`, eta by `setShearViscosity`,
25// and kappa by `setBulkViscosity`. If `setBulkViscosity` is not called,
26// kappa is set to zero. The user must also call `setEBShearViscosity` to set
27// viscosity on EB, and `setEBBulkViscosity` to set bulk viscosity on EB.
28// `setBulkViscosity` and `setEBBulkViscosity` must either both be called or
29// both be omitted. Passing a value of zero still counts as calling them.
30//
31// The scalars alpha and beta can be set with `setScalar(Real, Real)`. If
32// they are not set, their default value is 1.
33
36 : public MLEBABecLap
37{
38public:
39
41 MLEBTensorOp ();
47 MLEBTensorOp (const Vector<Geometry>& a_geom,
48 const Vector<BoxArray>& a_grids,
49 const Vector<DistributionMapping>& a_dmap,
50 const LPInfo& a_info,
51 const Vector<EBFArrayBoxFactory const*>& a_factory);
52
53 ~MLEBTensorOp () override;
54
55 MLEBTensorOp (const MLEBTensorOp&) = delete;
59
69 void define (const Vector<Geometry>& a_geom,
70 const Vector<BoxArray>& a_grids,
71 const Vector<DistributionMapping>& a_dmap,
72 const LPInfo& a_info,
73 const Vector<EBFArrayBoxFactory const*>& a_factory);
74
83 Location a_beta_loc);
90 void setShearViscosity (int amrlev, Real eta);
91
98 void setBulkViscosity (int amrlev, const Array<MultiFab const*,AMREX_SPACEDIM>& kappa);
105 void setBulkViscosity (int amrlev, Real kappa);
106
113 void setEBShearViscosity (int amrlev, MultiFab const& eta);
120 void setEBShearViscosity (int amrlev, Real eta);
128 void setEBShearViscosityWithInflow (int amrlev, MultiFab const& eta, MultiFab const& eb_vel);
129
136 void setEBBulkViscosity (int amrlev, MultiFab const& kappa);
146 void setEBBulkViscosity (int amrlev, Real kappa);
147
148 [[nodiscard]] int getNComp () const final { return AMREX_SPACEDIM; }
149
150 [[nodiscard]] bool isCrossStencil () const final { return false; }
151 [[nodiscard]] bool isTensorOp () const final { return true; }
152
159 [[nodiscard]] bool needsUpdate () const final {
160 return (m_needs_update || MLEBABecLap::needsUpdate());
161 }
168 void update () final {
169 amrex::Abort("MLEBTensorOp: update TODO");
170 }
171
173 void prepareForSolve () final;
174 [[nodiscard]] bool isSingular (int /*armlev*/) const final { return false; }
175 [[nodiscard]] bool isBottomSingular () const final { return false; }
176
188 void apply (int amrlev, int mglev, MultiFab& out, MultiFab& in, BCMode bc_mode,
189 StateMode s_mode, const MLMGBndry* bndry=nullptr) const final;
198 void compFlux (int amrlev, const Array<MultiFab*,AMREX_SPACEDIM>& fluxes,
199 MultiFab& sol, Location loc) const override;
200
209 void compVelGrad (int amrlev, const Array<MultiFab*,AMREX_SPACEDIM>& grads,
210 MultiFab& sol, Location loc) const;
211
212 void setBCoeffs (int amrlev, const Array<MultiFab const*,AMREX_SPACEDIM>& beta,
213 Location a_beta_loc) = delete;
214 void setEBDirichlet (int amrlev, const MultiFab& phi, const MultiFab& beta) = delete;
215 void setEBHomogDirichlet (int amrlev, const MultiFab& beta) = delete;
216
217protected:
218
219 bool m_has_kappa = false;
220 bool m_has_eb_kappa = false;
221 Vector<Vector<Array<MultiFab,AMREX_SPACEDIM> > > m_kappa;
223 mutable Vector<Vector<Array<MultiFab,AMREX_SPACEDIM> > > m_tauflux;
224
225private:
226
227 bool m_needs_update = true;
228
229public: // for cuda
230
241 void applyBCTensor (int amrlev, int mglev, MultiFab& vel,
242 BCMode bc_mode, StateMode s_mode, const MLMGBndry* bndry) const;
251 void compCrossTerms(int amrlev, int mglev, MultiFab const& mf,
252 const MLMGBndry* bndry) const;
253};
254
255}
256
257#endif
258
259// add ghost cells to kappa
typename MLLinOpT< MF >::Location Location
Definition AMReX_MLCellABecLap.H:28
typename MLLinOpT< MF >::BCMode BCMode
Definition AMReX_MLCellLinOp.H:38
typename MLLinOpT< MF >::StateMode StateMode
Definition AMReX_MLCellLinOp.H:39
Embedded-boundary ABec Laplacian (alpha a - beta div(b grad phi)).
Definition AMReX_MLEBABecLap.H:28
bool needsUpdate() const override
Does it need update if it's reused?
Definition AMReX_MLEBABecLap.H:191
Embedded-boundary tensor solver mirroring MLTensorOp inside the domain.
Definition AMReX_MLEBTensorOp.H:37
void apply(int amrlev, int mglev, MultiFab &out, MultiFab &in, BCMode bc_mode, StateMode s_mode, const MLMGBndry *bndry=nullptr) const final
Apply the EB tensor operator at (amrlev,mglev).
Definition AMReX_MLEBTensorOp.cpp:207
MLEBTensorOp(MLEBTensorOp &&)=delete
void prepareForSolve() final
Prepare shear/bulk coefficient caches and BC data before solving.
Definition AMReX_MLEBTensorOp.cpp:144
bool m_has_kappa
Definition AMReX_MLEBTensorOp.H:219
bool needsUpdate() const final
True if coefficients have changed since the last prepareForSolve().
Definition AMReX_MLEBTensorOp.H:159
void setEBBulkViscosity(int amrlev, MultiFab const &kappa)
Provide EB bulk viscosity from a MultiFab.
Definition AMReX_MLEBTensorOp.cpp:128
void compVelGrad(int amrlev, const Array< MultiFab *, 3 > &grads, MultiFab &sol, Location loc) const
Compute velocity gradients at the requested location.
Definition AMReX_MLEBTensorOp.cpp:620
bool isCrossStencil() const final
EB discretization uses a non-cross stencil.
Definition AMReX_MLEBTensorOp.H:150
void setEBHomogDirichlet(int amrlev, const MultiFab &beta)=delete
~MLEBTensorOp() override
void setShearViscosity(int amrlev, const Array< MultiFab const *, 3 > &eta, Location a_beta_loc)
Provide shear viscosity eta as face-centered MultiFabs.
Definition AMReX_MLEBTensorOp.cpp:74
void applyBCTensor(int amrlev, int mglev, MultiFab &vel, BCMode bc_mode, StateMode s_mode, const MLMGBndry *bndry) const
Apply tensor boundary conditions prior to an operator call.
Definition AMReX_MLEBTensorOp_bc.cpp:8
void compCrossTerms(int amrlev, int mglev, MultiFab const &mf, const MLMGBndry *bndry) const
Compute cross-derivative stress terms for cached BC data.
Definition AMReX_MLEBTensorOp.cpp:298
void setEBShearViscosity(int amrlev, MultiFab const &eta)
Provide EB-face shear viscosity.
Definition AMReX_MLEBTensorOp.cpp:107
void setEBDirichlet(int amrlev, const MultiFab &phi, const MultiFab &beta)=delete
int getNComp() const final
Return number of components.
Definition AMReX_MLEBTensorOp.H:148
void setBulkViscosity(int amrlev, const Array< MultiFab const *, 3 > &kappa)
Provide bulk viscosity kappa as face-centered MultiFabs.
Definition AMReX_MLEBTensorOp.cpp:87
Vector< Vector< Array< MultiFab, 3 > > > m_tauflux
Definition AMReX_MLEBTensorOp.H:223
void update() final
Not implemented for tensor operators.
Definition AMReX_MLEBTensorOp.H:168
Vector< Vector< MultiFab > > m_eb_kappa
Definition AMReX_MLEBTensorOp.H:222
void setBCoeffs(int amrlev, const Array< MultiFab const *, 3 > &beta, Location a_beta_loc)=delete
MLEBTensorOp & operator=(const MLEBTensorOp &)=delete
bool isBottomSingular() const final
True if the bottom level is singular.
Definition AMReX_MLEBTensorOp.H:175
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)
Define the AMR hierarchy using EB-aware factories.
Definition AMReX_MLEBTensorOp.cpp:32
void setEBShearViscosityWithInflow(int amrlev, MultiFab const &eta, MultiFab const &eb_vel)
Provide EB shear viscosity plus inflow velocity corrections.
Definition AMReX_MLEBTensorOp.cpp:121
MLEBTensorOp()
Construct an empty EB tensor operator; call define() before using.
Definition AMReX_MLEBTensorOp.cpp:14
void compFlux(int amrlev, const Array< MultiFab *, 3 > &fluxes, MultiFab &sol, Location loc) const override
Assemble viscous fluxes on AMR level amrlev.
Definition AMReX_MLEBTensorOp.cpp:509
bool isSingular(int) const final
True if AMR level amrlev is singular.
Definition AMReX_MLEBTensorOp.H:174
bool m_has_eb_kappa
Definition AMReX_MLEBTensorOp.H:220
bool isTensorOp() const final
Whether this operator is a tensor solve.
Definition AMReX_MLEBTensorOp.H:151
MLEBTensorOp(const MLEBTensorOp &)=delete
Vector< Vector< Array< MultiFab, 3 > > > m_kappa
Definition AMReX_MLEBTensorOp.H:221
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
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:79
std::array< T, N > Array
Definition AMReX_Array.H:31
Definition AMReX_Amr.cpp:50
void Abort(const std::string &msg)
Print a fatal-error message to stderr and abort execution.
Definition AMReX.cpp:241
Configuration knobs for multilevel linear operators (grid agglomeration, metrics, etc....
Definition AMReX_MLLinOp.H:51