Skip to content

Commit fb3235f

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 9916c6f commit fb3235f

File tree

11 files changed

+460
-92
lines changed

11 files changed

+460
-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: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +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
3850

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
@@ -218,6 +218,7 @@ namespace Opm {
218218
ranges[*tableIdx].first,
219219
ranges[*tableIdx].second);
220220

221+
this->populateMissingUndersaturatedStates();
221222

222223
this->populateSaturatedTable(keyword.name());
223224
}
@@ -261,4 +262,53 @@ namespace Opm {
261262
}
262263
}
263264

265+
void PvtxTable::populateMissingUndersaturatedStates()
266+
{
267+
for (const auto& [src, dest] : this->missingUSatTables()) {
268+
this->makeScaledUSatTableCopy(src, dest);
269+
}
270+
}
271+
272+
std::vector<std::pair<std::size_t, std::size_t>>
273+
PvtxTable::missingUSatTables() const
274+
{
275+
auto missing = std::vector<std::pair<std::size_t, std::size_t>>{};
276+
277+
if (this->m_underSaturatedTables.empty()) {
278+
return missing;
279+
}
280+
281+
auto src = this->m_underSaturatedTables.size() - 1;
282+
283+
for (auto destIx = src + 1; destIx > 0; --destIx) {
284+
const auto dest = destIx - 1;
285+
286+
if (this->m_underSaturatedTables[dest].numRows() > 1) {
287+
// There are undersaturated states in 'dest'. This is the
288+
// new 'src'.
289+
src = dest;
290+
}
291+
else {
292+
// There are no undersaturated states in 'dest'. Schedule
293+
// generation of a scaled copy of 'src's undersaturated
294+
// states in 'dest'.
295+
missing.emplace_back(src, dest);
296+
}
297+
}
298+
299+
return missing;
300+
}
301+
302+
void PvtxTable::makeScaledUSatTableCopy([[maybe_unused]] const std::size_t src,
303+
[[maybe_unused]] const std::size_t dest)
304+
{
305+
// Implemented only because we need to be able to create objects of
306+
// type 'PvtxTable' for serialisation purposes. Ideally, this would
307+
// be a pure virtual function.
308+
309+
throw std::runtime_error {
310+
"Derived type does not implement makeScaledUSatTableCopy()"
311+
};
312+
}
313+
264314
} // namespace Opm

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,39 @@ namespace Opm {
313313
/// \param[in] tableName Name of table/keyword we're internalising.
314314
/// Typically \code "PVTO" \endcode or \code "PVTG" \endcode.
315315
void populateSaturatedTable(const std::string& tableName);
316+
317+
/// Fill in any missing under-saturated states.
318+
///
319+
/// Takes scaled copies of under-saturated curves at higher
320+
/// composition/pressure nodes. Amends m_underSaturatedTables.
321+
void populateMissingUndersaturatedStates();
322+
323+
/// Identify missing under-saturated states in
324+
/// m_underSaturatedTables.
325+
///
326+
/// \return Pairs of source/destination indices. The
327+
/// under-saturated destination entries in m_underSaturatedTables
328+
/// will be scaled copies of the under-saturated source entries in
329+
/// m_underSaturatedTables.
330+
std::vector<std::pair<std::size_t, std::size_t>>
331+
missingUSatTables() const;
332+
333+
/// Generate scaled copies of under-saturated state curves.
334+
///
335+
/// Intended to amend a specific entry in m_underSaturatedTables
336+
/// based on source values in another specific entry in
337+
/// m_underSaturatedTables.
338+
///
339+
/// Virtual function in order to call back into the derived type for
340+
/// type-specific copying.
341+
///
342+
/// \param[in] src Index of source table with full set of
343+
/// under-saturated states.
344+
///
345+
/// \param[in] dest Index of destination table with no
346+
/// under-saturated states.
347+
virtual void makeScaledUSatTableCopy(const std::size_t src,
348+
const std::size_t dest);
316349
};
317350

318351
} // 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)