8000 Bugfix/initialize problem startup dependencies by jmikeowen · Pull Request #261 · LLNL/spheral · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Bugfix/initialize problem startup dependencies #261

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

Merged
merged 5 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
Version vX.Y.Z -- Release date xxxx-xx-xx
==============================================
* Important Notes:
*

Notable changes include:

* New features/ API changes:
* Adding an optional second-stage problem start-up hook to the Physics package interface: Physics::initializeProblemStartupDependencies. The idea is to keep basic sizing
of arrays and such in the first stage (Physics::initializeProblemStartup), while this new hook is used for updating any initial Physics state (and therefore provides a
State and StateDerivatives object).

* Build changes / improvements:
*

* Bug Fixes / improvements:
* Fixed bug with ConstantBoundary in the presence of porosity with the new porosity models introduced in v2024.01.00.

Version v2024.01.00 -- Release date 2024-01-19
==============================================
* Important Notes:
Expand Down
30 changes: 15 additions & 15 deletions src/ArtificialViscosity/CullenDehnenViscosity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ initializeProblemStartup(DataBase<Dimension>& dataBase) {
mR = dataBase.newFluidFieldList(0.0, "mR");
mVsig = dataBase.newFluidFieldList(0.0, "mVsig");

FieldList<Dimension, Scalar>& rvQ = myq.CqMultiplier();
FieldList<Dimension, Scalar>& rvL = myq.ClMultiplier();
auto& rvQ = myq.CqMultiplier();
auto& rvL = myq.ClMultiplier();
rvQ = dataBase.newFluidFieldList(malphMin, HydroFieldNames::ArtificialViscousCqMultiplier); // This will override the Q initializer intializing these to unity.
rvL = dataBase.newFluidFieldList(malphMin, HydroFieldNames::ArtificialViscousClMultiplier);
}
Expand All @@ -104,17 +104,17 @@ void
CullenDehnenViscosity<Dimension>::
registerState(DataBase<Dimension>& dataBase,
State<Dimension>& state) {
dataBase.resizeFluidFieldList(mPrevDvDt, Vector::zero, "mPrevDvDt", false);
dataBase.resizeFluidFieldList(mPrevDivV, 0.0, "mPrevDivV", false);
dataBase.resizeFluidFieldList(mCullAlpha, 1.0, "mCullAlpha", false);
CHECK(mPrevDvDt.numFields() == dataBase.numFluidNodeLists());
CHECK(mPrevDivV.numFields() == dataBase.numFluidNodeLists());
CHECK(mCullAlpha.numFields() == dataBase.numFluidNodeLists());
state.enroll(mPrevDvDt);
state.enroll(mPrevDivV);
state.enroll(mCullAlpha);

FieldList<Dimension, Scalar>& rvAlphaQ = myq.CqMultiplier();
FieldList<Dimension, Scalar>& rvAlphaL = myq.ClMultiplier();
state.enroll(rvAlphaQ, std::make_shared<IncrementCullenMultipliers<Dimension>>(malphMin, malphMax, mboolHopkins));
state.enroll(rvAlphaL);
auto& rvQ = myq.CqMultiplier();
auto& rvL = myq.ClMultiplier();
state.enroll(rvQ, make_policy<IncrementCullenMultipliers<Dimension>>(malphMin, malphMax, mboolHopkins));
state.enroll(rvL);
}

//------------------------------------------------------------------------------
Expand All @@ -125,12 +125,12 @@ void
CullenDehnenViscosity<Dimension>::
registerDerivatives(DataBase<Dimension>& dataBase,
StateDerivatives<Dimension>& derivs) {
dataBase.resizeFluidFieldList(mPrevDivV2, 0.0, "mPrevDivV2", false);
dataBase.resizeFluidFieldList(mCullAlpha2, 1.0, "mCullAlpha2", false);
dataBase.resizeFluidFieldList(mDalphaDt, 0.0, "mDalphaDt", false);
dataBase.resizeFluidFieldList(mAlphaLocal, 0.0, "mAlphaLocal", false);
dataBase.resizeFluidFieldList(mR, 0.0, "mR", false);
dataBase.resizeFluidFieldList(mVsig, 0.0, "mVsig", false);
CHECK(mPrevDivV2.numFields() == dataBase.numFluidNodeLists());
CHECK(mCullAlpha2.numFields() == dataBase.numFluidNodeLists());
CHECK(mDalphaDt.numFields() == dataBase.numFluidNodeLists());
CHECK(mAlphaLocal.numFields() == dataBase.numFluidNodeLists());
CHECK(mR.numFields() == dataBase.numFluidNodeLists());
CHECK(mVsig.numFields() == dataBase.numFluidNodeLists());
derivs.enroll(mPrevDivV2);
derivs.enroll(mCullAlpha2);
derivs.enroll(mDalphaDt);
Expand Down
12 changes: 6 additions & 6 deletions src/ArtificialViscosity/MorrisMonaghanReducingViscosity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ template<typename Dimension>
void
MorrisMonaghanReducingViscosity<Dimension>::
initializeProblemStartup(DataBase<Dimension>& dataBase) {
FieldList<Dimension, Scalar>& rvQ = myq.CqMultiplier();
FieldList<Dimension, Scalar>& rvL = myq.ClMultiplier();
auto& rvQ = myq.CqMultiplier();
auto& rvL = myq.ClMultiplier();
rvQ = dataBase.newFluidFieldList(0.0, HydroFieldNames::ArtificialViscousCqMultiplier); // This will override the Q initializer intializing these to unity.
rvL = dataBase.newFluidFieldList(0.0, HydroFieldNames::ArtificialViscousClMultiplier);
mDrvAlphaDtQ = dataBase.newFluidFieldList(0.0, IncrementBoundedState<Dimension, Scalar>::prefix() + HydroFieldNames::ArtificialViscousCqMultiplier);
Expand All @@ -145,10 +145,10 @@ void
MorrisMonaghanReducingViscosity<Dimension>::
registerState(DataBase<Dimension>& /*dataBase*/,
State<Dimension>& state) {
FieldList<Dimension, Scalar>& rvQ = myq.CqMultiplier();
FieldList<Dimension, Scalar>& rvL = myq.ClMultiplier();
state.enroll(rvQ, std::make_shared<IncrementBoundedState<Dimension, Scalar>>(maMin,maMax));
state.enroll(rvL, std::make_shared<IncrementBoundedState<Dimension, Scalar>>(maMin,maMax));
auto& rvQ = myq.CqMultiplier();
auto& rvL = myq.ClMultiplier();
state.enroll(rvQ, make_policy<IncrementBoundedState<Dimension, Scalar>>(maMin,maMax));
state.enroll(rvL, make_policy<IncrementBoundedState<Dimension, Scalar>>(maMin,maMax));
}

//------------------------------------------------------------------------------
Expand Down
13 changes: 7 additions & 6 deletions src/CRKSPH/CRKSPHHydroBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "DataBase/IncrementBoundedState.hh"
#include "DataBase/ReplaceState.hh"
#include "DataBase/ReplaceBoundedState.hh"
#include "DataBase/updateStateFields.hh"
#include "Hydro/SpecificThermalEnergyPolicy.hh"
#include "Hydro/SpecificFromTotalThermalEnergyPolicy.hh"
#include "Hydro/PressurePolicy.hh"
Expand Down Expand Up @@ -149,12 +150,14 @@ CRKSPHHydroBase<Dimension>::
template<typename Dimension>
void
CRKSPHHydroBase<Dimension>::
initializeProblemStartup(DataBase<Dimension>& dataBase) {
initializeProblemStartupDependencies(DataBase<Dimension>& dataBase,
State<Dimension>& state,
StateDerivatives<Dimension>& derivs) {

// Initialize the pressure, sound speed, and entropy.
dataBase.fluidPressure(mPressure);
dataBase.fluidSoundSpeed(mSoundSpeed);
dataBase.fluidEntropy(mEntropy);
updateStateFields<Dimension>(HydroFieldNames::pressure, state, derivs);
updateStateFields<Dimension>(HydroFieldNames::soundSpeed, state, derivs);
updateStateFields<Dimension>(HydroFieldNames::entropy, state, derivs);
}

//------------------------------------------------------------------------------
Expand All @@ -168,8 +171,6 @@ registerState(DataBase<Dimension>& dataBase,

// Create the local storage for time step mask, pressure, sound speed, and correction fields.
dataBase.resizeFluidFieldList(mTimeStepMask, 1, HydroFieldNames::timeStepMask);
// dataBase.fluidPressure(mPressure);
// dataBase.fluidSoundSpeed(mSoundSpeed);
dataBase.resizeFluidFieldList(mEntropy, 0.0, HydroFieldNames::entropy, false);
dataBase.resizeFluidFieldList(mPressure, 0.0, HydroFieldNames::pressure, false);
dataBase.resizeFluidFieldList(mSoundSpeed, 0.0, HydroFieldNames::soundSpeed, false);
Expand Down
4 changes: 3 additions & 1 deletion src/CRKSPH/CRKSPHHydroBase.hh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public:

// Tasks we do once on problem startup.
virtual
void initializeProblemStartup(DataBase<Dimension>& dataBase) override;
void initializeProblemStartupDependencies(DataBase<Dimension>& dataBase,
State<Dimension>& state,
StateDerivatives<Dimension>& derivs) override;

// Register the state Hydro expects to use and evolve.
virtual
Expand Down
19 changes: 14 additions & 5 deletions src/CRKSPH/CRKSPHHydroBaseRZ.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,19 @@ CRKSPHHydroBaseRZ::
//------------------------------------------------------------------------------
void
CRKSPHHydroBaseRZ::
initializeProblemStartup(DataBase<Dim<2> >& dataBase) {

initializeProblemStartup(DataBase<Dim<2>>& dataBase) {
GeometryRegistrar::coords(CoordinateType::RZ);
}

//------------------------------------------------------------------------------
// On problem start up some dependent state needs to be calculated
//------------------------------------------------------------------------------
void
CRKSPHHydroBaseRZ::
initializeProblemStartupDependencies(DataBase<Dim<2>>& dataBase,
State<Dim<2>>& state,
StateDerivatives<Dim<2>>& derivs) {

// Correct the mass to mass/r.
auto mass = dataBase.fluidMass();
const auto pos = dataBase.fluidPosition();
Expand All @@ -121,7 +130,7 @@ initializeProblemStartup(DataBase<Dim<2> >& dataBase) {
}

// Do general initializations.
CRKSPHHydroBase<Dim<2> >::initializeProblemStartup(dataBase);
CRKSPHHydroBase<Dim<2> >::initializeProblemStartupDependencies(dataBase, state, derivs);

// Convert back to mass.
for (unsigned nodeListi = 0; nodeListi != numNodeLists; ++nodeListi) {
Expand All @@ -138,8 +147,8 @@ initializeProblemStartup(DataBase<Dim<2> >& dataBase) {
//------------------------------------------------------------------------------
void
CRKSPHHydroBaseRZ::
registerState(DataBase<Dim<2> >& dataBase,
State<Dim<2> >& state) {
registerState(DataBase<Dim<2>>& dataBase,
State<Dim<2>>& state) {

// The base class does most of it.
CRKSPHHydroBase<Dim<2> >::registerState(dataBase, state);
Expand Down
16 changes: 13 additions & 3 deletions src/CRKSPH/CRKSPHHydroBaseRZ.hh
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,19 @@ public:
// Destructor.
virtual ~CRKSPHHydroBaseRZ();

// Tasks we do once on problem startup.
virtual
void initializeProblemStartup(DataBase<Dimension>& dataBase) override;
// An optional hook to initialize once when the problem is starting up.
// Typically this is used to size arrays once all the materials and NodeLists have
// been created. It is assumed after this method has been called it is safe to
// call Physics::registerState for instance to create full populated State objects.
virtual void initializeProblemStartup(DataBase<Dimension>& dataBase) override;

// A second optional method to be called on startup, after Physics::initializeProblemStartup has
// been called.
// One use for this hook is to fill in dependendent state using the State object, such as
// temperature or pressure.
virtual void initializeProblemStartupDependencies(DataBase<Dimension>& dataBase,
State<Dimension>& state,
StateDerivatives<Dimension>& derivs) override;

// Register the state Hydro expects to use and evolve.
virtual
Expand Down
Loading
0