Skip to content

Commit 02103b9

Browse files
committed
StressEquil: change to storing tensors as SymmTensor instances
1 parent f13b156 commit 02103b9

File tree

6 files changed

+62
-134
lines changed

6 files changed

+62
-134
lines changed

opm/common/utility/SymmTensor.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ SymmTensor<T> operator+(SymmTensor<T> t1, const SymmTensor<T>& t2)
113113
return t1;
114114
}
115115

116+
template<class T>
117+
bool SymmTensor<T>::operator==(const SymmTensor<T>& t1) const
118+
{
119+
return this->data_ == t1.data_;
120+
}
121+
122+
116123
#define INSTANTIATE_OPS(T1, T2) \
117124
template SymmTensor<T1> operator*(const T2, SymmTensor<T1>); \
118125
template SymmTensor<T1> operator*(SymmTensor<T1>, const T2);

opm/common/utility/SymmTensor.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class SymmTensor : public VoigtContainer<T>
4848

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

51+
bool operator==(const SymmTensor&) const;
52+
5153
void reset();
5254

5355
T trace() const;

opm/common/utility/VoigtArray.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ class VoigtContainer
8686

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

89+
template<class Serializer>
90+
void serializeOp(Serializer& serializer)
91+
{
92+
serializer(data_);
93+
}
94+
8995
protected:
9096
std::array<T, 6> data_{};
9197
};

opm/input/eclipse/EclipseState/InitConfig/Equil.cpp

Lines changed: 29 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,18 @@ namespace Opm {
105105
: datum_depth(record.getItem<ParserKeywords::STREQUIL::DATUM_DEPTH>().getSIDouble(0))
106106
, datum_posx(record.getItem<ParserKeywords::STREQUIL::DATUM_POSX>().getSIDouble(0))
107107
, datum_posy(record.getItem<ParserKeywords::STREQUIL::DATUM_POSY>().getSIDouble(0))
108-
, stress_xx(record.getItem<ParserKeywords::STREQUIL::STRESSXX>().getSIDouble(0))
109-
, stress_xx_grad(record.getItem<ParserKeywords::STREQUIL::STRESSXXGRAD>().getSIDouble(0))
110-
, stress_yy(record.getItem<ParserKeywords::STREQUIL::STRESSYY>().getSIDouble(0))
111-
, stress_yy_grad(record.getItem<ParserKeywords::STREQUIL::STRESSYYGRAD>().getSIDouble(0))
112-
, stress_zz(record.getItem<ParserKeywords::STREQUIL::STRESSZZ>().getSIDouble(0))
113-
, stress_zz_grad(record.getItem<ParserKeywords::STREQUIL::STRESSZZGRAD>().getSIDouble(0))
114-
, stress_xy(record.getItem<ParserKeywords::STREQUIL::STRESSXY>().getSIDouble(0))
115-
, stress_xy_grad(record.getItem<ParserKeywords::STREQUIL::STRESSXYGRAD>().getSIDouble(0))
116-
, stress_xz(record.getItem<ParserKeywords::STREQUIL::STRESSXZ>().getSIDouble(0))
117-
, stress_xz_grad(record.getItem<ParserKeywords::STREQUIL::STRESSXZGRAD>().getSIDouble(0))
118-
, stress_yz(record.getItem<ParserKeywords::STREQUIL::STRESSYZ>().getSIDouble(0))
119-
, stress_yz_grad(record.getItem<ParserKeywords::STREQUIL::STRESSYZGRAD>().getSIDouble(0))
108+
, stress_{record.getItem<ParserKeywords::STREQUIL::STRESSXX>().getSIDouble(0),
109+
record.getItem<ParserKeywords::STREQUIL::STRESSYY>().getSIDouble(0),
110+
record.getItem<ParserKeywords::STREQUIL::STRESSZZ>().getSIDouble(0),
111+
record.getItem<ParserKeywords::STREQUIL::STRESSYZ>().getSIDouble(0),
112+
record.getItem<ParserKeywords::STREQUIL::STRESSXZ>().getSIDouble(0),
113+
record.getItem<ParserKeywords::STREQUIL::STRESSXY>().getSIDouble(0)}
114+
, stress_grad_{record.getItem<ParserKeywords::STREQUIL::STRESSXXGRAD>().getSIDouble(0),
115+
record.getItem<ParserKeywords::STREQUIL::STRESSYYGRAD>().getSIDouble(0),
116+
record.getItem<ParserKeywords::STREQUIL::STRESSZZGRAD>().getSIDouble(0),
117+
record.getItem<ParserKeywords::STREQUIL::STRESSYZGRAD>().getSIDouble(0),
118+
record.getItem<ParserKeywords::STREQUIL::STRESSXZGRAD>().getSIDouble(0),
119+
record.getItem<ParserKeywords::STREQUIL::STRESSXYGRAD>().getSIDouble(0)}
120120
{}
121121

122122
StressEquilRecord StressEquilRecord::serializationTestObject()
@@ -125,19 +125,21 @@ namespace Opm {
125125
result.datum_depth = 1.0;
126126
result.datum_posx = 2.0;
127127
result.datum_posy = 3.0;
128-
result.stress_xx = 4.0;
129-
result.stress_xx_grad = 5.0;
130-
result.stress_yy = 6.0;
131-
result.stress_yy_grad = 7.0;
132-
result.stress_zz = 8.0;
133-
result.stress_zz_grad = 9.0;
134-
135-
result.stress_xy = 4.0;
136-
result.stress_xy_grad = 5.0;
137-
result.stress_xz = 6.0;
138-
result.stress_xz_grad = 7.0;
139-
result.stress_yz = 8.0;
140-
result.stress_yz_grad = 9.0;
128+
result.stress_[VoigtIndex::XX] = 4.0;
129+
result.stress_grad_[VoigtIndex::XX] = 5.0;
130+
result.stress_[VoigtIndex::YY] = 6.0;
131+
result.stress_grad_[VoigtIndex::YY] = 7.0;
132+
result.stress_[VoigtIndex::ZZ] = 8.0;
133+
result.stress_grad_[VoigtIndex::ZZ] = 9.0;
134+
135+
result.stress_[VoigtIndex::XZ] = 10.0;
136+
result.stress_grad_[VoigtIndex::XZ] = 11.0;
137+
result.stress_[VoigtIndex::XY] = 12.0;
138+
result.stress_grad_[VoigtIndex::XY] = 13.0;
139+
result.stress_[VoigtIndex::XZ] = 14.0;
140+
result.stress_grad_[VoigtIndex::XZ] = 15.0;
141+
result.stress_[VoigtIndex::YZ] = 16.0;
142+
result.stress_grad_[VoigtIndex::YZ] = 17.0;
141143

142144
return result;
143145
}
@@ -154,75 +156,13 @@ namespace Opm {
154156
return this->datum_posy;
155157
}
156158

157-
double StressEquilRecord::stressXX() const {
158-
return this->stress_xx;
159-
}
160-
161-
double StressEquilRecord::stressXX_grad() const {
162-
return this->stress_xx_grad;
163-
}
164-
165-
double StressEquilRecord::stressYY() const {
166-
return this->stress_yy;
167-
}
168-
169-
double StressEquilRecord::stressYY_grad() const {
170-
return this->stress_yy_grad;
171-
}
172-
173-
double StressEquilRecord::stressZZ() const {
174-
return this->stress_zz;
175-
}
176-
177-
double StressEquilRecord::stressZZ_grad() const {
178-
return this->stress_zz_grad;
179-
}
180-
181-
double StressEquilRecord::stressXY() const
182-
{
183-
return this->stress_xy;
184-
}
185-
186-
double StressEquilRecord::stressXY_grad() const
187-
{
188-
return this->stress_xy_grad;
189-
}
190-
191-
double StressEquilRecord::stressXZ() const
192-
{
193-
return this->stress_xz;
194-
}
195-
196-
double StressEquilRecord::stressXZ_grad() const
197-
{
198-
return this->stress_xz_grad;
199-
}
200-
201-
double StressEquilRecord::stressYZ() const
202-
{
203-
return this->stress_yz;
204-
}
205-
206-
double StressEquilRecord::stressYZ_grad() const
207-
{
208-
return this->stress_yz_grad;
209-
}
210-
211159
bool StressEquilRecord::operator==(const StressEquilRecord& data) const
212160
{
213161
return (datum_depth == data.datum_depth)
214162
&& (datum_posx == data.datum_posx)
215163
&& (datum_posy == data.datum_posy)
216-
217-
// Diagonal terms
218-
&& (stress_xx == data.stress_xx) && (stress_xx_grad == data.stress_xx_grad)
219-
&& (stress_yy == data.stress_yy) && (stress_yy_grad == data.stress_yy_grad)
220-
&& (stress_zz == data.stress_zz) && (stress_zz_grad == data.stress_zz_grad)
221-
222-
// Cross terms
223-
&& (stress_xy == data.stress_xy) && (stress_xy_grad == data.stress_xy_grad)
224-
&& (stress_xz == data.stress_xz) && (stress_xz_grad == data.stress_xz_grad)
225-
&& (stress_yz == data.stress_yz) && (stress_yz_grad == data.stress_yz_grad)
164+
&& (stress_ == data.stress_)
165+
&& (stress_grad_ == data.stress_grad_)
226166
;
227167
}
228168

opm/input/eclipse/EclipseState/InitConfig/Equil.hpp

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef OPM_EQUIL_HPP
22
#define OPM_EQUIL_HPP
33

4+
#include <opm/common/utility/SymmTensor.hpp>
5+
46
#include <cstddef>
57
#include <vector>
68

@@ -76,58 +78,29 @@ namespace Opm {
7678
double datumDepth() const;
7779
double datumPosX() const;
7880
double datumPosY() const;
79-
double stressXX() const;
80-
double stressXX_grad() const;
81-
double stressYY() const;
82-
double stressYY_grad() const;
83-
double stressZZ() const;
84-
double stressZZ_grad() const;
85-
86-
double stressXY() const;
87-
double stressXY_grad() const;
88-
double stressXZ() const;
89-
double stressXZ_grad() const;
90-
double stressYZ() const;
91-
double stressYZ_grad() const;
81+
82+
const SymmTensor<double>& stress() const
83+
{ return stress_; }
84+
85+
const SymmTensor<double>& stress_grad() const
86+
{ return stress_grad_; }
9287

9388
template<class Serializer>
9489
void serializeOp(Serializer& serializer)
9590
{
9691
serializer(datum_depth);
9792
serializer(datum_posx);
9893
serializer(datum_posy);
99-
serializer(stress_xx);
100-
serializer(stress_xx_grad);
101-
serializer(stress_yy);
102-
serializer(stress_yy_grad);
103-
serializer(stress_zz);
104-
serializer(stress_zz_grad);
105-
106-
serializer(stress_xy);
107-
serializer(stress_xy_grad);
108-
serializer(stress_xz);
109-
serializer(stress_xz_grad);
110-
serializer(stress_yz);
111-
serializer(stress_yz_grad);
94+
serializer(stress_);
95+
serializer(stress_grad_);
11296
}
11397

11498
private:
11599
double datum_depth = 0.0;
116100
double datum_posx = 0.0;
117101
double datum_posy = 0.0;
118-
double stress_xx = 0.0;
119-
double stress_xx_grad = 0.0;
120-
double stress_yy = 0.0;
121-
double stress_yy_grad = 0.0;
122-
double stress_zz = 0.0;
123-
double stress_zz_grad = 0.0;
124-
125-
double stress_xy = 0.0;
126-
double stress_xy_grad = 0.0;
127-
double stress_xz = 0.0;
128-
double stress_xz_grad = 0.0;
129-
double stress_yz = 0.0;
130-
double stress_yz_grad = 0.0;
102+
SymmTensor<double> stress_{};
103+
SymmTensor<double> stress_grad_{};
131104
};
132105

133106
template<class RecordType>

tests/parser/InitConfigTest.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,12 @@ BOOST_AUTO_TEST_CASE(StrEquilOperations)
383383
BOOST_CHECK_CLOSE(1.0, record.datumDepth(), 1.0);
384384
BOOST_CHECK_CLOSE(2.0, record.datumPosX(), 1e-12);
385385
BOOST_CHECK_CLOSE(3.0, record.datumPosY(), 1e-12);
386-
BOOST_CHECK_CLOSE(4.0 * unit::barsa, record.stressXX(), 1e-12);
387-
BOOST_CHECK_CLOSE(5.0 * unit::barsa, record.stressXX_grad(), 1e-12);
388-
BOOST_CHECK_CLOSE(6.0 * unit::barsa, record.stressYY(), 1e-12);
389-
BOOST_CHECK_CLOSE(7.0 * unit::barsa, record.stressYY_grad(), 1e-12);
390-
BOOST_CHECK_CLOSE(8.0 * unit::barsa, record.stressZZ(), 1e-12);
391-
BOOST_CHECK_CLOSE(9.0 * unit::barsa, record.stressZZ_grad(), 1e-12);
386+
BOOST_CHECK_CLOSE(4.0 * unit::barsa, record.stress()[VoigtIndex::XX], 1e-12);
387+
BOOST_CHECK_CLOSE(5.0 * unit::barsa, record.stress_grad()[VoigtIndex::XX], 1e-12);
388+
BOOST_CHECK_CLOSE(6.0 * unit::barsa, record.stress()[VoigtIndex::YY], 1e-12);
389+
BOOST_CHECK_CLOSE(7.0 * unit::barsa, record.stress_grad()[VoigtIndex::YY], 1e-12);
390+
BOOST_CHECK_CLOSE(8.0 * unit::barsa, record.stress()[VoigtIndex::ZZ], 1e-12);
391+
BOOST_CHECK_CLOSE(9.0 * unit::barsa, record.stress_grad()[VoigtIndex::ZZ], 1e-12);
392392
}
393393

394394
BOOST_AUTO_TEST_CASE(RestartCWD)

0 commit comments

Comments
 (0)