centroid_partitioner.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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 #include "libmesh/auto_ptr.h" // libmesh_make_unique
26 
27 // C++ includes
28 #include <utility> // pair
29 #include <vector>
30 
31 namespace libMesh
32 {
33 
34 // Forward declarations
35 class Elem;
36 
49 {
50 public:
51 
58  Y,
59  Z,
62 
67  explicit
69 
74  CentroidPartitioner (const CentroidPartitioner &) = default;
78  virtual ~CentroidPartitioner() = default;
79 
83  virtual std::unique_ptr<Partitioner> clone () const override
84  {
85  return libmesh_make_unique<CentroidPartitioner>(*this);
86  }
87 
92 
97 
101  virtual void partition_range(MeshBase & mesh,
104  const unsigned int n) override;
105 
106 protected:
107 
111  virtual void _do_partition (MeshBase & mesh,
112  const unsigned int n) override;
113 
114 private:
115 
121 
126  static bool sort_x (const std::pair<Point, Elem *> & lhs,
127  const std::pair<Point, Elem *> & rhs);
128 
133  static bool sort_y (const std::pair<Point, Elem *> & lhs,
134  const std::pair<Point, Elem *> & rhs);
135 
140  static bool sort_z (const std::pair<Point, Elem *> & lhs,
141  const std::pair<Point, Elem *> & rhs);
142 
147  static bool sort_radial (const std::pair<Point, Elem *> & lhs,
148  const std::pair<Point, Elem *> & rhs);
149 
154 
159  std::vector<std::pair<Point, Elem *>> _elem_centroids;
160 };
161 
162 } // namespace libMesh
163 
164 #endif // LIBMESH_CENTROID_PARTITIONER_H
virtual void _do_partition(MeshBase &mesh, const unsigned int n) override
std::vector< std::pair< Point, Elem * > > _elem_centroids
MeshBase & mesh
IterBase * end
Base class for Mesh.
Definition: mesh_base.h:77
Base class for all concrete Partitioner instantiations.
Definition: partitioner.h:50
CentroidPartitioner & operator=(const CentroidPartitioner &)=default
virtual void partition_range(MeshBase &mesh, MeshBase::element_iterator it, MeshBase::element_iterator end, const unsigned int n) override
virtual ~CentroidPartitioner()=default
static bool sort_radial(const std::pair< Point, Elem *> &lhs, const std::pair< Point, Elem *> &rhs)
static bool sort_y(const std::pair< Point, Elem *> &lhs, const std::pair< Point, Elem *> &rhs)
void set_sort_method(const CentroidSortMethod sm)
CentroidSortMethod sort_method() const
static bool sort_x(const std::pair< Point, Elem *> &lhs, const std::pair< Point, Elem *> &rhs)
virtual std::unique_ptr< Partitioner > clone() const override
static bool sort_z(const std::pair< Point, Elem *> &lhs, const std::pair< Point, Elem *> &rhs)
CentroidPartitioner(const CentroidSortMethod sm=X)
void compute_centroids(MeshBase::element_iterator it, MeshBase::element_iterator end)