20#ifndef OPM_GRID_CPGRID_LGROUTPUTHELPERS_HEADER_INCLUDED
21#define OPM_GRID_CPGRID_LGROUTPUTHELPERS_HEADER_INCLUDED
26#include <opm/input/eclipse/Units/UnitSystem.hpp>
27#include <opm/output/data/Cells.hpp>
28#include <opm/output/data/Solution.hpp>
29#include <opm/output/eclipse/RestartValue.hpp>
62template <
typename Container>
64 const std::vector<int>& toOutput);
87 const std::vector<std::vector<int>>& toOutput_refinedLevels,
88 const Opm::data::Solution& leafSolution,
89 std::vector<Opm::data::Solution>&);
102template <
typename Gr
id>
104 const Opm::RestartValue& leafRestartValue,
105 std::vector<Opm::RestartValue>& restartValue_levels);
110template <
typename Container>
112 const std::vector<int>& toOutput)
115 Container outputContainer;
116 outputContainer.resize(toOutput.size());
117 for (std::size_t i = 0; i < toOutput.size(); ++i) {
118 outputContainer[i] = simulatorContainer[toOutput[i]];
120 return outputContainer;
123template <
typename Gr
id>
125 const Opm::RestartValue& leafRestartValue,
126 std::vector<Opm::RestartValue>& restartValue_levels)
128 if constexpr (std::is_same_v<Grid, Dune::CpGrid>) {
130 int maxLevel = grid.maxLevel();
131 restartValue_levels.resize(maxLevel+1);
135 std::vector<std::vector<int>> toOutput_refinedLevels{};
136 toOutput_refinedLevels.resize(maxLevel);
139 for (
int level = 1; level <= maxLevel; ++level) {
143 std::vector<Opm::data::Solution> dataSolutionLevels{};
145 toOutput_refinedLevels,
146 leafRestartValue.solution,
149 for (
int level = 0; level <= maxLevel; ++level) {
150 restartValue_levels[level] = Opm::RestartValue(std::move(dataSolutionLevels[level]),
151 leafRestartValue.wells,
152 leafRestartValue.grp_nwrk,
153 leafRestartValue.aquifer,
157 for (
const auto& [rst_key, leafVector] : leafRestartValue.extra) {
159 std::vector<std::vector<double>> levelVectors{};
160 levelVectors.resize(maxLevel+1);
164 for (
int level = 0; level <= maxLevel; ++level) {
165 levelVectors[level].resize(grid.levelGridView(level).size(0),
166 std::numeric_limits<double>::max());
170 for (
const auto& element : Dune::elements(grid.leafGridView())) {
171 levelVectors[element.level()][element.getLevelElem().index()] = leafVector[element.index()];
175 for (
int level = 1; level<=maxLevel; ++level) {
179 for (
int level = 0; level <= maxLevel; ++level) {
180 restartValue_levels[level].addExtra(rst_key.key, rst_key.dim, std::move(levelVectors[level]));
[ provides Dune::Grid ]
Definition: CpGrid.hpp:203
Definition: cpgrid/LevelCartesianIndexMapper.hpp:53
void extractSolutionLevelGrids(const Dune::CpGrid &grid, const std::vector< std::vector< int > > &toOutput_refinedLevels, const Opm::data::Solution &leafSolution, std::vector< Opm::data::Solution > &)
Extracts and organizes solution data for all grid refinement levels.
void extractRestartValueLevelGrids(const Grid &grid, const Opm::RestartValue &leafRestartValue, std::vector< Opm::RestartValue > &restartValue_levels)
Constructs restart-value containers for all grid refinement levels.
Definition: LgrOutputHelpers.hpp:124
Container reorderForOutput(const Container &simulatorContainer, const std::vector< int > &toOutput)
Reorder data from a simulation container into the order assumed by output for refined level grids.
Definition: LgrOutputHelpers.hpp:111
std::vector< int > mapLevelIndicesToCartesianOutputOrder(const Dune::CpGrid &grid, const Opm::LevelCartesianIndexMapper< Dune::CpGrid > &levelCartMapp, int level)
Builds a mapping from level element indices to the Cartesian ordering required by output files.
Holds the implementation of the CpGrid as a pimple.
Definition: CellQuadrature.hpp:26