22 #include "libmesh/centroid_partitioner.h" 23 #include "libmesh/elem.h" 24 #include "libmesh/enum_partitioner_type.h" 25 #include "libmesh/int_range.h" 54 libmesh_assert_greater (n, 0);
57 if (!
mesh.is_serial())
58 libmesh_not_implemented();
108 libmesh_error_msg(
"Unknown sort method: " << this->
sort_method());
112 const dof_id_type target_size = cast_int<dof_id_type>
122 std::min (cast_int<processor_id_type>(i / target_size),
123 cast_int<processor_id_type>(n-1));
130 const unsigned int n)
133 mesh.elements_begin(),
145 for (
auto & elem :
as_range(it, end))
153 const std::pair<Point, Elem *> & rhs)
155 return (lhs.first(0) < rhs.first(0));
162 const std::pair<Point, Elem *> & rhs)
164 return (lhs.first(1) < rhs.first(1));
172 const std::pair<Point, Elem *> & rhs)
174 return (lhs.first(2) < rhs.first(2));
180 const std::pair<Point, Elem *> & rhs)
182 return (lhs.first.norm() < rhs.first.norm());
The definition of the element_iterator struct.
virtual void _do_partition(MeshBase &mesh, const unsigned int n) override
Partitions the mesh into n subdomains.
bool 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...
This is the base class from which all geometric element types are derived.
The libMesh namespace provides an interface to certain functionality in the library.
This is the MeshBase class.
virtual PartitionerType type() const override
virtual void partition_range(MeshBase &mesh, MeshBase::element_iterator it, MeshBase::element_iterator end, const unsigned int n) override
Called by the SubdomainPartitioner to partition elements in the range (it, end).
PartitionerType
Defines an enum for mesh partitioner types.
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.
static bool sort_radial(const std::pair< Point, Elem *> &lhs, const std::pair< Point, Elem *> &rhs)
Helper function which sorts by the vertex averages's distance from the origin in the internal std::so...
std::vector< std::pair< Point, Elem * > > _elem_vertex_avgs
Vector which holds pairs of vertex averages and their respective element pointers.
static bool sort_y(const std::pair< Point, Elem *> &lhs, const std::pair< Point, Elem *> &rhs)
Helper function which sorts by the vertex average's y-coordinate in the internal std::sort call...
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 vertex average's x-coordinate in the internal std::sort call...
void compute_vertex_avgs(MeshBase::element_iterator it, MeshBase::element_iterator end)
Computes a list of element vertex averages for the mesh.
static bool sort_z(const std::pair< Point, Elem *> &lhs, const std::pair< Point, Elem *> &rhs)
Helper function which sorts by the vertex average's z-coordinate in the internal std::sort call...
processor_id_type processor_id() const
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...