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

Feature/variable resolution damage #68

Merged
merged 38 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b224ced
Moving all usage of explicit flaws out of DamageModel base class.
jmikeowen Apr 13, 2021
7753b77
Starting the new damage class.
jmikeowen Apr 15, 2021
5fc5089
Checkpoint
jmikeowen Apr 21, 2021
b7dcf32
Checkpoint
jmikeowen May 3, 2021
a639250
Missed one new file.
jmikeowen May 3, 2021
7634a72
Merge branch 'develop' into feature/variable-resolution-damage
jmikeowen May 3, 2021
1f2d7a2
Checkpoint.
jmikeowen May 5, 2021
1e316e0
Merge branch 'develop' into feature/variable-resolution-damage
jmikeowen May 6, 2021
4388b9b
New much more efficient method of generating the Grady-Kipp-Owen
jmikeowen May 7, 2021
e4edb91
Merge branch 'LLNL' into feature/variable-resolution-damage
jmikeowen May 10, 2021
599d5d4
Adding a new random number generator class, which will be appropriate
jmikeowen May 11, 2021
ccf368b
Tests of uniform_random_01 passing.
jmikeowen May 11, 2021
e28a8e1
Adding infrastructure support for uniform_random_01 (DataTypeTraits,
jmikeowen May 12, 2021
10b5aee
Adding the random number generator unit test.
jmikeowen May 12, 2021
eef48f3
Initial implementation of the Probabilistic damage model. Compiling
jmikeowen May 13, 2021
9a9f829
Removing debug print.
jmikeowen May 13, 2021
d17ab88
Starting to test/debug ProbabilisticDamage.
jmikeowen May 13, 2021
cbbde4b
More testing.
jmikeowen May 14, 2021
60004ba
Altering the algorithm for generating flaws each step, which requires
jmikeowen May 14, 2021
5f13593
Missing methods.
jmikeowen May 17, 2021
028b7a7
Checkpoint.
jmikeowen May 17, 2021
c40e7af
ProbabilisticDamageModel giving reasonable results on 1D tests.
jmikeowen May 17, 2021
f040d3a
Removing debug prints.
jmikeowen May 17, 2021
5ab891c
Using unsigned Fields is crashing Python during viz output for some r…
jmikeowen May 17, 2021
1c25053
Changing numFlaws to be an int field as a workaround for our strange
jmikeowen May 17, 2021
40825e6
Adding a convenient shadow constructor for the ProbabilisticDamageModel.
jmikeowen May 18, 2021
3e1267f
Getting all our constructor arguments working for the shadow layer on…
jmikeowen May 18, 2021
5475e3f
Bugfixes for variable resolution
jmikeowen May 18, 2021
75c3de4
Adding another LC build script.
jmikeowen May 19, 2021
66fb245
Fixes for damage mask in ProbabilisticDamageModel.
jmikeowen May 24, 2021
43d35f2
Commenting out a defunct warning.
jmikeowen May 24, 2021
b925d06
Fixing some diagnostic output, efficiency changes, and upping the
jmikeowen May 26, 2021
f2173d4
Found an analytic method of handling the fraction of flaws activated
jmikeowen May 27, 2021
b9716d6
Cleaning up our improved probabilistic damage model.
jmikeowen May 27, 2021
969a836
Adding test of ProbabilisticDamageModel.
jmikeowen May 27, 2021
e7e3ec8
Missed the reference data.
jmikeowen May 27, 2021
97e679c
Merge branch 'develop' into feature/variable-resolution-damage
jmikeowen May 27, 2021
354bf08
nullptr change.
jmikeowen Jun 3, 2021
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
25 changes: 25 additions & 0 deletions scripts/lc-builds/toss3_gcc8.1.0-release-mpi-cxx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

SCRIPT_PATH=${0%/*}
. "$SCRIPT_PATH/utils/parse-args.sh"

# Inherit build directory name from script name
BUILD_SUFFIX="lc_$(TMP=${BASH_SOURCE##*/}; echo ${TMP%.*})"

rm -rf ${BUILD_SUFFIX} 2>/dev/null
mkdir -p ${BUILD_SUFFIX}/install
mkdir -p ${BUILD_SUFFIX}/build && cd ${BUILD_SUFFIX}/build

module load cmake/3.14.5
module load gcc/8.1.0

cmake \
${SRC_DIR} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_COMPILER=/usr/tce/packages/gcc/gcc-8.1.0/bin/g++ \
-C ${HOST_CONFIGS_DIR}/lc-builds/toss3/gcc8.1.0_tpl.cmake \
-DENABLE_OPENMP=On \
-DENABLE_MPI=On \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
-DENABLE_STATIC_CXXONLY=On \
$CMAKE_ARGS \
2 changes: 1 addition & 1 deletion src/Boundary/ConstantBoundary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ConstantBoundary(DataBase<Dimension>& dataBase,
mNodeFlags[*itr] = 1;
}

// // Issue a big old warning!
// Issue a big old warning!
// if (Process::getRank() == 0) cerr << "WARNING: ConstantBoundary is currently not compatible with redistributing nodes!\nMake sure you don't allow redistribution with this Boundary condition." << endl;
}

Expand Down
6 changes: 6 additions & 0 deletions src/Damage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ include_directories(.)
set(Damage_inst
DamageModel
TensorDamageModel
ProbabilisticDamageModel
ProbabilisticDamagePolicy
StrainPolicy
TensorStrainPolicy
TensorDamagePolicy
Expand Down Expand Up @@ -39,7 +41,10 @@ set(Damage_headers
StrainPolicy.hh
TensorDamageModel.hh
TensorDamageModelInline.hh
ProbabilisticDamageModel.hh
ProbabilisticDamageModelInline.hh
TensorDamagePolicy.hh
ProbabilisticDamagePolicy.hh
TensorStrainPolicy.hh
YoungsModulusPolicy.hh
computeFragmentField.hh
Expand All @@ -53,6 +58,7 @@ spheral_install_python_files(
WeibullDamage.py
GradyKippTensorDamage.py
JohnsonCookDamageFactories.py
ShadowProbabilisticDamageModel.py
)

spheral_add_cxx_library(Damage)
Expand Down
88 changes: 2 additions & 86 deletions src/Damage/DamageModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
//----------------------------------------------------------------------------//
#include "FileIO/FileIO.hh"
#include "DamageModel.hh"
#include "YoungsModulusPolicy.hh"
#include "LongitudinalSoundSpeedPolicy.hh"
#include "DamagedSoundSpeedPolicy.hh"
#include "Strength/SolidFieldNames.hh"
#include "NodeList/SolidNodeList.hh"
#include "DataBase/DataBase.hh"
Expand Down Expand Up @@ -57,17 +54,12 @@ DamageModel<Dimension>::
DamageModel(SolidNodeList<Dimension>& nodeList,
const TableKernel<Dimension>& W,
const double crackGrowthMultiplier,
const DamageCouplingAlgorithm damageCouplingAlgorithm,
const FlawStorageType& flaws):
const DamageCouplingAlgorithm damageCouplingAlgorithm):
Physics<Dimension>(),
mFlaws(SolidFieldNames::flaws, flaws),
mNodeList(nodeList),
mW(W),
mCrackGrowthMultiplier(crackGrowthMultiplier),
mCriticalNodesPerSmoothingScale(0.99),
mDamageCouplingAlgorithm(damageCouplingAlgorithm),
mYoungsModulus(SolidFieldNames::YoungsModulus, nodeList),
mLongitudinalSoundSpeed(SolidFieldNames::longitudinalSoundSpeed, nodeList),
mExcludeNode("Nodes excluded from damage", nodeList, 0),
mNodeCouplingPtr(new NodeCoupling()),
mComputeIntersectConnectivity(false),
Expand Down Expand Up @@ -97,7 +89,6 @@ computeScalarDDDt(const DataBase<Dimension>& /*dataBase*/,

// Pre-conditions.
REQUIRE(DDDt.nodeListPtr() == &mNodeList);
REQUIRE(mFlaws.nodeListPtr() == &mNodeList);

// Get the state fields.
const auto clKey = State<Dimension>::buildFieldKey(SolidFieldNames::longitudinalSoundSpeed, mNodeList.name());
Expand Down Expand Up @@ -135,29 +126,6 @@ computeScalarDDDt(const DataBase<Dimension>& /*dataBase*/,
END_CONTRACT_SCOPE
}

//------------------------------------------------------------------------------
// Register our state.
//------------------------------------------------------------------------------
template<typename Dimension>
void
DamageModel<Dimension>::
registerState(DataBase<Dimension>& dataBase,
State<Dimension>& state) {

// Register Youngs modulus and the longitudinal sound speed.
typedef typename State<Dimension>::PolicyPointer PolicyPointer;
PolicyPointer EPolicy(new YoungsModulusPolicy<Dimension>());
PolicyPointer clPolicy(new LongitudinalSoundSpeedPolicy<Dimension>());
state.enroll(mYoungsModulus, EPolicy);
state.enroll(mLongitudinalSoundSpeed, clPolicy);

// Set the initial values for the Youngs modulus, sound speed, and pressure.
typename StateDerivatives<Dimension>::PackageList dummyPackages;
StateDerivatives<Dimension> derivs(dataBase, dummyPackages);
EPolicy->update(state.key(mYoungsModulus), state, derivs, 1.0, 0.0, 0.0);
clPolicy->update(state.key(mLongitudinalSoundSpeed), state, derivs, 1.0, 0.0, 0.0);
}

//------------------------------------------------------------------------------
// initialize (before evaluateDerivatives)
// This is where we update the damage coupling, which is stored in the
Expand Down Expand Up @@ -238,30 +206,13 @@ finalize(const Scalar /*time*/,
const auto ntot = std::max(1, dataBase.globalNumInternalNodes());
const auto dfrac = double(nD)/double(ntot);
mComputeIntersectConnectivity = (dfrac > 0.2); // Should tune this number...
if (Process::getRank() == 0) std::cout << "DamageModel dfrac = " << nD << "/" << ntot << " = " << dfrac << " : " << mComputeIntersectConnectivity << std::endl;
// if (Process::getRank() == 0) std::cout << "DamageModel dfrac = " << nD << "/" << ntot << " = " << dfrac << " : " << mComputeIntersectConnectivity << std::endl;
}

TIME_DamageModel_finalize.stop();
TIME_Damage.stop();
}

//------------------------------------------------------------------------------
// Cull the flaws on each node to the single weakest one.
//------------------------------------------------------------------------------
template<typename Dimension>
void
DamageModel<Dimension>::
cullToWeakestFlaws() {
#pragma omp parallel for
for (auto i = 0u; i < mNodeList.numInternalNodes(); ++i) {
auto& flaws = mFlaws[i];
if (flaws.size() > 0) {
const auto maxVal = *max_element(flaws.begin(), flaws.end());
flaws = vector<double>(maxVal);
}
}
}

//------------------------------------------------------------------------------
// Access the set of nodes to be excluded from damage.
//------------------------------------------------------------------------------
Expand Down Expand Up @@ -289,39 +240,6 @@ excludeNodes(vector<int> ids) {
}
}

//------------------------------------------------------------------------------
// Compute a Field with the sum of the activation energies per node.
//------------------------------------------------------------------------------
template<typename Dimension>
Field<Dimension, typename Dimension::Scalar>
DamageModel<Dimension>::
sumActivationEnergiesPerNode() const {
Field<Dimension, Scalar> result("Sum activation energies", mNodeList);
for (auto i = 0u; i != mNodeList.numInternalNodes(); ++i) {
const vector<double>& flaws = mFlaws(i);
for (vector<double>::const_iterator flawItr = flaws.begin();
flawItr != flaws.end();
++flawItr) {
result(i) += *flawItr;
}
}
return result;
}

//------------------------------------------------------------------------------
// Compute a Field with the number of flaws per node.
//------------------------------------------------------------------------------
template<typename Dimension>
Field<Dimension, typename Dimension::Scalar>
DamageModel<Dimension>::
numFlawsPerNode() const {
Field<Dimension, Scalar> result("num flaws", mNodeList);
for (auto i = 0u; i != mNodeList.numInternalNodes(); ++i) {
result(i) = flawsForNode(i).size();
}
return result;
}

//------------------------------------------------------------------------------
// Dump the current state to the given file.
//------------------------------------------------------------------------------
Expand All @@ -330,7 +248,6 @@ void
DamageModel<Dimension>::
dumpState(FileIO& file, const string& pathName) const {
file.write(mCrackGrowthMultiplier, pathName + "/crackGrowthMultiplier");
file.write(mFlaws, pathName + "/flaws");
file.write(mExcludeNode, pathName + "/excludeNode");
file.write(mComputeIntersectConnectivity, pathName + "/computeIntersectConnectivity");
}
Expand All @@ -343,7 +260,6 @@ void
DamageModel<Dimension>::
restoreState(const FileIO& file, const string& pathName) {
file.read(mCrackGrowthMultiplier, pathName + "/crackGrowthMultiplier");
file.read(mFlaws, pathName + "/flaws");
file.read(mExcludeNode, pathName + "/excludeNode");
file.read(mComputeIntersectConnectivity, pathName + "/computeIntersectConnectivity");
}
Expand Down
52 changes: 7 additions & 45 deletions src/Damage/DamageModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ public:
DamageModel(SolidNodeList<Dimension>& nodeList,
const TableKernel<Dimension>& W,
const double crackGrowthMultiplier,
const DamageCouplingAlgorithm damageCouplingAlgorithm,
const FlawStorageType& flaws);
const DamageCouplingAlgorithm damageCouplingAlgorithm);
virtual ~DamageModel();

// Compute the generic Grady-Kipp (ala Benz-Asphaug) scalar damage time
Expand All @@ -79,15 +78,11 @@ public:

//...........................................................................
// Provide a subset of the required physics package interface.
virtual void registerState(DataBase<Dimension>& dataBase,
State<Dimension>& state) override;

virtual
void initialize(const Scalar time,
const Scalar dt,
const DataBase<Dimension>& dataBase,
State<Dimension>& state,
StateDerivatives<Dimension>& derivatives) override;
virtual void initialize(const Scalar time,
const Scalar dt,
const DataBase<Dimension>& dataBase,
State<Dimension>& state,
StateDerivatives<Dimension>& derivatives) override;

virtual void finalize(const Scalar time,
const Scalar dt,
Expand All @@ -96,17 +91,9 @@ public:
StateDerivatives<Dimension>& derivs);

virtual bool requireGhostConnectivity() const override;

virtual bool requireIntersectionConnectivity() const override;

//...........................................................................
// Optional method to cull the set of flaws to the single weakest one on
// each point.
void cullToWeakestFlaws();

// Get the set of flaw activation energies for the given node index.
const std::vector<double> flawsForNode(const size_t index) const;

// Access the SolidNodeList we're damaging.
SolidNodeList<Dimension>& nodeList();
const SolidNodeList<Dimension>& nodeList() const;
Expand All @@ -123,44 +110,19 @@ public:
std::vector<int> excludeNodes() const;
void excludeNodes(std::vector<int> ids);

// Provide access to the state fields we maintain.
const Field<Dimension, Scalar>& youngsModulus() const;
const Field<Dimension, Scalar>& longitudinalSoundSpeed() const;

// Access the flaw field.
const FlawStorageType& flaws() const;
FlawStorageType& flaws();

// Compute a Field with the sum of the activation energies per node.
Field<Dimension, Scalar> sumActivationEnergiesPerNode() const;

// Compute a Field with the number of flaws per node.
Field<Dimension, Scalar> numFlawsPerNode() const;

// The effective critical number of nodes per smoothing scale, below which we
// assume all flaws are active on a node.
double criticalNodesPerSmoothingScale() const;
void criticalNodesPerSmoothingScale(double x);

//**************************************************************************
// Restart methods.
virtual std::string label() const override { return "DamageModel"; }
virtual void dumpState(FileIO& file, const std::string& pathName) const;
virtual void restoreState(const FileIO& file, const std::string& pathName);
//**************************************************************************

protected:
//-------------------------- Protected Interface --------------------------//
FlawStorageType mFlaws;

private:
//--------------------------- Private Interface ---------------------------//
SolidNodeList<Dimension>& mNodeList;
const TableKernel<Dimension>& mW;
double mCrackGrowthMultiplier, mCriticalNodesPerSmoothingScale;
double mCrackGrowthMultiplier;
DamageCouplingAlgorithm mDamageCouplingAlgorithm;
Field<Dimension, Scalar> mYoungsModulus;
Field<Dimension, Scalar> mLongitudinalSoundSpeed;
Field<Dimension, int> mExcludeNode;
NodeCouplingPtr mNodeCouplingPtr;
bool mComputeIntersectConnectivity;
Expand Down
72 changes: 0 additions & 72 deletions src/Damage/DamageModelInline.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,40 +21,6 @@ requireIntersectionConnectivity() const {
return mComputeIntersectConnectivity;
}

//------------------------------------------------------------------------------
// The effective critical number of nodes per smoothing scale, below which we
// assume all flaws are active on a node.
//------------------------------------------------------------------------------
template<typename Dimension>
inline
double
DamageModel<Dimension>::
criticalNodesPerSmoothingScale() const {
return mCriticalNodesPerSmoothingScale;
}

template<typename Dimension>
inline
void
DamageModel<Dimension>::
criticalNodesPerSmoothingScale(double x) {
VERIFY(x >= 0.0);
mCriticalNodesPerSmoothingScale = x;
}

//------------------------------------------------------------------------------
// Return the set of flaw activation energies for the given node.
//------------------------------------------------------------------------------
template<typename Dimension>
inline
const std::vector<double>
DamageModel<Dimension>::
flawsForNode(const size_t index) const {
REQUIRE(index < mNodeList.numInternalNodes());
REQUIRE(mFlaws.nodeListPtr() == &mNodeList);
return mFlaws(index);
}

//------------------------------------------------------------------------------
// Access the internal parameters of the model.
//------------------------------------------------------------------------------
Expand Down Expand Up @@ -106,42 +72,4 @@ nodeCoupling() const {
return *mNodeCouplingPtr;
}

//------------------------------------------------------------------------------
// Access the state fields.
//------------------------------------------------------------------------------
template<typename Dimension>
inline
const Field<Dimension, typename Dimension::Scalar>&
DamageModel<Dimension>::
youngsModulus() const {
return mYoungsModulus;
}

template<typename Dimension>
inline
const Field<Dimension, typename Dimension::Scalar>&
DamageModel<Dimension>::
longitudinalSoundSpeed() const {
return mLongitudinalSoundSpeed;
}

//------------------------------------------------------------------------------
// Access the flaw activation strains.
//------------------------------------------------------------------------------
template<typename Dimension>
inline
const typename DamageModel<Dimension>::FlawStorageType&
DamageModel<Dimension>::
flaws() const {
return mFlaws;
}

template<typename Dimension>
inline
typename DamageModel<Dimension>::FlawStorageType&
DamageModel<Dimension>::
flaws() {
return mFlaws;
}

}
Loading