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