libMesh
partitioner.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_PARTITIONER_H
21 #define LIBMESH_PARTITIONER_H
22 
23 // Local Includes
24 #include "libmesh/libmesh.h"
25 #include "libmesh/auto_ptr.h"
26 #include "libmesh/id_types.h"
27 #include "libmesh/mesh_base.h" // for MeshBase::element_iterator
28 
29 // C++ Includes
30 #include <cstddef>
31 
32 namespace libMesh
33 {
34 
35 // Forward Declarations
36 class ErrorVector;
37 
49 {
50 public:
51 
56 
60  virtual ~Partitioner() {}
61 
68  virtual UniquePtr<Partitioner> clone () const = 0;
69 
85  virtual void partition (MeshBase & mesh,
86  const unsigned int n);
87 
103  virtual void partition (MeshBase & mesh);
104 
120  virtual void partition_range (MeshBase & /*mesh*/,
123  const unsigned int /*n_parts*/)
124  { libmesh_not_implemented(); }
125 
132  void repartition (MeshBase & mesh,
133  const unsigned int n);
134 
140  void repartition (MeshBase & mesh);
141 
146  static void partition_unpartitioned_elements (MeshBase & mesh);
147 
148  static void partition_unpartitioned_elements (MeshBase & mesh,
149  const unsigned int n);
150 
156  static void set_parent_processor_ids(MeshBase & mesh);
157 
163  static void set_node_processor_ids(MeshBase & mesh);
164 
170  virtual void attach_weights(ErrorVector * /*weights*/) { libmesh_not_implemented(); }
171 
172 protected:
173 
180  void single_partition (MeshBase & mesh);
181 
188 
194  virtual void _do_partition(MeshBase & mesh,
195  const unsigned int n) = 0;
196 
204  virtual void _do_repartition (MeshBase & mesh,
205  const unsigned int n) { this->_do_partition (mesh, n); }
206 
212 
217 };
218 
219 } // namespace libMesh
220 
221 #endif // LIBMESH_PARTITIONER_H
The definition of the element_iterator struct.
Definition: mesh_base.h:1476
void single_partition(MeshBase &mesh)
Trivially "partitions" the mesh for one processor.
Definition: partitioner.C:151
Partitioner()
Constructor.
Definition: partitioner.h:55
virtual UniquePtr< Partitioner > clone() const =0
virtual void attach_weights(ErrorVector *)
Attach weights that can be used for partitioning.
Definition: partitioner.h:170
The ErrorVector is a specialization of the StatisticsVector for error data computed on a finite eleme...
Definition: error_vector.h:50
static void set_node_processor_ids(MeshBase &mesh)
This function is called after partitioning to set the processor IDs for the nodes.
Definition: partitioner.C:416
MeshBase & mesh
const class libmesh_nullptr_t libmesh_nullptr
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
The libMesh namespace provides an interface to certain functionality in the library.
virtual void partition_range(MeshBase &, MeshBase::element_iterator, MeshBase::element_iterator, const unsigned int)
Partitions elements in the range (it, end) into n parts.
Definition: partitioner.h:120
This is the MeshBase class.
Definition: mesh_base.h:68
The Partitioner class provides a uniform interface for partitioning algorithms.
Definition: partitioner.h:48
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
virtual void _do_repartition(MeshBase &mesh, const unsigned int n)
This is the actual re-partitioning method which can be overridden in derived classes.
Definition: partitioner.h:204
void repartition(MeshBase &mesh, const unsigned int n)
Repartitions the MeshBase into n parts.
Definition: partitioner.C:116
ErrorVector * _weights
The weights that might be used for partitioning.
Definition: partitioner.h:216
void single_partition_range(MeshBase::element_iterator it, MeshBase::element_iterator end)
Slightly generalized version of single_partition which acts on a range of elements defined by the pai...
Definition: partitioner.C:159
virtual void _do_partition(MeshBase &mesh, const unsigned int n)=0
This is the actual partitioning method which must be overridden in derived classes.
static void partition_unpartitioned_elements(MeshBase &mesh)
These functions assign processor IDs to newly-created elements (in parallel) which are currently assi...
Definition: partitioner.C:175
static const dof_id_type communication_blocksize
The blocksize to use when doing blocked parallel communication.
Definition: partitioner.h:211
virtual void partition(MeshBase &mesh, const unsigned int n)
Partitions the MeshBase into n parts by setting processor_id() on Nodes and Elems.
Definition: partitioner.C:49
static void set_parent_processor_ids(MeshBase &mesh)
This function is called after partitioning to set the processor IDs for the inactive parent elements...
Definition: partitioner.C:256
virtual ~Partitioner()
Destructor.
Definition: partitioner.h:60
uint8_t dof_id_type
Definition: id_types.h:64