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

Refactor State to use std::any and a more rigorous update pattern #315

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .gitlab/os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
.on_blueos_3_ppc64:
variables:
ARCH: 'blueos_3_ppc64le_ib_p9'
GCC_VERSION: '8.3.1'
GCC_VERSION: '10.2.1'
CLANG_VERSION: '9.0.0'
SPHERAL_BUILDS_DIR: /p/gpfs1/sphapp/spheral-ci-builds
extends: [.sys_config]
Expand Down
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ Notable changes include:
* Physics packages can indicate if they require Voronoi cell information be available. If so, a new package which computes and
updates the Voronoi information is automatically added to the package list by the SpheralController (similar to how the
Reproducing Kernel corrections are handled).
* 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.

* Build changes / improvements:
* Distributed source directory must always be built now.
Expand Down
6 changes: 3 additions & 3 deletions scripts/devtools/spec-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
]
,
"blueos_3_ppc64le_ib_p9": [
"gcc@8.3.1",
"gcc@8.3.1+cuda~mpi cuda_arch=70",
"gcc@8.3.1+cuda cuda_arch=70"
"gcc@10.2.1",
"gcc@10.2.1+cuda~mpi cuda_arch=70",
"gcc@10.2.1+cuda cuda_arch=70"
]
}
}
10 changes: 5 additions & 5 deletions scripts/spack/configs/blueos_3_ppc64le_ib/compilers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ compilers:
environment: {}
extra_rpaths: []
- compiler:
spec: gcc@8.3.1
spec: gcc@10.2.1
paths:
cc: /usr/tce/packages/gcc/gcc-8.3.1/bin/gcc
cxx: /usr/tce/packages/gcc/gcc-8.3.1/bin/g++
f77: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran
fc: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran
cc: /usr/tce/packages/gcc/gcc-10.2.1/bin/gcc
cxx: /usr/tce/packages/gcc/gcc-10.2.1/bin/g++
f77: /usr/tce/packages/gcc/gcc-10.2.1/bin/gfortran
fc: /usr/tce/packages/gcc/gcc-10.2.1/bin/gfortran
flags: {}
operating_system: rhel7
target: ppc64le
Expand Down
2 changes: 2 additions & 0 deletions scripts/spack/configs/blueos_3_ppc64le_ib/packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ packages:
- 10.1.243
buildable: false
externals:
- spec: [email protected]+allow-unsupported-compilers
prefix: /usr/tce/packages/cuda/cuda-11.4.1
- spec: [email protected]~allow-unsupported-compilers
prefix: /usr/tce/packages/cuda/cuda-11.1.0
- spec: [email protected]~allow-unsupported-compilers
Expand Down
4 changes: 2 additions & 2 deletions src/ArtificialConduction/ArtificialConduction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ evaluateDerivatives(const typename Dimension::Scalar /*time*/,
ReproducingKernel<Dimension> WR;
auto maxOrder = RKOrder::ZerothOrder;
if (useRK) {
const auto& rkOrders = state.template getAny<std::set<RKOrder>>(RKFieldNames::rkOrders);
const auto& rkOrders = state.template get<std::set<RKOrder>>(RKFieldNames::rkOrders);
CHECK(not rkOrders.empty());
const auto maxOrder = *rkOrders.rbegin();
WR = state.template getAny<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(maxOrder));
WR = state.template get<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(maxOrder));
}

// The connectivity map
Expand Down
2 changes: 1 addition & 1 deletion src/ArtificialViscosity/TensorCRKSPHViscosity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ calculateSigmaAndGradDivV(const DataBase<Dimension>& dataBase,
const auto velocity = state.fields(HydroFieldNames::velocity, Vector::zero);
const auto rho = state.fields(HydroFieldNames::massDensity, 0.0);
const auto H = state.fields(HydroFieldNames::H, SymTensor::zero);
const auto WR = state.template getAny<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(order));
const auto WR = state.template get<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(order));
const auto corrections = state.fields(RKFieldNames::rkCorrections(order), RKCoefficients<Dimension>());

const auto& connectivityMap = dataBase.connectivityMap();
Expand Down
2 changes: 1 addition & 1 deletion src/ArtificialViscosity/VonNeumanViscosity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ initialize(const DataBase<Dimension>& dataBase,
const auto pressure = state.fields(HydroFieldNames::pressure, 0.0);
const auto soundSpeed = state.fields(HydroFieldNames::soundSpeed, 0.0);
const auto vol = mass/massDensity;
const auto WR = state.template getAny<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(order));
const auto WR = state.template get<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(order));
const auto corrections = state.fields(RKFieldNames::rkCorrections(order), RKCoefficients<Dimension>());

// We'll compute the higher-accuracy RK gradient.
Expand Down
4 changes: 2 additions & 2 deletions src/CRKSPH/CRKSPHEvaluateDerivatives.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ evaluateDerivatives(const typename Dimension::Scalar /*time*/,
auto& Q = this->artificialViscosity();

// The kernels and such.
const auto& WR = state.template getAny<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(mOrder));
const auto& WR = state.template get<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(mOrder));

// A few useful constants we'll use in the following loop.
//const double tiny = 1.0e-30;
Expand Down Expand Up @@ -65,7 +65,7 @@ evaluateDerivatives(const typename Dimension::Scalar /*time*/,
auto maxViscousPressure = derivatives.fields(HydroFieldNames::maxViscousPressure, 0.0);
auto effViscousPressure = derivatives.fields(HydroFieldNames::effectiveViscousPressure, 0.0);
auto viscousWork = derivatives.fields(HydroFieldNames::viscousWork, 0.0);
auto& pairAccelerations = derivatives.getAny(HydroFieldNames::pairAccelerations, vector<Vector>());
auto& pairAccelerations = derivatives.get(HydroFieldNames::pairAccelerations, vector<Vector>());
auto XSPHDeltaV = derivatives.fields(HydroFieldNames::XSPHDeltaV, Vector::zero);
CHECK(DxDt.size() == numNodeLists);
CHECK(DrhoDt.size() == numNodeLists);
Expand Down
6 changes: 3 additions & 3 deletions src/CRKSPH/CRKSPHHydroBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ registerDerivatives(DataBase<Dimension>& dataBase,
derivs.enroll(mDspecificThermalEnergyDt);
derivs.enroll(mDvDx);
derivs.enroll(mInternalDvDx);
derivs.enrollAny(HydroFieldNames::pairAccelerations, mPairAccelerations);
derivs.enroll(HydroFieldNames::pairAccelerations, mPairAccelerations);
}

//------------------------------------------------------------------------------
Expand All @@ -282,7 +282,7 @@ preStepInitialize(const DataBase<Dimension>& dataBase,
if (mDensityUpdate == MassDensityType::RigorousSumDensity or
mDensityUpdate == MassDensityType::VoronoiCellDensity) {
auto massDensity = state.fields(HydroFieldNames::massDensity, 0.0);
const auto& WR = state.template getAny<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(mOrder));
const auto& WR = state.template get<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(mOrder));
const auto& W = WR.kernel();
const auto& connectivityMap = dataBase.connectivityMap();
const auto mass = state.fields(HydroFieldNames::mass, 0.0);
Expand Down Expand Up @@ -311,7 +311,7 @@ initialize(const typename Dimension::Scalar time,
State<Dimension>& state,
StateDerivatives<Dimension>& derivs) {
// Initialize the artificial viscosity
const auto& WR = state.template getAny<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(mOrder));
const auto& WR = state.template get<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(mOrder));
auto& Q = this->artificialViscosity();
Q.initialize(dataBase,
state,
Expand Down
4 changes: 2 additions & 2 deletions src/CRKSPH/CRKSPHHydroBaseRZ.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ evaluateDerivatives(const Dim<2>::Scalar /*time*/,

// The kernels and such.
//const auto order = this->correctionOrder();
const auto& WR = state.template getAny<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(mOrder));
const auto& WR = state.template get<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(mOrder));

// A few useful constants we'll use in the following loop.
//const auto tiny = 1.0e-30;
Expand Down Expand Up @@ -263,7 +263,7 @@ evaluateDerivatives(const Dim<2>::Scalar /*time*/,
auto maxViscousPressure = derivatives.fields(HydroFieldNames::maxViscousPressure, 0.0);
auto effViscousPressure = derivatives.fields(HydroFieldNames::effectiveViscousPressure, 0.0);
auto viscousWork = derivatives.fields(HydroFieldNames::viscousWork, 0.0);
auto& pairAccelerations = derivatives.getAny(HydroFieldNames::pairAccelerations, vector<Vector>());
auto& pairAccelerations = derivatives.get(HydroFieldNames::pairAccelerations, vector<Vector>());
auto XSPHDeltaV = derivatives.fields(HydroFieldNames::XSPHDeltaV, Vector::zero);
CHECK(DxDt.size() == numNodeLists);
CHECK(DrhoDt.size() == numNodeLists);
Expand Down
4 changes: 2 additions & 2 deletions src/CRKSPH/SolidCRKSPHHydroBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ evaluateDerivatives(const typename Dimension::Scalar /*time*/,

// The kernels and such.
const auto order = this->correctionOrder();
const auto& WR = state.template getAny<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(order));
const auto& WR = state.template get<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(order));

// A few useful constants we'll use in the following loop.
//const double tiny = 1.0e-30;
Expand Down Expand Up @@ -318,7 +318,7 @@ evaluateDerivatives(const typename Dimension::Scalar /*time*/,
auto maxViscousPressure = derivatives.fields(HydroFieldNames::maxViscousPressure, 0.0);
auto effViscousPressure = derivatives.fields(HydroFieldNames::effectiveViscousPressure, 0.0);
auto viscousWork = derivatives.fields(HydroFieldNames::viscousWork, 0.0);
auto& pairAccelerations = derivatives.getAny(HydroFieldNames::pairAccelerations, vector<Vector>());
auto& pairAccelerations = derivatives.get(HydroFieldNames::pairAccelerations, vector<Vector>());
auto XSPHDeltaV = derivatives.fields(HydroFieldNames::XSPHDeltaV, Vector::zero);
auto DSDt = derivatives.fields(IncrementState<Dimension, SymTensor>::prefix() + SolidFieldNames::deviatoricStress, SymTensor::zero);
CHECK(DxDt.size() == numNodeLists);
Expand Down
4 changes: 2 additions & 2 deletions src/CRKSPH/SolidCRKSPHHydroBaseRZ.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ evaluateDerivatives(const Dim<2>::Scalar /*time*/,

// The kernels and such.
const auto order = this->correctionOrder();
const auto& WR = state.template getAny<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(order));
const auto& WR = state.template get<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(order));

// A few useful constants we'll use in the following loop.
//const double tiny = 1.0e-30;
Expand Down Expand Up @@ -334,7 +334,7 @@ evaluateDerivatives(const Dim<2>::Scalar /*time*/,
auto maxViscousPressure = derivatives.fields(HydroFieldNames::maxViscousPressure, 0.0);
auto effViscousPressure = derivatives.fields(HydroFieldNames::effectiveViscousPressure, 0.0);
auto viscousWork = derivatives.fields(HydroFieldNames::viscousWork, 0.0);
auto& pairAccelerations = derivatives.getAny(HydroFieldNames::pairAccelerations, vector<Vector>());
auto& pairAccelerations = derivatives.get(HydroFieldNames::pairAccelerations, vector<Vector>());
auto XSPHDeltaV = derivatives.fields(HydroFieldNames::XSPHDeltaV, Vector::zero);
auto DSDt = derivatives.fields(IncrementState<Dimension, SymTensor>::prefix() + SolidFieldNames::deviatoricStress, SymTensor::zero);
CHECK(DxDt.size() == numNodeLists);
Expand Down
2 changes: 1 addition & 1 deletion src/DEM/IncrementPairFieldList.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ update(const KeyType& key,
// Find all the available matching derivative FieldList keys.
const auto incrementKey = prefix() + fieldKey;
// cerr << "IncrementPairFieldList: [" << fieldKey << "] [" << incrementKey << "] : " << endl;
const auto allkeys = derivs.fieldKeys();
const auto allkeys = derivs.fullFieldKeys();
vector<string> incrementKeys;
for (const auto& key: allkeys) {
// if (std::regex_search(key, std::regex("^" + incrementKey))) {
Expand Down
6 changes: 3 additions & 3 deletions src/DEM/SolidBoundary/CircularPlaneSolidBoundary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ registerState(DataBase<Dimension>& dataBase,
const auto pointKey = boundaryKey +"_point";
const auto velocityKey = boundaryKey +"_velocity";
const auto normalKey = boundaryKey +"_normal";
state.enrollAny(pointKey,mPoint);
state.enrollAny(pointKey,mVelocity);
state.enrollAny(pointKey,mNormal);
state.enroll(pointKey,mPoint);
state.enroll(pointKey,mVelocity);
state.enroll(pointKey,mNormal);
}

template<typename Dimension>
Expand Down
6 changes: 3 additions & 3 deletions src/DEM/SolidBoundary/ClippedSphereSolidBoundary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ registerState(DataBase<Dimension>& dataBase,
const auto clipPointKey = boundaryKey +"_clipPoint";
const auto velocityKey = boundaryKey +"_velocity";

state.enrollAny(pointKey,mCenter);
state.enrollAny(clipPointKey,mClipPoint);
state.enrollAny(pointKey,mVelocity);
state.enroll(pointKey,mCenter);
state.enroll(clipPointKey,mClipPoint);
state.enroll(pointKey,mVelocity);

}

Expand Down
6 changes: 3 additions & 3 deletions src/DEM/SolidBoundary/CylinderSolidBoundary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ registerState(DataBase<Dimension>& dataBase,
const auto pointKey = boundaryKey +"_point";
const auto velocityKey = boundaryKey +"_velocity";
//const auto normalKey = boundaryKey +"_normal";
state.enrollAny(pointKey,mPoint);
state.enrollAny(pointKey,mVelocity);
//state.enrollAny(pointKey,mNormal);
state.enroll(pointKey,mPoint);
state.enroll(pointKey,mVelocity);
//state.enroll(pointKey,mNormal);
}

template<typename Dimension>
Expand Down
6 changes: 3 additions & 3 deletions src/DEM/SolidBoundary/InfinitePlaneSolidBoundary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ registerState(DataBase<Dimension>& dataBase,
const auto pointKey = boundaryKey +"_point";
const auto velocityKey = boundaryKey +"_velocity";
const auto normalKey = boundaryKey +"_normal";
state.enrollAny(pointKey,mPoint);
state.enrollAny(velocityKey,mVelocity);
state.enrollAny(normalKey,mNormal);
state.enroll(pointKey,mPoint);
state.enroll(velocityKey,mVelocity);
state.enroll(normalKey,mNormal);
}

template<typename Dimension>
Expand Down
4 changes: 2 additions & 2 deletions src/DEM/SolidBoundary/RectangularPlaneSolidBoundary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ registerState(DataBase<Dimension>& dataBase,
const auto boundaryKey = "RectangularPlaneSolidBoundary_" + std::to_string(std::abs(this->uniqueIndex()));
const auto pointKey = boundaryKey +"_point";
const auto velocityKey = boundaryKey +"_velocity";
state.enrollAny(pointKey,mPoint);
state.enrollAny(velocityKey,mVelocity);
state.enroll(pointKey,mPoint);
state.enroll(velocityKey,mVelocity);
}
template<typename Dimension>
void
Expand Down
4 changes: 2 additions & 2 deletions src/DEM/SolidBoundary/SphereSolidBoundary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ registerState(DataBase<Dimension>& dataBase,
const auto pointKey = boundaryKey +"_point";
const auto velocityKey = boundaryKey +"_velocity";

state.enrollAny(pointKey,mCenter);
state.enrollAny(pointKey,mVelocity);
state.enroll(pointKey,mCenter);
state.enroll(pointKey,mVelocity);

}

Expand Down
4 changes: 2 additions & 2 deletions src/DataBase/CopyStateInline.hh
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ update(const KeyType& key,
REQUIRE(key == mCopyStateName);

// The state we're updating
ValueType& f = state.template getAny<ValueType>(key);
ValueType& f = state.template get<ValueType>(key);

// The master state we're copying
const ValueType& fmaster = state.template getAny<ValueType>(mMasterStateName);
const ValueType& fmaster = state.template get<ValueType>(mMasterStateName);

// Copy the master state using the assignment operator
f = fmaster;
Expand Down
1 change: 0 additions & 1 deletion src/DataBase/DataBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "Material/EquationOfState.hh"
#include "Utilities/testBoxIntersection.hh"
#include "Utilities/safeInv.hh"
#include "State.hh"
#include "Hydro/HydroFieldNames.hh"
#include "Utilities/globalBoundingVolumes.hh"
#include "Utilities/globalNodeIDs.hh"
Expand Down
Loading
Loading