1#include <libmesh/partitioner.h>
2#include <libmesh/mesh.h>
3#include <libmesh/mesh_generation.h>
4#include <libmesh/equation_systems.h>
5#include <libmesh/elem.h>
6#include <libmesh/system.h>
7#include <libmesh/dof_map.h>
27 std::unique_ptr<Partitioner>
clone()
const override
29 return std::make_unique<ContrivedPartitioner>(*
this);
37 unsigned int n_interior_elems = 0;
40 bool internal_elem =
true;
41 for (
const Elem *
const neighbor : elem->neighbor_ptr_range())
44 internal_elem =
false;
52 n_interior_elems += internal_elem;
53 elem->processor_id() = internal_elem;
57 CPPUNIT_ASSERT_EQUAL(n_interior_elems, 1u);
86 auto & nodal_dof_map = nodal_system.get_dof_map();
87 nodal_dof_map.remove_default_ghosting();
90 auto & elem_dof_map = elem_system.get_dof_map();
91 elem_dof_map.remove_default_ghosting();
96 auto n_evaluable = std::distance(
mesh.evaluable_elements_begin(nodal_dof_map),
97 mesh.evaluable_elements_end(nodal_dof_map));
98 typedef decltype(n_evaluable) comp_type;
102 CPPUNIT_ASSERT_EQUAL(n_evaluable, comp_type(9));
106 CPPUNIT_ASSERT_EQUAL(n_evaluable, comp_type(1));
110 CPPUNIT_ASSERT_EQUAL(n_evaluable, comp_type(0));
116 auto n_evaluable = std::distance(
mesh.evaluable_elements_begin(elem_dof_map),
117 mesh.evaluable_elements_end(elem_dof_map));
118 typedef decltype(n_evaluable) comp_type;
122 CPPUNIT_ASSERT_EQUAL(n_evaluable, comp_type(
TestCommWorld->size() == 1 ? 9 : 8));
126 CPPUNIT_ASSERT_EQUAL(n_evaluable, comp_type(1));
130 CPPUNIT_ASSERT_EQUAL(n_evaluable, comp_type(0));
136 std::vector<const DofMap *> dof_maps = {&nodal_dof_map, &elem_dof_map};
137 auto n_evaluable = std::distance(
mesh.multi_evaluable_elements_begin(dof_maps),
138 mesh.multi_evaluable_elements_end(dof_maps));
139 typedef decltype(n_evaluable) comp_type;
143 CPPUNIT_ASSERT_EQUAL(n_evaluable, comp_type(
TestCommWorld->size() == 1 ? 9 : 8));
147 CPPUNIT_ASSERT_EQUAL(n_evaluable, comp_type(1));
151 CPPUNIT_ASSERT_EQUAL(n_evaluable, comp_type(0));
void _do_partition(MeshBase &mesh, const unsigned int n) override
This is the actual partitioning method which must be overridden in derived classes.
ContrivedPartitioner & operator=(ContrivedPartitioner &&)=default
ContrivedPartitioner()=default
ContrivedPartitioner & operator=(const ContrivedPartitioner &)=default
ContrivedPartitioner(ContrivedPartitioner &&)=default
std::unique_ptr< Partitioner > clone() const override
ContrivedPartitioner(const ContrivedPartitioner &)=default
virtual ~ContrivedPartitioner()=default
LIBMESH_CPPUNIT_TEST_SUITE(MultiEvaluablePredTest)
This is the base class from which all geometric element types are derived.
This is the EquationSystems class.
virtual void init()
Initialize all the systems.
virtual System & add_system(std::string_view system_type, std::string_view name)
Add the system of type system_type named name to the systems array.
This is the MeshBase class.
virtual std::unique_ptr< Partitioner > & partitioner()
A partitioner to use at each partitioning.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
The Partitioner class provides a uniform interface for partitioning algorithms.
Manages consistently variables, degrees of freedom, and coefficient vectors.
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
Communicator * TestCommWorld
CPPUNIT_TEST_SUITE_REGISTRATION(MultiEvaluablePredTest)
The libMesh namespace provides an interface to certain functionality in the library.
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.