My Project
Loading...
Searching...
No Matches
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 <optional>
25#include <tuple>
26#include <vector>
27
28#include <opm/common/OpmLog/KeywordLocation.hpp>
29
30namespace Opm
31{
32
33class GridDims;
34
35struct NNCdata {
36 NNCdata(size_t c1, size_t c2, double t)
37 : cell1(c1), cell2(c2), trans(t)
38 {}
39 NNCdata() = default;
40
41 bool operator==(const NNCdata& data) const
42 {
43 return cell1 == data.cell1 &&
44 cell2 == data.cell2 &&
45 trans == data.trans;
46 }
47
48 template<class Serializer>
49 void serializeOp(Serializer& serializer)
50 {
51 serializer(cell1);
52 serializer(cell2);
53 serializer(trans);
54 }
55
56 // Observe that the operator< is only for cell ordering and does not consider the
57 // trans member
58 bool operator<(const NNCdata& other) const
59 {
60 return std::tie(this->cell1, this->cell2) < std::tie(other.cell1, other.cell2);
61 }
62
63 size_t cell1;
64 size_t cell2;
65 double trans;
66};
67
68
69
70class Deck;
71class EclipseGrid;
72
73/*
74 This class is an internalization of the NNC and EDITNNC keywords. Because the
75 opm-common codebase does not itself manage the simulation grid the purpose of
76 the NNC class is mainly to hold on to the NNC/EDITNNC input and pass it on to
77 the grid construction proper.
78
79 The EDITNNC keywords can operate on two different types of NNCs.
80
81 1. NNCs which have been explicitly entered using the NNC keyword.
82 2. NNCs which are inderectly inferred from the grid - e.g. due to faults.
83
84 When processing the EDITNNC keyword the class will search through the NNCs
85 configured explicitly with the NNC keyword and apply the edit transformation
86 on those NNCs, EDITNNCs which affect NNCs which are not configured explicitly
87 are stored for later use by the simulator.
88
89 The class guarantees the following ordering:
90
91 1. For all NNC / EDITNNC records we will have cell1 <= cell2
92 2. The vectors NNC::input() and NNC::edit() will be ordered in ascending
93 order.
94
95 While constructing from a deck NNCs connected to inactive cells will be
96 silently ignored. Do observe though that the addNNC() function does not check
97 the arguments and alas there is no guarantee that only active cells are
98 involved.
99*/
100
101class NNC
102{
103public:
104 NNC() = default;
106 NNC(const EclipseGrid& grid, const Deck& deck);
107
108 static NNC serializationTestObject();
109
110 bool addNNC(const size_t cell1, const size_t cell2, const double trans);
112 const std::vector<NNCdata>& input() const { return m_input; }
114 const std::vector<NNCdata>& edit() const { return m_edit; }
116 const std::vector<NNCdata>& editr() const { return m_editr; }
117 KeywordLocation input_location(const NNCdata& nnc) const;
118 KeywordLocation edit_location(const NNCdata& nnc) const;
119 KeywordLocation editr_location(const NNCdata& nnc) const;
120
121
122 bool operator==(const NNC& data) const;
123
124 template<class Serializer>
125 void serializeOp(Serializer& serializer)
126 {
127 serializer(m_input);
128 serializer(m_edit);
129 serializer(m_editr);
130 serializer(m_nnc_location);
131 serializer(m_edit_location);
132 serializer(m_editr_location);
133 }
134
135private:
136
137 void load_input(const EclipseGrid& grid, const Deck& deck);
138 void load_edit(const EclipseGrid& grid, const Deck& deck);
139 void load_editr(const EclipseGrid& grid, const Deck& deck);
140 void add_edit(const NNCdata& edit_node);
141
143 std::vector<NNCdata> m_input;
145 std::vector<NNCdata> m_edit;
147 std::vector<NNCdata> m_editr;
148 std::optional<KeywordLocation> m_nnc_location;
149 std::optional<KeywordLocation> m_edit_location;
150 std::optional<KeywordLocation> m_editr_location;
151};
152
153
154} // namespace Opm
155
156
157#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:55
Definition KeywordLocation.hpp:27
Definition NNC.hpp:102
const std::vector< NNCdata > & input() const
Get the combined information from NNC.
Definition NNC.hpp:112
const std::vector< NNCdata > & editr() const
Get the information from EDITNNCR keyword.
Definition NNC.hpp:116
const std::vector< NNCdata > & edit() const
Get the information from EDITNNC keyword.
Definition NNC.hpp:114
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:35