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;
54 CPPUNIT_TEST( testDofOwnerOnEdge3 );
56 CPPUNIT_TEST( testDofOwnerOnQuad9 );
57 CPPUNIT_TEST( testDofOwnerOnTri6 );
60 CPPUNIT_TEST( testDofOwnerOnHex27 );
63 #if defined(LIBMESH_ENABLE_EXCEPTIONS) 64 CPPUNIT_TEST( testBadElemFECombo );
67 #if defined(LIBMESH_ENABLE_CONSTRAINTS) && defined(LIBMESH_ENABLE_EXCEPTIONS) && LIBMESH_DIM > 1 68 CPPUNIT_TEST( testConstraintLoopDetection );
71 CPPUNIT_TEST( testArrayDofIndices );
73 CPPUNIT_TEST_SUITE_END();
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)
228 testArrayDofIndicesWithType({i,
LAGRANGE});
230 testArrayDofIndicesWithType({i,
MONOMIAL});
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
ElemType
Defines an enum for geometric element types.
dof_id_type end_dof(const processor_id_type proc) const
This is the EquationSystems class.
void testDofOwnerOnQuad9()
processor_id_type dof_owner(const dof_id_type dof) const
void testConstraintLoopDetection()
libMesh::Parallel::Communicator * TestCommWorld
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.
const Parallel::Communicator & comm() const
dof_id_type n_dofs(const unsigned int vn) const
The libMesh namespace provides an interface to certain functionality in the library.
void set_error_on_constraint_loop(bool error_on_constraint_loop)
dof_id_type n_local_elem() const
void testDofOwnerOnEdge3()
void attach_constraint_object(Constraint &constrain)
Register a user object for imposing constraints.
void testDofOwner(const ElemType elem_type)
This class handles the numbering of degrees of freedom on a mesh.
uint8_t processor_id_type
void testDofOwnerOnTri6()
void min(const T &r, T &o, Request &req) 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 ...
Manages consistently variables, degrees of freedom, and coefficient vectors.
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
void testArrayDofIndices()
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.
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
void max(const T &r, T &o, Request &req) const
A class to represent the internal "this should never happen" errors, to be thrown by "libmesh_error()...
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.
void constrain()
Constraint function.
Abstract base class to be used for system constraints.
void testBadElemFECombo()
virtual void init()
Initialize all the systems.
dof_id_type first_dof(const processor_id_type proc) const
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.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
void testDofOwnerOnHex27()
const DofMap & get_dof_map() const
CPPUNIT_TEST_SUITE_REGISTRATION(DofMapTest)
void testArrayDofIndicesWithType(const FEType &fe_type)
MyConstraint(System &sys)