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);
39 unsigned int n_interior_elems = 0;
42 bool internal_elem =
true;
43 for (
const Elem *
const neighbor : elem->neighbor_ptr_range())
46 internal_elem =
false;
54 n_interior_elems += internal_elem;
55 elem->processor_id() = internal_elem;
59 CPPUNIT_ASSERT_EQUAL(n_interior_elems, 1u);
88 auto & nodal_dof_map = nodal_system.get_dof_map();
89 nodal_dof_map.remove_default_ghosting();
92 auto & elem_dof_map = elem_system.get_dof_map();
93 elem_dof_map.remove_default_ghosting();
98 auto n_evaluable = std::distance(
mesh.evaluable_elements_begin(nodal_dof_map),
99 mesh.evaluable_elements_end(nodal_dof_map));
100 typedef decltype(n_evaluable) comp_type;
104 CPPUNIT_ASSERT_EQUAL(n_evaluable, comp_type(9));
108 CPPUNIT_ASSERT_EQUAL(n_evaluable, comp_type(1));
112 CPPUNIT_ASSERT_EQUAL(n_evaluable, comp_type(0));
118 auto n_evaluable = std::distance(
mesh.evaluable_elements_begin(elem_dof_map),
119 mesh.evaluable_elements_end(elem_dof_map));
120 typedef decltype(n_evaluable) comp_type;
124 CPPUNIT_ASSERT_EQUAL(n_evaluable, comp_type(
TestCommWorld->size() == 1 ? 9 : 8));
128 CPPUNIT_ASSERT_EQUAL(n_evaluable, comp_type(1));
132 CPPUNIT_ASSERT_EQUAL(n_evaluable, comp_type(0));
138 std::vector<const DofMap *> dof_maps = {&nodal_dof_map, &elem_dof_map};
139 auto n_evaluable = std::distance(
mesh.multi_evaluable_elements_begin(dof_maps),
140 mesh.multi_evaluable_elements_end(dof_maps));
141 typedef decltype(n_evaluable) comp_type;
145 CPPUNIT_ASSERT_EQUAL(n_evaluable, comp_type(
TestCommWorld->size() == 1 ? 9 : 8));
149 CPPUNIT_ASSERT_EQUAL(n_evaluable, comp_type(1));
153 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 bool partitions_from_scratch() const override
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.