MeshKit  1.0
OneToOneSwept.hpp
Go to the documentation of this file.
00001 //-----------------------------------C++-------------------------------------//
00002 // File: src/algs/OneToOneSwept.hpp
00003 // Wednesday February 11 10:50 2011
00004 // Brief: OneToOneSwept class definition: generate the all-hexahedral mesh by
00005 //        general sweeping 
00006 //---------------------------------------------------------------------------//
00007 
00008 
00009 #ifndef MESHKIT_ONETOONESWEPT_HPP
00010 #define MESHKIT_ONETOONESWEPT_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 #include <math.h>
00021 
00022 #include "Global.hpp"
00023 #include "meshkit/MKCore.hpp"
00024 #include "meshkit/ModelEnt.hpp"
00025 #include "meshkit/SizingFunction.hpp"
00026 
00027 #include <iMesh.h>
00028 #include <iGeom.h>
00029 #include <iRel.h>
00030 #include <vector>
00031 #include <set>
00032 #include <list>
00033 
00034 #include "meshkit/MeshScheme.hpp"
00035 
00036 using namespace std;
00037 
00038 namespace MeshKit {
00039 //===========================================================================//
00047 //===========================================================================//
00048 
00049 class OneToOneSwept: public MeshScheme {
00050 public:
00051 
00052   OneToOneSwept(MKCore *mk_core, const MEntVector &me_vec);
00053   ~OneToOneSwept();
00054 
00055   virtual void setup_this();
00056   virtual void execute_this();
00057 
00059   static const char* name()
00060   {
00061     return "OneToOneSwept";
00062   }
00063 
00068   static bool can_mesh(iBase_EntityType dim)
00069   {
00070     return iBase_REGION == dim;
00071   }
00072 
00079   static bool can_mesh(ModelEnt *me)
00080   {
00081     return canmesh_region(me);
00082   }
00083 
00087   static const moab::EntityType* output_types();
00088 
00092   virtual const moab::EntityType* mesh_types_arr() const
00093   {
00094     return output_types();
00095   }
00096 
00097   //specify the source surface for OneToOneSwept class
00098   void SetSourceSurface(int index);
00099 
00100   //specify the target surface for OneToOneSwept class
00101   void SetTargetSurface(int index);
00102 
00103 private:
00104 #ifdef HAVE_ARMADILLO
00105   void SurfMeshHarmonic(iBase_EntityHandle vol, vector<iBase_EntityHandle> &newNodehandle);
00106 #endif
00107   //determine whether the source surface is concave or multi-connected
00108   bool isConcave();
00109 
00110   void BuildLateralBoundaryLayers(ModelEnt * me, std::vector<moab::EntityHandle> & layers);
00111 
00112   moab::ErrorCode NodeAbove(moab::EntityHandle node1, moab::EntityHandle node2, moab::Range & quadsOnLateralSurfaces,
00113       moab::EntityHandle & node3, moab::EntityHandle & node4);
00114 
00115   moab::ErrorCode FourthNodeInQuad(moab::EntityHandle node1, moab::EntityHandle node2, moab::EntityHandle node3,
00116       moab::Range & quadsOnLateralSurfaces, moab::EntityHandle & node4);
00117 
00118   //function for all-quad meshing on the target surface
00119   int TargetSurfProjection(std::vector<moab::EntityHandle> & boundLayers);
00120 
00121   // to compute node positions in the interior of volume, numLayers-1 times
00122   // use similar code to TargetSurfProjection, but do not project on surface...
00123   int ProjectInteriorLayers(std::vector<moab::EntityHandle> & boundLayers, vector<vector<Vertex> > &linkVertexList);
00124 
00125   //create the hexahedral elements between the source surface and target surface
00126   int CreateElements(vector<vector<Vertex> > &linkVertexList);
00127 
00128   // input: list of nodes on source, boundary center, list of nodes on target, target center
00129   // output: 3x3 matrix A such that
00130   //  target= A * ( source - 2*sc + tc) + sc
00131   void computeTransformationFromSourceToTarget(std::vector<Vector3D> & sNodes, Vector3D & sc,
00132       std::vector<Vector3D> & tNodes, Vector3D & tc, Matrix3D & transMatrix);
00133 
00134 #ifdef HAVE_MESQUITE
00135   //target surface mesh by Mesquite
00136   void SurfMeshOptimization();
00137 #endif
00138 
00139 private:
00140   //private member variable
00141   iBase_EntityHandle sourceSurface;
00142   iBase_EntityHandle targetSurface;
00143   iBase_EntityHandle volume;
00144   moab::Interface *mb;
00145   int numLayers;
00146   int numLoops;
00147   int sizeBLayer;
00148   iGeom * igeom_inst;
00149   int index_src, index_tar;
00150   iBase_TagHandle geom_id_tag;
00151 
00152   std::vector<Vertex> NodeList; //mesh nodes on the source surface
00153   std::vector<Vertex> TVertexList; //mesh nodes on the target surface
00154 
00155   std::vector<Face> FaceList;
00156   iBase_EntitySetHandle volumeSet;
00157 
00158   std::set<moab::EntityHandle> markedMoabEnts;
00159 };
00160 
00161 }
00162 
00163 #endif
00164 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines