libMesh
centroid_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 #ifndef LIBMESH_CENTROID_PARTITIONER_H
20 #define LIBMESH_CENTROID_PARTITIONER_H
21 
22 // Local includes
23 #include "libmesh/partitioner.h"
24 #include "libmesh/point.h"
25 
26 // C++ includes
27 #include <utility> // pair
28 #include <vector>
29 
30 namespace libMesh
31 {
32 
33 // Forward declarations
34 class Elem;
35 
48 {
49 public:
50 
57  Y,
58  Z,
61 
66  explicit
68 
72  virtual UniquePtr<Partitioner> clone () const libmesh_override
73  {
75  }
76 
81 
86 
90  virtual void partition_range(MeshBase & mesh,
93  const unsigned int n) libmesh_override;
94 
95 protected:
96 
100  virtual void _do_partition (MeshBase & mesh,
101  const unsigned int n) libmesh_override;
102 
103 private:
104 
110 
115  static bool sort_x (const std::pair<Point, Elem *> & lhs,
116  const std::pair<Point, Elem *> & rhs);
117 
122  static bool sort_y (const std::pair<Point, Elem *> & lhs,
123  const std::pair<Point, Elem *> & rhs);
124 
129  static bool sort_z (const std::pair<Point, Elem *> & lhs,
130  const std::pair<Point, Elem *> & rhs);
131 
136  static bool sort_radial (const std::pair<Point, Elem *> & lhs,
137  const std::pair<Point, Elem *> & rhs);
138 
143 
148  std::vector<std::pair<Point, Elem *>> _elem_centroids;
149 };
150 
151 } // namespace libMesh
152 
153 #endif // LIBMESH_CENTROID_PARTITIONER_H
The definition of the element_iterator struct.
Definition: mesh_base.h:1476
std::vector< std::pair< Point, Elem * > > _elem_centroids
Vector which holds pairs of centroids and their respective element pointers.
CentroidSortMethod
A typedef which controls the sorting method used for ordering the centroids.
MeshBase & mesh
virtual void _do_partition(MeshBase &mesh, const unsigned int n) libmesh_override
Partitions the mesh into n subdomains.
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.
static bool sort_y(const std::pair< Point, Elem * > &lhs, const std::pair< Point, Elem * > &rhs)
Helper function which sorts by the centroid&#39;s y-coordinate in the internal std::sort call...
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
static bool sort_radial(const std::pair< Point, Elem * > &lhs, const std::pair< Point, Elem * > &rhs)
Helper function which sorts by the centroid&#39;s distance from the origin in the internal std::sort call...
static bool sort_z(const std::pair< Point, Elem * > &lhs, const std::pair< Point, Elem * > &rhs)
Helper function which sorts by the centroid&#39;s z-coordinate in the internal std::sort call...
Partitions the Mesh based on the locations of element centroids.
CentroidSortMethod sort_method() const
Getter for the current sorting method.
static bool sort_x(const std::pair< Point, Elem * > &lhs, const std::pair< Point, Elem * > &rhs)
Helper function which sorts by the centroid&#39;s x-coordinate in the internal std::sort call...
void set_sort_method(const CentroidSortMethod sm)
Setter for the current sorting method.
CentroidSortMethod _sort_method
Flag indicating the type of sort method we are using.
virtual UniquePtr< Partitioner > clone() const libmesh_override
CentroidPartitioner(const CentroidSortMethod sm=X)
Constructor.
virtual void partition_range(MeshBase &mesh, MeshBase::element_iterator it, MeshBase::element_iterator end, const unsigned int n) libmesh_override
Called by the SubdomainPartitioner to partition elements in the range (it, end).
void compute_centroids(MeshBase::element_iterator it, MeshBase::element_iterator end)
Computes a list of element centroids for the mesh.