20 #ifndef OPM_PARSER_NNC_HPP 21 #define OPM_PARSER_NNC_HPP 23 #include <opm/common/OpmLog/KeywordLocation.hpp> 37 NNCdata(std::size_t c1, std::size_t c2,
double t)
38 : cell1(c1), cell2(c2), trans(t)
42 bool operator==(
const NNCdata& data)
const 44 return cell1 == data.cell1 &&
45 cell2 == data.cell2 &&
49 template<
class Serializer>
59 bool operator<(
const NNCdata& other)
const 61 return std::tie(this->cell1, this->cell2) < std::tie(other.cell1, other.cell2);
104 virtual ~
NNC() =
default;
108 static NNC serializationTestObject();
110 virtual bool addNNC(
const std::size_t cell1,
const std::size_t cell2,
const double trans);
113 virtual void merge(
const std::vector<NNCdata>& nncs);
115 const std::vector<NNCdata>&
input()
const {
return m_input; }
117 const std::vector<NNCdata>&
edit()
const {
return m_edit; }
119 const std::vector<NNCdata>&
editr()
const {
return m_editr; }
124 bool operator==(
const NNC& data)
const;
126 template<
class Serializer>
132 serializer(m_nnc_location);
133 serializer(m_edit_location);
134 serializer(m_editr_location);
139 void load_input(
const EclipseGrid& grid,
const Deck& deck);
140 void load_edit(
const EclipseGrid& grid,
const Deck& deck);
141 void load_editr(
const EclipseGrid& grid,
const Deck& deck);
142 void add_edit(
const NNCdata& edit_node);
145 std::vector<NNCdata> m_input;
147 std::vector<NNCdata> m_edit;
149 std::vector<NNCdata> m_editr;
150 std::optional<KeywordLocation> m_nnc_location;
151 std::optional<KeywordLocation> m_edit_location;
152 std::optional<KeywordLocation> m_editr_location;
154 friend class NNCDiffGrid;
163 virtual bool addNNC(
const std::size_t cell1,
const std::size_t cell2,
const double trans);
166 const std::vector<NNCdata>& input()
const {
return nnc_container; }
171 std::vector<NNCdata> nnc_container;
184 bool addNNC(
const std::size_t cell1,
const std::size_t cell2,
185 const double trans)
override;
187 void swap_adj(std::size_t grid1, std::size_t grid2);
214 bool hasCrossGridNNC(std::size_t grid1, std::size_t grid2)
const;
222 for (
const auto& [grid, nnc] : m_sameGridNNCs)
223 if (!nnc.input().empty())
return false;
224 for (
const auto& [grids, nnc] : m_diffGridNNCs)
225 if (!nnc.input().empty())
return false;
233 bool hasSameGridNNC(std::size_t grid)
const;
249 if (((grid_index == 0) &&
hasGlobalNNC()) || ((grid_index != 0) && hasSameGridNNC(grid_index)))
253 for (
const auto& [grid, nnc] : m_diffGridNNCs) {
254 if (
const auto& [g1, g2] = grid;
255 ((g1 == grid_index) || (g2 == grid_index)) && !nnc.input().empty())
266 return m_sameGridNNCs;
272 return m_diffGridNNCs;
296 const std::vector<std::vector<NNCdata>>& outputNnc,
297 const std::vector<std::vector<NNCdata>>& outputNncGlobalLocal,
298 const std::vector<std::vector<std::vector<NNCdata>>>& outputAmalgamatedNnc);
302 return m_sameGridNNCs == other.m_sameGridNNCs &&
303 m_diffGridNNCs == other.m_diffGridNNCs;
309 std::map<std::size_t, NNCDataContainer> m_sameGridNNCs;
312 std::map<std::pair<std::size_t,std::size_t>, NNCDataContainerDiffGrid> m_diffGridNNCs;
317 #endif // OPM_PARSER_NNC_HPP const NNCDataContainerDiffGrid & getNNC(std::size_t grid1, std::size_t grid2) const
Returns a const reference to the cross-grid NNC for the (grid1, grid2) pair.
Definition: NNC.cpp:465
const std::map< std::pair< std::size_t, std::size_t >, NNCDataContainerDiffGrid > & diff_grid_nnc() const
Returns a view of all cross-grid NNCs keyed by normalised (g1,g2) pairs.
Definition: NNC.hpp:270
void swap_adj(std::size_t grid1, std::size_t grid2)
Swaps cell1 and cell2 in every entry when grid1 > grid2, so that the container is always stored in no...
Definition: NNC.cpp:411
Definition: KeywordLocation.hpp:27
static NNCCollection fromLGROutputContainers(const std::vector< std::vector< NNCdata >> &outputNnc, const std::vector< std::vector< NNCdata >> &outputNncGlobalLocal, const std::vector< std::vector< std::vector< NNCdata >>> &outputAmalgamatedNnc)
Build an NNCCollection from the three output containers produced by EclGenericWriter::exportNncStruct...
Definition: NNC.cpp:566
About cell information and dimension: The actual grid information is held in a pointer to an ERT ecl_...
Definition: EclipseGrid.hpp:63
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
virtual bool addNNC(const std::size_t cell1, const std::size_t cell2, const double trans)
Inserts an NNC entry (cell1, cell2, trans) into the container, enforcing cell1 <= cell2...
Definition: NNC.cpp:377
bool hasNNCForGrid(std::size_t grid_index) const
Returns true if the given grid has any NNC involvement: same-grid NNCs with data, or cross-grid NNCs ...
Definition: NNC.hpp:247
const std::vector< NNCdata > & edit() const
Get the information from EDITNNC keyword.
Definition: NNC.hpp:117
const std::vector< NNCdata > & input() const
Get the combined information from NNC.
Definition: NNC.hpp:115
bool empty() const
Returns true if the collection holds no NNC data of any kind.
Definition: NNC.hpp:220
bool hasGlobalNNC() const
Returns true if the global grid has actual same-grid NNC data.
Definition: NNC.hpp:243
const std::map< std::size_t, NNCDataContainer > & same_grid_nnc() const
Returns a view of all same-grid NNCs as (grid_index, NNC) pairs.
Definition: NNC.hpp:264
void addNNC(std::size_t grid1, std::size_t grid2, NNCDataContainerDiffGrid nnc)
Add a cross-grid NNC between grid1 and grid2.
Definition: NNC.cpp:446
NNCCollection()
Default constructor: the global grid (grid 0) always exists, initially with an empty NNC container...
Definition: NNC.cpp:431
bool addNNC(const std::size_t cell1, const std::size_t cell2, const double trans) override
Inserts a cross-grid NNC entry without enforcing any cell ordering, since cell1 and cell2 belong to d...
Definition: NNC.cpp:403
const NNCDataContainer & getGlobalNNC() const
Returns a const reference to the global (grid 0) same-grid NNC.
Definition: NNC.cpp:548
const std::vector< NNCdata > & editr() const
Get the information from EDITNNCR keyword.
Definition: NNC.hpp:119
Class for (de-)serializing.
Definition: Serializer.hpp:95
virtual void merge(const std::vector< NNCdata > &nncs)
Merge additional NNCs into sorted NNCs.
Definition: NNC.cpp:290