Skip to content

Commit 4e27343

Browse files
authored
Merge pull request #315 from LLNL/feature/StateRefactor
Refactor State to use std::any and a more rigorous update pattern
2 parents 224c6ef + 6ec081c commit 4e27343

File tree

60 files changed

+698
-720
lines changed

Some content is hidden

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

60 files changed

+698
-720
lines changed

.gitlab/os.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
.on_blueos_3_ppc64:
1919
variables:
2020
ARCH: 'blueos_3_ppc64le_ib_p9'
21-
GCC_VERSION: '8.3.1'
21+
GCC_VERSION: '10.2.1'
2222
CLANG_VERSION: '9.0.0'
2323
SPHERAL_BUILDS_DIR: /p/gpfs1/sphapp/spheral-ci-builds
2424
extends: [.sys_config]

RELEASE_NOTES.md

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Notable changes include:
2828
* Physics packages can indicate if they require Voronoi cell information be available. If so, a new package which computes and
2929
updates the Voronoi information is automatically added to the package list by the SpheralController (similar to how the
3030
Reproducing Kernel corrections are handled).
31+
* Cleaned up use of std::any in State objects using a visitor pattern to be rigorous ensuring all state entries are handled properly
32+
during assignement, equality, and cloning operations. This is intended to help ensure our Physics advance during time integration
33+
is correct.
3134
3235
* Build changes / improvements:
3336
* Distributed source directory must always be built now.

scripts/devtools/spec-list.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
]
88
,
99
"blueos_3_ppc64le_ib_p9": [
10-
"gcc@8.3.1",
11-
"gcc@8.3.1+cuda~mpi cuda_arch=70",
12-
"gcc@8.3.1+cuda cuda_arch=70"
10+
"gcc@10.2.1",
11+
"gcc@10.2.1+cuda~mpi cuda_arch=70",
12+
"gcc@10.2.1+cuda cuda_arch=70"
1313
]
1414
}
1515
}

scripts/spack/configs/blueos_3_ppc64le_ib/compilers.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ compilers:
1313
environment: {}
1414
extra_rpaths: []
1515
- compiler:
16-
spec: gcc@8.3.1
16+
spec: gcc@10.2.1
1717
paths:
18-
cc: /usr/tce/packages/gcc/gcc-8.3.1/bin/gcc
19-
cxx: /usr/tce/packages/gcc/gcc-8.3.1/bin/g++
20-
f77: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran
21-
fc: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran
18+
cc: /usr/tce/packages/gcc/gcc-10.2.1/bin/gcc
19+
cxx: /usr/tce/packages/gcc/gcc-10.2.1/bin/g++
20+
f77: /usr/tce/packages/gcc/gcc-10.2.1/bin/gfortran
21+
fc: /usr/tce/packages/gcc/gcc-10.2.1/bin/gfortran
2222
flags: {}
2323
operating_system: rhel7
2424
target: ppc64le

scripts/spack/configs/blueos_3_ppc64le_ib/packages.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ packages:
3939
- 10.1.243
4040
buildable: false
4141
externals:
42+
- spec: [email protected]+allow-unsupported-compilers
43+
prefix: /usr/tce/packages/cuda/cuda-11.4.1
4244
- spec: [email protected]~allow-unsupported-compilers
4345
prefix: /usr/tce/packages/cuda/cuda-11.1.0
4446
- spec: [email protected]~allow-unsupported-compilers

src/ArtificialConduction/ArtificialConduction.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ evaluateDerivatives(const typename Dimension::Scalar /*time*/,
121121
ReproducingKernel<Dimension> WR;
122122
auto maxOrder = RKOrder::ZerothOrder;
123123
if (useRK) {
124-
const auto& rkOrders = state.template getAny<std::set<RKOrder>>(RKFieldNames::rkOrders);
124+
const auto& rkOrders = state.template get<std::set<RKOrder>>(RKFieldNames::rkOrders);
125125
CHECK(not rkOrders.empty());
126126
const auto maxOrder = *rkOrders.rbegin();
127-
WR = state.template getAny<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(maxOrder));
127+
WR = state.template get<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(maxOrder));
128128
}
129129

130130
// The connectivity map

src/ArtificialViscosity/TensorCRKSPHViscosity.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ calculateSigmaAndGradDivV(const DataBase<Dimension>& dataBase,
184184
const auto velocity = state.fields(HydroFieldNames::velocity, Vector::zero);
185185
const auto rho = state.fields(HydroFieldNames::massDensity, 0.0);
186186
const auto H = state.fields(HydroFieldNames::H, SymTensor::zero);
187-
const auto WR = state.template getAny<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(order));
187+
const auto WR = state.template get<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(order));
188188
const auto corrections = state.fields(RKFieldNames::rkCorrections(order), RKCoefficients<Dimension>());
189189

190190
const auto& connectivityMap = dataBase.connectivityMap();

src/ArtificialViscosity/VonNeumanViscosity.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ initialize(const DataBase<Dimension>& dataBase,
8383
const auto pressure = state.fields(HydroFieldNames::pressure, 0.0);
8484
const auto soundSpeed = state.fields(HydroFieldNames::soundSpeed, 0.0);
8585
const auto vol = mass/massDensity;
86-
const auto WR = state.template getAny<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(order));
86+
const auto WR = state.template get<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(order));
8787
const auto corrections = state.fields(RKFieldNames::rkCorrections(order), RKCoefficients<Dimension>());
8888

8989
// We'll compute the higher-accuracy RK gradient.

src/CRKSPH/CRKSPHEvaluateDerivatives.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ evaluateDerivatives(const typename Dimension::Scalar /*time*/,
1616
auto& Q = this->artificialViscosity();
1717

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

2121
// A few useful constants we'll use in the following loop.
2222
//const double tiny = 1.0e-30;
@@ -65,7 +65,7 @@ evaluateDerivatives(const typename Dimension::Scalar /*time*/,
6565
auto maxViscousPressure = derivatives.fields(HydroFieldNames::maxViscousPressure, 0.0);
6666
auto effViscousPressure = derivatives.fields(HydroFieldNames::effectiveViscousPressure, 0.0);
6767
auto viscousWork = derivatives.fields(HydroFieldNames::viscousWork, 0.0);
68-
auto& pairAccelerations = derivatives.getAny(HydroFieldNames::pairAccelerations, vector<Vector>());
68+
auto& pairAccelerations = derivatives.get(HydroFieldNames::pairAccelerations, vector<Vector>());
6969
auto XSPHDeltaV = derivatives.fields(HydroFieldNames::XSPHDeltaV, Vector::zero);
7070
CHECK(DxDt.size() == numNodeLists);
7171
CHECK(DrhoDt.size() == numNodeLists);

src/CRKSPH/CRKSPHHydroBase.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ registerDerivatives(DataBase<Dimension>& dataBase,
263263
derivs.enroll(mDspecificThermalEnergyDt);
264264
derivs.enroll(mDvDx);
265265
derivs.enroll(mInternalDvDx);
266-
derivs.enrollAny(HydroFieldNames::pairAccelerations, mPairAccelerations);
266+
derivs.enroll(HydroFieldNames::pairAccelerations, mPairAccelerations);
267267
}
268268

269269
//------------------------------------------------------------------------------
@@ -282,7 +282,7 @@ preStepInitialize(const DataBase<Dimension>& dataBase,
282282
if (mDensityUpdate == MassDensityType::RigorousSumDensity or
283283
mDensityUpdate == MassDensityType::VoronoiCellDensity) {
284284
auto massDensity = state.fields(HydroFieldNames::massDensity, 0.0);
285-
const auto& WR = state.template getAny<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(mOrder));
285+
const auto& WR = state.template get<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(mOrder));
286286
const auto& W = WR.kernel();
287287
const auto& connectivityMap = dataBase.connectivityMap();
288288
const auto mass = state.fields(HydroFieldNames::mass, 0.0);
@@ -311,7 +311,7 @@ initialize(const typename Dimension::Scalar time,
311311
State<Dimension>& state,
312312
StateDerivatives<Dimension>& derivs) {
313313
// Initialize the artificial viscosity
314-
const auto& WR = state.template getAny<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(mOrder));
314+
const auto& WR = state.template get<ReproducingKernel<Dimension>>(RKFieldNames::reproducingKernel(mOrder));
315315
auto& Q = this->artificialViscosity();
316316
Q.initialize(dataBase,
317317
state,

src/CRKSPH/CRKSPHHydroBaseRZ.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ evaluateDerivatives(const Dim<2>::Scalar /*time*/,
219219

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

224224
// A few useful constants we'll use in the following loop.
225225
//const auto tiny = 1.0e-30;
@@ -263,7 +263,7 @@ evaluateDerivatives(const Dim<2>::Scalar /*time*/,
263263
auto maxViscousPressure = derivatives.fields(HydroFieldNames::maxViscousPressure, 0.0);
264264
auto effViscousPressure = derivatives.fields(HydroFieldNames::effectiveViscousPressure, 0.0);
265265
auto viscousWork = derivatives.fields(HydroFieldNames::viscousWork, 0.0);
266-
auto& pairAccelerations = derivatives.getAny(HydroFieldNames::pairAccelerations, vector<Vector>());
266+
auto& pairAccelerations = derivatives.get(HydroFieldNames::pairAccelerations, vector<Vector>());
267267
auto XSPHDeltaV = derivatives.fields(HydroFieldNames::XSPHDeltaV, Vector::zero);
268268
CHECK(DxDt.size() == numNodeLists);
269269
CHECK(DrhoDt.size() == numNodeLists);

src/CRKSPH/SolidCRKSPHHydroBase.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ evaluateDerivatives(const typename Dimension::Scalar /*time*/,
258258

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

263263
// A few useful constants we'll use in the following loop.
264264
//const double tiny = 1.0e-30;
@@ -318,7 +318,7 @@ evaluateDerivatives(const typename Dimension::Scalar /*time*/,
318318
auto maxViscousPressure = derivatives.fields(HydroFieldNames::maxViscousPressure, 0.0);
319319
auto effViscousPressure = derivatives.fields(HydroFieldNames::effectiveViscousPressure, 0.0);
320320
auto viscousWork = derivatives.fields(HydroFieldNames::viscousWork, 0.0);
321-
auto& pairAccelerations = derivatives.getAny(HydroFieldNames::pairAccelerations, vector<Vector>());
321+
auto& pairAccelerations = derivatives.get(HydroFieldNames::pairAccelerations, vector<Vector>());
322322
auto XSPHDeltaV = derivatives.fields(HydroFieldNames::XSPHDeltaV, Vector::zero);
323323
auto DSDt = derivatives.fields(IncrementState<Dimension, SymTensor>::prefix() + SolidFieldNames::deviatoricStress, SymTensor::zero);
324324
CHECK(DxDt.size() == numNodeLists);

src/CRKSPH/SolidCRKSPHHydroBaseRZ.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ evaluateDerivatives(const Dim<2>::Scalar /*time*/,
275275

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

280280
// A few useful constants we'll use in the following loop.
281281
//const double tiny = 1.0e-30;
@@ -334,7 +334,7 @@ evaluateDerivatives(const Dim<2>::Scalar /*time*/,
334334
auto maxViscousPressure = derivatives.fields(HydroFieldNames::maxViscousPressure, 0.0);
335335
auto effViscousPressure = derivatives.fields(HydroFieldNames::effectiveViscousPressure, 0.0);
336336
auto viscousWork = derivatives.fields(HydroFieldNames::viscousWork, 0.0);
337-
auto& pairAccelerations = derivatives.getAny(HydroFieldNames::pairAccelerations, vector<Vector>());
337+
auto& pairAccelerations = derivatives.get(HydroFieldNames::pairAccelerations, vector<Vector>());
338338
auto XSPHDeltaV = derivatives.fields(HydroFieldNames::XSPHDeltaV, Vector::zero);
339339
auto DSDt = derivatives.fields(IncrementState<Dimension, SymTensor>::prefix() + SolidFieldNames::deviatoricStress, SymTensor::zero);
340340
CHECK(DxDt.size() == numNodeLists);

src/DEM/IncrementPairFieldList.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ update(const KeyType& key,
5050
// Find all the available matching derivative FieldList keys.
5151
const auto incrementKey = prefix() + fieldKey;
5252
// cerr << "IncrementPairFieldList: [" << fieldKey << "] [" << incrementKey << "] : " << endl;
53-
const auto allkeys = derivs.fieldKeys();
53+
const auto allkeys = derivs.fullFieldKeys();
5454
vector<string> incrementKeys;
5555
for (const auto& key: allkeys) {
5656
// if (std::regex_search(key, std::regex("^" + incrementKey))) {

src/DEM/SolidBoundary/CircularPlaneSolidBoundary.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ registerState(DataBase<Dimension>& dataBase,
6363
const auto pointKey = boundaryKey +"_point";
6464
const auto velocityKey = boundaryKey +"_velocity";
6565
const auto normalKey = boundaryKey +"_normal";
66-
state.enrollAny(pointKey,mPoint);
67-
state.enrollAny(pointKey,mVelocity);
68-
state.enrollAny(pointKey,mNormal);
66+
state.enroll(pointKey,mPoint);
67+
state.enroll(pointKey,mVelocity);
68+
state.enroll(pointKey,mNormal);
6969
}
7070

7171
template<typename Dimension>

src/DEM/SolidBoundary/ClippedSphereSolidBoundary.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ registerState(DataBase<Dimension>& dataBase,
8787
const auto clipPointKey = boundaryKey +"_clipPoint";
8888
const auto velocityKey = boundaryKey +"_velocity";
8989

90-
state.enrollAny(pointKey,mCenter);
91-
state.enrollAny(clipPointKey,mClipPoint);
92-
state.enrollAny(pointKey,mVelocity);
90+
state.enroll(pointKey,mCenter);
91+
state.enroll(clipPointKey,mClipPoint);
92+
state.enroll(pointKey,mVelocity);
9393

9494
}
9595

src/DEM/SolidBoundary/CylinderSolidBoundary.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ registerState(DataBase<Dimension>& dataBase,
6464
const auto pointKey = boundaryKey +"_point";
6565
const auto velocityKey = boundaryKey +"_velocity";
6666
//const auto normalKey = boundaryKey +"_normal";
67-
state.enrollAny(pointKey,mPoint);
68-
state.enrollAny(pointKey,mVelocity);
69-
//state.enrollAny(pointKey,mNormal);
67+
state.enroll(pointKey,mPoint);
68+
state.enroll(pointKey,mVelocity);
69+
//state.enroll(pointKey,mNormal);
7070
}
7171

7272
template<typename Dimension>

src/DEM/SolidBoundary/InfinitePlaneSolidBoundary.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ registerState(DataBase<Dimension>& dataBase,
5454
const auto pointKey = boundaryKey +"_point";
5555
const auto velocityKey = boundaryKey +"_velocity";
5656
const auto normalKey = boundaryKey +"_normal";
57-
state.enrollAny(pointKey,mPoint);
58-
state.enrollAny(velocityKey,mVelocity);
59-
state.enrollAny(normalKey,mNormal);
57+
state.enroll(pointKey,mPoint);
58+
state.enroll(velocityKey,mVelocity);
59+
state.enroll(normalKey,mNormal);
6060
}
6161

6262
template<typename Dimension>

src/DEM/SolidBoundary/RectangularPlaneSolidBoundary.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ registerState(DataBase<Dimension>& dataBase,
5757
const auto boundaryKey = "RectangularPlaneSolidBoundary_" + std::to_string(std::abs(this->uniqueIndex()));
5858
const auto pointKey = boundaryKey +"_point";
5959
const auto velocityKey = boundaryKey +"_velocity";
60-
state.enrollAny(pointKey,mPoint);
61-
state.enrollAny(velocityKey,mVelocity);
60+
state.enroll(pointKey,mPoint);
61+
state.enroll(velocityKey,mVelocity);
6262
}
6363
template<typename Dimension>
6464
void

src/DEM/SolidBoundary/SphereSolidBoundary.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ registerState(DataBase<Dimension>& dataBase,
6262
const auto pointKey = boundaryKey +"_point";
6363
const auto velocityKey = boundaryKey +"_velocity";
6464

65-
state.enrollAny(pointKey,mCenter);
66-
state.enrollAny(pointKey,mVelocity);
65+
state.enroll(pointKey,mCenter);
66+
state.enroll(pointKey,mVelocity);
6767

6868
}
6969

src/DataBase/CopyStateInline.hh

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ update(const KeyType& key,
4242
REQUIRE(key == mCopyStateName);
4343

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

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

5050
// Copy the master state using the assignment operator
5151
f = fmaster;

src/DataBase/DataBase.cc

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "Material/EquationOfState.hh"
1414
#include "Utilities/testBoxIntersection.hh"
1515
#include "Utilities/safeInv.hh"
16-
#include "State.hh"
1716
#include "Hydro/HydroFieldNames.hh"
1817
#include "Utilities/globalBoundingVolumes.hh"
1918
#include "Utilities/globalNodeIDs.hh"

0 commit comments

Comments
 (0)