dune-grid  2.6-git
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 
49  typedef enum {counterclockwise=1,clockwise=-1} orientation_t;
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;
145  facemap_t facemap;
146 
147  // true if parameters on a boundary found
149 
150  // set by generator depending on element type wanted
151  element_t element;
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
161  int nofvtxparams,nofelparams;
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
bool cube2simplex
Definition: parser.hh:158
static const char delimiter
delimiter
Definition: parser.hh:39
element_t element
Definition: parser.hh:151
std::vector< double > emptyParam_
Definition: parser.hh:168
std::vector< std::vector< int > > bound
Definition: parser.hh:137
int dimw
Definition: parser.hh:120
std::pair< int, BoundaryParameter > BndParam
Definition: parser.hh:143
static type convert(const std::string &parameter)
copy from string
Definition: parser.hh:33
bool simplexgrid
Definition: parser.hh:155
element_t
Definition: parser.hh:47
The DuneGridFormatParser class: reads a DGF file and stores build information in vector structures us...
Definition: parser.hh:44
facemap_t facemap
Definition: parser.hh:145
std::map< DGFEntityKey< unsigned int >, BndParam > facemap_t
Definition: parser.hh:144
std::vector< std::vector< double > > vtxParams
Definition: parser.hh:163
bool haveBndParameters
Definition: parser.hh:148
int nofbound
Definition: parser.hh:139
Definition: io/file/dgfparser/dgfparser.cc:23
Contains types for additional features.
Definition: parser.hh:20
int nofelements
Definition: parser.hh:134
DGFPrintInfo * info
Definition: parser.hh:166
std::string type
type of additional boundary parameters
Definition: parser.hh:23
int nofvtx
Definition: parser.hh:125
DGFBoundaryParameter::type BoundaryParameter
Definition: parser.hh:142
Definition: parser.hh:47
int vtxoffset
Definition: parser.hh:127
int nofvtxparams
Definition: parser.hh:161
Definition: agrid.hh:65
std::vector< std::vector< double > > vtx
Definition: parser.hh:123
orientation_t
Definition: parser.hh:49
double minVertexDistance
Definition: parser.hh:129
static const type & defaultValue()
default constructor
Definition: parser.hh:26
std ::vector< std ::vector< unsigned int > > elements
Definition: parser.hh:132
Include standard header files.
Definition: agrid.hh:58