Skip to content

Commit 508fabe

Browse files
authored
Merge pull request #317 from LLNL/feature/ArtificialViscosityPackage
Splitting Artificial viscosity out of hydrodynamics packages into its own physics package
2 parents 4a1c0ab + 8896de7 commit 508fabe

File tree

319 files changed

+8386
-11539
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

319 files changed

+8386
-11539
lines changed

RELEASE_NOTES.md

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ Notable changes include:
3434
is correct.
3535
* Performance regression testing is now available. All developers are encouraged to run the performance testing suite for any code changes that might impact performance. See documentation for more details.
3636
* Added our old ASPH IdealH H update as an option. While it is not as reliable as our current default ASPH, it does not require building the Voronoi and is therefore signifcantly faster.
37+
* Converted artificial viscosities to Physics packages, and add them as pre-subpackages to Hydro objects.
38+
* Split artificial viscosities based on the type of pressure they compute (currently Scalar or Tensor), which is slightly more efficient.
39+
* This required making the hydro packages evaluateDerivatives into templated methods based on the type of Q they are handed.
40+
* Also introduced a new base class (ArtificialViscosityHandle), which provides a handle class not templated on the type
41+
of Q pressure for Hydro objects to hold onto.
3742
3843
* Build changes / improvements:
3944
* Distributed source directory must always be built now.

scripts/devtools/performance_analysis.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def get_caliper_files(file_path):
255255
th.stats.std(rtest, metrics)
256256
# Compute the max allowable time for the main region
257257
ctest.statsframe.dataframe["thresh"] = compute_threshold(rtest.statsframe, metric0)
258-
ctest.move_metrics_to_statsframe([metric0])
258+
ctest.move_metrics_to_statsframe([metric0,metric1])
259259
ref_main = get_times(rtest.statsframe, "main", metric0+"_mean")[0]
260260
cur_main = get_times(ctest.statsframe, "main", metric0)[0]
261261
ref_thresh = get_times(ctest.statsframe, "main", "thresh")[0]

src/ArtificialViscosity/ArtificialViscosity.cc

-438
This file was deleted.

src/ArtificialViscosity/ArtificialViscosity.hh

+51-207
Original file line numberDiff line numberDiff line change
@@ -2,230 +2,74 @@
22
// ArtificialViscosity -- The base class for all ArtificialViscosities in
33
// Spheral++.
44
//
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+
//
59
// Created by JMO, Sun May 21 21:16:43 PDT 2000
610
//----------------------------------------------------------------------------//
711
#ifndef __Spheral_ArtificialViscosity__
812
#define __Spheral_ArtificialViscosity__
913

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"
3015

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>
3818

3919
namespace Spheral {
4020

41-
template<typename Dimension>
42-
class ArtificialViscosity {
21+
template<typename Dimension, typename QPiType>
22+
class ArtificialViscosity: public ArtificialViscosityHandle<Dimension> {
4323
public:
4424
//--------------------------- 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;
5029

51-
typedef typename std::vector<Boundary<Dimension>*>::const_iterator ConstBoundaryIterator;
30+
using ReturnType = QPiType;
5231

53-
// Constructors.
32+
// Constructors, destructor
5433
ArtificialViscosity(const Scalar Clinear,
5534
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;
22571
};
22672

22773
}
22874

229-
#include "ArtificialViscosityInline.hh"
230-
23175
#endif

0 commit comments

Comments
 (0)