MOAB: Mesh Oriented datABase  (version 5.4.1)
ParallelMergeMesh.hpp
Go to the documentation of this file.
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 
00021 class ParallelComm;
00022 class TupleList;
00023 
00024 class ParallelMergeMesh
00025 {
00026   public:
00027     ParallelMergeMesh( ParallelComm* pc, const double epsilon );
00028 
00029     // Public Function to identify shared elements
00030     ErrorCode merge( EntityHandle levelset = 0, bool skip_local_merge = false, int dim = -1 );
00031 
00032   private:
00033     ParallelComm* myPcomm;
00034     Interface* myMB;
00035     std::vector< Range > mySkinEnts;
00036     double myEps;
00037     TupleList myTup, myMatches;
00038     gs_data::crystal_data myCD;
00039 
00040     // Wrapper of merge() that performs the merge
00041     ErrorCode PerformMerge( EntityHandle levelset = 0, bool skip_local_merge = false, int dim = -1 );
00042     // Determine the local skin entities (fills mySkinEnts)
00043     ErrorCode PopulateMySkinEnts( const EntityHandle meshset, int dim, bool skip_local_merge = false );
00044     // Get the global bounding box
00045     ErrorCode GetGlobalBox( double* gbox );
00046     // Fill out the local myTup before the first gather-scatter
00047     ErrorCode PopulateMyTup( double* gbox );
00048     // Once myTup is filled and gather scattered, figure out the matches
00049     ErrorCode PopulateMyMatches();
00050     // Sort the matching tuples
00051     ErrorCode SortMyMatches();
00052     // Tag the shared elements once the myMatches has been filled
00053     ErrorCode TagSharedElements( int dim );
00054     // Cleanup any data allocated by class members
00055     void CleanUp();
00056     // Partition the global box by the number of procs
00057     // Returns results in lengths and parts, which needs to be of length 3
00058     ErrorCode PartitionGlobalBox( double* gbox, double* lengths, int* parts );
00059     // A function for determining how many parts a side should be split into
00060     static int PartitionSide( double sideLeng, double restLen, unsigned numProcs, bool altRatio );
00061 
00062     // Swap 2 tuples
00063     static void SwapTuples( TupleList& tup, unsigned long a, unsigned long b );
00064 
00065     // Sort a tuple list by its real values
00066     static void SortTuplesByReal( TupleList& tup, double eps2 = 0 );
00067 
00068     // The recursive sorting function
00069     static void PerformRealSort( TupleList& tup, unsigned long left, unsigned long right, double eps2, uint tup_mr );
00070 
00071     // Determines whether tuple i is greater than tuple j
00072     static bool TupleGreaterThan( TupleList& tup, unsigned long vrI, unsigned long vrJ, double eps2, uint tup_mr );
00073 };
00074 
00075 }  // namespace moab
00076 
00077 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines