|
2 | 2 | // ArtificialViscosity -- The base class for all ArtificialViscosities in
|
3 | 3 | // Spheral++.
|
4 | 4 | //
|
| 5 | +// This intermediate class between ArtificialViscosityHandle and the actual |
| 6 | +// artficial viscosity implementations specifies the QPi = Q/rho^2 return type, |
| 7 | +// generally either a Scalar or a Tensor. |
| 8 | +// |
5 | 9 | // Created by JMO, Sun May 21 21:16:43 PDT 2000
|
6 | 10 | //----------------------------------------------------------------------------//
|
7 | 11 | #ifndef __Spheral_ArtificialViscosity__
|
8 | 12 | #define __Spheral_ArtificialViscosity__
|
9 | 13 |
|
10 |
| -#include <utility> |
11 |
| - |
12 |
| -#include "Geometry/Dimension.hh" |
13 |
| -#include "RK/RKCorrectionParams.hh" |
14 |
| - |
15 |
| -#include <vector> |
16 |
| -#include "Field/FieldList.hh" |
17 |
| -#include "DataOutput/registerWithRestart.hh" |
18 |
| - |
19 |
| -namespace Spheral { |
20 |
| - |
21 |
| - template<typename Dimension> class AllNodeIterator; |
22 |
| - template<typename Dimension> class InternalNodeIterator; |
23 |
| - template<typename Dimension> class GhostNodeIterator; |
24 |
| - template<typename Dimension> class MasterNodeIterator; |
25 |
| - template<typename Dimension> class CoarseNodeIterator; |
26 |
| - template<typename Dimension> class RefineNodeIterator; |
27 |
| - |
28 |
| - template<typename Dimension> class State; |
29 |
| - template<typename Dimension> class StateDerivatives; |
| 14 | +#include "ArtificialViscosity/ArtificialViscosityHandle.hh" |
30 | 15 |
|
31 |
| - template<typename Dimension> class DataBase; |
32 |
| - template<typename Dimension, typename DataType> class FieldList; |
33 |
| - class FileIO; |
34 |
| - template<typename Dimension> class ConnectivityMap; |
35 |
| - template<typename Dimension> class TableKernel; |
36 |
| - template<typename Dimension> class Boundary; |
37 |
| -} |
| 16 | +#include <utility> |
| 17 | +#include <typeindex> |
38 | 18 |
|
39 | 19 | namespace Spheral {
|
40 | 20 |
|
41 |
| -template<typename Dimension> |
42 |
| -class ArtificialViscosity { |
| 21 | +template<typename Dimension, typename QPiType> |
| 22 | +class ArtificialViscosity: public ArtificialViscosityHandle<Dimension> { |
43 | 23 | public:
|
44 | 24 | //--------------------------- Public Interface ---------------------------//
|
45 |
| - typedef typename Dimension::Scalar Scalar; |
46 |
| - typedef typename Dimension::Vector Vector; |
47 |
| - typedef typename Dimension::Tensor Tensor; |
48 |
| - typedef typename Dimension::SymTensor SymTensor; |
49 |
| - typedef typename std::pair<double, std::string> TimeStepType; |
| 25 | + using Scalar = typename Dimension::Scalar; |
| 26 | + using Vector = typename Dimension::Vector; |
| 27 | + using Tensor = typename Dimension::Tensor; |
| 28 | + using SymTensor = typename Dimension::SymTensor; |
50 | 29 |
|
51 |
| - typedef typename std::vector<Boundary<Dimension>*>::const_iterator ConstBoundaryIterator; |
| 30 | + using ReturnType = QPiType; |
52 | 31 |
|
53 |
| - // Constructors. |
| 32 | + // Constructors, destructor |
54 | 33 | ArtificialViscosity(const Scalar Clinear,
|
55 | 34 | const Scalar Cquadratic,
|
56 |
| - const RKOrder QcorrectionOrder = RKOrder::LinearOrder); |
57 |
| - |
58 |
| - // Destructor. |
59 |
| - virtual ~ArtificialViscosity(); |
60 |
| - |
61 |
| - // Initialize the artificial viscosity for all FluidNodeLists in the given |
62 |
| - // DataBase. |
63 |
| - virtual void initialize(const DataBase<Dimension>& dataBase, |
64 |
| - const State<Dimension>& state, |
65 |
| - const StateDerivatives<Dimension>& derivs, |
66 |
| - ConstBoundaryIterator boundaryBegin, |
67 |
| - ConstBoundaryIterator boundaryEnd, |
68 |
| - const Scalar /*time*/, |
69 |
| - const Scalar /*dt*/, |
70 |
| - const TableKernel<Dimension>& W); |
71 |
| - |
72 |
| - // Require all descendents to return the artificial viscous Pi = P/rho^2 as a tensor. |
73 |
| - // Scalar viscosities should just return a diagonal tensor with their value along the diagonal. |
74 |
| - virtual std::pair<Tensor, Tensor> Piij(const unsigned nodeListi, const unsigned i, |
75 |
| - const unsigned nodeListj, const unsigned j, |
76 |
| - const Vector& xi, |
77 |
| - const Vector& etai, |
78 |
| - const Vector& vi, |
79 |
| - const Scalar rhoi, |
80 |
| - const Scalar csi, |
81 |
| - const SymTensor& Hi, |
82 |
| - const Vector& xj, |
83 |
| - const Vector& etaj, |
84 |
| - const Vector& vj, |
85 |
| - const Scalar rhoj, |
86 |
| - const Scalar csj, |
87 |
| - const SymTensor& Hj) const = 0; |
88 |
| - |
89 |
| - // Allow access to the linear and quadratic constants. |
90 |
| - Scalar Cl() const; |
91 |
| - void Cl(Scalar Cl); |
92 |
| - |
93 |
| - Scalar Cq() const; |
94 |
| - void Cq(Scalar Cq); |
95 |
| - |
96 |
| - //Allow access to the Q correction order. |
97 |
| - RKOrder QcorrectionOrder() const; |
98 |
| - void QcorrectionOrder(RKOrder order); |
99 |
| - |
100 |
| - // Toggle for the Balsara shear correction. |
101 |
| - bool balsaraShearCorrection() const; |
102 |
| - void balsaraShearCorrection(bool value); |
103 |
| - |
104 |
| - // Calculate the curl of the velocity given the stress tensor. |
105 |
| - Scalar curlVelocityMagnitude(const Tensor& DvDx) const; |
106 |
| - |
107 |
| - // Access the FieldList of multiplicative corrections. |
108 |
| - FieldList<Dimension, Scalar>& ClMultiplier(); |
109 |
| - FieldList<Dimension, Scalar>& CqMultiplier(); |
110 |
| - FieldList<Dimension, Scalar>& shearCorrection(); |
111 |
| - const FieldList<Dimension, Scalar>& ClMultiplier() const; |
112 |
| - const FieldList<Dimension, Scalar>& CqMultiplier() const; |
113 |
| - const FieldList<Dimension, Scalar>& shearCorrection() const; |
114 |
| - |
115 |
| - // Access the internally computed estimate of sigma: |
116 |
| - // sig^ab = \partial v^a / \partial x^b. |
117 |
| - const FieldList<Dimension, Tensor>& sigma() const; |
118 |
| - |
119 |
| - // Access the internally computed estimate of the velocity gradient and |
120 |
| - // grad div velocity. |
121 |
| - const FieldList<Dimension, Vector>& gradDivVelocity() const; |
122 |
| - |
123 |
| - // Switch to turn the del^2 v limiter on/off. |
124 |
| - bool limiter() const; |
125 |
| - void limiter(bool value); |
126 |
| - |
127 |
| - // Access the epsilon safety factor. |
128 |
| - Scalar epsilon2() const; |
129 |
| - void epsilon2(Scalar epsilon2); |
130 |
| - |
131 |
| - // Method to return the limiter magnitude for the given node. |
132 |
| - Tensor calculateLimiter(const Vector& /*vi*/, |
133 |
| - const Vector& /*vj*/, |
134 |
| - const Scalar ci, |
135 |
| - const Scalar /*cj*/, |
136 |
| - const Scalar hi, |
137 |
| - const Scalar /*hj*/, |
138 |
| - const int nodeListID, |
139 |
| - const int nodeID) const; |
140 |
| - |
141 |
| - // Helper for the limiter, calculate the unit grad div v term for the given |
142 |
| - // node. |
143 |
| - Vector shockDirection(const Scalar ci, |
144 |
| - const Scalar hi, |
145 |
| - const int nodeListID, |
146 |
| - const int nodeID) const; |
147 |
| - |
148 |
| - // The negligible sound speed parameter for use in the limiter. |
149 |
| - Scalar negligibleSoundSpeed() const; |
150 |
| - void negligibleSoundSpeed(Scalar val); |
151 |
| - |
152 |
| - // The multiplier for sound speed in the limiter. |
153 |
| - Scalar csMultiplier() const; |
154 |
| - void csMultiplier(Scalar val); |
155 |
| - |
156 |
| - // The multiplier for energy in the limiter. |
157 |
| - Scalar energyMultiplier() const; |
158 |
| - void energyMultiplier(Scalar val); |
159 |
| - |
160 |
| - // Helper method to calculate Del cross V from the given sigma tensor. |
161 |
| - Scalar computeDelCrossVMagnitude(const Tensor& sigma) const; |
162 |
| - |
163 |
| - // Helper method to calculate the weighting based on the given position |
164 |
| - // for use in the sigma calculation. |
165 |
| - Vector sigmaWeighting(const Vector& r) const; |
166 |
| - |
167 |
| - // Figure out the total stress-strain tensor for a given node pair based on |
168 |
| - // the stored average value and the given (position, velocity) pair. |
169 |
| - Tensor sigmaij(const Vector& rji, |
170 |
| - const Vector& rjiUnit, |
171 |
| - const Vector& vji, |
172 |
| - const Scalar& hi2, |
173 |
| - const int nodeListID, |
174 |
| - const int nodeID) const; |
175 |
| - |
176 |
| - //**************************************************************************** |
177 |
| - // Methods required for restarting. |
178 |
| - virtual std::string label() const { return "ArtificialViscosity"; } |
179 |
| - virtual void dumpState(FileIO& file, const std::string& pathName) const; |
180 |
| - virtual void restoreState(const FileIO& file, const std::string& pathName); |
181 |
| - //**************************************************************************** |
182 |
| - |
183 |
| - // Allow descendents to request that sigma be calculated. |
184 |
| - bool calculateSigma() const; |
185 |
| - void calculateSigma(bool value); |
186 |
| - |
187 |
| -protected: |
188 |
| - //--------------------------- Protected Interface ---------------------------// |
189 |
| - Scalar mClinear; |
190 |
| - Scalar mCquadratic; |
191 |
| - RKOrder mQcorrectionOrder; |
192 |
| - |
193 |
| - // Switch for the Balsara shear correction. |
194 |
| - bool mBalsaraShearCorrection; |
195 |
| - |
196 |
| - // Generic multipliers for the linear and quadratic terms. |
197 |
| - FieldList<Dimension, Scalar> mClMultiplier, mCqMultiplier, mShearCorrection; |
198 |
| - |
199 |
| - // Parameters for the Q limiter. |
200 |
| - bool mCalculateSigma; |
201 |
| - bool mLimiterSwitch; |
202 |
| - Scalar mEpsilon2; |
203 |
| - Scalar mNegligibleSoundSpeed; |
204 |
| - Scalar mCsMultiplier; |
205 |
| - Scalar mEnergyMultiplier; |
206 |
| - FieldList<Dimension, Tensor> mSigma; |
207 |
| - FieldList<Dimension, Vector> mGradDivVelocity; |
208 |
| - |
209 |
| - // The restart registration. |
210 |
| - RestartRegistrationType mRestart; |
211 |
| - |
212 |
| - // Protected methods. |
213 |
| - virtual void calculateSigmaAndGradDivV(const DataBase<Dimension>& dataBase, |
214 |
| - const State<Dimension>& state, |
215 |
| - const StateDerivatives<Dimension>& /*derivs*/, |
216 |
| - const TableKernel<Dimension>& W, |
217 |
| - ConstBoundaryIterator boundaryBegin, |
218 |
| - ConstBoundaryIterator boundaryEnd); |
219 |
| - |
220 |
| -private: |
221 |
| - //--------------------------- Private Interface ---------------------------// |
222 |
| - ArtificialViscosity(); |
223 |
| - ArtificialViscosity(const ArtificialViscosity&); |
224 |
| - ArtificialViscosity& operator=(const ArtificialViscosity&) const; |
| 35 | + const TableKernel<Dimension>& kernel): ArtificialViscosityHandle<Dimension>(Clinear, Cquadratic, kernel) {} |
| 36 | + virtual ~ArtificialViscosity() = default; |
| 37 | + |
| 38 | + // No default constructor, copying, or assignment |
| 39 | + ArtificialViscosity() = delete; |
| 40 | + ArtificialViscosity(const ArtificialViscosity&) = delete; |
| 41 | + ArtificialViscosity& operator=(const ArtificialViscosity&) = delete; |
| 42 | + |
| 43 | + //........................................................................... |
| 44 | + // Virtual methods we expect ArtificialViscosities to provide |
| 45 | + // Required method returning the type_index of the descendant QPiType |
| 46 | + virtual std::type_index QPiTypeIndex() const override { return std::type_index(typeid(QPiType)); } |
| 47 | + |
| 48 | + // All ArtificialViscosities must provide the pairwise QPi term (pressure/rho^2) |
| 49 | + // Returns the pair values QPiij and QPiji by reference as the first two arguments. |
| 50 | + // Note the final FieldLists (fCl, fCQ, DvDx) should be the special versions registered |
| 51 | + // by the ArtficialViscosity (particularly DvDx). |
| 52 | + virtual void QPiij(QPiType& QPiij, QPiType& QPiji, // result for QPi (Q/rho^2) |
| 53 | + Scalar& Qij, Scalar& Qji, // result for viscous pressure |
| 54 | + const unsigned nodeListi, const unsigned i, |
| 55 | + const unsigned nodeListj, const unsigned j, |
| 56 | + const Vector& xi, |
| 57 | + const SymTensor& Hi, |
| 58 | + const Vector& etai, |
| 59 | + const Vector& vi, |
| 60 | + const Scalar rhoi, |
| 61 | + const Scalar csi, |
| 62 | + const Vector& xj, |
| 63 | + const SymTensor& Hj, |
| 64 | + const Vector& etaj, |
| 65 | + const Vector& vj, |
| 66 | + const Scalar rhoj, |
| 67 | + const Scalar csj, |
| 68 | + const FieldList<Dimension, Scalar>& fCl, |
| 69 | + const FieldList<Dimension, Scalar>& fCq, |
| 70 | + const FieldList<Dimension, Tensor>& DvDx) const = 0; |
225 | 71 | };
|
226 | 72 |
|
227 | 73 | }
|
228 | 74 |
|
229 |
| -#include "ArtificialViscosityInline.hh" |
230 |
| - |
231 | 75 | #endif
|
0 commit comments