vag.hpp
Go to the documentation of this file.
1 /*===========================================================================
2 //
3 // File: vag.hpp
4 //
5 // Created: 2012-06-08 15:46:23+0200
6 //
7 // Authors: Knut-Andreas Lie <Knut-Andreas.Lie@sintef.no>
8 // Halvor M. Nilsen <HalvorMoll.Nilsen@sintef.no>
9 // Atgeirr F. Rasmussen <atgeirr@sintef.no>
10 // Xavier Raynaud <Xavier.Raynaud@sintef.no>
11 // Bård Skaflestad <Bard.Skaflestad@sintef.no>
12 //
13 //==========================================================================*/
14 
15 
16 /*
17  Copyright 2012 SINTEF ICT, Applied Mathematics.
18  Copyright 2012 Statoil ASA.
19 
20  This file is part of the Open Porous Media Project (OPM).
21 
22  OPM is free software: you can redistribute it and/or modify
23  it under the terms of the GNU General Public License as published by
24  the Free Software Foundation, either version 3 of the License, or
25  (at your option) any later version.
26 
27  OPM is distributed in the hope that it will be useful,
28  but WITHOUT ANY WARRANTY; without even the implied warranty of
29  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  GNU General Public License for more details.
31 
32  You should have received a copy of the GNU General Public License
33  along with OPM. If not, see <http://www.gnu.org/licenses/>.
34 */
35 
36 #ifndef OPM_VAG_HPP_HEADER
37 #define OPM_VAG_HPP_HEADER
38 
39 
40 
41 #include <opm/core/grid.h>
42 #include <istream>
43 #include <ostream>
44 #include <string>
45 #include <vector>
46 
47 namespace Opm
48 {
54  struct PosStruct{
55  std::vector<int> pos;
56  std::vector<int> value;
57  };
62  struct VAG{
68  std::vector<double> vertices;
78  std::vector<int> edges;
80  std::vector<int> faces_to_volumes;
87  std::vector<double> material;
88  };
95  void readVagGrid(std::istream& is,Opm::VAG& vag_grid);
102  void writeVagFormat(std::ostream& os,Opm::VAG& vag_grid);
108  template <typename T>
109  void readVector(std::istream& is,std::vector<T>& vec){
110  using namespace std;
111  for(int i=0;i< int(vec.size());++i){
112  is >> vec[i];
113  }
114  }
121  template <typename T>
122  void writeVector(std::ostream& os,std::vector<T>& vec,int n){
123  typedef typename std::vector<T>::size_type sz_t;
124 
125  const sz_t nn = n;
126 
127  for (sz_t i = 0; i < vec.size(); ++i) {
128  os << vec[i] << (((i % nn) == 0) ? '\n' : ' ');
129  }
130 
131  if ((vec.size() % nn) != 0) {
132  os << '\n';
133  }
134  }
135 
142  void readPosStruct(std::istream& is,int n,PosStruct& pos_struct);
148  void writePosStruct(std::ostream& os,PosStruct& pos_struct);
149 
156 
163 }
164 #endif /* OPM_VAG_HPP_HEADER */
165 
void vagToUnstructuredGrid(Opm::VAG &vag_grid, UnstructuredGrid &grid)
int number_of_edges
Definition: vag.hpp:66
Definition: grid.h:98
Definition: AnisotropicEikonal.hpp:43
void writePosStruct(std::ostream &os, PosStruct &pos_struct)
PosStruct volumes_to_vertices
Definition: vag.hpp:72
int number_of_volumes
Definition: vag.hpp:64
void writeVector(std::ostream &os, std::vector< T > &vec, int n)
Definition: vag.hpp:122
PosStruct volumes_to_faces
Definition: vag.hpp:70
int number_of_vertices
Definition: vag.hpp:63
std::vector< int > value
Definition: vag.hpp:56
std::vector< int > edges
Definition: vag.hpp:78
void readPosStruct(std::istream &is, int n, PosStruct &pos_struct)
int number_of_faces
Definition: vag.hpp:65
std::vector< int > pos
Definition: vag.hpp:55
void readVector(std::istream &is, std::vector< T > &vec)
Definition: vag.hpp:109
STL namespace.
void writeVagFormat(std::ostream &os, Opm::VAG &vag_grid)
void readVagGrid(std::istream &is, Opm::VAG &vag_grid)
PosStruct faces_to_edges
Definition: vag.hpp:74
std::vector< double > material
Definition: vag.hpp:87
std::vector< double > vertices
Definition: vag.hpp:68
const UnstructuredGrid & grid
Definition: ColumnExtract.hpp:31
PosStruct faces_to_vertices
Definition: vag.hpp:76
Definition: vag.hpp:54
void unstructuredGridToVag(UnstructuredGrid &grid, Opm::VAG &vag_grid)
std::vector< int > faces_to_volumes
Definition: vag.hpp:80
Definition: vag.hpp:62