dune-grid
2.2.0
|
00001 #ifndef DUNE_DGF_DUNEGRIDFORMATPARSER_HH 00002 #define DUNE_DGF_DUNEGRIDFORMATPARSER_HH 00003 00004 #include <iostream> 00005 #include <string> 00006 #include <vector> 00007 #include <map> 00008 00009 #include <dune/grid/io/file/dgfparser/entitykey.hh> 00010 00011 namespace Dune 00012 { 00013 00014 class DGFPrintInfo; 00015 00018 struct DGFBoundaryParameter 00019 { 00021 typedef std::string type; 00022 00024 static const type &defaultValue () 00025 { 00026 static type value; 00027 return value; 00028 } 00029 00031 static type convert ( const std::string & parameter ) 00032 { 00033 return parameter; 00034 } 00035 00037 static const char delimiter = ':'; 00038 }; 00039 00042 class DuneGridFormatParser 00043 { 00044 public: 00045 typedef enum {Simplex,Cube,General} element_t; 00046 00047 typedef enum {counterclockwise=1,clockwise=-1} orientation_t; 00048 00050 DuneGridFormatParser ( int rank, int size ); 00051 00062 static bool isDuneGridFormat ( std::istream &input ); 00063 00073 static bool isDuneGridFormat ( const std::string &filename ); 00074 00087 bool readDuneGrid( std::istream &input, int dimG, int dimW ); 00088 00089 bool readDuneGrid( std::istream &input, int dimG = -1 ) DUNE_DEPRECATED 00090 { 00091 return readDuneGrid( input, dimG, -1 ); 00092 } 00093 00095 void writeTetgenPoly ( const std::string &, std::string &, std::string & ); 00096 00097 void writeTetgenPoly ( std::ostream & out, const bool writeSegments = true ); 00098 00099 protected: 00100 void generateBoundaries ( std::istream &, bool ); 00101 00102 // call to tetgen/triangle 00103 void generateSimplexGrid ( std::istream & ); 00104 void readTetgenTriangle ( const std::string & ); 00105 00106 // helper methods 00107 void removeCopies (); 00108 00109 void setOrientation ( int use1, int use2, 00110 orientation_t orientation=counterclockwise ); 00111 00112 void setRefinement ( int use1, int use2, int is1=-1, int is2=-1 ); 00113 00114 double testTriang ( int snr ); 00115 00116 std::vector< double > & getElParam ( int i, std::vector< double > & coord ); 00117 00118 std::vector< double > & getVtxParam ( int i, std::vector< double > & coord ); 00119 00120 static std::string temporaryFileName (); 00121 00122 // dimension of world and problem: set through the readDuneGrid() method 00123 int dimw, dimgrid; 00124 00125 // vector of vertex coordinates 00126 std::vector < std::vector < double > > vtx; 00127 00128 int nofvtx; 00129 00130 int vtxoffset; 00131 00132 double minVertexDistance; // min. L^1 distance of distinct points 00133 00134 // vector of elements 00135 std :: vector< std :: vector< unsigned int > > elements; 00136 00137 int nofelements; 00138 00139 // vector of boundary segments + identifier 00140 std::vector < std::vector < int > > bound; 00141 00142 int nofbound; 00143 00144 // map to generate and find boundary segments 00145 typedef DGFBoundaryParameter::type BoundaryParameter; 00146 typedef std::pair < int, BoundaryParameter > BndParam; 00147 typedef std::map< DGFEntityKey< unsigned int >, BndParam > facemap_t; 00148 facemap_t facemap; 00149 00150 // true if parameters on a boundary found 00151 bool haveBndParameters; 00152 00153 // set by generator depending on element type wanted 00154 element_t element; 00155 00156 // set by the readDuneGrid method depending 00157 // on what type the elements were generated 00158 bool simplexgrid; 00159 00160 // true if grid is generated using the intervall Block 00161 bool cube2simplex; 00162 00163 // parameters on elements 00164 int nofvtxparams,nofelparams; 00165 00166 std::vector< std::vector< double > > vtxParams,elParams; 00167 00168 // write information about generation process 00169 DGFPrintInfo * info; 00170 00171 std::vector < double > emptyParam_; 00172 00173 00174 private: 00175 int rank_; 00176 int size_; 00177 00178 template< class GridType > 00179 friend class DGFGridFactory; 00180 00181 template< class GridType > 00182 friend class DGFBaseFactory; 00183 00184 }; 00185 00186 } // end namespace Dune 00187 00188 #endif