moab
|
00001 #ifndef PARALLELMERGEMESH_HPP 00002 #define PARALLELMERGEMESH_HPP 00003 00004 #include "moab/Types.hpp" 00005 #include <vector> 00006 #include "moab/Range.hpp" 00007 #include "moab/ParallelComm.hpp" 00008 00009 #include "moab/TupleList.hpp" 00010 #include "moab/gs.hpp" 00011 00012 /* 00013 Class to merge meshes in parallel 00014 Requires a ParallelComm and tolerance epsilon 00015 Currently uses a 1 dimensional partition of the global box 00016 */ 00017 00018 namespace moab { 00019 00020 class ParallelComm; 00021 class TupleList; 00022 00023 class ParallelMergeMesh { 00024 public: 00025 ParallelMergeMesh(ParallelComm *pc, 00026 const double epsilon); 00027 00028 //Public Function to identify shared elements 00029 ErrorCode merge(); 00030 00031 private: 00032 ParallelComm *myPcomm; 00033 Interface *myMB; 00034 std::vector<Range> mySkinEnts; 00035 double myEps; 00036 TupleList myTup, myMatches; 00037 gs_data::crystal_data myCD; 00038 00039 //Wrapper of merge() that performs the merge 00040 ErrorCode PerformMerge(); 00041 //Determine the local skin entities (fills mySkinEnts) 00042 ErrorCode PopulateMySkinEnts(const EntityHandle meshset,int dim); 00043 //Get the global bounding box 00044 ErrorCode GetGlobalBox(double *gbox); 00045 //Fill out the local myTup before the first gather-scatter 00046 ErrorCode PopulateMyTup(double * gbox); 00047 //Once myTup is filled and gather scattered, figure out the matches 00048 ErrorCode PopulateMyMatches(); 00049 //Sort the matching tuples 00050 ErrorCode SortMyMatches(); 00051 //Tag the shared elements once the myMatches has been filled 00052 ErrorCode TagSharedElements(int dim); 00053 //Cleanup any data allocated by class members 00054 void CleanUp(); 00055 //Partition the global box by the number of procs 00056 //Returns results in lengths and parts, which needs to be of length 3 00057 ErrorCode PartitionGlobalBox(double *gbox, double *lengths, int *parts); 00058 //A function for determining how many parts a side should be split into 00059 static int PartitionSide(double sideLeng, double restLen, unsigned numProcs, bool altRatio); 00060 00061 //Swap 2 tuples 00062 static void SwapTuples(TupleList &tup, 00063 unsigned long a, 00064 unsigned long b); 00065 00066 //Sort a tuple list by its real values 00067 static void SortTuplesByReal(TupleList &tup, 00068 double eps2=0); 00069 00070 //The recursive sorting function 00071 static void PerformRealSort(TupleList &tup, 00072 unsigned long left, 00073 unsigned long right, 00074 double eps2, 00075 uint tup_mr); 00076 00077 //Determines whether tuple i is greater than tuple j 00078 static bool TupleGreaterThan(TupleList &tup, 00079 unsigned long vrI, 00080 unsigned long vrJ, 00081 double eps2, 00082 uint tup_mr); 00083 }; 00084 00085 } // namespace moab 00086 00087 #endif