|
Sierra Toolkit
Version of the Day
|
00001 /*----------------------------------------------------------------------*/ 00002 /* */ 00003 /* author: Jonathan Scott Rath */ 00004 /* author2: Michael W. Glass (DEC/2000) */ 00005 /* filename: ZoltanPartition.h */ 00006 /* purpose: header file for stk toolkit zoltan methods */ 00007 /* */ 00008 /*----------------------------------------------------------------------*/ 00009 /* Copyright 2001,2010 Sandia Corporation. */ 00010 /* Under the terms of Contract DE-AC04-94AL85000, there is a */ 00011 /* non-exclusive license for use of this work by or on behalf */ 00012 /* of the U.S. Government. Export of this program may require */ 00013 /* a license from the United States Government. */ 00014 /*----------------------------------------------------------------------*/ 00015 00016 // Copyright 2001 Sandia Corporation, Albuquerque, NM. 00017 00018 #ifndef stk_rebalance_ZoltanPartition_hpp 00019 #define stk_rebalance_ZoltanPartition_hpp 00020 00021 #include <utility> 00022 #include <vector> 00023 #include <string> 00024 00025 #include <Teuchos_ParameterList.hpp> 00026 #include <stk_mesh/base/Types.hpp> 00027 #include <stk_rebalance/GeomDecomp.hpp> 00028 00029 //Forward declaration for pointer to a Zoltan structrue. 00030 struct Zoltan_Struct; 00031 00048 namespace stk_classic { 00049 namespace rebalance { 00050 00051 typedef Teuchos::ParameterList Parameters; 00052 00053 class Zoltan : public GeomDecomp { 00054 00055 public: 00056 00089 struct MeshInfo { 00090 std::vector<mesh::Entity *> mesh_entities; 00091 const VectorField * nodal_coord_ref ; 00092 const ScalarField * elem_weight_ref; 00093 std::vector<unsigned> dest_proc_ids ; 00094 00096 MeshInfo(): 00097 nodal_coord_ref(NULL), 00098 elem_weight_ref(NULL) {} 00099 00101 ~MeshInfo() {} 00102 }; 00103 00117 virtual void set_mesh_info ( const std::vector<mesh::Entity *> &mesh_entities, 00118 const VectorField * nodal_coord_ref, 00119 const ScalarField * elem_weight_ref=NULL); 00120 00128 void reset_dest_proc_data (); 00129 00131 static const std::string zoltan_parameters_name(); 00132 00134 static const std::string default_parameters_name(); 00135 00136 00157 explicit Zoltan(ParallelMachine pm, 00158 const unsigned ndim, 00159 Teuchos::ParameterList & rebal_region_parameters, 00160 std::string parameters_name=default_parameters_name()); 00161 00166 virtual ~Zoltan(); 00167 00169 unsigned num_elems() const { return m_total_number_entities_ ; } 00170 00172 double entity_weight(const unsigned moid) const; 00173 00175 void set_destination_proc(const unsigned moid, 00176 const unsigned proc ); 00177 00180 int globalID (const unsigned moid) const 00181 { return m_mesh_information_.mesh_entities[ moid ]->identifier(); } 00182 00184 unsigned num_moid() const; 00185 00187 bool find_mesh_entity(const mesh::Entity * entity, unsigned & moid) const; 00188 00190 mesh::Entity *mesh_entity(const unsigned moid ) const; 00191 00193 const VectorField * entity_coord_ref () const; 00194 00196 const ScalarField * entity_weight_ref () const; 00197 00201 00209 static void merge_default_values (const Teuchos::ParameterList &from, 00210 Teuchos::ParameterList &to); 00211 00217 static void convert_names_and_values (const Teuchos::ParameterList &from, 00218 Teuchos::ParameterList &to); 00219 00220 00234 virtual void determine_new_partition (bool & RebalancingNeeded); 00235 00250 virtual int get_new_partition(stk_classic::mesh::EntityProcVec &new_partition); 00251 00253 bool partition_dependents_needed() const 00254 { return true; /* Zoltan partitions elements and leaves the rest to someone else */ } 00255 00278 int evaluate ( int print_stats, 00279 int *nentity, 00280 double *entity_wgt, 00281 int *ncuts, 00282 double *cut_wgt, 00283 int *nboundary, 00284 int *nadj ); 00285 00287 double zoltan_version() const; 00288 00290 const std::string & parameter_entry_name() const; 00291 00293 Zoltan_Struct * zoltan() { 00294 return m_zoltan_id_; 00295 } 00296 00298 const Zoltan_Struct * zoltan() const { 00299 return m_zoltan_id_; 00300 } 00301 00303 unsigned spatial_dimension() const { 00304 return m_spatial_dimension_; 00305 } 00306 00307 private: 00309 struct Zoltan_Struct *m_zoltan_id_; 00310 00311 const unsigned m_spatial_dimension_; 00315 std::string m_parameter_entry_name_; 00316 00317 static const std::string m_zoltanparametersname_; 00318 static const std::string m_defaultparametersname_; 00319 Parameters m_default_parameters_; 00320 MeshInfo m_mesh_information_; 00321 unsigned m_total_number_entities_; 00322 00323 void init_default_parameters(); 00324 void init(const std::vector< std::pair<std::string, std::string> > 00325 &dynamicLoadRebalancingParameters); 00326 static double init_zoltan_library(); 00327 00329 unsigned destination_proc(const unsigned moid) const; 00330 00332 int register_callbacks(); 00333 00334 00335 }; 00336 00339 } 00340 } // namespace stk_classic 00341 00342 #endif