Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions opm/common/utility/SymmTensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ SymmTensor<T> operator+(SymmTensor<T> t1, const SymmTensor<T>& t2)
return t1;
}

template<class T>
bool SymmTensor<T>::operator==(const SymmTensor<T>& t1) const
{
return this->data_ == t1.data_;
}


#define INSTANTIATE_OPS(T1, T2) \
template SymmTensor<T1> operator*(const T2, SymmTensor<T1>); \
template SymmTensor<T1> operator*(SymmTensor<T1>, const T2);
Expand Down
2 changes: 2 additions & 0 deletions opm/common/utility/SymmTensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class SymmTensor : public VoigtContainer<T>

SymmTensor<T>& operator=(const T value);

bool operator==(const SymmTensor&) const;

void reset();

T trace() const;
Expand Down
6 changes: 6 additions & 0 deletions opm/common/utility/VoigtArray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ class VoigtContainer

constexpr std::size_t size() const { return data_.size(); }

template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(data_);
}

protected:
std::array<T, 6> data_{};
};
Expand Down
118 changes: 29 additions & 89 deletions opm/input/eclipse/EclipseState/InitConfig/Equil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,18 @@ namespace Opm {
: datum_depth(record.getItem<ParserKeywords::STREQUIL::DATUM_DEPTH>().getSIDouble(0))
, datum_posx(record.getItem<ParserKeywords::STREQUIL::DATUM_POSX>().getSIDouble(0))
, datum_posy(record.getItem<ParserKeywords::STREQUIL::DATUM_POSY>().getSIDouble(0))
, stress_xx(record.getItem<ParserKeywords::STREQUIL::STRESSXX>().getSIDouble(0))
, stress_xx_grad(record.getItem<ParserKeywords::STREQUIL::STRESSXXGRAD>().getSIDouble(0))
, stress_yy(record.getItem<ParserKeywords::STREQUIL::STRESSYY>().getSIDouble(0))
, stress_yy_grad(record.getItem<ParserKeywords::STREQUIL::STRESSYYGRAD>().getSIDouble(0))
, stress_zz(record.getItem<ParserKeywords::STREQUIL::STRESSZZ>().getSIDouble(0))
, stress_zz_grad(record.getItem<ParserKeywords::STREQUIL::STRESSZZGRAD>().getSIDouble(0))
, stress_xy(record.getItem<ParserKeywords::STREQUIL::STRESSXY>().getSIDouble(0))
, stress_xy_grad(record.getItem<ParserKeywords::STREQUIL::STRESSXYGRAD>().getSIDouble(0))
, stress_xz(record.getItem<ParserKeywords::STREQUIL::STRESSXZ>().getSIDouble(0))
, stress_xz_grad(record.getItem<ParserKeywords::STREQUIL::STRESSXZGRAD>().getSIDouble(0))
, stress_yz(record.getItem<ParserKeywords::STREQUIL::STRESSYZ>().getSIDouble(0))
, stress_yz_grad(record.getItem<ParserKeywords::STREQUIL::STRESSYZGRAD>().getSIDouble(0))
, stress_{record.getItem<ParserKeywords::STREQUIL::STRESSXX>().getSIDouble(0),
record.getItem<ParserKeywords::STREQUIL::STRESSYY>().getSIDouble(0),
record.getItem<ParserKeywords::STREQUIL::STRESSZZ>().getSIDouble(0),
record.getItem<ParserKeywords::STREQUIL::STRESSYZ>().getSIDouble(0),
record.getItem<ParserKeywords::STREQUIL::STRESSXZ>().getSIDouble(0),
record.getItem<ParserKeywords::STREQUIL::STRESSXY>().getSIDouble(0)}
, stress_grad_{record.getItem<ParserKeywords::STREQUIL::STRESSXXGRAD>().getSIDouble(0),
record.getItem<ParserKeywords::STREQUIL::STRESSYYGRAD>().getSIDouble(0),
record.getItem<ParserKeywords::STREQUIL::STRESSZZGRAD>().getSIDouble(0),
record.getItem<ParserKeywords::STREQUIL::STRESSYZGRAD>().getSIDouble(0),
record.getItem<ParserKeywords::STREQUIL::STRESSXZGRAD>().getSIDouble(0),
record.getItem<ParserKeywords::STREQUIL::STRESSXYGRAD>().getSIDouble(0)}
{}

StressEquilRecord StressEquilRecord::serializationTestObject()
Expand All @@ -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;
}
Expand All @@ -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_)
;
}

Expand Down
51 changes: 12 additions & 39 deletions opm/input/eclipse/EclipseState/InitConfig/Equil.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef OPM_EQUIL_HPP
#define OPM_EQUIL_HPP

#include <opm/common/utility/SymmTensor.hpp>

#include <cstddef>
#include <vector>

Expand Down Expand Up @@ -76,58 +78,29 @@ 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<double>& stress() const
{ return stress_; }

const SymmTensor<double>& stress_grad() const
{ return stress_grad_; }

template<class Serializer>
void serializeOp(Serializer& serializer)
{
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<double> stress_{};
SymmTensor<double> stress_grad_{};
};

template<class RecordType>
Expand Down
12 changes: 6 additions & 6 deletions tests/parser/InitConfigTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions tests/test_Serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down