EquilCompReport.hpp
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*
4 Copyright 2026 SINTEF Digital
5
6 This file is part of the Open Porous Media project (OPM).
7
8 OPM is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 OPM is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with OPM. If not, see <http://www.gnu.org/licenses/>.
20
21 Consult the COPYING file in the top-level source directory of this
22 module for the precise wording of the license and the list of
23 copyright holders.
24*/
31#ifndef OPM_EQUIL_COMP_REPORT_HPP
32#define OPM_EQUIL_COMP_REPORT_HPP
33
34#include <opm/input/eclipse/Units/UnitSystem.hpp>
35
36#include <fmt/format.h>
37
38#include <array>
39#include <cstddef>
40#include <iterator>
41#include <string>
42#include <string_view>
43#include <utility>
44#include <vector>
45
47
49template <class Scalar, std::size_t NumComponents>
51{
52 Scalar depth{};
53 Scalar poil{};
54 Scalar pwat{};
55 Scalar pgas{};
56 Scalar deno{};
57 Scalar denw{};
58 Scalar deng{};
59 Scalar soil{};
60 Scalar swat{};
61 Scalar sgas{};
63 Scalar psat{};
65 Scalar statedPsat{};
66 std::array<Scalar, NumComponents> oil{};
67 std::array<Scalar, NumComponents> gas{};
68 std::array<Scalar, NumComponents> total{};
69};
70
80template <class Scalar, std::size_t NumComponents>
81std::string
82formatCompositionVersusDepth(const std::size_t region,
83 const int satTable,
85 const std::array<std::string_view, NumComponents>& componentNames,
86 const UnitSystem& units)
87{
88 using Measure = UnitSystem::measure;
90 std::string report;
91 const auto out = std::back_inserter(report);
92
93 fmt::format_to(out, "\nComposition versus depth in equilibration region {} "
94 "(saturation table {})\n\n", region, satTable);
95 fmt::format_to(out, "{:>10} {:>10} {:>10} {:>10} {:>9} {:>9} {:>9} "
96 "{:>7} {:>7} {:>7} {:>9} {:>9}\n",
97 "Depth", "Poil", "Pwat", "Pgas", "Deno", "Denw", "Deng",
98 "Soil", "Swat", "Sgas", "Psat", "Ps(obs)");
99 const auto length = units.name(Measure::length);
100 const auto pressure = units.name(Measure::pressure);
101 const auto density = units.name(Measure::density);
102 fmt::format_to(out, "{:>10} {:>10} {:>10} {:>10} {:>9} {:>9} {:>9} "
103 "{:>7} {:>7} {:>7} {:>9} {:>9}\n",
104 length, pressure, pressure, pressure, density, density, density,
105 "", "", "", pressure, pressure);
106 fmt::format_to(out, "{:->10} {:->10} {:->10} {:->10} {:->9} {:->9} {:->9} "
107 "{:->7} {:->7} {:->7} {:->9} {:->9}\n",
108 "", "", "", "", "", "", "", "", "", "", "", "");
109 for (const auto& row : rows) {
110 fmt::format_to(out, "{:10.2f} {:10.3f} {:10.3f} {:10.3f} {:9.3f} {:9.3f} {:9.3f} "
111 "{:7.4f} {:7.4f} {:7.4f} {:9.2f} {:9.2f}\n",
112 units.from_si(Measure::length, row.depth),
113 units.from_si(Measure::pressure, row.poil),
114 units.from_si(Measure::pressure, row.pwat),
115 units.from_si(Measure::pressure, row.pgas),
116 units.from_si(Measure::density, row.deno),
117 units.from_si(Measure::density, row.denw),
118 units.from_si(Measure::density, row.deng),
119 row.soil, row.swat, row.sgas,
120 units.from_si(Measure::pressure, row.psat),
121 units.from_si(Measure::pressure, row.statedPsat));
122 }
123
124 for (const auto& [phase, fractions] :
125 {std::pair{"Oil", &Row::oil},
126 std::pair{"Gas", &Row::gas},
127 std::pair{"Total", &Row::total}}) {
128 fmt::format_to(out, "\n{} composition\n\n{:>10}", phase, "Depth");
129 for (const auto name : componentNames) {
130 fmt::format_to(out, " {:>8.8}", name);
131 }
132 fmt::format_to(out, "\n{:>10}\n{:->10}", length, "");
133 for (std::size_t c = 0; c < NumComponents; ++c) {
134 fmt::format_to(out, " {:->8}", "");
135 }
136 fmt::format_to(out, "\n");
137 for (const auto& row : rows) {
138 fmt::format_to(out, "{:10.2f}", units.from_si(Measure::length, row.depth));
139 for (const auto fraction : row.*fractions) {
140 fmt::format_to(out, " {:8.5f}", fraction);
141 }
142 fmt::format_to(out, "\n");
143 }
144 }
145 return report;
146}
147
148} // namespace Opm::EQUIL::Comp
149
150#endif // OPM_EQUIL_COMP_REPORT_HPP
Definition: EquilCompReport.hpp:46
std::string formatCompositionVersusDepth(const std::size_t region, const int satTable, const std::vector< CompositionVersusDepthRow< Scalar, NumComponents > > &rows, const std::array< std::string_view, NumComponents > &componentNames, const UnitSystem &units)
Definition: EquilCompReport.hpp:82
One depth of the composition versus depth report, in SI units.
Definition: EquilCompReport.hpp:51
std::array< Scalar, NumComponents > total
Definition: EquilCompReport.hpp:68
Scalar deng
Definition: EquilCompReport.hpp:58
Scalar depth
Definition: EquilCompReport.hpp:52
Scalar sgas
Definition: EquilCompReport.hpp:61
Scalar psat
Bubble point of the oil composition, zero when none is reported.
Definition: EquilCompReport.hpp:63
Scalar pwat
Definition: EquilCompReport.hpp:54
Scalar denw
Definition: EquilCompReport.hpp:57
Scalar statedPsat
Saturation pressure that COMPVD states, zero without one.
Definition: EquilCompReport.hpp:65
Scalar soil
Definition: EquilCompReport.hpp:59
Scalar swat
Definition: EquilCompReport.hpp:60
Scalar poil
Definition: EquilCompReport.hpp:53
std::array< Scalar, NumComponents > oil
Definition: EquilCompReport.hpp:66
Scalar pgas
Definition: EquilCompReport.hpp:55
Scalar deno
Definition: EquilCompReport.hpp:56
std::array< Scalar, NumComponents > gas
Definition: EquilCompReport.hpp:67