libMesh
Public Member Functions | List of all members
DofMapTest Class Reference
Inheritance diagram for DofMapTest:
[legend]

Public Member Functions

 CPPUNIT_TEST_SUITE (DofMapTest)
 
 CPPUNIT_TEST (testDofOwnerOnEdge3)
 
 CPPUNIT_TEST (testDofOwnerOnQuad9)
 
 CPPUNIT_TEST (testDofOwnerOnTri6)
 
 CPPUNIT_TEST (testDofOwnerOnHex27)
 
 CPPUNIT_TEST (testConstraintLoopDetection)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void testDofOwner (const ElemType elem_type)
 
void testDofOwnerOnEdge3 ()
 
void testDofOwnerOnQuad9 ()
 
void testDofOwnerOnTri6 ()
 
void testDofOwnerOnHex27 ()
 
void testConstraintLoopDetection ()
 

Detailed Description

Definition at line 46 of file dof_map_test.C.

Member Function Documentation

◆ CPPUNIT_TEST() [1/5]

DofMapTest::CPPUNIT_TEST ( testConstraintLoopDetection  )

◆ CPPUNIT_TEST() [2/5]

DofMapTest::CPPUNIT_TEST ( testDofOwnerOnEdge3  )

◆ CPPUNIT_TEST() [3/5]

DofMapTest::CPPUNIT_TEST ( testDofOwnerOnHex27  )

◆ CPPUNIT_TEST() [4/5]

DofMapTest::CPPUNIT_TEST ( testDofOwnerOnQuad9  )

◆ CPPUNIT_TEST() [5/5]

DofMapTest::CPPUNIT_TEST ( testDofOwnerOnTri6  )

◆ CPPUNIT_TEST_SUITE()

DofMapTest::CPPUNIT_TEST_SUITE ( DofMapTest  )

◆ CPPUNIT_TEST_SUITE_END()

DofMapTest::CPPUNIT_TEST_SUITE_END ( )

◆ setUp()

void DofMapTest::setUp ( )
inline

Definition at line 68 of file dof_map_test.C.

69  {}

◆ tearDown()

void DofMapTest::tearDown ( )
inline

Definition at line 71 of file dof_map_test.C.

72  {}

◆ testConstraintLoopDetection()

void DofMapTest::testConstraintLoopDetection ( )
inline

Definition at line 117 of file dof_map_test.C.

118  {
120 
121  EquationSystems es(mesh);
122  System & sys = es.add_system<System> ("SimpleSystem");
123  sys.add_variable("u", FIRST);
124 
125  MyConstraint my_constraint(sys);
126  sys.attach_constraint_object(my_constraint);
127 
128  MeshTools::Generation::build_square (mesh,4,4,-1., 1.,-1., 1., QUAD4);
129 
130  // Tell the dof_map to check for constraint loops
131  DofMap & dof_map = sys.get_dof_map();
132  dof_map.set_error_on_constraint_loop(true);
133 
134  CPPUNIT_ASSERT_THROW_MESSAGE("Constraint loop not detected", es.init(), libMesh::LogicError);
135  }

References libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::System::attach_constraint_object(), libMesh::MeshTools::Generation::build_square(), libMesh::FIRST, libMesh::System::get_dof_map(), libMesh::EquationSystems::init(), mesh, libMesh::QUAD4, libMesh::DofMap::set_error_on_constraint_loop(), and TestCommWorld.

◆ testDofOwner()

void DofMapTest::testDofOwner ( const ElemType  elem_type)
inline

Definition at line 74 of file dof_map_test.C.

75  {
77 
79  System &sys = es.add_system<System> ("SimpleSystem");
80  sys.add_variable("u", THIRD, HIERARCHIC);
81 
82  const unsigned int n_elem_per_side = 3;
83  const std::unique_ptr<Elem> test_elem = Elem::build(elem_type);
84  const unsigned int ymax = test_elem->dim() > 1;
85  const unsigned int zmax = test_elem->dim() > 2;
86  const unsigned int ny = ymax * n_elem_per_side;
87  const unsigned int nz = zmax * n_elem_per_side;
88 
90  n_elem_per_side,
91  ny,
92  nz,
93  0., 1.,
94  0., ymax,
95  0., zmax,
96  elem_type);
97 
98  es.init();
99 
100  DofMap & dof_map = sys.get_dof_map();
101  for (dof_id_type id = 0; id != dof_map.n_dofs(); ++id)
102  {
103  const processor_id_type pid = dof_map.dof_owner(id);
104  CPPUNIT_ASSERT(dof_map.first_dof(pid) <= id);
105  CPPUNIT_ASSERT(id < dof_map.end_dof(pid));
106  }
107  }

References libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::Elem::build(), libMesh::MeshTools::Generation::build_cube(), libMesh::DofMap::dof_owner(), libMesh::DofMap::end_dof(), libMesh::DofMap::first_dof(), libMesh::System::get_dof_map(), libMesh::HIERARCHIC, libMesh::EquationSystems::init(), mesh, libMesh::DofMap::n_dofs(), TestCommWorld, and libMesh::THIRD.

◆ testDofOwnerOnEdge3()

void DofMapTest::testDofOwnerOnEdge3 ( )
inline

Definition at line 111 of file dof_map_test.C.

111 { testDofOwner(EDGE3); }

References libMesh::EDGE3.

◆ testDofOwnerOnHex27()

void DofMapTest::testDofOwnerOnHex27 ( )
inline

Definition at line 114 of file dof_map_test.C.

114 { testDofOwner(HEX27); }

References libMesh::HEX27.

◆ testDofOwnerOnQuad9()

void DofMapTest::testDofOwnerOnQuad9 ( )
inline

Definition at line 112 of file dof_map_test.C.

112 { testDofOwner(QUAD9); }

References libMesh::QUAD9.

◆ testDofOwnerOnTri6()

void DofMapTest::testDofOwnerOnTri6 ( )
inline

Definition at line 113 of file dof_map_test.C.

113 { testDofOwner(TRI6); }

References libMesh::TRI6.


The documentation for this class was generated from the following file:
libMesh::System
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:100
libMesh::dof_id_type
uint8_t dof_id_type
Definition: id_types.h:67
libMesh::Mesh
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
libMesh::DofMap::n_dofs
dof_id_type n_dofs() const
Definition: dof_map.h:625
libMesh::MeshTools::Generation::build_cube
void build_cube(UnstructuredMesh &mesh, const unsigned int nx=0, const unsigned int ny=0, const unsigned int nz=0, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const Real zmin=0., const Real zmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
Builds a (elements) cube.
Definition: mesh_generation.C:298
libMesh::LogicError
A class to represent the internal "this should never happen" errors, to be thrown by "libmesh_error()...
Definition: libmesh_exceptions.h:38
MyConstraint
Definition: dof_map_test.C:15
mesh
MeshBase & mesh
Definition: mesh_communication.C:1257
libMesh::DofMap::first_dof
dof_id_type first_dof(const processor_id_type proc) const
Definition: dof_map.h:650
libMesh::System::attach_constraint_object
void attach_constraint_object(Constraint &constrain)
Register a user object for imposing constraints.
Definition: system.C:1809
libMesh::DofMap::set_error_on_constraint_loop
void set_error_on_constraint_loop(bool error_on_constraint_loop)
Definition: dof_map.C:250
libMesh::MeshTools::Generation::build_square
void build_square(UnstructuredMesh &mesh, const unsigned int nx, const unsigned int ny, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 2D meshes.
Definition: mesh_generation.C:1501
libMesh::HEX27
Definition: enum_elem_type.h:49
libMesh::System::add_variable
unsigned int add_variable(const std::string &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.
Definition: system.C:1069
libMesh::QUAD4
Definition: enum_elem_type.h:41
TestCommWorld
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:111
libMesh::processor_id_type
uint8_t processor_id_type
Definition: id_types.h:104
libMesh::HIERARCHIC
Definition: enum_fe_family.h:37
libMesh::EquationSystems
This is the EquationSystems class.
Definition: equation_systems.h:74
libMesh::TRI6
Definition: enum_elem_type.h:40
libMesh::DofMap
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:176
libMesh::EDGE3
Definition: enum_elem_type.h:36
libMesh::THIRD
Definition: enum_order.h:44
libMesh::QUAD9
Definition: enum_elem_type.h:43
libMesh::System::get_dof_map
const DofMap & get_dof_map() const
Definition: system.h:2099
DofMapTest::testDofOwner
void testDofOwner(const ElemType elem_type)
Definition: dof_map_test.C:74
libMesh::DofMap::dof_owner
processor_id_type dof_owner(const dof_id_type dof) const
Definition: dof_map.h:701
libMesh::FIRST
Definition: enum_order.h:42
libMesh::DofMap::end_dof
dof_id_type end_dof(const processor_id_type proc) const
Definition: dof_map.h:692