Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Splitting Artificial viscosity out of hydrodynamics packages into its own physics package #317

Draft
wants to merge 72 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
30d1444
Moving grad-h corrections to SPH::postStateUpdate to avoid mixing tim…
jmikeowen Nov 18, 2024
af2c1b1
Parameter change in interpolation kernel (no real change)
jmikeowen Nov 19, 2024
9a22af9
Converted NodePairList storage in ConnectivityMap to be a shared_ptr
jmikeowen Nov 20, 2024
faf2546
Convert NodePairList to use size_t
jmikeowen Nov 21, 2024
e510788
Split up the NodePairIdxType and NodePairList into separate headers,
jmikeowen Nov 21, 2024
d83759d
Initial introduction of PairwiseField. Also split out NodePairIdxType
jmikeowen Nov 21, 2024
d3093c2
Using the pair->index lookup computed by NodePairList
jmikeowen Nov 21, 2024
f8ac3a9
Interim checkin
jmikeowen Nov 22, 2024
6a5c976
Lot of renaming
jmikeowen Nov 22, 2024
7b55da6
Converting SPH classes to use PairwiseField for pair-accelerations.
jmikeowen Nov 26, 2024
f41931e
Updating Python front-end constructor
jmikeowen Nov 26, 2024
56c4dd8
Initial conversion of SPH PYB11 package (untested)
jmikeowen Nov 26, 2024
04af076
Updating thermal energy policies for PairwiseField use
jmikeowen Nov 26, 2024
7f339ad
Fixing some DataTypeTraits zeros, and making Python better respect co…
jmikeowen Nov 27, 2024
0a08b64
SPH can now run using PairwiseField for pair accelerations, but the i…
jmikeowen Nov 27, 2024
b47d696
Merge branch 'develop' into bugfix/EvalDerivCleanup
jmikeowen Nov 27, 2024
83c46a1
Making State and StateDerivatives not default constructable
jmikeowen Nov 27, 2024
92f85b8
Changing initialization order in Integrators and DataBase such that
jmikeowen Nov 28, 2024
11d4e8a
Clean up unused method
jmikeowen Nov 28, 2024
89bd714
Fixing a comment in SPH, and starting to convert CRK
jmikeowen Dec 2, 2024
844414a
Simplifying dependencies for postion update, eps, and RZ cases
jmikeowen Dec 2, 2024
da23e11
Initial conversion of CRKSPH to newer interface with PairwiseField
jmikeowen Dec 3, 2024
6cc6e02
Some SPH fixes with new interface
jmikeowen Dec 3, 2024
e576f2e
PSPH needs to start inconsistently (need to fix this)
jmikeowen Dec 3, 2024
28625e3
Got PSPH functioning
jmikeowen Dec 3, 2024
2aa7d14
FSISPH converted to PairwiseFields
jmikeowen Dec 3, 2024
09fc429
Converted GSPH to PairwiseField
jmikeowen Dec 4, 2024
909bacb
Moved how we build the State to be robust when not running a full
jmikeowen Dec 4, 2024
2f09aeb
Removed unused option filter
jmikeowen Dec 4, 2024
6ebdba6
Fixed incorrect contract
jmikeowen Dec 4, 2024
5b48f65
Adding a getPtr method that never throws -- just returns nullptr on f…
jmikeowen Dec 4, 2024
b7a6e3d
Fix for running non-compatible energy (can't get the pairAccelerations
jmikeowen Dec 4, 2024
24bdd33
Checkpoint
jmikeowen Dec 11, 2024
3d68c02
- Converted all viscosities to Physics packages
jmikeowen Dec 12, 2024
5d0c2f2
Rearranging a bit
jmikeowen Dec 13, 2024
c797ebf
Missed some necessary overrides for TensorCRKSPHViscosity
jmikeowen Dec 13, 2024
01a29ea
Initial update of Python bindings -- not compiled yet
jmikeowen Dec 13, 2024
f7ed821
Introducing ArtficialViscosityHandle to split off QPiType template
jmikeowen Dec 13, 2024
d7f5414
Adding back effective viscous pressure
jmikeowen Dec 13, 2024
0020b93
FSI conversion
jmikeowen Dec 13, 2024
1eb7d44
Initial conversion of SPH
jmikeowen Dec 14, 2024
99c2cd7
Converted CRK C++
jmikeowen Dec 14, 2024
3ba2735
Compiles and links
jmikeowen Dec 16, 2024
e548163
Planar Noh tests are passing
jmikeowen Dec 17, 2024
47d0b1a
Working through failing tests
jmikeowen Dec 17, 2024
1cc320e
Fixed outdated graphics
jmikeowen Dec 17, 2024
ee65a90
Moving initialization of AV FieldList sizes to initializeProblemStartup
jmikeowen Dec 17, 2024
5268d73
Updating for interface change to Morris-Monaghan and Cullen-Dehnen
jmikeowen Dec 17, 2024
f66f675
Fix for spherical geometry
jmikeowen Dec 17, 2024
db68a19
Clean up warnings in optimized build
jmikeowen Dec 17, 2024
fc6b8c4
Removing redundant Q constructor in test
jmikeowen Dec 18, 2024
9b04100
Updated release notes
jmikeowen Dec 18, 2024
f43682c
Merge branch 'develop' into feature/ArtificialViscosityPackage
jmikeowen Dec 18, 2024
f2c49dd
Cleaning up State and StateDerivatives a bit, and allowing default co…
jmikeowen Dec 18, 2024
dc02ef4
Changing DataBase::nodeListIndex to use size_t
jmikeowen Dec 18, 2024
a9b825b
During initialization we have to be careful about recreating
jmikeowen Dec 18, 2024
fed1318
On BlueOS with gcc we have some problem with using "any" without the
jmikeowen Dec 19, 2024
77ef956
Cleaning up warnings
jmikeowen Dec 19, 2024
8cd72bf
More warning cleanup
jmikeowen Dec 19, 2024
4c3963e
Compile fix for blueos
jmikeowen Dec 20, 2024
c93a65a
Making NodePairList::Pair2Index lazy evaluation gets back most of the
jmikeowen Dec 20, 2024
2b06fd7
Making PairwiseField allow more than one Value per pair as an optional
jmikeowen Dec 21, 2024
8626700
Merge branch 'develop' into feature/ArtificialViscosityPackage
jmikeowen Jan 31, 2025
e3629ab
Parameter tweaking
jmikeowen Feb 1, 2025
0ffb2b6
MFV not working quite right
jmikeowen Feb 1, 2025
2b0db32
Adding header to CMakeLists install files
jmikeowen Feb 3, 2025
ecca719
Another missing header
jmikeowen Feb 3, 2025
05016e5
Updating test reference data
jmikeowen Feb 3, 2025
3117d30
Adding damage coupling as parameter
jmikeowen Feb 4, 2025
e68c993
Experimenting with using the Python yep module to get perftools style
jmikeowen Feb 5, 2025
bd7dff8
Using reserve on NodePairList to preserve some idea of the size of the
jmikeowen Feb 5, 2025
9a2f5f4
Fix for CI reservation on Ruby
jmikeowen Feb 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ Notable changes include:
* Cleaned up use of std::any in State objects using a visitor pattern to be rigorous ensuring all state entries are handled properly
during assignement, equality, and cloning operations. This is intended to help ensure our Physics advance during time integration
is correct.
* Converted artificial viscosities to Physics packages, and add them as pre-subpackages to Hydro objects.
* Split artificial viscosities based on the type of pressure they compute (currently Scalar or Tensor), which is slightly more efficient.
* This required making the hydro packages evaluateDerivatives into templated methods based on the type of Q they are handed.
* Also introduced a new base class (ArtificialViscosityHandle), which provides a handle class not templated on the type
of Q pressure for Hydro objects to hold onto.

* Build changes / improvements:
* Distributed source directory must always be built now.
Expand Down
594 changes: 240 additions & 354 deletions src/ArtificialViscosity/ArtificialViscosity.cc

Large diffs are not rendered by default.

258 changes: 51 additions & 207 deletions src/ArtificialViscosity/ArtificialViscosity.hh
Original file line number Diff line number Diff line change
Expand Up @@ -2,230 +2,74 @@
// ArtificialViscosity -- The base class for all ArtificialViscosities in
// Spheral++.
//
// This intermediate class between ArtificialViscosityHandle and the actual
// artficial viscosity implementations specifies the QPi = Q/rho^2 return type,
// generally either a Scalar or a Tensor.
//
// Created by JMO, Sun May 21 21:16:43 PDT 2000
//----------------------------------------------------------------------------//
#ifndef __Spheral_ArtificialViscosity__
#define __Spheral_ArtificialViscosity__

#include <utility>

#include "Geometry/Dimension.hh"
#include "RK/RKCorrectionParams.hh"

#include <vector>
#include "Field/FieldList.hh"
#include "DataOutput/registerWithRestart.hh"

namespace Spheral {

template<typename Dimension> class AllNodeIterator;
template<typename Dimension> class InternalNodeIterator;
template<typename Dimension> class GhostNodeIterator;
template<typename Dimension> class MasterNodeIterator;
template<typename Dimension> class CoarseNodeIterator;
template<typename Dimension> class RefineNodeIterator;

template<typename Dimension> class State;
template<typename Dimension> class StateDerivatives;
#include "ArtificialViscosity/ArtificialViscosityHandle.hh"

template<typename Dimension> class DataBase;
template<typename Dimension, typename DataType> class FieldList;
class FileIO;
template<typename Dimension> class ConnectivityMap;
template<typename Dimension> class TableKernel;
template<typename Dimension> class Boundary;
}
#include <utility>
#include <typeindex>

namespace Spheral {

template<typename Dimension>
class ArtificialViscosity {
template<typename Dimension, typename QPiType>
class ArtificialViscosity: public ArtificialViscosityHandle<Dimension> {
public:
//--------------------------- Public Interface ---------------------------//
typedef typename Dimension::Scalar Scalar;
typedef typename Dimension::Vector Vector;
typedef typename Dimension::Tensor Tensor;
typedef typename Dimension::SymTensor SymTensor;
typedef typename std::pair<double, std::string> TimeStepType;
using Scalar = typename Dimension::Scalar;
using Vector = typename Dimension::Vector;
using Tensor = typename Dimension::Tensor;
using SymTensor = typename Dimension::SymTensor;

typedef typename std::vector<Boundary<Dimension>*>::const_iterator ConstBoundaryIterator;
using ReturnType = QPiType;

// Constructors.
// Constructors, destructor
ArtificialViscosity(const Scalar Clinear,
const Scalar Cquadratic,
const RKOrder QcorrectionOrder = RKOrder::LinearOrder);

// Destructor.
virtual ~ArtificialViscosity();

// Initialize the artificial viscosity for all FluidNodeLists in the given
// DataBase.
virtual void initialize(const DataBase<Dimension>& dataBase,
const State<Dimension>& state,
const StateDerivatives<Dimension>& derivs,
ConstBoundaryIterator boundaryBegin,
ConstBoundaryIterator boundaryEnd,
const Scalar /*time*/,
const Scalar /*dt*/,
const TableKernel<Dimension>& W);

// Require all descendents to return the artificial viscous Pi = P/rho^2 as a tensor.
// Scalar viscosities should just return a diagonal tensor with their value along the diagonal.
virtual std::pair<Tensor, Tensor> Piij(const unsigned nodeListi, const unsigned i,
const unsigned nodeListj, const unsigned j,
const Vector& xi,
const Vector& etai,
const Vector& vi,
const Scalar rhoi,
const Scalar csi,
const SymTensor& Hi,
const Vector& xj,
const Vector& etaj,
const Vector& vj,
const Scalar rhoj,
const Scalar csj,
const SymTensor& Hj) const = 0;

// Allow access to the linear and quadratic constants.
Scalar Cl() const;
void Cl(Scalar Cl);

Scalar Cq() const;
void Cq(Scalar Cq);

//Allow access to the Q correction order.
RKOrder QcorrectionOrder() const;
void QcorrectionOrder(RKOrder order);

// Toggle for the Balsara shear correction.
bool balsaraShearCorrection() const;
void balsaraShearCorrection(bool value);

// Calculate the curl of the velocity given the stress tensor.
Scalar curlVelocityMagnitude(const Tensor& DvDx) const;

// Access the FieldList of multiplicative corrections.
FieldList<Dimension, Scalar>& ClMultiplier();
FieldList<Dimension, Scalar>& CqMultiplier();
FieldList<Dimension, Scalar>& shearCorrection();
const FieldList<Dimension, Scalar>& ClMultiplier() const;
const FieldList<Dimension, Scalar>& CqMultiplier() const;
const FieldList<Dimension, Scalar>& shearCorrection() const;

// Access the internally computed estimate of sigma:
// sig^ab = \partial v^a / \partial x^b.
const FieldList<Dimension, Tensor>& sigma() const;

// Access the internally computed estimate of the velocity gradient and
// grad div velocity.
const FieldList<Dimension, Vector>& gradDivVelocity() const;

// Switch to turn the del^2 v limiter on/off.
bool limiter() const;
void limiter(bool value);

// Access the epsilon safety factor.
Scalar epsilon2() const;
void epsilon2(Scalar epsilon2);

// Method to return the limiter magnitude for the given node.
Tensor calculateLimiter(const Vector& /*vi*/,
const Vector& /*vj*/,
const Scalar ci,
const Scalar /*cj*/,
const Scalar hi,
const Scalar /*hj*/,
const int nodeListID,
const int nodeID) const;

// Helper for the limiter, calculate the unit grad div v term for the given
// node.
Vector shockDirection(const Scalar ci,
const Scalar hi,
const int nodeListID,
const int nodeID) const;

// The negligible sound speed parameter for use in the limiter.
Scalar negligibleSoundSpeed() const;
void negligibleSoundSpeed(Scalar val);

// The multiplier for sound speed in the limiter.
Scalar csMultiplier() const;
void csMultiplier(Scalar val);

// The multiplier for energy in the limiter.
Scalar energyMultiplier() const;
void energyMultiplier(Scalar val);

// Helper method to calculate Del cross V from the given sigma tensor.
Scalar computeDelCrossVMagnitude(const Tensor& sigma) const;

// Helper method to calculate the weighting based on the given position
// for use in the sigma calculation.
Vector sigmaWeighting(const Vector& r) const;

// Figure out the total stress-strain tensor for a given node pair based on
// the stored average value and the given (position, velocity) pair.
Tensor sigmaij(const Vector& rji,
const Vector& rjiUnit,
const Vector& vji,
const Scalar& hi2,
const int nodeListID,
const int nodeID) const;

//****************************************************************************
// Methods required for restarting.
virtual std::string label() const { return "ArtificialViscosity"; }
virtual void dumpState(FileIO& file, const std::string& pathName) const;
virtual void restoreState(const FileIO& file, const std::string& pathName);
//****************************************************************************

// Allow descendents to request that sigma be calculated.
bool calculateSigma() const;
void calculateSigma(bool value);

protected:
//--------------------------- Protected Interface ---------------------------//
Scalar mClinear;
Scalar mCquadratic;
RKOrder mQcorrectionOrder;

// Switch for the Balsara shear correction.
bool mBalsaraShearCorrection;

// Generic multipliers for the linear and quadratic terms.
FieldList<Dimension, Scalar> mClMultiplier, mCqMultiplier, mShearCorrection;

// Parameters for the Q limiter.
bool mCalculateSigma;
bool mLimiterSwitch;
Scalar mEpsilon2;
Scalar mNegligibleSoundSpeed;
Scalar mCsMultiplier;
Scalar mEnergyMultiplier;
FieldList<Dimension, Tensor> mSigma;
FieldList<Dimension, Vector> mGradDivVelocity;

// The restart registration.
RestartRegistrationType mRestart;

// Protected methods.
virtual void calculateSigmaAndGradDivV(const DataBase<Dimension>& dataBase,
const State<Dimension>& state,
const StateDerivatives<Dimension>& /*derivs*/,
const TableKernel<Dimension>& W,
ConstBoundaryIterator boundaryBegin,
ConstBoundaryIterator boundaryEnd);

private:
//--------------------------- Private Interface ---------------------------//
ArtificialViscosity();
ArtificialViscosity(const ArtificialViscosity&);
ArtificialViscosity& operator=(const ArtificialViscosity&) const;
const TableKernel<Dimension>& kernel): ArtificialViscosityHandle<Dimension>(Clinear, Cquadratic, kernel) {}
virtual ~ArtificialViscosity() = default;

// No default constructor, copying, or assignment
ArtificialViscosity() = delete;
ArtificialViscosity(const ArtificialViscosity&) = delete;
ArtificialViscosity& operator=(const ArtificialViscosity&) = delete;

//...........................................................................
// Virtual methods we expect ArtificialViscosities to provide
// Required method returning the type_index of the descendant QPiType
virtual std::type_index QPiTypeIndex() const override { return std::type_index(typeid(QPiType)); }

// All ArtificialViscosities must provide the pairwise QPi term (pressure/rho^2)
// Returns the pair values QPiij and QPiji by reference as the first two arguments.
// Note the final FieldLists (fCl, fCQ, DvDx) should be the special versions registered
// by the ArtficialViscosity (particularly DvDx).
virtual void QPiij(QPiType& QPiij, QPiType& QPiji, // result for QPi (Q/rho^2)
Scalar& Qij, Scalar& Qji, // result for viscous pressure
const unsigned nodeListi, const unsigned i,
const unsigned nodeListj, const unsigned j,
const Vector& xi,
const SymTensor& Hi,
const Vector& etai,
const Vector& vi,
const Scalar rhoi,
const Scalar csi,
const Vector& xj,
const SymTensor& Hj,
const Vector& etaj,
const Vector& vj,
const Scalar rhoj,
const Scalar csj,
const FieldList<Dimension, Scalar>& fCl,
const FieldList<Dimension, Scalar>& fCq,
const FieldList<Dimension, Tensor>& DvDx) const = 0;
};

}

#include "ArtificialViscosityInline.hh"

#endif
Loading