Sierra Toolkit  Version of the Day
ZoltanPartition.hpp
Go to the documentation of this file.
1 /*----------------------------------------------------------------------*/
2 /* */
3 /* author: Jonathan Scott Rath */
4 /* author2: Michael W. Glass (DEC/2000) */
5 /* filename: ZoltanPartition.h */
6 /* purpose: header file for stk toolkit zoltan methods */
7 /* */
8 /*----------------------------------------------------------------------*/
9 /* Copyright 2001,2010 Sandia Corporation. */
10 /* Under the terms of Contract DE-AC04-94AL85000, there is a */
11 /* non-exclusive license for use of this work by or on behalf */
12 /* of the U.S. Government. Export of this program may require */
13 /* a license from the United States Government. */
14 /*----------------------------------------------------------------------*/
15 
16 // Copyright 2001 Sandia Corporation, Albuquerque, NM.
17 
18 #ifndef stk_rebalance_ZoltanPartition_hpp
19 #define stk_rebalance_ZoltanPartition_hpp
20 
21 #include <utility>
22 #include <vector>
23 #include <string>
24 
25 #include <Teuchos_ParameterList.hpp>
26 #include <stk_mesh/base/Types.hpp>
28 
29 //Forward declaration for pointer to a Zoltan structrue.
30 struct Zoltan_Struct;
31 
48 namespace stk_classic {
49 namespace rebalance {
50 
51 typedef Teuchos::ParameterList Parameters;
52 
53 class Zoltan : public GeomDecomp {
54 
55 public:
56 
89  struct MeshInfo {
90  std::vector<mesh::Entity *> mesh_entities;
91  const VectorField * nodal_coord_ref ;
92  const ScalarField * elem_weight_ref;
93  std::vector<unsigned> dest_proc_ids ;
94 
97  nodal_coord_ref(NULL),
98  elem_weight_ref(NULL) {}
99 
102  };
103 
117  virtual void set_mesh_info ( const std::vector<mesh::Entity *> &mesh_entities,
118  const VectorField * nodal_coord_ref,
119  const ScalarField * elem_weight_ref=NULL);
120 
128  void reset_dest_proc_data ();
129 
131  static const std::string zoltan_parameters_name();
132 
134  static const std::string default_parameters_name();
135 
136 
157  explicit Zoltan(ParallelMachine pm,
158  const unsigned ndim,
159  Teuchos::ParameterList & rebal_region_parameters,
160  std::string parameters_name=default_parameters_name());
161 
166  virtual ~Zoltan();
167 
169  unsigned num_elems() const { return m_total_number_entities_ ; }
170 
172  double entity_weight(const unsigned moid) const;
173 
175  void set_destination_proc(const unsigned moid,
176  const unsigned proc );
177 
180  int globalID (const unsigned moid) const
181  { return m_mesh_information_.mesh_entities[ moid ]->identifier(); }
182 
184  unsigned num_moid() const;
185 
187  bool find_mesh_entity(const mesh::Entity * entity, unsigned & moid) const;
188 
190  mesh::Entity *mesh_entity(const unsigned moid ) const;
191 
193  const VectorField * entity_coord_ref () const;
194 
196  const ScalarField * entity_weight_ref () const;
197 
201 
209  static void merge_default_values (const Teuchos::ParameterList &from,
210  Teuchos::ParameterList &to);
211 
217  static void convert_names_and_values (const Teuchos::ParameterList &from,
218  Teuchos::ParameterList &to);
219 
220 
234  virtual void determine_new_partition (bool & RebalancingNeeded);
235 
250  virtual int get_new_partition(stk_classic::mesh::EntityProcVec &new_partition);
251 
253  bool partition_dependents_needed() const
254  { return true; /* Zoltan partitions elements and leaves the rest to someone else */ }
255 
278  int evaluate ( int print_stats,
279  int *nentity,
280  double *entity_wgt,
281  int *ncuts,
282  double *cut_wgt,
283  int *nboundary,
284  int *nadj );
285 
287  double zoltan_version() const;
288 
290  const std::string & parameter_entry_name() const;
291 
293  Zoltan_Struct * zoltan() {
294  return m_zoltan_id_;
295  }
296 
298  const Zoltan_Struct * zoltan() const {
299  return m_zoltan_id_;
300  }
301 
303  unsigned spatial_dimension() const {
304  return m_spatial_dimension_;
305  }
306 
307 private:
309  struct Zoltan_Struct *m_zoltan_id_;
310 
311  const unsigned m_spatial_dimension_;
315  std::string m_parameter_entry_name_;
316 
317  static const std::string m_zoltanparametersname_;
318  static const std::string m_defaultparametersname_;
319  Parameters m_default_parameters_;
320  MeshInfo m_mesh_information_;
321  unsigned m_total_number_entities_;
322 
323  void init_default_parameters();
324  void init(const std::vector< std::pair<std::string, std::string> >
325  &dynamicLoadRebalancingParameters);
326  static double init_zoltan_library();
327 
329  unsigned destination_proc(const unsigned moid) const;
330 
332  int register_callbacks();
333 
334 
335 };
336 
339 }
340 } // namespace stk_classic
341 
342 #endif
bool rebalance(mesh::BulkData &bulk_data, const mesh::Selector &selector, const VectorField *coord_ref, const ScalarField *elem_weight_ref, Partition &partition, const stk_classic::mesh::EntityRank rank=stk_classic::mesh::InvalidEntityRank)
Rebalance with a Partition object.
Definition: Rebalance.cpp:164
A structure to organize the mesh entity data.
Field with defined data type and multi-dimensions (if any)
Definition: Field.hpp:118
Geometric support for partitioning of mesh entities.
Sierra Toolkit.
MPI_Comm ParallelMachine
Definition: Parallel.hpp:32
Class for implementing Zoltan based rebalancing.