From 1acedbd3d7f3fc64330a01feaec0ebcd9df17bde Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 5 Feb 2025 10:34:43 +0100 Subject: [PATCH] MechContainer: store displacement as an array instead of 3 vectors --- opm/simulators/flow/MechContainer.cpp | 25 +++++++++++++------------ opm/simulators/flow/MechContainer.hpp | 5 ++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/opm/simulators/flow/MechContainer.cpp b/opm/simulators/flow/MechContainer.cpp index 0f7128ffd..35f0992d6 100644 --- a/opm/simulators/flow/MechContainer.cpp +++ b/opm/simulators/flow/MechContainer.cpp @@ -43,12 +43,13 @@ allocate(const std::size_t bufferSize, this->potentialPressForce_.resize(bufferSize, 0.0); rstKeywords["PRESPOTF"] = 0; - this->dispX_.resize(bufferSize, 0.0); - rstKeywords["DISPX"] = 0; - this->dispY_.resize(bufferSize, 0.0); - rstKeywords["DISPY"] = 0; - this->dispZ_.resize(bufferSize, 0.0); - rstKeywords["DISPZ"] = 0; + std::for_each(disp_.begin(), disp_.end(), + [suffix = "XYZ", is = 0, bufferSize, &rstKeywords](auto& v) mutable + { + v.resize(bufferSize, 0.0); + rstKeywords[std::string{"DISP"} + suffix[is++]] = 0; + }); + this->stressXX_.resize(bufferSize, 0.0); rstKeywords["STRESSXX"] = 0; this->stressYY_.resize(bufferSize, 0.0); @@ -122,9 +123,9 @@ void MechContainer:: assignDisplacement(const unsigned globalDofIdx, const Dune::FieldVector& disp) { - this->dispX_[globalDofIdx] = disp[0]; - this->dispY_[globalDofIdx] = disp[1]; - this->dispZ_[globalDofIdx] = disp[2]; + this->disp_[0][globalDofIdx] = disp[0]; + this->disp_[1][globalDofIdx] = disp[1]; + this->disp_[2][globalDofIdx] = disp[2]; } template @@ -169,9 +170,9 @@ outputRestart(data::Solution& sol) const DataEntry{"DELSTRXY", UnitSystem::measure::pressure, delstressXY_}, DataEntry{"DELSTRXZ", UnitSystem::measure::pressure, delstressXZ_}, DataEntry{"DELSTRYZ", UnitSystem::measure::pressure, delstressYZ_}, - DataEntry{"DISPX", UnitSystem::measure::length, dispX_}, - DataEntry{"DISPY", UnitSystem::measure::length, dispY_}, - DataEntry{"DISPZ", UnitSystem::measure::length, dispZ_}, + DataEntry{"DISPX", UnitSystem::measure::length, disp_[0]}, + DataEntry{"DISPY", UnitSystem::measure::length, disp_[1]}, + DataEntry{"DISPZ", UnitSystem::measure::length, disp_[2]}, DataEntry{"FRCSTRXX", UnitSystem::measure::pressure, fracstressXX_}, DataEntry{"FRCSTRYY", UnitSystem::measure::pressure, fracstressYY_}, DataEntry{"FRCSTRZZ", UnitSystem::measure::pressure, fracstressZZ_}, diff --git a/opm/simulators/flow/MechContainer.hpp b/opm/simulators/flow/MechContainer.hpp index ff633c5ee..071b5a34a 100644 --- a/opm/simulators/flow/MechContainer.hpp +++ b/opm/simulators/flow/MechContainer.hpp @@ -28,6 +28,7 @@ #include +#include #include #include #include @@ -64,9 +65,7 @@ public: ScalarBuffer potentialPressForce_; ScalarBuffer potentialTempForce_; - ScalarBuffer dispX_; - ScalarBuffer dispY_; - ScalarBuffer dispZ_; + std::array disp_; ScalarBuffer stressXX_; ScalarBuffer stressYY_; ScalarBuffer stressZZ_;