File: test_ReportConfig.cpp

package info (click to toggle)
opm-common 2024.10%2Bds-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 98,420 kB
  • sloc: cpp: 263,013; python: 3,155; sh: 198; xml: 174; pascal: 136; makefile: 12
file content (165 lines) | stat: -rw-r--r-- 3,716 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
  Copyright 2020 Equinor ASA.

  This file is part of the Open Porous Media project (OPM).

  OPM is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  OPM is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with OPM.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <stdexcept>

#define BOOST_TEST_MODULE ReportConfigTest
#include <boost/test/unit_test.hpp>

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

#include <opm/input/eclipse/EclipseState/EclipseState.hpp>

#include <opm/input/eclipse/Schedule/RPTConfig.hpp>
#include <opm/input/eclipse/Schedule/Schedule.hpp>

#include <opm/input/eclipse/Python/Python.hpp>

#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>



Opm::Schedule make_schedule(const std::string& sched_string) {
    std::string deck_string = R"(
RUNSPEC
DIMENS
5 5 5 /
OIL
WATER
TABDIMS
/
WELLDIMS
2  10  3  2 /
GRID
DXV
5*100 /
DYV
5*100 /
DZV
5*5 /
TOPS
25*2500 /
PORO
125*0.15 /
PERMX
125*500 /
COPY
'PERMX' 'PERMY' /
'PERMX' 'PERMZ' /
/
MULTIPLY
'PERMZ' 0.1 /
/
PROPS
SWOF
0 0 1 0
1 1 0 0 /

SCHEDULE
)";
    Opm::Parser parser;
    auto deck = parser.parseString(deck_string + sched_string);
    Opm::EclipseState ecl_state(deck);
    auto python = std::make_shared<Opm::Python>();
    return Opm::Schedule(deck, ecl_state, python);
}



BOOST_AUTO_TEST_CASE(ReportConfig_INVALID) {
    const std::string sched_string1 = R"(
RPTSCHED
  FIPSOL=X
)";

    const std::string sched_string2 = R"(
RPTSCHED
  FIPSOL=-1
)";

    const std::string sched_string3 = R"(
RPTSCHED
  FIPSOL=2.50
)";

    BOOST_CHECK_THROW(make_schedule(sched_string1), Opm::OpmInputError);
    BOOST_CHECK_THROW(make_schedule(sched_string2), Opm::OpmInputError);
    BOOST_CHECK_THROW(make_schedule(sched_string3), Opm::OpmInputError);
}




BOOST_AUTO_TEST_CASE(ReportConfig) {
    const std::string sched_string = R"(
DATES
   1 'JAN' 2000 /
/

RPTSCHED
  FIPSOL FIP=3 /

DATES
   1  'FEB' 2000 /
/

RPTSCHED
  FIPSOL FIP=3 NOTHING /

)";
    auto sched = make_schedule(sched_string);

    // Empty initial report configuration
    {
        auto report_config = sched[0].rpt_config.get();
        BOOST_CHECK_EQUAL(report_config.size(), 0U);

        BOOST_CHECK(!report_config.contains("FIPFOAM"));
        BOOST_CHECK_THROW( report_config.at("FIPFOAM"), std::out_of_range);
    }

    // Configuration at step 1
    {
        auto report_config = sched[1].rpt_config.get();
        BOOST_CHECK_EQUAL( report_config.size() , 2U);

        for (const auto& p : report_config) {
            if (p.first == "FIPSOL")
                BOOST_CHECK_EQUAL(p.second, 1U);

            if (p.first == "FIP")
                BOOST_CHECK_EQUAL(p.second, 3U);
        }

        BOOST_CHECK(!report_config.contains("FIPFOAM"));
        BOOST_CHECK(report_config.contains("FIP"));
        BOOST_CHECK_EQUAL(report_config.at("FIP"), 3U);
        BOOST_CHECK_EQUAL(report_config.at("FIPSOL"), 1U);
    }

    // Configuration at step 2 - the special 'NOTHING' has cleared everything
    {
        auto report_config = sched[2].rpt_config.get();
        BOOST_CHECK_EQUAL(report_config.size(), 0U);

        BOOST_CHECK(!report_config.contains("FIPFOAM"));
        BOOST_CHECK_THROW( report_config.at("FIPFOAM"), std::out_of_range);
    }
}