store stress as a VoigtArray in MechContainer

This commit is contained in:
Arne Morten Kvarving 2025-02-05 11:30:20 +01:00
parent 21b41cf5c3
commit 76e343d54d
2 changed files with 24 additions and 30 deletions

View File

@ -50,18 +50,20 @@ allocate(const std::size_t bufferSize,
rstKeywords[std::string{"DISP"} + suffix[is++]] = 0; rstKeywords[std::string{"DISP"} + suffix[is++]] = 0;
}); });
this->stressXX_.resize(bufferSize, 0.0); auto resizeAndRegister =
rstKeywords["STRESSXX"] = 0; [&rstKeywords,bufferSize](auto& tensor,
this->stressYY_.resize(bufferSize, 0.0); const std::string& name)
rstKeywords["STRESSYY"] = 0; {
this->stressZZ_.resize(bufferSize, 0.0); static constexpr auto fields = std::array{
rstKeywords["STRESSZZ"] = 0; "XX", "YY", "ZZ", "YZ", "XZ", "XY",
this->stressXY_.resize(bufferSize, 0.0); };
rstKeywords["STRESSXY"] = 0; tensor.resize(bufferSize);
this->stressXZ_.resize(bufferSize, 0.0); for (const auto& f : fields) {
rstKeywords["STRESSXZ"] = 0; rstKeywords[name + f] = 0;
this->stressYZ_.resize(bufferSize, 0.0); }
rstKeywords["STRESSYZ"] = 0; };
resizeAndRegister(stress_, "STRESS");
this->strainXX_.resize(bufferSize, 0.0); this->strainXX_.resize(bufferSize, 0.0);
rstKeywords["STRAINXX"] = 0; rstKeywords["STRAINXX"] = 0;
@ -145,12 +147,7 @@ void MechContainer<Scalar>::
assignStress(const unsigned globalDofIdx, assignStress(const unsigned globalDofIdx,
const Dune::FieldVector<Scalar,6>& stress) const Dune::FieldVector<Scalar,6>& stress)
{ {
this->stressXX_[globalDofIdx] = stress[0]; this->stress_.assign(globalDofIdx, VoigtContainer<Scalar>(stress));
this->stressYY_[globalDofIdx] = stress[1];
this->stressZZ_[globalDofIdx] = stress[2];
this->stressYZ_[globalDofIdx] = stress[3];
this->stressXZ_[globalDofIdx] = stress[4];
this->stressXY_[globalDofIdx] = stress[5];
} }
template<class Scalar> template<class Scalar>
@ -206,12 +203,12 @@ outputRestart(data::Solution& sol) const
DataEntry{"STRAINXY", UnitSystem::measure::identity, strainXY_}, DataEntry{"STRAINXY", UnitSystem::measure::identity, strainXY_},
DataEntry{"STRAINXZ", UnitSystem::measure::identity, strainXZ_}, DataEntry{"STRAINXZ", UnitSystem::measure::identity, strainXZ_},
DataEntry{"STRAINYZ", UnitSystem::measure::identity, strainYZ_}, DataEntry{"STRAINYZ", UnitSystem::measure::identity, strainYZ_},
DataEntry{"STRESSXX", UnitSystem::measure::length, stressXX_}, DataEntry{"STRESSXX", UnitSystem::measure::length, stress_[VoigtIndex::XX]},
DataEntry{"STRESSYY", UnitSystem::measure::length, stressYY_}, DataEntry{"STRESSYY", UnitSystem::measure::length, stress_[VoigtIndex::YY]},
DataEntry{"STRESSZZ", UnitSystem::measure::length, stressZZ_}, DataEntry{"STRESSZZ", UnitSystem::measure::length, stress_[VoigtIndex::ZZ]},
DataEntry{"STRESSXY", UnitSystem::measure::length, stressXY_}, DataEntry{"STRESSXY", UnitSystem::measure::length, stress_[VoigtIndex::XY]},
DataEntry{"STRESSXZ", UnitSystem::measure::length, stressXZ_}, DataEntry{"STRESSXZ", UnitSystem::measure::length, stress_[VoigtIndex::XZ]},
DataEntry{"STRESSYZ", UnitSystem::measure::length, stressYZ_}, DataEntry{"STRESSYZ", UnitSystem::measure::length, stress_[VoigtIndex::YZ]},
DataEntry{"TEMPPOTF", UnitSystem::measure::pressure, potentialTempForce_}, DataEntry{"TEMPPOTF", UnitSystem::measure::pressure, potentialTempForce_},
}; };

View File

@ -28,6 +28,8 @@
#include <dune/common/fvector.hh> #include <dune/common/fvector.hh>
#include <opm/simulators/utils/VoigtArray.hpp>
#include <array> #include <array>
#include <cstddef> #include <cstddef>
#include <map> #include <map>
@ -69,12 +71,7 @@ public:
ScalarBuffer potentialTempForce_; ScalarBuffer potentialTempForce_;
std::array<ScalarBuffer,3> disp_; std::array<ScalarBuffer,3> disp_;
ScalarBuffer stressXX_; VoigtArray<Scalar> stress_;
ScalarBuffer stressYY_;
ScalarBuffer stressZZ_;
ScalarBuffer stressXY_;
ScalarBuffer stressXZ_;
ScalarBuffer stressYZ_;
ScalarBuffer delstressXX_; ScalarBuffer delstressXX_;
ScalarBuffer delstressYY_; ScalarBuffer delstressYY_;
ScalarBuffer delstressZZ_; ScalarBuffer delstressZZ_;