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 
31 namespace Opm
32 {
33 
34 class GridDims;
35 
36 struct 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 
71 class Deck;
72 class 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 
102 class NNC
103 {
104 public:
105  NNC() = default;
107  NNC(const EclipseGrid& grid, const Deck& deck);
108 
109  static NNC serializeObject();
110 
111  bool addNNC(const size_t cell1, const size_t cell2, const double trans);
112  const std::vector<NNCdata>& input() const { return m_input; }
113  const std::vector<NNCdata>& edit() const { return m_edit; }
114  KeywordLocation input_location(const NNCdata& nnc) const;
115  KeywordLocation edit_location(const NNCdata& nnc) const;
116 
117 
118  bool operator==(const NNC& data) const;
119 
120  template<class Serializer>
121  void serializeOp(Serializer& serializer)
122  {
123  serializer.vector(m_input);
124  serializer.vector(m_edit);
125  serializer(m_nnc_location);
126  serializer(m_edit_location);
127  }
128 
129 private:
130 
131  void load_input(const EclipseGrid& grid, const Deck& deck);
132  void load_edit(const EclipseGrid& grid, const Deck& deck);
133  void add_edit(const NNCdata& edit_node);
134  bool update_nnc(std::size_t global_index1, std::size_t global_index2, double tran_mult);
135 
136  std::vector<NNCdata> m_input;
137  std::vector<NNCdata> m_edit;
138  std::optional<KeywordLocation> m_nnc_location;
139  std::optional<KeywordLocation> m_edit_location;
140 };
141 
142 
143 } // namespace Opm
144 
145 
146 #endif // OPM_PARSER_NNC_HPP
Definition: Deck.hpp:119
About cell information and dimension: The actual grid information is held in a pointer to an ERT ecl_...
Definition: EclipseGrid.hpp:55
Definition: NNC.hpp:103
NNC(const EclipseGrid &grid, const Deck &deck)
Construct from input deck.
Definition: Serializer.hpp:38
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29
Definition: NNC.hpp:36