00001 /* Meshes Combining cells to a mesh to represent a computational 00002 domain Importing more genereal 2D meshes from text files 00003 00004 @author Peter Kauf, 2005 00005 */ 00006 00007 #ifndef meshImport2Dgeneral_hh 00008 #define meshImport2Dgeneral_hh 00009 00010 #include "toolbox/inputOutput.hh" 00011 #include "meshImport2D.hh" 00012 #include "elementMaps.hh" 00013 00014 namespace concepts { 00015 00016 // ****************************************************************** File ** 00017 00019 class File { 00020 public: 00021 enum types {ATTRIBUTES, EDGCORR, EDGRADIA, DEFFILE}; 00022 File(const std::string file_name, enum types file_type); 00023 File(const File& file); 00024 const enum types type() const { return type_; } 00025 const std::string name() const { return name_; } 00026 protected: 00027 enum types type_; 00028 std::string name_; 00029 }; 00030 00031 class AttributesFile : public File { 00032 public: 00033 AttributesFile(const std::string file_name); 00034 }; 00035 00036 class EdgCorrFile : public File { 00037 public: 00038 EdgCorrFile(const std::string file_name); 00039 }; 00040 00041 class EdgRadiaFile : public File { 00042 public: 00043 EdgRadiaFile(const std::string file_name); 00044 }; 00045 00046 class DefFile : public File { 00047 public: 00048 DefFile(const std::string file_name); 00049 }; 00050 00051 //******************************************************Import2DMeshGeneral** 00052 00053 /* Imports 2D mesh with triangles and quadrilaterals (possibly mixed). 00054 00055 The class can import the same meshes like Import2DMesh, but 00056 allowes also additional properties. For the notation of 00057 coordinates, elements and attributes respectivly boundary files 00058 see Import2DMesh. Note that despite using edge correlations you have to 00059 specify the attributes for every edge / node, also for all of the 00060 periodic ones. Assigning different attributes to periodic objects in the 00061 attribute file will randomly pick one of the attributes. Be carefull to 00062 be consistent since there is no assertion for this case ! 00063 00064 PERIODIC BOUNDARY = topological edge correlation 00065 00066 If you want to read in periodic boundary conditions in the sense 00067 that opposite edges on the boundary are identified, you have to use 00068 this routine with an EdgCorr file. The routine is not made for the 00069 case, where "only" vertices on the boundary are identified, because 00070 this could lead to problems with edge identification. 00071 00072 For this an additional file has to be provided, in which the 00073 edges have to be identified. In the first column is a counter. 00074 The following four columns contain the number of nodes of two 00075 identified edges. 00076 00077 The order of the endpoints of the edges is important, e.g. 00078 <pre>1 1 2 5 6</pre> 00079 means a identification of vertices 1-6 and 2-5. 00080 00081 <pre> 00082 6 5 4 00083 ---------------------------- 00084 | | | 00085 | | | 00086 | | | 00087 | | | 00088 | | | 00089 ---------------------------- 00090 1 2 3</pre> 00091 00092 The identification of the horizontal edges in the sketch above is 00093 achieved by the following file. 00094 00095 <pre>1 1 2 5 6 00096 2 2 3 4 5</pre> 00097 00098 If we want to identify the left boundary edge with the right boundary 00099 edge, we will have to write: 00100 <pre>3 1 6 4 3</pre> 00101 or 00102 <pre>3 6 1 3 4</pre> 00103 or 00104 <pre>3 3 4 6 1</pre> 00105 or 00106 <pre>3 4 3 1 6</pre> 00107 00108 but not 00109 <pre>3 1 6 3 4</pre> 00110 or 00111 <pre>3 6 1 4 3</pre>. 00112 00113 CURVED EDGES (circular arc) 00114 00115 It is also possible to create cells (only quads) with circular 00116 edges. The edges and the corresponding radia have to be listed in 00117 a "EdgRadia" file. In the first column stands a counter. The 00118 following two columns contain the edge and the fourth one the 00119 radius, e.g. 00120 00121 <pre>1 1 2 34.342</pre> 00122 00123 This means that the edge with vertices 1 and 2 will be the segment of 00124 a circle of radius 34.342. The orientation of the curvature is 00125 indicated by the order of the vertices and the sign of the radius. 00126 00127 r > 0 means, the arc is on the right side of line from 1st to 2nd 00128 vertex. This is like in the above example (the length of the 00129 vertical line corresponds to the radius): 00130 00131 <pre> 00132 | 00133 | 00134 | 00135 1 - | - 2 00136 - | - 00137 - | - 00138 --</pre> 00139 00140 To get the circle bended on the other side one should write: 00141 00142 <pre>2 1 34.342</pre> 00143 or 00144 <pre>1 2 -34.342</pre> 00145 00146 The circle is determined geometrically by drawing a circle of radius 00147 34.342 around the first vertex and around the second vertex and then 00148 (depending on orientation) declare one of the two intersecting points 00149 as the middle point of the circle of which the edge will be a segment. 00150 This implies that the radius must be bigger than half the distance of 00151 the two vertices. 00152 00153 One word of caution: The Edgecorrelation routine gives back results 00154 for a special class of meshes which should not be further used. 00155 For the class of meshes with no inner cells (i.e. no cells which have 00156 all their edges in the interior of the mesh), you will impose further 00157 periodicity conditions in the interior by applying edgcorrelation. Here 00158 is an example: 00159 00160 <pre> 00161 7 6 5 00162 ---------------------------- 00163 | | | 00164 | 9 | | 00165 8 |----------|---------------| 4 00166 | | | 00167 | | | 00168 ---------------------------- 00169 1 2 3</pre> 00170 00171 By identifying (1,2) <--> (6,7), (2,3) <--> (5,6), (3,4) <--> (8,1) and 00172 (4,5) <--> (7,8) you will automatically identify (8,9) with (9,4) and 00173 (2,9) with (9,6). Thus for proper results you must only use meshes with 00174 at least one inner cell when applying edgecorrelation. 00175 00176 00177 00178 @author Peter Kauf, 2005 00179 @test test::MeshImp2DTest 00180 @ingroup geometry 00181 00182 */ 00183 00184 class Import2dMeshGeneral : public Import2dMeshBase { 00185 public: 00196 Import2dMeshGeneral(const std::string coord, const std::string elms, 00197 const File file, const uint idxStart = 1); 00198 Import2dMeshGeneral(const std::string coord, const std::string elms, 00199 const File file_1, const File file_2, 00200 const uint idxStart = 1); 00201 Import2dMeshGeneral(const std::string coord, const std::string elms, 00202 const File file_1, const File file_2, 00203 const File file_3, const uint idxStart = 1); 00204 virtual ~Import2dMeshGeneral(); 00205 00206 void addInfiniteQuad(const InOutParameters input); 00207 protected: 00208 virtual std::ostream& info(std::ostream& os) const; 00210 void construct_(const Array<const File*> files); 00212 void delete_(); 00214 bool has_EdgCorr_, has_EdgRadia_; 00216 MultiArray<2, MultiIndex<2> > EdgCorr_; 00218 std::multimap<uint, uint> VtxCorr_; 00219 std::vector<uint> KeyVector_; 00220 // belongs to the insert algorithm: 00221 bool is_paired_(const uint key, const uint a) const; 00222 // belongs to the insert algorithm: 00223 void add_(uint a, uint b); 00224 // belongs to the insert algorithm: 00225 void complete_(uint a, uint b); 00226 // belongs to the insert algorithm: 00227 bool build_(uint a, uint b); 00228 // putting the correlations of a and b and all implied correlations 00229 // into VtxCorr_ 00230 void insert_(uint a, uint b); 00231 void vtxcorr_(const std::string vtxcorr); 00232 void edgcorr_(const std::string edgcorr); 00233 // different Vertex generation routine! 00234 virtual void createEntity_(const MultiIndex<1>& idx); 00235 // different Edge generation routine! 00236 virtual void createEntity_(const MultiIndex<2>& idx); 00237 virtual void createEntity_(const MultiIndex<3>& idx) 00238 throw (concepts::MissingFeature) 00239 {Import2dMeshBase::createEntity_(idx);} 00240 virtual void createEntity_(const MultiIndex<4>& idx) 00241 throw (concepts::MissingFeature) 00242 {Import2dMeshBase::createEntity_(idx);} 00244 MultiArray<2, Real> EdgRadia_; 00246 void edgradia_(std::string edgradia); 00247 MultiArray<2, MappingEdge2d*> Edges_; 00248 std::vector<MappingEdge2d*> edges_vec_; 00250 virtual void createCell_(const MultiIndex<3>& idx) 00251 throw(concepts::MissingFeature); 00253 virtual void createCell_(const MultiIndex<4>& idx) 00254 throw(concepts::MissingFeature); 00255 }; // Import2dMeshGeneral 00256 00257 // ****************************************** import2dMeshGeneralFromInput ** 00258 00282 Import2dMeshGeneral* 00283 import2dMeshGeneralFromInput(const InOutParameters input, 00284 bool verbose = false); 00285 00286 00287 } // namespace concepts 00288 00289 #endif //meshImport2Dgeneral.hh