My Project
NNC.hpp
1/*
2 Copyright 2015 IRIS
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef OPM_PARSER_NNC_HPP
21#define OPM_PARSER_NNC_HPP
22
23#include <cstddef>
24#include <memory>
25#include <optional>
26#include <tuple>
27#include <vector>
28
29#include <opm/common/OpmLog/KeywordLocation.hpp>
30
31namespace Opm
32{
33
34class GridDims;
35
36struct NNCdata {
37 NNCdata(size_t c1, size_t c2, double t)
38 : cell1(c1), cell2(c2), trans(t)
39 {}
40 NNCdata() = default;
41
42 bool operator==(const NNCdata& data) const
43 {
44 return cell1 == data.cell1 &&
45 cell2 == data.cell2 &&
46 trans == data.trans;
47 }
48
49 template<class Serializer>
50 void serializeOp(Serializer& serializer)
51 {
52 serializer(cell1);
53 serializer(cell2);
54 serializer(trans);
55 }
56
57 // Observe that the operator< is only for cell ordering and does not consider the
58 // trans member
59 bool operator<(const NNCdata& other) const
60 {
61 return std::tie(this->cell1, this->cell2) < std::tie(other.cell1, other.cell2);
62 }
63
64 size_t cell1;
65 size_t cell2;
66 double trans;
67};
68
69
70
71class Deck;
72class EclipseGrid;
73
74/*
75 This class is an internalization of the NNC and EDITNNC keywords. Because the
76 opm-common codebase does not itself manage the simulation grid the purpose of
77 the NNC class is mainly to hold on to the NNC/EDITNNC input and pass it on to
78 the grid construction proper.
79
80 The EDITNNC keywords can operate on two different types of NNCs.
81
82 1. NNCs which have been explicitly entered using the NNC keyword.
83 2. NNCs which are inderectly inferred from the grid - e.g. due to faults.
84
85 When processing the EDITNNC keyword the class will search through the NNCs
86 configured explicitly with the NNC keyword and apply the edit transformation
87 on those NNCs, EDITNNCs which affect NNCs which are not configured explicitly
88 are stored for later use by the simulator.
89
90 The class guarantees the following ordering:
91
92 1. For all NNC / EDITNNC records we will have cell1 <= cell2
93 2. The vectors NNC::input() and NNC::edit() will be ordered in ascending
94 order.
95
96 While constructing from a deck NNCs connected to inactive cells will be
97 silently ignored. Do observe though that the addNNC() function does not check
98 the arguments and alas there is no guarantee that only active cells are
99 involved.
100*/
101
102class NNC
103{
104public:
105 NNC() = default;
107 NNC(const EclipseGrid& grid, const Deck& deck);
108
109 static NNC serializationTestObject();
110
111 bool addNNC(const size_t cell1, const size_t cell2, const double trans);
113 const std::vector<NNCdata>& input() const { return m_input; }
115 const std::vector<NNCdata>& edit() const { return m_edit; }
117 const std::vector<NNCdata>& editr() const { return m_editr; }
118 KeywordLocation input_location(const NNCdata& nnc) const;
119 KeywordLocation edit_location(const NNCdata& nnc) const;
120 KeywordLocation editr_location(const NNCdata& nnc) const;
121
122
123 bool operator==(const NNC& data) const;
124
125 template<class Serializer>
126 void serializeOp(Serializer& serializer)
127 {
128 serializer(m_input);
129 serializer(m_edit);
130 serializer(m_editr);
131 serializer(m_nnc_location);
132 serializer(m_edit_location);
133 serializer(m_editr_location);
134 }
135
136private:
137
138 void load_input(const EclipseGrid& grid, const Deck& deck);
139 void load_edit(const EclipseGrid& grid, const Deck& deck);
140 void load_editr(const EclipseGrid& grid, const Deck& deck);
141 void add_edit(const NNCdata& edit_node);
142
144 std::vector<NNCdata> m_input;
146 std::vector<NNCdata> m_edit;
148 std::vector<NNCdata> m_editr;
149 std::optional<KeywordLocation> m_nnc_location;
150 std::optional<KeywordLocation> m_edit_location;
151 std::optional<KeywordLocation> m_editr_location;
152};
153
154
155} // namespace Opm
156
157
158#endif // OPM_PARSER_NNC_HPP
Definition: Deck.hpp:49
About cell information and dimension: The actual grid information is held in a pointer to an ERT ecl_...
Definition: EclipseGrid.hpp:54
Definition: KeywordLocation.hpp:27
Definition: NNC.hpp:103
const std::vector< NNCdata > & input() const
Get the combined information from NNC.
Definition: NNC.hpp:113
NNC(const EclipseGrid &grid, const Deck &deck)
Construct from input deck.
const std::vector< NNCdata > & editr() const
Get the information from EDITNNCR keyword.
Definition: NNC.hpp:117
const std::vector< NNCdata > & edit() const
Get the information from EDITNNC keyword.
Definition: NNC.hpp:115
Class for (de-)serializing.
Definition: Serializer.hpp:84
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Definition: NNC.hpp:36