dune-grid  2.2.1
parser.hh
Go to the documentation of this file.
1 #ifndef DUNE_DGF_DUNEGRIDFORMATPARSER_HH
2 #define DUNE_DGF_DUNEGRIDFORMATPARSER_HH
3 
4 #include <iostream>
5 #include <string>
6 #include <vector>
7 #include <map>
8 
10 
11 namespace Dune
12 {
13 
14  class DGFPrintInfo;
15 
19  {
21  typedef std::string type;
22 
24  static const type &defaultValue ()
25  {
26  static type value;
27  return value;
28  }
29 
31  static type convert ( const std::string & parameter )
32  {
33  return parameter;
34  }
35 
37  static const char delimiter = ':';
38  };
39 
43  {
44  public:
45  typedef enum {Simplex,Cube,General} element_t;
46 
48 
50  DuneGridFormatParser ( int rank, int size );
51 
62  static bool isDuneGridFormat ( std::istream &input );
63 
73  static bool isDuneGridFormat ( const std::string &filename );
74 
87  bool readDuneGrid( std::istream &input, int dimG, int dimW );
88 
89  bool readDuneGrid( std::istream &input, int dimG = -1 ) DUNE_DEPRECATED
90  {
91  return readDuneGrid( input, dimG, -1 );
92  }
93 
95  void writeTetgenPoly ( const std::string &, std::string &, std::string & );
96 
97  void writeTetgenPoly ( std::ostream & out, const bool writeSegments = true );
98 
99  protected:
100  void generateBoundaries ( std::istream &, bool );
101 
102  // call to tetgen/triangle
103  void generateSimplexGrid ( std::istream & );
104  void readTetgenTriangle ( const std::string & );
105 
106  // helper methods
107  void removeCopies ();
108 
109  void setOrientation ( int use1, int use2,
110  orientation_t orientation=counterclockwise );
111 
112  void setRefinement ( int use1, int use2, int is1=-1, int is2=-1 );
113 
114  double testTriang ( int snr );
115 
116  std::vector< double > & getElParam ( int i, std::vector< double > & coord );
117 
118  std::vector< double > & getVtxParam ( int i, std::vector< double > & coord );
119 
120  static std::string temporaryFileName ();
121 
122  // dimension of world and problem: set through the readDuneGrid() method
123  int dimw, dimgrid;
124 
125  // vector of vertex coordinates
126  std::vector < std::vector < double > > vtx;
127 
128  int nofvtx;
129 
131 
132  double minVertexDistance; // min. L^1 distance of distinct points
133 
134  // vector of elements
135  std :: vector< std :: vector< unsigned int > > elements;
136 
138 
139  // vector of boundary segments + identifier
140  std::vector < std::vector < int > > bound;
141 
142  int nofbound;
143 
144  // map to generate and find boundary segments
146  typedef std::pair < int, BoundaryParameter > BndParam;
147  typedef std::map< DGFEntityKey< unsigned int >, BndParam > facemap_t;
149 
150  // true if parameters on a boundary found
152 
153  // set by generator depending on element type wanted
155 
156  // set by the readDuneGrid method depending
157  // on what type the elements were generated
159 
160  // true if grid is generated using the intervall Block
162 
163  // parameters on elements
165 
166  std::vector< std::vector< double > > vtxParams,elParams;
167 
168  // write information about generation process
170 
171  std::vector < double > emptyParam_;
172 
173 
174  private:
175  int rank_;
176  int size_;
177 
178  template< class GridType >
179  friend struct DGFGridFactory;
180 
181  template< class GridType >
182  friend struct DGFBaseFactory;
183 
184  };
185 
186 } // end namespace Dune
187 
188 #endif