File tree Expand file tree Collapse file tree 3 files changed +103
-32
lines changed
opm/input/eclipse/EclipseState/Grid Expand file tree Collapse file tree 3 files changed +103
-32
lines changed Original file line number Diff line number Diff line change 16
16
#include < opm/input/eclipse/EclipseState/Grid/AutoRefinement.hpp>
17
17
18
18
19
+ #include < stdexcept>
20
+
19
21
namespace Opm {
20
22
21
23
@@ -25,12 +27,20 @@ AutoRefinement::AutoRefinement()
25
27
AutoRefinement::AutoRefinement (int nx,
26
28
int ny,
27
29
int nz,
28
- double option_trans_mult)
29
- : nx_{nx},
30
- ny_{ny},
31
- nz_{nz},
32
- option_trans_mult_{option_trans_mult}
33
- {}
30
+ double option_trans_mult)
31
+ {
32
+ bool invalid = invalidRefinementFactor (nx) || invalidRefinementFactor (ny) || invalidRefinementFactor (nz);
33
+ bool notYet = (option_trans_mult>0 );
34
+ if (invalid) {
35
+ throw std::invalid_argument (" Refinement factors must be odd and positive." );
36
+ }
37
+ else if (notYet) {
38
+ throw std::invalid_argument (" Only OPTION_TRANS_MULT 0 is supported for now." );
39
+ }
40
+ nx_ = nx;
41
+ ny_ = ny;
42
+ nz_ = nz;
43
+ }
34
44
35
45
int AutoRefinement::NX () const
36
46
{
Original file line number Diff line number Diff line change @@ -38,6 +38,12 @@ class AutoRefinement {
38
38
int nz_;
39
39
double option_trans_mult_{0 .};
40
40
41
+ bool invalidRefinementFactor (int n)
42
+ {
43
+ return (n<=0 ) || (n%2 == 0 );
44
+ }
45
+
46
+
41
47
};
42
48
}
43
49
Original file line number Diff line number Diff line change @@ -32,8 +32,7 @@ using namespace Opm;
32
32
33
33
34
34
BOOST_AUTO_TEST_CASE (ReadAutoref) {
35
-
36
-
35
+
37
36
const std::string deck_string = R"(
38
37
RUNSPEC
39
38
54
53
TOPS
55
54
100*1 /
56
55
57
- PORO
58
- 1000*0.15 /
59
-
60
- PERMX
61
- 1000*1 /
62
-
63
- COPY
64
- PERMX PERMZ /
65
- PERMX PERMY /
66
- /
67
-
68
- EDIT
69
-
70
- OIL
71
- GAS
72
-
73
- TITLE
74
- The title
75
-
76
- START
77
- 16 JUN 1988 /
78
-
79
56
PROPS
80
57
81
- REGIONS
82
-
83
58
SOLUTION
84
59
85
60
SCHEDULE
@@ -101,3 +76,83 @@ SCHEDULE
101
76
BOOST_CHECK_EQUAL ( autoRef.NZ (), 1 );
102
77
BOOST_CHECK_EQUAL ( autoRef.OPTION_TRANS_MULT (), 0 .);
103
78
}
79
+
80
+ BOOST_AUTO_TEST_CASE (ThrowEvenRefinementFactor) {
81
+
82
+ const std::string deck_string = R"(
83
+ RUNSPEC
84
+
85
+ DIMENS
86
+ 1 1 1 /
87
+
88
+ AUTOREF
89
+ 3 2 1 0. /
90
+
91
+ GRID
92
+
93
+ DX
94
+ 1*1 /
95
+ DY
96
+ 1*1 /
97
+ DZ
98
+ 1*1 /
99
+ TOPS
100
+ 1*0 /
101
+
102
+ PROPS
103
+
104
+ SOLUTION
105
+
106
+ SCHEDULE
107
+ )" ;
108
+
109
+ Opm::Parser parser;
110
+ Opm::Deck deck = parser.parseString (deck_string);
111
+ Opm::EclipseState state (deck);
112
+
113
+ const auto & autoref_keyword = deck[" AUTOREF" ][0 ];
114
+
115
+ Opm::AutoRefManager autoRefManager{};
116
+
117
+ BOOST_CHECK_THROW (Opm::readKeywordAutoRef (autoref_keyword.getRecord (0 ), autoRefManager), std::invalid_argument);
118
+ }
119
+
120
+ BOOST_AUTO_TEST_CASE (ThrowNonDefaultOptionTransMult) {
121
+
122
+ const std::string deck_string = R"(
123
+ RUNSPEC
124
+
125
+ DIMENS
126
+ 1 1 1 /
127
+
128
+ AUTOREF
129
+ 3 5 7 1 /
130
+
131
+ GRID
132
+
133
+ DX
134
+ 1*1 /
135
+ DY
136
+ 1*1 /
137
+ DZ
138
+ 1*1 /
139
+ TOPS
140
+ 1*0 /
141
+
142
+ PROPS
143
+
144
+ SOLUTION
145
+
146
+ SCHEDULE
147
+ )" ;
148
+
149
+ Opm::Parser parser;
150
+ Opm::Deck deck = parser.parseString (deck_string);
151
+ Opm::EclipseState state (deck);
152
+
153
+ const auto & autoref_keyword = deck[" AUTOREF" ][0 ];
154
+
155
+ Opm::AutoRefManager autoRefManager{};
156
+
157
+ BOOST_CHECK_THROW (Opm::readKeywordAutoRef (autoref_keyword.getRecord (0 ), autoRefManager), std::invalid_argument);
158
+ }
You can’t perform that action at this time.
0 commit comments