From 2fe36caa08c1a282b03e2a2958809349be9d8b70 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 4 Feb 2025 17:36:53 +0100 Subject: [PATCH] move allocation of mech data into MechContainer --- .../flow/GenericOutputBlackoilModule.cpp | 88 +----------------- opm/simulators/flow/MechContainer.cpp | 91 +++++++++++++++++++ opm/simulators/flow/MechContainer.hpp | 10 ++ opm/simulators/flow/OutputBlackoilModule.hpp | 2 +- 4 files changed, 103 insertions(+), 88 deletions(-) diff --git a/opm/simulators/flow/GenericOutputBlackoilModule.cpp b/opm/simulators/flow/GenericOutputBlackoilModule.cpp index dcf6daefc..6ac5b1d74 100644 --- a/opm/simulators/flow/GenericOutputBlackoilModule.cpp +++ b/opm/simulators/flow/GenericOutputBlackoilModule.cpp @@ -992,93 +992,7 @@ doAllocBuffers(const unsigned bufferSize, rstKeywords["PRESSURE"] = 0; if (enableMech_ && eclState_.runspec().mech()) { - this->mech_.potentialForce_.resize(bufferSize,0.0); - rstKeywords["MECHPOTF"] = 0; - this->mech_.potentialTempForce_.resize(bufferSize,0.0); - rstKeywords["TEMPPOTF"] = 0; - this->mech_.potentialPressForce_.resize(bufferSize,0.0); - rstKeywords["PRESPOTF"] = 0; - - this->mech_.dispX_.resize(bufferSize,0.0); - rstKeywords["DISPX"] = 0; - this->mech_.dispY_.resize(bufferSize,0.0); - rstKeywords["DISPY"] = 0; - this->mech_.dispZ_.resize(bufferSize,0.0); - rstKeywords["DISPZ"] = 0; - this->mech_.stressXX_.resize(bufferSize,0.0); - rstKeywords["STRESSXX"] = 0; - this->mech_.stressYY_.resize(bufferSize,0.0); - rstKeywords["STRESSYY"] = 0; - this->mech_.stressZZ_.resize(bufferSize,0.0); - rstKeywords["STRESSZZ"] = 0; - this->mech_.stressXY_.resize(bufferSize,0.0); - rstKeywords["STRESSXY"] = 0; - this->mech_.stressXZ_.resize(bufferSize,0.0); - rstKeywords["STRESSXZ"] = 0; - this->mech_.stressXY_.resize(bufferSize,0.0); - rstKeywords["STRESSXY"] = 0; - this->mech_.stressYZ_.resize(bufferSize,0.0); - rstKeywords["STRESSYZ"] = 0; - - this->mech_.strainXX_.resize(bufferSize,0.0); - rstKeywords["STRAINXX"] = 0; - this->mech_.strainYY_.resize(bufferSize,0.0); - rstKeywords["STRAINYY"] = 0; - this->mech_.strainZZ_.resize(bufferSize,0.0); - rstKeywords["STRAINZZ"] = 0; - this->mech_.strainXY_.resize(bufferSize,0.0); - rstKeywords["STRAINXY"] = 0; - this->mech_.strainXZ_.resize(bufferSize,0.0); - rstKeywords["STRAINXZ"] = 0; - this->mech_.strainXY_.resize(bufferSize,0.0); - rstKeywords["STRAINXY"] = 0; - this->mech_.strainYZ_.resize(bufferSize,0.0); - rstKeywords["STRAINYZ"] = 0; - - this->mech_.delstressXX_.resize(bufferSize,0.0); - rstKeywords["DELSTRXX"] = 0; - this->mech_.delstressYY_.resize(bufferSize,0.0); - rstKeywords["DELSTRYY"] = 0; - this->mech_.delstressZZ_.resize(bufferSize,0.0); - rstKeywords["DELSTRZZ"] = 0; - this->mech_.delstressXY_.resize(bufferSize,0.0); - rstKeywords["DELSTRXY"] = 0; - this->mech_.delstressXZ_.resize(bufferSize,0.0); - rstKeywords["DELSTRXZ"] = 0; - this->mech_.delstressXY_.resize(bufferSize,0.0); - rstKeywords["DELSTRXY"] = 0; - this->mech_.delstressYZ_.resize(bufferSize,0.0); - rstKeywords["DELSTRYZ"] = 0; - - this->mech_.fracstressXX_.resize(bufferSize,0.0); - rstKeywords["FRCSTRXX"] = 0; - this->mech_.fracstressYY_.resize(bufferSize,0.0); - rstKeywords["FRCSTRYY"] = 0; - this->mech_.fracstressZZ_.resize(bufferSize,0.0); - rstKeywords["FRCSTRZZ"] = 0; - this->mech_.fracstressXY_.resize(bufferSize,0.0); - rstKeywords["FRCSTRXY"] = 0; - this->mech_.fracstressXZ_.resize(bufferSize,0.0); - rstKeywords["FRCSTRXZ"] = 0; - this->mech_.fracstressXY_.resize(bufferSize,0.0); - rstKeywords["FRCSTRXY"] = 0; - this->mech_.fracstressYZ_.resize(bufferSize,0.0); - rstKeywords["FRCSTRYZ"] = 0; - - this->mech_.linstressXX_.resize(bufferSize,0.0); - rstKeywords["LINSTRXX"] = 0; - this->mech_.linstressYY_.resize(bufferSize,0.0); - rstKeywords["LINSTRYY"] = 0; - this->mech_.linstressZZ_.resize(bufferSize,0.0); - rstKeywords["LINSTRZZ"] = 0; - this->mech_.linstressXY_.resize(bufferSize,0.0); - rstKeywords["LINSTRXY"] = 0; - this->mech_.linstressXZ_.resize(bufferSize,0.0); - rstKeywords["LINSTRXZ"] = 0; - this->mech_.linstressXY_.resize(bufferSize,0.0); - rstKeywords["LINSTRXY"] = 0; - this->mech_.linstressYZ_.resize(bufferSize,0.0); - rstKeywords["LINSTRYZ"] = 0; + this->mech_.allocate(bufferSize, rstKeywords); } // If TEMP is set in RPTRST we output temperature even if THERMAL diff --git a/opm/simulators/flow/MechContainer.cpp b/opm/simulators/flow/MechContainer.cpp index 777aee2ad..05f4c32a4 100644 --- a/opm/simulators/flow/MechContainer.cpp +++ b/opm/simulators/flow/MechContainer.cpp @@ -25,5 +25,96 @@ namespace Opm { +template +void MechContainer:: +allocate(const std::size_t bufferSize, + std::map& rstKeywords) +{ + this->potentialForce_.resize(bufferSize, 0.0); + rstKeywords["MECHPOTF"] = 0; + this->potentialTempForce_.resize(bufferSize, 0.0); + rstKeywords["TEMPPOTF"] = 0; + 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; + this->stressXX_.resize(bufferSize, 0.0); + rstKeywords["STRESSXX"] = 0; + this->stressYY_.resize(bufferSize, 0.0); + rstKeywords["STRESSYY"] = 0; + this->stressZZ_.resize(bufferSize, 0.0); + rstKeywords["STRESSZZ"] = 0; + this->stressXY_.resize(bufferSize, 0.0); + rstKeywords["STRESSXY"] = 0; + this->stressXZ_.resize(bufferSize, 0.0); + rstKeywords["STRESSXZ"] = 0; + this->stressYZ_.resize(bufferSize, 0.0); + rstKeywords["STRESSYZ"] = 0; + + this->strainXX_.resize(bufferSize, 0.0); + rstKeywords["STRAINXX"] = 0; + this->strainYY_.resize(bufferSize, 0.0); + rstKeywords["STRAINYY"] = 0; + this->strainZZ_.resize(bufferSize, 0.0); + rstKeywords["STRAINZZ"] = 0; + this->strainXY_.resize(bufferSize, 0.0); + rstKeywords["STRAINXY"] = 0; + this->strainXZ_.resize(bufferSize, 0.0); + rstKeywords["STRAINXZ"] = 0; + this->strainYZ_.resize(bufferSize, 0.0); + rstKeywords["STRAINYZ"] = 0; + + this->delstressXX_.resize(bufferSize, 0.0); + rstKeywords["DELSTRXX"] = 0; + this->delstressYY_.resize(bufferSize, 0.0); + rstKeywords["DELSTRYY"] = 0; + this->delstressZZ_.resize(bufferSize, 0.0); + rstKeywords["DELSTRZZ"] = 0; + this->delstressXY_.resize(bufferSize, 0.0); + rstKeywords["DELSTRXY"] = 0; + this->delstressXZ_.resize(bufferSize, 0.0); + rstKeywords["DELSTRXZ"] = 0; + this->delstressYZ_.resize(bufferSize, 0.0); + rstKeywords["DELSTRYZ"] = 0; + + this->fracstressXX_.resize(bufferSize,0.0); + rstKeywords["FRCSTRXX"] = 0; + this->fracstressYY_.resize(bufferSize,0.0); + rstKeywords["FRCSTRYY"] = 0; + this->fracstressZZ_.resize(bufferSize,0.0); + rstKeywords["FRCSTRZZ"] = 0; + this->fracstressXY_.resize(bufferSize,0.0); + rstKeywords["FRCSTRXY"] = 0; + this->fracstressXZ_.resize(bufferSize,0.0); + rstKeywords["FRCSTRXZ"] = 0; + this->fracstressYZ_.resize(bufferSize,0.0); + rstKeywords["FRCSTRYZ"] = 0; + + this->linstressXX_.resize(bufferSize,0.0); + rstKeywords["LINSTRXX"] = 0; + this->linstressYY_.resize(bufferSize,0.0); + rstKeywords["LINSTRYY"] = 0; + this->linstressZZ_.resize(bufferSize,0.0); + rstKeywords["LINSTRZZ"] = 0; + this->linstressXY_.resize(bufferSize,0.0); + rstKeywords["LINSTRXY"] = 0; + this->linstressXZ_.resize(bufferSize,0.0); + rstKeywords["LINSTRXZ"] = 0; + this->linstressYZ_.resize(bufferSize,0.0); + rstKeywords["LINSTRYZ"] = 0; + + allocated_ = true; +} + +template class MechContainer; + +#if FLOW_INSTANTIATE_FLOAT +template class MechContainer; +#endif } // namespace Opm diff --git a/opm/simulators/flow/MechContainer.hpp b/opm/simulators/flow/MechContainer.hpp index af37a7272..94b244b44 100644 --- a/opm/simulators/flow/MechContainer.hpp +++ b/opm/simulators/flow/MechContainer.hpp @@ -26,6 +26,9 @@ #ifndef OPM_MECH_CONTAINER_HPP #define OPM_MECH_CONTAINER_HPP +#include +#include +#include #include namespace Opm { @@ -36,6 +39,13 @@ class MechContainer using ScalarBuffer = std::vector; public: + void allocate(const std::size_t bufferSize, + std::map& rstKeywords); + + bool allocated() const + { return allocated_; } + + bool allocated_ = false; ScalarBuffer potentialForce_; ScalarBuffer potentialPressForce_; ScalarBuffer potentialTempForce_; diff --git a/opm/simulators/flow/OutputBlackoilModule.hpp b/opm/simulators/flow/OutputBlackoilModule.hpp index b6f457923..fb655fc37 100644 --- a/opm/simulators/flow/OutputBlackoilModule.hpp +++ b/opm/simulators/flow/OutputBlackoilModule.hpp @@ -196,7 +196,7 @@ public: void processElementMech(const ElementContext& elemCtx) { if constexpr (getPropValue()) { - if (this->mech_.potentialForce_.empty()) { + if (!this->mech_.allocated()) { return; }