dune-grid 2.8.0
Loading...
Searching...
No Matches
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
13namespace 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
121
122 // vector of vertex coordinates
123 std::vector < std::vector < double > > vtx;
124
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
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
Include standard header files.
Definition: agrid.hh:58
Definition: dgfgridfactory.hh:36
Definition: io/file/dgfparser/dgfparser.cc:24
Contains types for additional features.
Definition: parser.hh:21
static const type & defaultValue()
default constructor
Definition: parser.hh:26
static const char delimiter
delimiter
Definition: parser.hh:39
static type convert(const std::string &parameter)
copy from string
Definition: parser.hh:33
std::string type
type of additional boundary parameters
Definition: parser.hh:23
The DuneGridFormatParser class: reads a DGF file and stores build information in vector structures us...
Definition: parser.hh:45
int nofvtxparams
Definition: parser.hh:161
int nofbound
Definition: parser.hh:139
std::pair< int, BoundaryParameter > BndParam
Definition: parser.hh:143
void readTetgenTriangle(const std::string &)
Definition: io/file/dgfparser/dgfparser.cc:793
static bool isDuneGridFormat(std::istream &input)
check whether a stream is in DUNE grid format
Definition: io/file/dgfparser/dgfparser.cc:269
void setOrientation(int use1, int use2, orientation_t orientation=counterclockwise)
Definition: io/file/dgfparser/dgfparser.cc:908
std::vector< std::vector< double > > vtxParams
Definition: parser.hh:163
void setRefinement(int use1, int use2, int is1=-1, int is2=-1)
Definition: io/file/dgfparser/dgfparser.cc:987
friend struct DGFBaseFactory
Definition: parser.hh:179
static std::string temporaryFileName()
Definition: io/file/dgfparser/dgfparser.cc:1094
void removeCopies()
Definition: io/file/dgfparser/dgfparser.cc:462
int dimw
Definition: parser.hh:120
int dimgrid
Definition: parser.hh:120
element_t element
Definition: parser.hh:151
DGFBoundaryParameter::type BoundaryParameter
Definition: parser.hh:142
int nofelements
Definition: parser.hh:134
orientation_t
Definition: parser.hh:49
@ clockwise
Definition: parser.hh:49
@ counterclockwise
Definition: parser.hh:49
double testTriang(int snr)
Definition: io/file/dgfparser/dgfparser.cc:1048
double minVertexDistance
Definition: parser.hh:129
bool simplexgrid
Definition: parser.hh:155
std::map< DGFEntityKey< unsigned int >, BndParam > facemap_t
Definition: parser.hh:144
std::vector< std::vector< int > > bound
Definition: parser.hh:137
void generateSimplexGrid(std::istream &)
Definition: io/file/dgfparser/dgfparser.cc:622
std::vector< double > emptyParam_
Definition: parser.hh:168
int nofelparams
Definition: parser.hh:161
std::vector< std::vector< double > > elParams
Definition: parser.hh:163
facemap_t facemap
Definition: parser.hh:145
element_t
Definition: parser.hh:47
@ General
Definition: parser.hh:47
@ Cube
Definition: parser.hh:47
@ Simplex
Definition: parser.hh:47
bool cube2simplex
Definition: parser.hh:158
int nofvtx
Definition: parser.hh:125
void writeTetgenPoly(const std::string &, std::string &, std::string &)
method to write in Tetgen/Triangle Poly Format
Definition: io/file/dgfparser/dgfparser.cc:121
std::vector< std::vector< double > > vtx
Definition: parser.hh:123
int vtxoffset
Definition: parser.hh:127
bool readDuneGrid(std::istream &input, int dimG, int dimW)
parse dune grid format from stream
Definition: io/file/dgfparser/dgfparser.cc:296
std ::vector< std ::vector< unsigned int > > elements
Definition: parser.hh:132
bool haveBndParameters
Definition: parser.hh:148
DGFPrintInfo * info
Definition: parser.hh:166
void generateBoundaries(std::istream &, bool)
Definition: io/file/dgfparser/dgfparser.cc:500
std::vector< double > & getVtxParam(int i, std::vector< double > &coord)
Definition: io/file/dgfparser/dgfparser.cc:1084
std::vector< double > & getElParam(int i, std::vector< double > &coord)
Definition: io/file/dgfparser/dgfparser.cc:1068