Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
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
8namespace amrex {
9
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.
27//
28// The scalars alpha and beta can be set with `setScalars(Real, Real)`. If
29// they are not set, their default value is 1.
30
33 : public MLABecLaplacian
34{
35public:
36
38 MLTensorOp ();
44 MLTensorOp (const Vector<Geometry>& a_geom,
45 const Vector<BoxArray>& a_grids,
46 const Vector<DistributionMapping>& a_dmap,
47 const LPInfo& a_info = LPInfo(),
48 const Vector<FabFactory<FArrayBox> const*>& a_factory = {});
52 MLTensorOp (const Vector<Geometry>& a_geom,
53 const Vector<BoxArray>& a_grids,
54 const Vector<DistributionMapping>& a_dmap,
55 const Vector<iMultiFab const*>& a_overset_mask, // 1: unknown, 0: known
56 const LPInfo& a_info = LPInfo(),
57 const Vector<FabFactory<FArrayBox> const*>& a_factory = {});
58 ~MLTensorOp () override = default;
59
60 MLTensorOp (const MLTensorOp&) = delete;
61 MLTensorOp (MLTensorOp&&) = delete;
62 MLTensorOp& operator= (const MLTensorOp&) = delete;
64
74 void define (const Vector<Geometry>& a_geom,
75 const Vector<BoxArray>& a_grids,
76 const Vector<DistributionMapping>& a_dmap,
77 const LPInfo& a_info = LPInfo(),
78 const Vector<FabFactory<FArrayBox> const*>& a_factory = {});
79
90 void define (const Vector<Geometry>& a_geom,
91 const Vector<BoxArray>& a_grids,
92 const Vector<DistributionMapping>& a_dmap,
93 const Vector<iMultiFab const*>& a_overset_mask,
94 const LPInfo& a_info = LPInfo(),
95 const Vector<FabFactory<FArrayBox> const*>& a_factory = {});
96
103 void setShearViscosity (int amrlev, const Array<MultiFab const*,AMREX_SPACEDIM>& eta);
110 void setShearViscosity (int amrlev, Real eta);
117 void setBulkViscosity (int amrlev, const Array<MultiFab const*,AMREX_SPACEDIM>& kappa);
124 void setBulkViscosity (int amrlev, Real kappa);
125
126 [[nodiscard]] int getNComp () const final { return AMREX_SPACEDIM; }
127
128 [[nodiscard]] bool isCrossStencil () const final { return false; }
129 [[nodiscard]] bool isTensorOp () const final { return true; }
130
132 [[nodiscard]] bool needsUpdate () const final {
133 return (m_needs_update || MLABecLaplacian::needsUpdate());
134 }
136 void update () final {
137 amrex::Abort("MLTensorOp: update TODO");
138 }
139
141 void prepareForSolve () final;
142 [[nodiscard]] bool isSingular (int /*armlev*/) const final { return false; }
143 [[nodiscard]] bool isBottomSingular () const final { return false; }
144
156 void apply (int amrlev, int mglev, MultiFab& out, MultiFab& in, BCMode bc_mode,
157 StateMode s_mode, const MLMGBndry* bndry=nullptr) const final;
158
167 void compFlux (int amrlev, const Array<MultiFab*,AMREX_SPACEDIM>& fluxes,
168 MultiFab& sol, Location loc) const override;
169
178 void compVelGrad (int amrlev, const Array<MultiFab*,AMREX_SPACEDIM>& fluxes,
179 MultiFab& sol, Location loc) const;
180
181 void setBCoeffs (int amrlev, const Array<MultiFab const*,AMREX_SPACEDIM>& beta) = delete;
182
183protected:
184
185 bool m_has_kappa = false;
186 Vector<Vector<Array<MultiFab,AMREX_SPACEDIM> > > m_kappa;
187
188private:
189
190 bool m_needs_update = true;
191
192public: // for cuda
193
204 void applyBCTensor (int amrlev, int mglev, MultiFab& vel,
205 BCMode bc_mode, StateMode s_mode, const MLMGBndry* bndry
206 ) const;
207};
208
209}
210
211#endif
Fixed-size array types for use on GPU and CPU.
Definition AMReX_FabFactory.H:50
Definition AMReX_MLABecLaplacian.H:22
typename MLLinOpT< MF >::Location Location
Definition AMReX_MLABecLaplacian.H:29
bool needsUpdate() const override
True if coefficients need to be averaged down before the next apply().
Definition AMReX_MLABecLaplacian.H:170
typename MLLinOpT< MF >::BCMode BCMode
Definition AMReX_MLCellLinOp.H:38
typename MLLinOpT< MF >::StateMode StateMode
Definition AMReX_MLCellLinOp.H:39
Boundary helper for MLMG that manages coarse/fine and physical BC metadata.
Definition AMReX_MLMGBndry.H:20
Tensor solver with shear/bulk viscosity inputs for high-Reynolds flows.
Definition AMReX_MLTensorOp.H:34
bool isTensorOp() const final
Whether this operator is a tensor solve.
Definition AMReX_MLTensorOp.H:129
void update() final
Rebuild coefficient averages (not yet implemented).
Definition AMReX_MLTensorOp.H:136
bool m_has_kappa
Definition AMReX_MLTensorOp.H:185
MLTensorOp(MLTensorOp &&)=delete
bool isBottomSingular() const final
Convenience helper for the coarsest level singularity flag.
Definition AMReX_MLTensorOp.H:143
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={})
Define the hierarchy for standard tensor solves.
Definition AMReX_MLTensorOp.cpp:39
MLTensorOp(const MLTensorOp &)=delete
void setShearViscosity(int amrlev, const Array< MultiFab const *, 3 > &eta)
Provide shear viscosity eta as face-centered MultiFabs.
Definition AMReX_MLTensorOp.cpp:96
~MLTensorOp() override=default
void setBCoeffs(int amrlev, const Array< MultiFab const *, 3 > &beta)=delete
bool needsUpdate() const final
True if viscosity coefficients need to be rebuilt before apply().
Definition AMReX_MLTensorOp.H:132
bool isSingular(int) const final
Query whether AMR level amrlev is singular (null space present).
Definition AMReX_MLTensorOp.H:142
void prepareForSolve() final
Assemble viscosity data/BC caches before solving.
Definition AMReX_MLTensorOp.cpp:128
Vector< Vector< Array< MultiFab, 3 > > > m_kappa
Definition AMReX_MLTensorOp.H:186
void compVelGrad(int amrlev, const Array< MultiFab *, 3 > &fluxes, MultiFab &sol, Location loc) const
Compute velocity gradients (symmetrized) at the requested location.
Definition AMReX_MLTensorOp_grad.cpp:130
void setBulkViscosity(int amrlev, const Array< MultiFab const *, 3 > &kappa)
Provide bulk viscosity kappa as face-centered MultiFabs.
Definition AMReX_MLTensorOp.cpp:108
bool isCrossStencil() const final
Whether the stencil is the cross shape.
Definition AMReX_MLTensorOp.H:128
MLTensorOp & operator=(const MLTensorOp &)=delete
void apply(int amrlev, int mglev, MultiFab &out, MultiFab &in, BCMode bc_mode, StateMode s_mode, const MLMGBndry *bndry=nullptr) const final
Apply the tensor operator on AMR level amrlev / MG level mglev.
Definition AMReX_MLTensorOp.cpp:200
int getNComp() const final
Return number of components.
Definition AMReX_MLTensorOp.H:126
MLTensorOp()
Construct an empty tensor operator; call define() before solving.
Definition AMReX_MLTensorOp.cpp:12
void compFlux(int amrlev, const Array< MultiFab *, 3 > &fluxes, MultiFab &sol, Location loc) const override
Assemble viscous fluxes on AMR level amrlev.
Definition AMReX_MLTensorOp_grad.cpp:7
void applyBCTensor(int amrlev, int mglev, MultiFab &vel, BCMode bc_mode, StateMode s_mode, const MLMGBndry *bndry) const
Apply tensor-specific boundary conditions on (amrlev,mglev).
Definition AMReX_MLTensorOp.cpp:333
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