Dune Core Modules (2.7.0)

parser.hh
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
11#include <dune/grid/io/file/dgfparser/entitykey.hh>
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
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
127 int vtxoffset;
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
134 int nofelements;
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
142 typedef DGFBoundaryParameter::type BoundaryParameter;
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
148 bool haveBndParameters;
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
155 bool simplexgrid;
156
157 // true if grid is generated using the intervall Block
158 bool cube2simplex;
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
166 DGFPrintInfo * info;
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
The DuneGridFormatParser class: reads a DGF file and stores build information in vector structures us...
Definition: parser.hh:45
static bool isDuneGridFormat(std::istream &input)
check whether a stream is in DUNE grid format
Definition: dgfparser.cc:269
DuneGridFormatParser(int rank, int size)
constructor
Definition: dgfparser.cc:95
void writeTetgenPoly(const std::string &, std::string &, std::string &)
method to write in Tetgen/Triangle Poly Format
Definition: dgfparser.cc:121
bool readDuneGrid(std::istream &input, int dimG, int dimW)
parse dune grid format from stream
Definition: dgfparser.cc:296
Dune namespace.
Definition: alignedallocator.hh:14
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
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Oct 13, 22:30, 2024)