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 1616#include < opm/input/eclipse/EclipseState/Grid/AutoRefinement.hpp>
1717
1818
19+ #include < stdexcept>
20+
1921namespace Opm {
2022
2123
@@ -25,12 +27,20 @@ AutoRefinement::AutoRefinement()
2527AutoRefinement::AutoRefinement (int nx,
2628 int ny,
2729 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+ }
3444
3545int AutoRefinement::NX () const
3646{
Original file line number Diff line number Diff line change @@ -38,6 +38,12 @@ class AutoRefinement {
3838 int nz_;
3939 double option_trans_mult_{0 .};
4040
41+ bool invalidRefinementFactor (int n)
42+ {
43+ return (n<=0 ) || (n%2 == 0 );
44+ }
45+
46+
4147};
4248}
4349
Original file line number Diff line number Diff line change @@ -32,8 +32,7 @@ using namespace Opm;
3232
3333
3434BOOST_AUTO_TEST_CASE (ReadAutoref) {
35-
36-
35+
3736 const std::string deck_string = R"(
3837RUNSPEC
3938
5453TOPS
5554100*1 /
5655
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-
7956PROPS
8057
81- REGIONS
82-
8358SOLUTION
8459
8560SCHEDULE
@@ -101,3 +76,83 @@ SCHEDULE
10176 BOOST_CHECK_EQUAL ( autoRef.NZ (), 1 );
10277 BOOST_CHECK_EQUAL ( autoRef.OPTION_TRANS_MULT (), 0 .);
10378}
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