Flow123d  release_2.1.2-337-g6b7a56b
partitioning.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file partitioning.hh
15  * @brief
16  */
17 
18 #ifndef PARTITIONING_HH_
19 #define PARTITIONING_HH_
20 
22 #include "input/accessors.hh"
23 
24 class Mesh;
25 class SparseGraph;
26 class Distribution;
27 
28 /**
29  * @brief Class for the mesh partitioning.
30  * This should provide:
31  * - construction of cenectivity graph from the mesh
32  * - call a partitioner
33  * - provide new element numbering and new element distribution
34  * (global numbers for the local part - at least for ghost part)
35  * (+ old indices of elements for the local part of the mesh - in order to do not change current implementation)
36  * TODO:
37  * - deal with partitioining of boundary mesh
38  */
39 class Partitioning {
40 public:
41 
42  /// Input specification objects.
44  static const Input::Type::Selection & get_tool_sel();
45  static const Input::Type::Record & get_input_type();
46 
47  TYPEDEF_ERR_INFO(EI_MeshFile, std::string);
48  TYPEDEF_ERR_INFO(EI_NElems, unsigned int);
49  TYPEDEF_ERR_INFO(EI_NProcs, unsigned int);
50  DECLARE_INPUT_EXCEPTION(ExcDecomposeMesh,
51  << "Number of processors " << EI_NProcs::val << " greater then number of elements "
52  << EI_NElems::val << ". Can not make partitioning of the mesh " << EI_MeshFile::qval << ".\n" );
53 
54  /**
55  * Constructor. A pointer to the mesh and accessor to an input record have to be provided.
56  */
57  Partitioning(Mesh *mesh, Input::Record in);
58 
59  /**
60  * Get initial distribution.
61  */
62  const Distribution *get_init_distr() const;
63  /**
64  * Get local part of mesh partition.
65  */
66  const int *get_loc_part() const;
67 
68  /**
69  * Creates and returns vector with element partitioning for output.
70  */
71  shared_ptr< vector<int> > subdomain_id_field_data();
72 
73  /**
74  * Obsolete see source file for doc.
75  */
76  void id_maps(int n_ids, int *id_4_old,
77  Distribution * &new_ds, int * &id_4_loc, int * &new_4_id);
78 
79 
80  static void id_maps(int n_ids, int *id_4_old,
81  const Distribution &old_ds, int *loc_part,
82  Distribution * &new_ds, int * &id_4_loc, int * &new_4_id);
83 
84  /// Destructor.
85  ~Partitioning();
86 
87 private:
88  /**
89  * Types of partitioning algorithms.
90  */
92  PETSc, ///< Use PETSc interface to various partitioing tools.
93  METIS ///< Use direct interface to Metis.
94  };
95 
96  /**
97  * Types of weights used for element partitioning.
98  */
100  any_neighboring, ///< Add edge for any pair of neighboring elements
101  any_weight_lower_dim_cuts, ///< Same as before and assign higher weight to cuts of lower dimension in order to make them stick to one face
102  same_dimension_neighboring, ///< Add edge for any pair of neighboring elements of same dimension (bad for matrix multiply)
103  };
104 
105  /// The input mesh
107  /// Input Record accessor.
109 
110  /// Graph used to partitioning the mesh.
112  /// Partition numbers for local elements in original distribution of elements given be @p init_el_ds_.
113  int * loc_part_;
114  /// Original distribution of elements. Depends on type of partitioner
116  /// Sequential partitioning for output.
117  shared_ptr< vector<int> > seq_part_;
118 
119  /**
120  * Creates sparse parallel graph from the mesh (using algorithm given by the key "graph_type" of the input record accessor @p in_
121  */
123  /**
124  * Creates sparse parallel graph from the mesh (using algorithm given by the key "graph_type" of the input record accessor @p in_)
125  * calls partitioning tool given by the key "tool" of the input record accessor @p in_)
126  * result is local part of the partitioning. Can be retrieved by @p get_loc_part().
127  */
128  void make_partition();
129 
130 
131 };
132 
133 
134 #endif /* PARTITIONING_HH_ */
Class for the mesh partitioning. This should provide:
Definition: partitioning.hh:39
DECLARE_INPUT_EXCEPTION(ExcDecomposeMesh,<< "Number of processors "<< EI_NProcs::val<< " greater then number of elements "<< EI_NElems::val<< ". Can not make partitioning of the mesh "<< EI_MeshFile::qval<< ".\n")
Mesh * mesh_
The input mesh.
~Partitioning()
Destructor.
Definition: partitioning.cc:65
shared_ptr< vector< int > > subdomain_id_field_data()
void id_maps(int n_ids, int *id_4_old, Distribution *&new_ds, int *&id_4_loc, int *&new_4_id)
void make_element_connection_graph()
Definition: partitioning.cc:88
static const Input::Type::Record & get_input_type()
Definition: partitioning.cc:45
Add edge for any pair of neighboring elements.
shared_ptr< vector< int > > seq_part_
Sequential partitioning for output.
Definition: mesh.h:97
TYPEDEF_ERR_INFO(EI_MeshFile, std::string)
Use PETSc interface to various partitioing tools.
Definition: partitioning.hh:92
static const Input::Type::Selection & get_tool_sel()
Definition: partitioning.cc:38
Input::Record in_
Input Record accessor.
Virtual class for construction and partitioning of a distributed sparse graph.
Definition: sparse_graph.hh:54
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
Use direct interface to Metis.
Definition: partitioning.hh:93
Distribution * init_el_ds_
Original distribution of elements. Depends on type of partitioner.
Same as before and assign higher weight to cuts of lower dimension in order to make them stick to one...
const Distribution * get_init_distr() const
Definition: partitioning.cc:74
const int * get_loc_part() const
Definition: partitioning.cc:81
void make_partition()
Record type proxy class.
Definition: type_record.hh:182
SparseGraph * graph_
Graph used to partitioning the mesh.
static const Input::Type::Selection & get_graph_type_sel()
Input specification objects.
Definition: partitioning.cc:27
Add edge for any pair of neighboring elements of same dimension (bad for matrix multiply) ...
Partitioning(Mesh *mesh, Input::Record in)
Definition: partitioning.cc:57
Template for classes storing finite set of named values.
int * loc_part_
Partition numbers for local elements in original distribution of elements given be init_el_ds_...