diff --git a/opm/common/utility/SymmTensor.cpp b/opm/common/utility/SymmTensor.cpp index 7294580ac17..ca56537bef0 100644 --- a/opm/common/utility/SymmTensor.cpp +++ b/opm/common/utility/SymmTensor.cpp @@ -113,6 +113,13 @@ SymmTensor operator+(SymmTensor t1, const SymmTensor& t2) return t1; } +template +bool SymmTensor::operator==(const SymmTensor& t1) const +{ + return this->data_ == t1.data_; +} + + #define INSTANTIATE_OPS(T1, T2) \ template SymmTensor operator*(const T2, SymmTensor); \ template SymmTensor operator*(SymmTensor, const T2); diff --git a/opm/common/utility/SymmTensor.hpp b/opm/common/utility/SymmTensor.hpp index f2b5a3e4dae..ee67853df2b 100644 --- a/opm/common/utility/SymmTensor.hpp +++ b/opm/common/utility/SymmTensor.hpp @@ -48,6 +48,8 @@ class SymmTensor : public VoigtContainer SymmTensor& operator=(const T value); + bool operator==(const SymmTensor&) const; + void reset(); T trace() const; diff --git a/opm/common/utility/VoigtArray.hpp b/opm/common/utility/VoigtArray.hpp index c2a648fffb6..94cdd9f55a0 100644 --- a/opm/common/utility/VoigtArray.hpp +++ b/opm/common/utility/VoigtArray.hpp @@ -86,6 +86,12 @@ class VoigtContainer constexpr std::size_t size() const { return data_.size(); } + template + void serializeOp(Serializer& serializer) + { + serializer(data_); + } + protected: std::array data_{}; }; diff --git a/opm/input/eclipse/EclipseState/InitConfig/Equil.cpp b/opm/input/eclipse/EclipseState/InitConfig/Equil.cpp index af510df603d..96d1f9ba0d6 100644 --- a/opm/input/eclipse/EclipseState/InitConfig/Equil.cpp +++ b/opm/input/eclipse/EclipseState/InitConfig/Equil.cpp @@ -105,18 +105,18 @@ namespace Opm { : datum_depth(record.getItem().getSIDouble(0)) , datum_posx(record.getItem().getSIDouble(0)) , datum_posy(record.getItem().getSIDouble(0)) - , stress_xx(record.getItem().getSIDouble(0)) - , stress_xx_grad(record.getItem().getSIDouble(0)) - , stress_yy(record.getItem().getSIDouble(0)) - , stress_yy_grad(record.getItem().getSIDouble(0)) - , stress_zz(record.getItem().getSIDouble(0)) - , stress_zz_grad(record.getItem().getSIDouble(0)) - , stress_xy(record.getItem().getSIDouble(0)) - , stress_xy_grad(record.getItem().getSIDouble(0)) - , stress_xz(record.getItem().getSIDouble(0)) - , stress_xz_grad(record.getItem().getSIDouble(0)) - , stress_yz(record.getItem().getSIDouble(0)) - , stress_yz_grad(record.getItem().getSIDouble(0)) + , stress_{record.getItem().getSIDouble(0), + record.getItem().getSIDouble(0), + record.getItem().getSIDouble(0), + record.getItem().getSIDouble(0), + record.getItem().getSIDouble(0), + record.getItem().getSIDouble(0)} + , stress_grad_{record.getItem().getSIDouble(0), + record.getItem().getSIDouble(0), + record.getItem().getSIDouble(0), + record.getItem().getSIDouble(0), + record.getItem().getSIDouble(0), + record.getItem().getSIDouble(0)} {} StressEquilRecord StressEquilRecord::serializationTestObject() @@ -125,19 +125,21 @@ namespace Opm { result.datum_depth = 1.0; result.datum_posx = 2.0; result.datum_posy = 3.0; - result.stress_xx = 4.0; - result.stress_xx_grad = 5.0; - result.stress_yy = 6.0; - result.stress_yy_grad = 7.0; - result.stress_zz = 8.0; - result.stress_zz_grad = 9.0; - - result.stress_xy = 4.0; - result.stress_xy_grad = 5.0; - result.stress_xz = 6.0; - result.stress_xz_grad = 7.0; - result.stress_yz = 8.0; - result.stress_yz_grad = 9.0; + result.stress_[VoigtIndex::XX] = 4.0; + result.stress_grad_[VoigtIndex::XX] = 5.0; + result.stress_[VoigtIndex::YY] = 6.0; + result.stress_grad_[VoigtIndex::YY] = 7.0; + result.stress_[VoigtIndex::ZZ] = 8.0; + result.stress_grad_[VoigtIndex::ZZ] = 9.0; + + result.stress_[VoigtIndex::XZ] = 10.0; + result.stress_grad_[VoigtIndex::XZ] = 11.0; + result.stress_[VoigtIndex::XY] = 12.0; + result.stress_grad_[VoigtIndex::XY] = 13.0; + result.stress_[VoigtIndex::XZ] = 14.0; + result.stress_grad_[VoigtIndex::XZ] = 15.0; + result.stress_[VoigtIndex::YZ] = 16.0; + result.stress_grad_[VoigtIndex::YZ] = 17.0; return result; } @@ -154,75 +156,13 @@ namespace Opm { return this->datum_posy; } - double StressEquilRecord::stressXX() const { - return this->stress_xx; - } - - double StressEquilRecord::stressXX_grad() const { - return this->stress_xx_grad; - } - - double StressEquilRecord::stressYY() const { - return this->stress_yy; - } - - double StressEquilRecord::stressYY_grad() const { - return this->stress_yy_grad; - } - - double StressEquilRecord::stressZZ() const { - return this->stress_zz; - } - - double StressEquilRecord::stressZZ_grad() const { - return this->stress_zz_grad; - } - - double StressEquilRecord::stressXY() const - { - return this->stress_xy; - } - - double StressEquilRecord::stressXY_grad() const - { - return this->stress_xy_grad; - } - - double StressEquilRecord::stressXZ() const - { - return this->stress_xz; - } - - double StressEquilRecord::stressXZ_grad() const - { - return this->stress_xz_grad; - } - - double StressEquilRecord::stressYZ() const - { - return this->stress_yz; - } - - double StressEquilRecord::stressYZ_grad() const - { - return this->stress_yz_grad; - } - bool StressEquilRecord::operator==(const StressEquilRecord& data) const { return (datum_depth == data.datum_depth) && (datum_posx == data.datum_posx) && (datum_posy == data.datum_posy) - - // Diagonal terms - && (stress_xx == data.stress_xx) && (stress_xx_grad == data.stress_xx_grad) - && (stress_yy == data.stress_yy) && (stress_yy_grad == data.stress_yy_grad) - && (stress_zz == data.stress_zz) && (stress_zz_grad == data.stress_zz_grad) - - // Cross terms - && (stress_xy == data.stress_xy) && (stress_xy_grad == data.stress_xy_grad) - && (stress_xz == data.stress_xz) && (stress_xz_grad == data.stress_xz_grad) - && (stress_yz == data.stress_yz) && (stress_yz_grad == data.stress_yz_grad) + && (stress_ == data.stress_) + && (stress_grad_ == data.stress_grad_) ; } diff --git a/opm/input/eclipse/EclipseState/InitConfig/Equil.hpp b/opm/input/eclipse/EclipseState/InitConfig/Equil.hpp index cd42b92498c..7ddf2675a40 100644 --- a/opm/input/eclipse/EclipseState/InitConfig/Equil.hpp +++ b/opm/input/eclipse/EclipseState/InitConfig/Equil.hpp @@ -1,6 +1,8 @@ #ifndef OPM_EQUIL_HPP #define OPM_EQUIL_HPP +#include + #include #include @@ -76,19 +78,12 @@ namespace Opm { double datumDepth() const; double datumPosX() const; double datumPosY() const; - double stressXX() const; - double stressXX_grad() const; - double stressYY() const; - double stressYY_grad() const; - double stressZZ() const; - double stressZZ_grad() const; - - double stressXY() const; - double stressXY_grad() const; - double stressXZ() const; - double stressXZ_grad() const; - double stressYZ() const; - double stressYZ_grad() const; + + const SymmTensor& stress() const + { return stress_; } + + const SymmTensor& stress_grad() const + { return stress_grad_; } template void serializeOp(Serializer& serializer) @@ -96,38 +91,16 @@ namespace Opm { serializer(datum_depth); serializer(datum_posx); serializer(datum_posy); - serializer(stress_xx); - serializer(stress_xx_grad); - serializer(stress_yy); - serializer(stress_yy_grad); - serializer(stress_zz); - serializer(stress_zz_grad); - - serializer(stress_xy); - serializer(stress_xy_grad); - serializer(stress_xz); - serializer(stress_xz_grad); - serializer(stress_yz); - serializer(stress_yz_grad); + serializer(stress_); + serializer(stress_grad_); } private: double datum_depth = 0.0; double datum_posx = 0.0; double datum_posy = 0.0; - double stress_xx = 0.0; - double stress_xx_grad = 0.0; - double stress_yy = 0.0; - double stress_yy_grad = 0.0; - double stress_zz = 0.0; - double stress_zz_grad = 0.0; - - double stress_xy = 0.0; - double stress_xy_grad = 0.0; - double stress_xz = 0.0; - double stress_xz_grad = 0.0; - double stress_yz = 0.0; - double stress_yz_grad = 0.0; + SymmTensor stress_{}; + SymmTensor stress_grad_{}; }; template diff --git a/tests/parser/InitConfigTest.cpp b/tests/parser/InitConfigTest.cpp index 7c0e0446663..fa30fcf2650 100644 --- a/tests/parser/InitConfigTest.cpp +++ b/tests/parser/InitConfigTest.cpp @@ -383,12 +383,12 @@ BOOST_AUTO_TEST_CASE(StrEquilOperations) BOOST_CHECK_CLOSE(1.0, record.datumDepth(), 1.0); BOOST_CHECK_CLOSE(2.0, record.datumPosX(), 1e-12); BOOST_CHECK_CLOSE(3.0, record.datumPosY(), 1e-12); - BOOST_CHECK_CLOSE(4.0 * unit::barsa, record.stressXX(), 1e-12); - BOOST_CHECK_CLOSE(5.0 * unit::barsa, record.stressXX_grad(), 1e-12); - BOOST_CHECK_CLOSE(6.0 * unit::barsa, record.stressYY(), 1e-12); - BOOST_CHECK_CLOSE(7.0 * unit::barsa, record.stressYY_grad(), 1e-12); - BOOST_CHECK_CLOSE(8.0 * unit::barsa, record.stressZZ(), 1e-12); - BOOST_CHECK_CLOSE(9.0 * unit::barsa, record.stressZZ_grad(), 1e-12); + BOOST_CHECK_CLOSE(4.0 * unit::barsa, record.stress()[VoigtIndex::XX], 1e-12); + BOOST_CHECK_CLOSE(5.0 * unit::barsa, record.stress_grad()[VoigtIndex::XX], 1e-12); + BOOST_CHECK_CLOSE(6.0 * unit::barsa, record.stress()[VoigtIndex::YY], 1e-12); + BOOST_CHECK_CLOSE(7.0 * unit::barsa, record.stress_grad()[VoigtIndex::YY], 1e-12); + BOOST_CHECK_CLOSE(8.0 * unit::barsa, record.stress()[VoigtIndex::ZZ], 1e-12); + BOOST_CHECK_CLOSE(9.0 * unit::barsa, record.stress_grad()[VoigtIndex::ZZ], 1e-12); } BOOST_AUTO_TEST_CASE(RestartCWD) diff --git a/tests/test_Serialization.cpp b/tests/test_Serialization.cpp index 0c8e97b1062..861d73db7cb 100644 --- a/tests/test_Serialization.cpp +++ b/tests/test_Serialization.cpp @@ -310,6 +310,7 @@ TEST_FOR_TYPE(SimulationConfig) TEST_FOR_TYPE(SkprpolyTable) TEST_FOR_TYPE(SkprwatTable) TEST_FOR_TYPE(SICD) +TEST_FOR_TYPE(StressEquil) TEST_FOR_TYPE(SolventDensityTable) TEST_FOR_TYPE(SummaryConfig) TEST_FOR_TYPE(SummaryConfigNode)