MeshKit
1.0
|
00001 //-----------------------------------C++-------------------------------------// 00002 // File: algs/SCDMesh.hpp 00003 // Author: Stuart R. Slattery 00004 // Wednesday February 2 16:15:8 2011 00005 // Brief: SCDMesh class definition 00006 //---------------------------------------------------------------------------// 00007 00008 #ifndef MESHKIT_SCDMESH_HPP 00009 #define MESHKIT_SCDMESH_HPP 00010 00011 #include <vector> 00012 00013 #include "meshkit/Types.hpp" 00014 #include "meshkit/Error.hpp" 00015 #include "meshkit/MeshScheme.hpp" 00016 #include "meshkit/ModelEnt.hpp" 00017 #include "meshkit/iGeom.hpp" 00018 00019 #include "moab/Core.hpp" 00020 #include "moab/Range.hpp" 00021 #include "moab/Interface.hpp" 00022 #include "moab/ScdInterface.hpp" 00023 #include "moab/GeomTopoTool.hpp" 00024 00025 namespace MeshKit 00026 { 00027 00028 //===========================================================================// 00037 //===========================================================================// 00038 00039 00040 class SCDMesh : public MeshScheme 00041 { 00042 public: 00043 00044 // 2 different interface types 00045 // full - full element and vertex representation in moab 00046 // scd - minimal structured mesh represenation using ScdInterface in MOAB 00047 enum InterfaceSchemeType { full, scd}; 00048 00049 // 2 different grid scheme types 00050 // cfMesh - provide a coarse number of i, j, k cells and a number of fine 00051 // sub-cells in a given coarse division 00052 // vtxMesh - provide an exact list of the vertex coordinates to be used 00053 // in each direction 00054 enum GridSchemeType { cfMesh, vtxMesh}; 00055 00056 // 2 different axis scheme types 00057 // cartesian - i, j, k directions are parallel to the x, y, z axes 00058 // oriented - i, j, k directions oriented with the primary geometric axes 00059 enum AxisSchemeType { cartesian, oriented}; 00060 00061 // Set how the geometry volumes will be meshed 00062 // all - A single structured grid is created for all geometric volumes specified 00063 // individual - Every geometric volume specified gets its own structured grid 00064 enum GeomSchemeType { all, individual}; 00065 00066 private: 00067 00068 // enum types defining the mesh generation 00069 InterfaceSchemeType interfaceType; 00070 GridSchemeType gridType; 00071 AxisSchemeType axisType; 00072 GeomSchemeType geomType; 00073 00074 // MOAB ScdInterface instance - generated when InterfaceSchemeType set to scd 00075 moab::ScdInterface *scdIface; 00076 00077 // number of coarse divisions in each direction 00078 unsigned int coarse_i; 00079 unsigned int coarse_j; 00080 unsigned int coarse_k; 00081 00082 // array of fine divisions in each division 00083 std::vector<int> fine_i; 00084 std::vector<int> fine_j; 00085 std::vector<int> fine_k; 00086 00087 // vertex arrays in each direction 00088 std::vector<double> i_arr; 00089 std::vector<double> j_arr; 00090 std::vector<double> k_arr; 00091 00092 // error codes 00093 iGeom::Error gerr; 00094 moab::ErrorCode rval; 00095 00096 // bounding box min, max coordiantes 00097 double minCoord[3], maxCoord[3]; 00098 00099 // number of ijk vertices 00100 int num_i; 00101 int num_j; 00102 int num_k; 00103 int num_verts; 00104 00105 // box size increasement ratio, default is 0.0 00106 double boxIncrease; 00107 00108 // vertex coordinates 00109 std::vector<double> full_coords; 00110 00111 // created vertex and hex ranges 00112 moab::Range vtx_range; 00113 moab::Range hex_range; 00114 00115 moab::Tag bb_tag; 00116 00117 bool useMeshGeom; 00118 00119 public: 00120 00122 SCDMesh(MKCore *mkcore, const MEntVector &me_vec); 00123 00125 virtual ~SCDMesh(); 00126 00130 virtual void setup_this(); 00131 00133 virtual void execute_this(); 00134 00136 static const char* name() 00137 { return "SCDMesh"; } 00138 00143 static bool can_mesh(iBase_EntityType dim) 00144 { return iBase_REGION == dim; } 00145 00152 static bool can_mesh(ModelEnt* ent) 00153 { return canmesh_region(ent); } 00154 00158 static const moab::EntityType* output_types(); 00159 00163 virtual const moab::EntityType* mesh_types_arr() const 00164 { return output_types(); } 00165 00170 void set_interface_scheme(InterfaceSchemeType scheme); 00171 00176 InterfaceSchemeType get_interface_scheme() const; 00177 00182 void set_grid_scheme(GridSchemeType scheme); 00183 00188 GridSchemeType get_grid_scheme() const; 00189 00194 void set_axis_scheme(AxisSchemeType scheme); 00195 00200 AxisSchemeType get_axis_scheme() const; 00201 00206 void set_geometry_scheme(GeomSchemeType scheme); 00207 00212 GeomSchemeType get_geometry_scheme() const; 00213 00218 void set_coarse_i_grid(int coarse_i_); 00219 00224 void set_coarse_j_grid(int coarse_j_); 00225 00230 void set_coarse_k_grid(int coarse_k_); 00231 00236 void set_fine_i_grid(std::vector<int> fine_i_); 00237 00242 void set_fine_j_grid(std::vector<int> fine_j_); 00243 00248 void set_fine_k_grid(std::vector<int> fine_k_); 00249 00253 void get_box_dimension(double* min, double* max); 00254 00258 void set_box_increase_ratio(double box_increase = .03); 00259 00263 void use_mesh_geometry(bool use); 00264 00268 void set_cart_box_min_max(double* min, double* max, double box_increase); 00269 00270 00271 private: 00272 00274 void set_cart_box_all(); 00275 00277 void set_cart_box_individual(ModelEnt *this_me); 00278 00280 void create_cart_edges(); 00281 00283 void create_vertex_coords(); 00284 00286 void create_full_mesh(moab::Range& me_range); 00287 00289 void create_light_mesh(moab::Range& me_range); 00290 00291 }; // end class SCDMesh 00292 00293 00294 /* Inline Functions */ 00295 00296 inline SCDMesh::~SCDMesh() 00297 { 00298 } 00299 00300 inline void SCDMesh::set_interface_scheme(SCDMesh::InterfaceSchemeType scheme) 00301 { 00302 interfaceType = scheme; 00303 } 00304 00305 inline SCDMesh::InterfaceSchemeType SCDMesh::get_interface_scheme() const 00306 { 00307 return interfaceType; 00308 } 00309 00310 inline void SCDMesh::set_grid_scheme(SCDMesh::GridSchemeType scheme) 00311 { 00312 gridType = scheme; 00313 } 00314 00315 inline SCDMesh::GridSchemeType SCDMesh::get_grid_scheme() const 00316 { 00317 return gridType; 00318 } 00319 00320 inline void SCDMesh::set_axis_scheme(SCDMesh::AxisSchemeType scheme) 00321 { 00322 axisType = scheme; 00323 } 00324 00325 inline SCDMesh::AxisSchemeType SCDMesh::get_axis_scheme() const 00326 { 00327 return axisType; 00328 } 00329 00330 inline void SCDMesh::set_geometry_scheme(SCDMesh::GeomSchemeType scheme) 00331 { 00332 geomType = scheme; 00333 } 00334 00335 inline SCDMesh::GeomSchemeType SCDMesh::get_geometry_scheme() const 00336 { 00337 return geomType; 00338 } 00339 00340 inline void SCDMesh::set_coarse_i_grid(int coarse_i_) 00341 { 00342 coarse_i = coarse_i_; 00343 } 00344 00345 inline void SCDMesh::set_coarse_j_grid(int coarse_j_) 00346 { 00347 coarse_j = coarse_j_; 00348 } 00349 00350 inline void SCDMesh::set_coarse_k_grid(int coarse_k_) 00351 { 00352 coarse_k = coarse_k_; 00353 } 00354 00355 inline void SCDMesh::set_fine_i_grid(std::vector<int> fine_i_) 00356 { 00357 fine_i = fine_i_; 00358 } 00359 00360 inline void SCDMesh::set_fine_j_grid(std::vector<int> fine_j_) 00361 { 00362 fine_j = fine_j_; 00363 } 00364 00365 inline void SCDMesh::set_fine_k_grid(std::vector<int> fine_k_) 00366 { 00367 fine_k = fine_k_; 00368 } 00369 00370 inline void SCDMesh::get_box_dimension(double* min, double* max) 00371 { 00372 for (int i = 0; i < 3; i++) { 00373 min[i] = minCoord[i]; 00374 max[i] = maxCoord[i]; 00375 } 00376 } 00377 00378 inline void SCDMesh::set_box_increase_ratio(double box_increase) 00379 { 00380 boxIncrease = box_increase; 00381 } 00382 00383 inline void SCDMesh::use_mesh_geometry(bool use) 00384 { 00385 useMeshGeom = use; 00386 } 00387 00388 } // end namespace MeshKit 00389 00390 #endif // end if __SCDMESH_HPP 00391 00392 //---------------------------------------------------------------------------// 00393 // end algs/SCDMesh.hpp 00394 //---------------------------------------------------------------------------//