MeshKit  1.0
SubMapping.hpp
Go to the documentation of this file.
00001 //-----------------------------------C++-------------------------------------//
00002 // File: src/algs/Submapping.hpp
00003 // Wednesday February 11 10:50 2011
00004 // Brief: SubMapping class definition: generate the structural mesh by
00005 //        submapping 
00006 //---------------------------------------------------------------------------//
00007 
00008 
00009 #ifndef MESHKIT_SUBMAPPING_HPP
00010 #define MESHKIT_SUBMAPPING_HPP
00011 
00012 #include <stdlib.h>
00013 #include <stdio.h>
00014 #include <assert.h>
00015 #include <string>
00016 #include <iostream>
00017 #include <fstream>
00018 #include <string.h>
00019 #include <limits.h>
00020 
00021 #include <iGeom.h>
00022 #include "meshkit/MKCore.hpp"
00023 #include "meshkit/ModelEnt.hpp"
00024 #include "meshkit/SizingFunction.hpp"
00025 #include "moab/ReadUtilIface.hpp"
00026 #include "Global.hpp"
00027 #include <iMesh.h>
00028 #include <iGeom.h>
00029 #include <set>
00030 #include <iRel.h>
00031 #include <vector>
00032 #include <set>
00033 #include <list>
00034 
00035 #include "meshkit/MeshScheme.hpp"
00036 
00037 using namespace std;
00038 
00039 namespace MeshKit
00040 {
00041 //===========================================================================//
00050 //===========================================================================//
00051 enum VertexTypes{REVERSAL=-2, CORNER=-1, SIDE = 0, END = 1};
00052 enum EdgeTypes{POSI_I = 0, NEG_I= 1, POSI_J = 2, NEG_J = 3};
00053 class SubMapping :  public MeshScheme
00054 {       
00055 public:
00056 
00057         SubMapping(MKCore *mk_core, const MEntVector &me_vec);
00058         ~SubMapping();
00059 
00060         virtual void setup_this();
00061         virtual void execute_this();
00062 
00063  
00065         static const char* name() 
00066           { return "SubMapping"; }
00067 
00072         static bool can_mesh(iBase_EntityType dim)
00073           { return iBase_FACE == dim; }
00074 
00081         static bool can_mesh(ModelEnt *me)
00082           { return canmesh_region(me); }
00083 
00087         static const moab::EntityType* output_types();
00088 
00092         virtual const moab::EntityType* mesh_types_arr() const
00093           { return output_types();}
00094 
00095                 //setup the mesh size
00096                 void SetupMeshSize(double size = 1.0);
00097 
00098 private:
00099                 //classify the vertices as side, end, reversal and corner
00100                 void VertexClassification(ModelEnt *ent);
00101 
00102                 //classify the boundary edges as -I, +I, -J, +J
00103                 void EdgeClassification();
00104 
00105                 //assign the i,j coordinates for each node on the boundary
00106                 void EdgeDiscretization(ModelEnt *me);
00107 
00108                 //ReOrganize the vertices and edges on the boundary
00109                 void VerEdgOrganize(std::set<iBase_EntityHandle> edge_set, std::vector<iBase_EntityHandle> g_edge, iBase_EntityHandle surf);
00110 
00111                 //subdivide the surface 
00112                 void InteriorNodeInterpolation(ModelEnt *me);
00113 
00114                 //calculate the angle for each vertex
00115                 void GetAngle(iBase_EntityHandle surf, vector<double> &angle);
00116 
00117                 //assign the i-j coordinates for boundary nodes
00118                 void AssignIJCoords(double &u, double &v, EdgeTypes type, int index);
00119 
00120                 //call the linear programming library to solve the linear programm
00121                 void VtxClassificationLP();
00122 
00123                 //check whether a point is outside the surface or not
00124                 bool isOutSideSurf(vector<Vertex> corner, int i, int j);
00125                 double Angle2D(double x1, double y1, double x2, double y2);
00126 
00127                 //Use the Winslow to smooth the structured mesh
00128                 void MeshSmoothing(ModelEnt *ent);
00129 
00130                 void buildAssociation();
00131 
00132                 bool isCurved(int vtx_index, vector<double> u1, vector<double> u2, vector<double> u3, vector<double> u4, vector<vector<double> > tang_pre, vector<vector<double> > tang_next);
00133 
00134                 void LinearProgramming();
00135 
00136                 
00137 private://private member variable
00138         vector<VertexTypes> vertices_types;
00139         vector<Vertex> nodes, vertices;
00140         vector<Edge> edges;
00141         
00142         vector<double> interior_angle;
00143         vector<int> sorted_vertex_list, sorted_node_list, sorted_edge_list;
00144         vector<EdgeTypes> edges_types;  
00145         
00146         iBase_TagHandle g_taghandle, m_taghandle;
00147 
00148         vector<vector<int> > coordinate_i_j;
00149 
00150         double size_low_bound;
00151 
00152         unsigned int start_index;
00153 
00154         vector<int> edge_size;
00155         map<int, int> geom_mesh_node;
00156         map<int, int> mesh_geom_vertex;
00157 
00158         vector<Face> quads;
00159 
00160         
00161 };
00162 
00163 }
00164 
00165 #endif
00166 
00167 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines