Dune Core Modules (2.9.0)

parser.hh
1// SPDX-FileCopyrightText: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5#ifndef DUNE_DGF_DUNEGRIDFORMATPARSER_HH
6#define DUNE_DGF_DUNEGRIDFORMATPARSER_HH
7
8#include <iostream>
9#include <string>
10#include <vector>
11#include <map>
12
13#include <dune/grid/io/file/dgfparser/entitykey.hh>
14
15namespace Dune
16{
17
18 class DGFPrintInfo;
19
23 {
25 typedef std::string type;
26
28 static const type &defaultValue ()
29 {
30 static type value;
31 return value;
32 }
33
35 static type convert ( const std::string & parameter )
36 {
37 return parameter;
38 }
39
41 static const char delimiter = ':';
42 };
43
47 {
48 public:
49 typedef enum {Simplex,Cube,General} element_t;
50
51 typedef enum {counterclockwise=1,clockwise=-1} orientation_t;
52
54 DuneGridFormatParser ( int rank, int size );
55
66 static bool isDuneGridFormat ( std::istream &input );
67
77 static bool isDuneGridFormat ( const std::string &filename );
78
91 bool readDuneGrid( std::istream &input, int dimG, int dimW );
92
94 void writeTetgenPoly ( const std::string &, std::string &, std::string & );
95
96 void writeTetgenPoly ( std::ostream & out, const bool writeSegments = true );
97
98 protected:
99 void generateBoundaries ( std::istream &, bool );
100
101 // call to tetgen/triangle
102 void generateSimplexGrid ( std::istream & );
103 void readTetgenTriangle ( const std::string & );
104
105 // helper methods
106 void removeCopies ();
107
108 void setOrientation ( int use1, int use2,
109 orientation_t orientation=counterclockwise );
110
111 void setRefinement ( int use1, int use2, int is1=-1, int is2=-1 );
112
113 double testTriang ( int snr );
114
115 std::vector< double > & getElParam ( int i, std::vector< double > & coord );
116
117 std::vector< double > & getVtxParam ( int i, std::vector< double > & coord );
118
119 static std::string temporaryFileName ();
120
121 // dimension of world and problem: set through the readDuneGrid() method
122 int dimw, dimgrid;
123
124 // vector of vertex coordinates
125 std::vector < std::vector < double > > vtx;
126
127 int nofvtx;
128
129 int vtxoffset;
130
131 double minVertexDistance; // min. L^1 distance of distinct points
132
133 // vector of elements
134 std :: vector< std :: vector< unsigned int > > elements;
135
136 int nofelements;
137
138 // vector of boundary segments + identifier
139 std::vector < std::vector < int > > bound;
140
141 int nofbound;
142
143 // map to generate and find boundary segments
144 typedef DGFBoundaryParameter::type BoundaryParameter;
145 typedef std::pair < int, BoundaryParameter > BndParam;
146 typedef std::map< DGFEntityKey< unsigned int >, BndParam > facemap_t;
147 facemap_t facemap;
148
149 // true if parameters on a boundary found
150 bool haveBndParameters;
151
152 // set by generator depending on element type wanted
153 element_t element;
154
155 // set by the readDuneGrid method depending
156 // on what type the elements were generated
157 bool simplexgrid;
158
159 // true if grid is generated using the intervall Block
160 bool cube2simplex;
161
162 // parameters on elements
163 int nofvtxparams,nofelparams;
164
165 std::vector< std::vector< double > > vtxParams,elParams;
166
167 // write information about generation process
168 DGFPrintInfo * info;
169
170 std::vector < double > emptyParam_;
171
172
173 private:
174 int rank_;
175 int size_;
176
177 template< class GridType >
178 friend struct DGFGridFactory;
179
180 template< class GridType >
181 friend struct DGFBaseFactory;
182
183 };
184
185} // end namespace Dune
186
187#endif
The DuneGridFormatParser class: reads a DGF file and stores build information in vector structures us...
Definition: parser.hh:47
static bool isDuneGridFormat(std::istream &input)
check whether a stream is in DUNE grid format
Definition: dgfparser.cc:271
DuneGridFormatParser(int rank, int size)
constructor
Definition: dgfparser.cc:97
void writeTetgenPoly(const std::string &, std::string &, std::string &)
method to write in Tetgen/Triangle Poly Format
Definition: dgfparser.cc:123
bool readDuneGrid(std::istream &input, int dimG, int dimW)
parse dune grid format from stream
Definition: dgfparser.cc:298
Dune namespace.
Definition: alignedallocator.hh:13
Contains types for additional features.
Definition: parser.hh:23
static const type & defaultValue()
default constructor
Definition: parser.hh:28
static const char delimiter
delimiter
Definition: parser.hh:41
static type convert(const std::string &parameter)
copy from string
Definition: parser.hh:35
std::string type
type of additional boundary parameters
Definition: parser.hh:25
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)