2#include <libmesh/dof_map.h>
3#include <libmesh/elem.h>
4#include <libmesh/equation_systems.h>
5#include <libmesh/linear_implicit_system.h>
6#include <libmesh/non_manifold_coupling.h>
7#include <libmesh/partitioner.h>
8#include <libmesh/replicated_mesh.h>
9#include <libmesh/sides_to_elem_map.h>
39 virtual std::unique_ptr<Partitioner>
clone ()
const override
41 return std::make_unique<NonManifoldTestPartitioner>(*
this);
50 const unsigned int n)
override
62 libmesh_assert_greater (n, 0);
66 auto success = [&]() ->
bool
68 for (
const auto & elem :
mesh.element_ptr_range())
69 for (
auto s : elem->side_index_range())
71 const auto [side_neighbors_begin, side_neighbors_end] =
74 if (std::distance(side_neighbors_begin, side_neighbors_end) == 5)
76 for (
auto [e, it] = std::make_tuple(0u, side_neighbors_begin);
77 it != side_neighbors_end; ++e, ++it)
108 libmesh_error_msg_if(!success,
"Did not find expected non-manifold edge.");
121 std::unique_ptr<EquationSystems>
_es;
129 _mesh->read(mesh_filename);
133 _mesh->partitioner() = std::make_unique<NonManifoldTestPartitioner>();
135 _mesh->prepare_for_use();
144 _es = std::make_unique<EquationSystems>(*
_mesh);
158 auto ghosting_functor = std::make_shared<NonManifoldGhostingFunctor>(*
_mesh);
175#if defined(LIBMESH_HAVE_EXODUS_API)
207 System & system =
_es->get_system(
"SimpleSystem");
209 const std::vector<dof_id_type> & send_list = dof_map.
get_send_list();
217 auto side_neighbors_found = [&]() ->
bool
219 for (
const auto & elem :
_mesh->element_ptr_range())
220 for (
auto s : elem->side_index_range())
223 if (std::distance(range.first, range.second) == 5)
237 CPPUNIT_ASSERT(side_neighbors_found);
242 for (
auto it_e = beg; it_e != end; ++it_e)
243 for (
auto it_f = std::next(it_e); it_f != end; ++it_f)
246 auto check_dofs = [&](
const Elem * elem)
248 std::vector<dof_id_type> dof_indices;
251 for (
const auto & dof : dof_indices)
254 bool is_in_send_list = (
Utility::binary_find(send_list.begin(), send_list.end(), dof) != send_list.end());
255 CPPUNIT_ASSERT(is_local || is_in_send_list);
259 const Elem * elem_e = *it_e;
260 const Elem * elem_f = *it_f;
void read_mesh(const std::string &mesh_filename)
std::unique_ptr< MeshBase > _mesh
std::unique_ptr< EquationSystems > _es
CPPUNIT_TEST(verifySendListEntries1)
void verifySendListEntries2()
void verify_send_list_entries_helper(const std::string &mesh_filename)
void verifySendListEntries3()
LIBMESH_CPPUNIT_TEST_SUITE(NonManifoldGhostingFunctorTest)
void verifySendListEntries0()
CPPUNIT_TEST(verifySendListEntries0)
void verifySendListEntries1()
CPPUNIT_TEST(verifySendListEntries3)
CPPUNIT_TEST(verifySendListEntries2)
virtual ~NonManifoldTestPartitioner()=default
NonManifoldTestPartitioner()=default
virtual std::unique_ptr< Partitioner > clone() const override
NonManifoldTestPartitioner(NonManifoldTestPartitioner &&)=default
NonManifoldTestPartitioner & operator=(const NonManifoldTestPartitioner &)=default
virtual void _do_partition(MeshBase &mesh, const unsigned int n) override
Partition the MeshBase onto n processors.
NonManifoldTestPartitioner(const NonManifoldTestPartitioner &)=default
dof_id_type first_dof(const processor_id_type proc) const
dof_id_type end_dof(const processor_id_type proc) const
This class handles the numbering of degrees of freedom on a mesh.
const std::vector< dof_id_type > & get_send_list() const
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
void add_coupling_functor(GhostingFunctor &coupling_functor, bool to_mesh=true)
Adds a functor which can specify coupling requirements for creation of sparse matrices.
processor_id_type processor_id() const
This is the base class from which all geometric element types are derived.
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
This is the MeshBase class.
virtual const Elem * elem_ptr(const dof_id_type i) const =0
The Partitioner class provides a uniform interface for partitioning algorithms.
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...
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.
const DofMap & get_dof_map() const
Communicator * TestCommWorld
ForwardIterator binary_find(ForwardIterator first, ForwardIterator last, const T &value)
The STL provides std::binary_search() which returns true or false depending on whether the searched-f...
The libMesh namespace provides an interface to certain functionality in the library.
CPPUNIT_TEST_SUITE_REGISTRATION(NonManifoldGhostingFunctorTest)