1#include <libmesh/equation_systems.h>
2#include <libmesh/mesh.h>
3#include <libmesh/mesh_generation.h>
4#include <libmesh/elem.h>
5#include <libmesh/dof_map.h>
17#ifdef LIBMESH_ENABLE_CONSTRAINTS
36 constraint_row[1] = 1.0;
42 constraint_row[0] = 1.0;
63#if defined(LIBMESH_ENABLE_EXCEPTIONS)
67#if defined(LIBMESH_ENABLE_CONSTRAINTS) && defined(LIBMESH_ENABLE_EXCEPTIONS) && LIBMESH_DIM > 1
92 const unsigned int n_elem_per_side = 3;
93 const std::unique_ptr<Elem> test_elem =
Elem::build(elem_type);
94 const unsigned int ymax = test_elem->dim() > 1;
95 const unsigned int zmax = test_elem->dim() > 2;
96 const unsigned int ny = ymax * n_elem_per_side;
97 const unsigned int nz = zmax * n_elem_per_side;
114 CPPUNIT_ASSERT(dof_map.
first_dof(pid) <=
id);
115 CPPUNIT_ASSERT(
id < dof_map.
end_dof(pid));
126#if defined(LIBMESH_ENABLE_EXCEPTIONS)
151 bool threw_desired_exception =
false;
156 std::regex msg_regex(
"only supports FEInterface::max_order");
157 CPPUNIT_ASSERT(std::regex_search(e.what(), msg_regex));
158 threw_desired_exception =
true;
161 CPPUNIT_ASSERT_MESSAGE(
"Unexpected exception type thrown",
false);
168 CPPUNIT_ASSERT(threw_desired_exception);
172#if defined(LIBMESH_ENABLE_CONSTRAINTS) && defined(LIBMESH_ENABLE_EXCEPTIONS)
203 auto & dof_map = sys.get_dof_map();
207 std::vector<dof_id_type> array_dofs, work_dofs, dofs;
208 dof_map.array_dof_indices(elem, array_dofs, last_var);
210 std::sort(array_dofs.begin(), array_dofs.end());
211 auto it = std::unique(array_dofs.begin(), array_dofs.end());
212 array_dofs.erase(it, array_dofs.end());
213 CPPUNIT_ASSERT_EQUAL(
static_cast<std::size_t
>(dof_map.n_dofs()), array_dofs.size());
214 dof_map.dof_indices(elem, work_dofs, last_var);
216 dof_map.dof_indices(elem, work_dofs, last_var - 1);
217 dofs.insert(dofs.end(), work_dofs.begin(), work_dofs.end());
218 std::sort(dofs.begin(), dofs.end());
219 CPPUNIT_ASSERT(array_dofs == dofs);
226 for (
int i = 1; i < 3; ++i)
CPPUNIT_TEST(testDofOwnerOnQuad9)
void testConstraintLoopDetection()
CPPUNIT_TEST(testBadElemFECombo)
CPPUNIT_TEST(testConstraintLoopDetection)
CPPUNIT_TEST(testDofOwnerOnEdge3)
LIBMESH_CPPUNIT_TEST_SUITE(DofMapTest)
CPPUNIT_TEST(testDofOwnerOnHex27)
void testBadElemFECombo()
void testDofOwnerOnTri6()
void testArrayDofIndicesWithType(const FEType &fe_type)
CPPUNIT_TEST(testDofOwnerOnTri6)
void testDofOwner(const ElemType elem_type)
CPPUNIT_TEST(testArrayDofIndices)
void testArrayDofIndices()
void testDofOwnerOnEdge3()
void testDofOwnerOnHex27()
void testDofOwnerOnQuad9()
MyConstraint(System &sys)
void max(const T &r, T &o, Request &req) const
void min(const T &r, T &o, Request &req) const
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.
processor_id_type dof_owner(const dof_id_type dof) const
dof_id_type n_dofs(const unsigned int vn) const
void add_constraint_row(const dof_id_type dof_number, const DofConstraintRow &constraint_row, const Number constraint_rhs, const bool forbid_constraint_overwrite)
Adds a copy of the user-defined row to the constraint matrix, using an inhomogeneous right-hand-side ...
void set_error_on_constraint_loop(bool error_on_constraint_loop)
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
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.
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
A class to represent the internal "this should never happen" errors, to be thrown by "libmesh_error()...
dof_id_type n_local_elem() const
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
const Parallel::Communicator & comm() const
Abstract base class to be used for system constraints.
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.
unsigned int add_variable_array(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds variables vars to the list of variables for this system.
void attach_constraint_object(Constraint &constrain)
Register a user object for imposing constraints.
const DofMap & get_dof_map() const
Communicator * TestCommWorld
CPPUNIT_TEST_SUITE_REGISTRATION(DofMapTest)
The libMesh namespace provides an interface to certain functionality in the library.
ElemType
Defines an enum for geometric element types.
std::map< dof_id_type, Real, std::less< dof_id_type >, Threads::scalable_allocator< std::pair< const dof_id_type, Real > > > DofConstraintRow
A row of the Dof constraint matrix.
uint8_t processor_id_type