MOAB: Mesh Oriented datABase
(version 5.2.1)
|
00001 /** 00002 * MOAB, a Mesh-Oriented datABase, is a software component for creating, 00003 * storing and accessing finite element mesh data. 00004 * 00005 * Copyright 2004 Sandia Corporation. Under the terms of Contract 00006 * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 00007 * retains certain rights in this software. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 */ 00015 00016 #ifndef __partitioner_base_hpp__ 00017 #define __partitioner_base_hpp__ 00018 00019 #include <stdlib.h> 00020 #include <vector> 00021 00022 #include "moab/MOABConfig.h" 00023 #include "moab/Range.hpp" 00024 #include "moab/Types.hpp" 00025 00026 #ifdef MOAB_HAVE_MPI 00027 #include "moab_mpi.h" 00028 #include "moab/ParallelComm.hpp" 00029 #endif 00030 namespace moab 00031 { 00032 00033 class Interface; 00034 } 00035 00036 using namespace moab; 00037 00038 template < typename T > 00039 class PartitionerBase 00040 { 00041 00042 public: 00043 PartitionerBase( Interface* impl = NULL, const bool use_coords = false ); 00044 00045 virtual ~PartitionerBase(); 00046 00047 virtual ErrorCode partition_mesh_and_geometry( const double part_geom_mesh_size, const T nparts, 00048 const char* zmethod, const char* other_method, double imbal_tol, 00049 const int part_dim = 3, const bool write_as_sets = true, 00050 const bool write_as_tags = false, const int obj_weight = 0, 00051 const int edge_weight = 0, const bool part_surf = false, 00052 const bool ghost = false, const int projection_type = 0, const bool recompute_rcb_box = false, 00053 const bool print_time = false ) = 0; 00054 00055 virtual ErrorCode partition_mesh( const T nparts, const char* method, const int part_dim = 3, 00056 const bool write_as_sets = true, const bool write_as_tags = false, 00057 const bool partition_tagged_sets = false, 00058 const bool partition_tagged_ents = false, const char* aggregating_tag = NULL, 00059 const bool print_time = false ) = 0; 00060 00061 virtual ErrorCode write_partition( const T nparts, Range& elems, const T* assignment, const bool write_as_sets, 00062 const bool write_as_tags ) = 0; 00063 00064 // put closure of entities in the part sets too 00065 virtual ErrorCode include_closure() = 0; 00066 00067 Range& part_sets() 00068 { 00069 return partSets; 00070 }; 00071 00072 const Range& part_sets() const 00073 { 00074 return partSets; 00075 }; 00076 00077 void set_global_id_option( bool id_opt ) 00078 { 00079 assign_global_ids = id_opt; 00080 } 00081 00082 bool get_global_id_option() 00083 { 00084 return assign_global_ids; 00085 } 00086 00087 protected: 00088 Interface* mbImpl; 00089 #ifdef MOAB_HAVE_MPI 00090 ParallelComm* mbpc; 00091 #endif 00092 bool write_output; 00093 bool useCoords; 00094 bool newComm; 00095 bool assign_global_ids; 00096 00097 Range partSets; 00098 }; 00099 00100 template < typename T > 00101 inline PartitionerBase< T >::PartitionerBase( Interface* impl, const bool use_coords ) 00102 : mbImpl( impl ), useCoords( use_coords ), newComm( false ) 00103 { 00104 #ifdef MOAB_HAVE_MPI 00105 mbpc = ParallelComm::get_pcomm( mbImpl, 0 ); 00106 if( !mbpc ) 00107 { 00108 mbpc = new ParallelComm( impl, MPI_COMM_WORLD, 0 ); 00109 newComm = true; 00110 } 00111 #endif 00112 } 00113 00114 template < typename T > 00115 inline PartitionerBase< T >::~PartitionerBase() 00116 { 00117 #ifdef MOAB_HAVE_MPI 00118 if( newComm ) delete mbpc; 00119 #endif 00120 mbImpl = NULL; 00121 } 00122 00123 #endif