SimulationDataContainer.hpp
Go to the documentation of this file.
1/*
2 Copyright 2016 Statoil ASA.
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 SIMULATION_DATA_CONTAINER_HPP
21#define SIMULATION_DATA_CONTAINER_HPP
22
23#include <cstddef>
24#include <string>
25#include <map>
26#include <vector>
27
28namespace Opm {
29
30
44 {
45 public:
53 SimulationDataContainer(size_t num_cells, size_t num_faces, size_t num_phases);
54
60
66
69
70 size_t numPhases() const;
71 size_t numFaces() const;
72 size_t numCells() const;
73
74 bool hasCellData( const std::string& name ) const;
75
78 void registerCellData( const std::string& name , size_t components , double initialValue = 0.0 );
79 std::vector<double>& getCellData( const std::string& name );
80 const std::vector<double>& getCellData( const std::string& name ) const;
81
82 bool hasFaceData( const std::string& name ) const;
83 void registerFaceData( const std::string& name , size_t components , double initialValue = 0.0 );
84 std::vector<double>& getFaceData( const std::string& name );
85 const std::vector<double>& getFaceData( const std::string& name ) const;
86
94 size_t numCellDataComponents( const std::string& name ) const;
95 bool equal(const SimulationDataContainer& other) const;
96
97
101 void setCellDataComponent( const std::string& key , size_t component , const std::vector<int>& cells , const std::vector<double>& values);
102
103 // Direct explicit field access for certain default fields.
104 // These methods are all deprecated, and will eventually be moved to
105 // concrete subclasses.
106
107 std::vector<double>& pressure ();
108 std::vector<double>& temperature ();
109 std::vector<double>& saturation ();
110
111 std::vector<double>& facepressure();
112 std::vector<double>& faceflux ();
113
114 const std::vector<double>& pressure () const;
115 const std::vector<double>& temperature () const;
116 const std::vector<double>& saturation () const;
117
118 const std::vector<double>& facepressure() const;
119 const std::vector<double>& faceflux () const;
120
121 const std::map<std::string, std::vector<double>>& cellData() const;
122 std::map<std::string, std::vector<double>>& cellData();
123
124 private:
125 void addDefaultFields();
126 void setReferencePointers();
127
128 size_t m_num_cells;
129 size_t m_num_faces;
130 size_t m_num_phases;
131
132 std::map< std::string , std::vector<double> > m_cell_data;
133 std::map< std::string , std::vector<double> > m_face_data;
134
135 std::vector<double>* pressure_ref_;
136 std::vector<double>* temperature_ref_;
137 std::vector<double>* saturation_ref_;
138 std::vector<double>* facepressure_ref_;
139 std::vector<double>* faceflux_ref_;
140 };
141
142
143 // Inline implementations of the direct accessors required to guarantee
144 // performance.
145
146
147 inline std::vector<double>& SimulationDataContainer::pressure( ) {
148 return *pressure_ref_;
149 }
150
151 inline std::vector<double>& SimulationDataContainer::temperature() {
152 return *temperature_ref_;
153 }
154
155 inline std::vector<double>& SimulationDataContainer::saturation() {
156 return *saturation_ref_;
157 }
158
159 inline std::vector<double>& SimulationDataContainer::facepressure() {
160 return *facepressure_ref_;
161 }
162
163 inline std::vector<double>& SimulationDataContainer::faceflux() {
164 return *faceflux_ref_;
165 }
166
167 inline const std::vector<double>& SimulationDataContainer::pressure( ) const {
168 return *pressure_ref_;
169 }
170
171 inline const std::vector<double>& SimulationDataContainer::temperature() const {
172 return *temperature_ref_;
173 }
174
175 inline const std::vector<double>& SimulationDataContainer::saturation() const {
176 return *saturation_ref_;
177 }
178
179 inline const std::vector<double>& SimulationDataContainer::facepressure() const {
180 return *facepressure_ref_;
181 }
182
183 inline const std::vector<double>& SimulationDataContainer::faceflux() const {
184 return *faceflux_ref_;
185 }
186
187
188
189}
190
191#endif
const char *const name
Definition: cJSON.h:258
const char *const string
Definition: cJSON.h:170
Definition: SimulationDataContainer.hpp:44
std::vector< double > & temperature()
Definition: SimulationDataContainer.hpp:151
SimulationDataContainer(size_t num_cells, size_t num_faces, size_t num_phases)
void swap(SimulationDataContainer &other)
Efficient O(1) swap.
void setCellDataComponent(const std::string &key, size_t component, const std::vector< int > &cells, const std::vector< double > &values)
std::vector< double > & getCellData(const std::string &name)
std::vector< double > & facepressure()
Definition: SimulationDataContainer.hpp:159
std::vector< double > & getFaceData(const std::string &name)
size_t numCellDataComponents(const std::string &name) const
const std::vector< double > & getCellData(const std::string &name) const
bool hasCellData(const std::string &name) const
std::map< std::string, std::vector< double > > & cellData()
const std::map< std::string, std::vector< double > > & cellData() const
std::vector< double > & faceflux()
Definition: SimulationDataContainer.hpp:163
bool hasFaceData(const std::string &name) const
const std::vector< double > & getFaceData(const std::string &name) const
SimulationDataContainer(const SimulationDataContainer &)
SimulationDataContainer & operator=(const SimulationDataContainer &)
std::vector< double > & pressure()
Definition: SimulationDataContainer.hpp:147
void registerCellData(const std::string &name, size_t components, double initialValue=0.0)
bool equal(const SimulationDataContainer &other) const
void registerFaceData(const std::string &name, size_t components, double initialValue=0.0)
std::vector< double > & saturation()
Definition: SimulationDataContainer.hpp:155
Definition: A.hpp:4