Skip to content

Commit 3408412

Browse files
committed
Add Undersaturated State Handling in Table Initialisation
This commit adds a procedure for expanding missing undersaturated states in PVTO/PVTG in the low-level Pvt*Table classes on top of which the higher level types are built. This, as an added benefit, directly ensures that we emit fully expanded PVTO/PVTG tables to the .INIT file. To this end, equip the base class PvtxTable with a helper function void PvtxTable::populateMissingUndersaturatedStates() which will invoke the virtual function makeScaledUSatTableCopy(src, dest) in its derived classes--especially PvtoTable and PvtgTable--for each missing undersaturated state. The type-specific procedures for PvtoTable and PvtgTable is defined in such a way that the scaled copies preserve oil compressibility.
1 parent 4e13b05 commit 3408412

File tree

11 files changed

+461
-92
lines changed

11 files changed

+461
-92
lines changed

opm/input/eclipse/EclipseState/Tables/PvtgTable.hpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,38 @@
1515
1616
You should have received a copy of the GNU General Public License
1717
along with OPM. If not, see <http://www.gnu.org/licenses/>.
18-
*/
18+
*/
19+
1920
#ifndef OPM_PARSER_PVTG_TABLE_HPP
20-
#define OPM_PARSER_PVTG_TABLE_HPP
21+
#define OPM_PARSER_PVTG_TABLE_HPP
2122

2223
#include <opm/input/eclipse/EclipseState/Tables/PvtxTable.hpp>
2324

25+
#include <cstddef>
26+
2427
namespace Opm {
2528

2629
class DeckKeyword;
2730

28-
class PvtgTable : public PvtxTable {
31+
} // namespace Opm
32+
33+
namespace Opm {
34+
35+
class PvtgTable : public PvtxTable
36+
{
2937
public:
3038
PvtgTable() = default;
31-
PvtgTable( const DeckKeyword& keyword, size_t tableIdx);
39+
PvtgTable(const DeckKeyword& keyword, std::size_t tableIdx);
3240

3341
static PvtgTable serializationTestObject();
3442

3543
bool operator==(const PvtgTable& data) const;
44+
45+
private:
46+
void makeScaledUSatTableCopy(const std::size_t src,
47+
const std::size_t dest) override;
3648
};
37-
}
3849

39-
#endif
50+
} // namespace Opm
51+
52+
#endif // OPM_PARSER_PVTG_TABLE_HPP

opm/input/eclipse/EclipseState/Tables/PvtgwTable.hpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,38 @@
1616
1717
You should have received a copy of the GNU General Public License
1818
along with OPM. If not, see <http://www.gnu.org/licenses/>.
19-
*/
19+
*/
20+
2021
#ifndef OPM_PARSER_PVTGW_TABLE_HPP
21-
#define OPM_PARSER_PVTGW_TABLE_HPP
22+
#define OPM_PARSER_PVTGW_TABLE_HPP
2223

2324
#include <opm/input/eclipse/EclipseState/Tables/PvtxTable.hpp>
2425

26+
#include <cstddef>
27+
2528
namespace Opm {
2629

2730
class DeckKeyword;
2831

29-
class PvtgwTable : public PvtxTable {
32+
} // namespace Opm
33+
34+
namespace Opm {
35+
36+
class PvtgwTable : public PvtxTable
37+
{
3038
public:
3139
PvtgwTable() = default;
32-
PvtgwTable( const DeckKeyword& keyword, size_t tableIdx);
40+
PvtgwTable(const DeckKeyword& keyword, const std::size_t tableIdx);
3341

3442
static PvtgwTable serializationTestObject();
3543

3644
bool operator==(const PvtgwTable& data) const;
45+
46+
private:
47+
void makeScaledUSatTableCopy(const std::size_t src,
48+
const std::size_t dest) override;
3749
};
38-
}
3950

40-
#endif
51+
} // namespace Opm
52+
53+
#endif // OPM_PARSER_PVTGW_TABLE_HPP

opm/input/eclipse/EclipseState/Tables/PvtgwoTable.hpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,38 @@
1616
1717
You should have received a copy of the GNU General Public License
1818
along with OPM. If not, see <http://www.gnu.org/licenses/>.
19-
*/
19+
*/
20+
2021
#ifndef OPM_PARSER_PVTGWO_TABLE_HPP
21-
#define OPM_PARSER_PVTGWO_TABLE_HPP
22+
#define OPM_PARSER_PVTGWO_TABLE_HPP
2223

2324
#include <opm/input/eclipse/EclipseState/Tables/PvtxTable.hpp>
2425

26+
#include <cstddef>
27+
2528
namespace Opm {
2629

2730
class DeckKeyword;
2831

29-
class PvtgwoTable : public PvtxTable {
32+
} // namespaced Opm
33+
34+
namespace Opm {
35+
36+
class PvtgwoTable : public PvtxTable
37+
{
3038
public:
3139
PvtgwoTable() = default;
32-
PvtgwoTable( const DeckKeyword& keyword, size_t tableIdx);
40+
PvtgwoTable(const DeckKeyword& keyword, const std::size_t tableIdx);
3341

3442
static PvtgwoTable serializationTestObject();
3543

3644
bool operator==(const PvtgwoTable& data) const;
45+
46+
private:
47+
void makeScaledUSatTableCopy(const std::size_t src,
48+
const std::size_t dest) override;
3749
};
38-
}
3950

40-
#endif
51+
} // namespace Opm
52+
53+
#endif // OPM_PARSER_PVTGWO_TABLE_HPP

opm/input/eclipse/EclipseState/Tables/PvtoTable.hpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
1616
You should have received a copy of the GNU General Public License
1717
along with OPM. If not, see <http://www.gnu.org/licenses/>.
18-
*/
18+
*/
19+
1920
#ifndef OPM_PARSER_PVTO_TABLE_HPP
2021
#define OPM_PARSER_PVTO_TABLE_HPP
2122

@@ -29,23 +30,34 @@ namespace Opm {
2930

3031
class DeckKeyword;
3132

32-
class PvtoTable : public PvtxTable {
33+
} // namespace Opm
34+
35+
namespace Opm {
36+
37+
class PvtoTable : public PvtxTable
38+
{
3339
public:
34-
struct FlippedFVF {
40+
struct FlippedFVF
41+
{
3542
std::size_t i;
3643
std::array<double, std::size_t{2}> Rs;
3744
std::array<double, std::size_t{2}> Bo;
3845
};
3946

4047
PvtoTable() = default;
41-
PvtoTable(const DeckKeyword& keyword, size_t tableIdx);
48+
PvtoTable(const DeckKeyword& keyword, std::size_t tableIdx);
4249

4350
static PvtoTable serializationTestObject();
4451

4552
bool operator==(const PvtoTable& data) const;
4653

4754
std::vector<FlippedFVF> nonMonotonicSaturatedFVF() const;
55+
56+
private:
57+
void makeScaledUSatTableCopy(const std::size_t src,
58+
const std::size_t dest) override;
4859
};
49-
}
5060

51-
#endif
61+
} // namespace Opm
62+
63+
#endif // OPM_PARSER_PVTO_TABLE_HPP

opm/input/eclipse/EclipseState/Tables/PvtsolTable.hpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,37 @@
1515
1616
You should have received a copy of the GNU General Public License
1717
along with OPM. If not, see <http://www.gnu.org/licenses/>.
18-
*/
18+
*/
19+
1920
#ifndef OPM_PARSER_PVTSOL_TABLE_HPP
20-
#define OPM_PARSER_PVTSOL_TABLE_HPP
21+
#define OPM_PARSER_PVTSOL_TABLE_HPP
2122

2223
#include <opm/input/eclipse/EclipseState/Tables/PvtxTable.hpp>
2324

25+
#include <cstddef>
26+
2427
namespace Opm {
2528

2629
class DeckKeyword;
2730

28-
class PvtsolTable : public PvtxTable {
31+
} // namespace Opm
32+
33+
namespace Opm {
34+
35+
class PvtsolTable : public PvtxTable
36+
{
2937
public:
3038
PvtsolTable() = default;
31-
PvtsolTable(const DeckKeyword& keyword, size_t tableIdx);
39+
PvtsolTable(const DeckKeyword& keyword, const std::size_t tableIdx);
40+
3241
static PvtsolTable serializationTestObject();
3342
bool operator==(const PvtsolTable& data) const;
43+
44+
private:
45+
void makeScaledUSatTableCopy(const std::size_t src,
46+
const std::size_t dest) override;
3447
};
35-
}
3648

37-
#endif
49+
} // namespace Opm
50+
51+
#endif // OPM_PARSER_PVTSOL_TABLE_HPP

opm/input/eclipse/EclipseState/Tables/PvtxTable.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ namespace Opm {
197197
ranges[*tableIdx].first,
198198
ranges[*tableIdx].second);
199199

200+
this->populateMissingUndersaturatedStates();
200201

201202
this->populateSaturatedTable(keyword.name());
202203
}
@@ -240,4 +241,53 @@ namespace Opm {
240241
}
241242
}
242243

244+
void PvtxTable::populateMissingUndersaturatedStates()
245+
{
246+
for (const auto& [src, dest] : this->missingUSatTables()) {
247+
this->makeScaledUSatTableCopy(src, dest);
248+
}
249+
}
250+
251+
std::vector<std::pair<std::size_t, std::size_t>>
252+
PvtxTable::missingUSatTables() const
253+
{
254+
auto missing = std::vector<std::pair<std::size_t, std::size_t>>{};
255+
256+
if (this->m_underSaturatedTables.empty()) {
257+
return missing;
258+
}
259+
260+
auto src = this->m_underSaturatedTables.size() - 1;
261+
262+
for (auto destIx = src + 1; destIx > 0; --destIx) {
263+
const auto dest = destIx - 1;
264+
265+
if (this->m_underSaturatedTables[dest].numRows() > 1) {
266+
// There are undersaturated states in 'dest'. This is the
267+
// new 'src'.
268+
src = dest;
269+
}
270+
else {
271+
// There are no undersaturated states in 'dest'. Schedule
272+
// generation of a scaled copy of 'src's undersaturated
273+
// states in 'dest'.
274+
missing.emplace_back(src, dest);
275+
}
276+
}
277+
278+
return missing;
279+
}
280+
281+
void PvtxTable::makeScaledUSatTableCopy([[maybe_unused]] const std::size_t src,
282+
[[maybe_unused]] const std::size_t dest)
283+
{
284+
// Implemented only because we need to be able to create objects of
285+
// type 'PvtxTable' for serialisation purposes. Ideally, this would
286+
// be a pure virtual function.
287+
288+
throw std::runtime_error {
289+
"Derived type does not implement makeScaledUSatTableCopy()"
290+
};
291+
}
292+
243293
} // namespace Opm

opm/input/eclipse/EclipseState/Tables/PvtxTable.hpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,39 @@ namespace Opm {
297297
/// \param[in] tableName Name of table/keyword we're internalising.
298298
/// Typically \code "PVTO" \endcode or \code "PVTG" \endcode.
299299
void populateSaturatedTable(const std::string& tableName);
300+
301+
/// Fill in any missing under-saturated states.
302+
///
303+
/// Takes scaled copies of under-saturated curves at higher
304+
/// composition/pressure nodes. Amends m_underSaturatedTables.
305+
void populateMissingUndersaturatedStates();
306+
307+
/// Identify missing under-saturated states in
308+
/// m_underSaturatedTables.
309+
///
310+
/// \return Pairs of source/destination indices. The
311+
/// under-saturated destination entries in m_underSaturatedTables
312+
/// will be scaled copies of the under-saturated source entries in
313+
/// m_underSaturatedTables.
314+
std::vector<std::pair<std::size_t, std::size_t>>
315+
missingUSatTables() const;
316+
317+
/// Generate scaled copies of under-saturated state curves.
318+
///
319+
/// Intended to amend a specific entry in m_underSaturatedTables
320+
/// based on source values in another specific entry in
321+
/// m_underSaturatedTables.
322+
///
323+
/// Virtual function in order to call back into the derived type for
324+
/// type-specific copying.
325+
///
326+
/// \param[in] src Index of source table with full set of
327+
/// under-saturated states.
328+
///
329+
/// \param[in] dest Index of destination table with no
330+
/// under-saturated states.
331+
virtual void makeScaledUSatTableCopy(const std::size_t src,
332+
const std::size_t dest);
300333
};
301334

302335
} // namespace Opm

opm/input/eclipse/EclipseState/Tables/RwgsaltTable.hpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,38 @@
1616
1717
You should have received a copy of the GNU General Public License
1818
along with OPM. If not, see <http://www.gnu.org/licenses/>.
19-
*/
19+
*/
20+
2021
#ifndef OPM_PARSER_RWGSALT_TABLE_HPP
21-
#define OPM_PARSER_RWGSALT_TABLE_HPP
22+
#define OPM_PARSER_RWGSALT_TABLE_HPP
2223

2324
#include <opm/input/eclipse/EclipseState/Tables/PvtxTable.hpp>
2425

26+
#include <cstddef>
27+
2528
namespace Opm {
2629

2730
class DeckKeyword;
2831

29-
class RwgsaltTable : public PvtxTable {
32+
} // namespace Opm
33+
34+
namespace Opm {
35+
36+
class RwgsaltTable : public PvtxTable
37+
{
3038
public:
3139
RwgsaltTable() = default;
32-
RwgsaltTable( const DeckKeyword& keyword, size_t tableIdx);
40+
RwgsaltTable(const DeckKeyword& keyword, std::size_t tableIdx);
3341

3442
static RwgsaltTable serializationTestObject();
3543

3644
bool operator==(const RwgsaltTable& data) const;
45+
46+
private:
47+
void makeScaledUSatTableCopy(const std::size_t src,
48+
const std::size_t dest) override;
3749
};
38-
}
3950

40-
#endif
51+
} // namespace Opm
52+
53+
#endif // OPM_PARSER_RWGSALT_TABLE_HPP

0 commit comments

Comments
 (0)