Loading [MathJax]/extensions/tex2jax.js
Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PartitionerBase.hpp
Go to the documentation of this file.
1 /** 2  * MOAB, a Mesh-Oriented datABase, is a software component for creating, 3  * storing and accessing finite element mesh data. 4  * 5  * Copyright 2004 Sandia Corporation. Under the terms of Contract 6  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 7  * retains certain rights in this software. 8  * 9  * This library is free software; you can redistribute it and/or 10  * modify it under the terms of the GNU Lesser General Public 11  * License as published by the Free Software Foundation; either 12  * version 2.1 of the License, or (at your option) any later version. 13  * 14  */ 15  16 #ifndef __partitioner_base_hpp__ 17 #define __partitioner_base_hpp__ 18  19 #include <cstdlib> 20 #include <vector> 21  22 #include "moab/MOABConfig.h" 23 #include "moab/Range.hpp" 24 #include "moab/Types.hpp" 25  26 #ifdef MOAB_HAVE_MPI 27 #include "moab_mpi.h" 28 #include "moab/ParallelComm.hpp" 29 #endif 30 namespace moab 31 { 32  33 class Interface; 34 } // namespace moab 35  36 using namespace moab; 37  38 template < typename T > 39 class PartitionerBase 40 { 41  42  public: 43  PartitionerBase( Interface* impl = NULL, 44  const bool use_coords = false 45 #ifdef MOAB_HAVE_MPI 46  , 47  ParallelComm* parcomm = NULL 48 #endif 49  ); 50  51  virtual ~PartitionerBase(); 52  53  virtual ErrorCode partition_mesh_and_geometry( const double part_geom_mesh_size, 54  const T nparts, 55  const char* zmethod, 56  const char* other_method, 57  double imbal_tol, 58  const int part_dim = 3, 59  const bool write_as_sets = true, 60  const bool write_as_tags = false, 61  const int obj_weight = 0, 62  const int edge_weight = 0, 63  const int projection_type = 0, 64  const bool recompute_rcb_box = false, 65  const bool print_time = false ) = 0; 66  67  virtual ErrorCode partition_mesh( const T nparts, 68  const char* method, 69  const int part_dim = 3, 70  const bool write_as_sets = true, 71  const bool write_as_tags = false, 72  const bool partition_tagged_sets = false, 73  const bool partition_tagged_ents = false, 74  const char* aggregating_tag = NULL, 75  const bool print_time = false ) = 0; 76  77  virtual ErrorCode write_partition( const T nparts, 78  Range& elems, 79  const T* assignment, 80  const bool write_as_sets, 81  const bool write_as_tags ) = 0; 82  83  // put closure of entities in the part sets too 84  virtual ErrorCode include_closure() = 0; 85  86  Range& part_sets() 87  { 88  return partSets; 89  }; 90  91  const Range& part_sets() const 92  { 93  return partSets; 94  }; 95  96  void set_global_id_option( bool id_opt ) 97  { 98  assign_global_ids = id_opt; 99  } 100  101  bool get_global_id_option() 102  { 103  return assign_global_ids; 104  } 105  106  protected: 107  Interface* mbImpl; 108 #ifdef MOAB_HAVE_MPI 109  ParallelComm* mbpc; 110 #endif 111  bool useCoords; 112  bool newComm; 113  bool assign_global_ids; 114  115  Range partSets; 116 }; 117  118 template < typename T > 119 inline PartitionerBase< T >::PartitionerBase( Interface* impl, 120  const bool use_coords 121 #ifdef MOAB_HAVE_MPI 122  , 123  ParallelComm* parcomm 124 #endif 125  ) 126  : mbImpl( impl ) 127 #ifdef MOAB_HAVE_MPI 128  , 129  mbpc( parcomm ) 130 #endif 131  , 132  useCoords( use_coords ), newComm( false ), assign_global_ids( false ) 133 { 134 #ifdef MOAB_HAVE_MPI 135  if( !mbpc ) 136  { 137  mbpc = ParallelComm::get_pcomm( mbImpl, 0 ); 138  if( !mbpc ) 139  { 140  mbpc = new ParallelComm( impl, MPI_COMM_WORLD, 0 ); 141  newComm = true; 142  } 143  } 144 #endif 145 } 146  147 template < typename T > 148 inline PartitionerBase< T >::~PartitionerBase() 149 { 150 #ifdef MOAB_HAVE_MPI 151  if( newComm ) delete mbpc; 152 #endif 153  mbImpl = NULL; 154 } 155  156 #endif