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

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (MixedDimensionRefinedMeshTest)
 The goal of this test is the same as the previous, but now we do a uniform refinement and make sure the result mesh is consistent. More...
 
 CPPUNIT_TEST (testMesh)
 
 CPPUNIT_TEST (testDofOrdering)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void testMesh ()
 
void testDofOrdering ()
 
 LIBMESH_CPPUNIT_TEST_SUITE (MixedDimensionMeshTest)
 The goal of this test is to ensure that a 2D mesh with 1D elements overlapping on the edge is consistent. More...
 
 CPPUNIT_TEST (testPointLocatorTree)
 
void tearDown ()
 
void testPointLocatorTree ()
 

Protected Member Functions

void build_mesh ()
 

Protected Attributes

std::unique_ptr< ReplicatedMesh_mesh
 

Detailed Description

Definition at line 202 of file mixed_dim_mesh_test.C.

Member Function Documentation

◆ build_mesh()

void MixedDimensionMeshTest::build_mesh ( )
inlineprotectedinherited

Definition at line 41 of file mixed_dim_mesh_test.C.

References libMesh::Elem::build(), libMesh::EDGE2, libMesh::QUAD4, libMesh::Elem::set_node(), and libMesh::Elem::subdomain_id().

42  {
43  _mesh = std::make_unique<ReplicatedMesh>(*TestCommWorld);
44 
45  // (0,1) (1,1)
46  // x---------------x
47  // | |
48  // | |
49  // | |
50  // | |
51  // | |
52  // x---------------x
53  // (0,0) (1,0)
54  // | |
55  // | |
56  // | |
57  // | |
58  // x---------------x
59  // (0,-1) (1,-1)
60 
61  _mesh->set_mesh_dimension(2);
62 
63  _mesh->add_point( Point(0.0,-1.0), 4 );
64  _mesh->add_point( Point(1.0,-1.0), 5 );
65  _mesh->add_point( Point(1.0, 0.0), 1 );
66  _mesh->add_point( Point(1.0, 1.0), 2 );
67  _mesh->add_point( Point(0.0, 1.0), 3 );
68  _mesh->add_point( Point(0.0, 0.0), 0 );
69 
70  {
71  Elem * elem_top = _mesh->add_elem(Elem::build(QUAD4));
72  elem_top->set_node(0) = _mesh->node_ptr(0);
73  elem_top->set_node(1) = _mesh->node_ptr(1);
74  elem_top->set_node(2) = _mesh->node_ptr(2);
75  elem_top->set_node(3) = _mesh->node_ptr(3);
76 
77  Elem * elem_bottom = _mesh->add_elem(Elem::build(QUAD4));
78  elem_bottom->set_node(0) = _mesh->node_ptr(4);
79  elem_bottom->set_node(1) = _mesh->node_ptr(5);
80  elem_bottom->set_node(2) = _mesh->node_ptr(1);
81  elem_bottom->set_node(3) = _mesh->node_ptr(0);
82 
83  Elem * edge = _mesh->add_elem(Elem::build(EDGE2));
84  edge->set_node(0) = _mesh->node_ptr(0);
85  edge->set_node(1) = _mesh->node_ptr(1);
86 
87  // 2D elements will have subdomain id 0, this one will have 1
88  edge->subdomain_id() = 1;
89  }
90 
91  _mesh->allow_renumbering(true);
92  _mesh->prepare_for_use();
93  }
virtual Node *& set_node(const unsigned int i)
Definition: elem.h:2381
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
subdomain_id_type subdomain_id() const
Definition: elem.h:2391
std::unique_ptr< ReplicatedMesh > _mesh
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39

◆ CPPUNIT_TEST() [1/3]

MixedDimensionMeshTest::CPPUNIT_TEST ( testPointLocatorTree  )
inherited

◆ CPPUNIT_TEST() [2/3]

MixedDimensionRefinedMeshTest::CPPUNIT_TEST ( testMesh  )

◆ CPPUNIT_TEST() [3/3]

MixedDimensionRefinedMeshTest::CPPUNIT_TEST ( testDofOrdering  )

◆ CPPUNIT_TEST_SUITE_END()

MixedDimensionRefinedMeshTest::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE() [1/2]

MixedDimensionMeshTest::LIBMESH_CPPUNIT_TEST_SUITE ( MixedDimensionMeshTest  )
inherited

The goal of this test is to ensure that a 2D mesh with 1D elements overlapping on the edge is consistent.

That is, they share the same global node numbers and the same dof numbers for a variable.

◆ LIBMESH_CPPUNIT_TEST_SUITE() [2/2]

MixedDimensionRefinedMeshTest::LIBMESH_CPPUNIT_TEST_SUITE ( MixedDimensionRefinedMeshTest  )

The goal of this test is the same as the previous, but now we do a uniform refinement and make sure the result mesh is consistent.

i.e. the new node shared between the 1D elements is the same as the node shared on the underlying quads, and so on.

◆ setUp()

void MixedDimensionRefinedMeshTest::setUp ( )
inline

Definition at line 224 of file mixed_dim_mesh_test.C.

References libMesh::MeshRefinement::uniformly_refine().

225  {
226  // 3-------10------2
227  // | | |
228  // | 5 | 6 |
229  // 8-------7-------9
230  // | | |
231  // | 3 | 4 |
232  // 0-------6-------1
233  // | | |
234  // | 9 | 10 |
235  // 13------12-------14
236  // | | |
237  // | 7 | 8 |
238  // 4-------11------5
239 #if LIBMESH_DIM > 1
240  this->build_mesh();
241 
242 #ifdef LIBMESH_ENABLE_AMR
243  MeshRefinement(*_mesh).uniformly_refine(1);
244 #endif
245 #endif
246  }
Implements (adaptive) mesh refinement algorithms for a MeshBase.
void uniformly_refine(unsigned int n=1)
Uniformly refines the mesh n times.

◆ tearDown()

void MixedDimensionMeshTest::tearDown ( )
inlineinherited

Definition at line 103 of file mixed_dim_mesh_test.C.

103 {}

◆ testDofOrdering()

void MixedDimensionRefinedMeshTest::testDofOrdering ( )
inline

Definition at line 302 of file mixed_dim_mesh_test.C.

References libMesh::EquationSystems::add_system(), libMesh::DofMap::dof_indices(), libMesh::FIRST, libMesh::EquationSystems::get_system(), and libMesh::EquationSystems::init().

303  {
304 #ifdef LIBMESH_ENABLE_AMR
305  LOG_UNIT_TEST;
306 
307  EquationSystems es(*_mesh);
308  es.add_system<LinearImplicitSystem>("TestDofSystem");
309  es.get_system("TestDofSystem").add_variable("u",FIRST);
310  es.init();
311 
312  DofMap& dof_map = es.get_system("TestDofSystem").get_dof_map();
313 
314  std::vector<dof_id_type> top_quad3_dof_indices, top_quad4_dof_indices;
315  std::vector<dof_id_type> bottom_quad9_dof_indices, bottom_quad10_dof_indices;
316  std::vector<dof_id_type> edge11_dof_indices, edge12_dof_indices;
317 
318  dof_map.dof_indices( _mesh->elem_ptr(3), top_quad3_dof_indices );
319  dof_map.dof_indices( _mesh->elem_ptr(4), top_quad4_dof_indices );
320  dof_map.dof_indices( _mesh->elem_ptr(9), bottom_quad9_dof_indices );
321  dof_map.dof_indices( _mesh->elem_ptr(10), bottom_quad10_dof_indices );
322  dof_map.dof_indices( _mesh->elem_ptr(11), edge11_dof_indices );
323  dof_map.dof_indices( _mesh->elem_ptr(12), edge12_dof_indices );
324 
325  // EDGE2,id=11 should have same dofs as of bottom of QUAD4, id=3
326  CPPUNIT_ASSERT_EQUAL( edge11_dof_indices[0], top_quad3_dof_indices[0] );
327  CPPUNIT_ASSERT_EQUAL( edge11_dof_indices[1], top_quad3_dof_indices[1] );
328 
329  // EDGE2,id=12 should have same dofs of bottom of QUAD4, id=4
330  CPPUNIT_ASSERT_EQUAL( edge12_dof_indices[0], top_quad4_dof_indices[0] );
331  CPPUNIT_ASSERT_EQUAL( edge12_dof_indices[1], top_quad4_dof_indices[1] );
332 
333  // EDGE2,id=11 should have same dofs of top of QUAD4, id=9
334  CPPUNIT_ASSERT_EQUAL( edge11_dof_indices[0], bottom_quad9_dof_indices[3] );
335  CPPUNIT_ASSERT_EQUAL( edge11_dof_indices[1], bottom_quad9_dof_indices[2] );
336 
337  // EDGE2,id=12 should have same dofs of top of QUAD4, id=10
338  CPPUNIT_ASSERT_EQUAL( edge12_dof_indices[0], bottom_quad10_dof_indices[3] );
339  CPPUNIT_ASSERT_EQUAL( edge12_dof_indices[1], bottom_quad10_dof_indices[2] );
340 
341  //EDGE2 elements should have same shared dof number
342  CPPUNIT_ASSERT_EQUAL( edge11_dof_indices[1], edge12_dof_indices[0] );
343 #endif
344  }
This is the EquationSystems class.
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Fills the vector di with the global degree of freedom indices for the element.
Definition: dof_map.C:1992
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:169
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.
Definition: system.C:1305
std::unique_ptr< ReplicatedMesh > _mesh

◆ testMesh()

void MixedDimensionRefinedMeshTest::testMesh ( )
inline

Definition at line 248 of file mixed_dim_mesh_test.C.

249  {
250 #ifdef LIBMESH_ENABLE_AMR
251  LOG_UNIT_TEST;
252 
253  // We should have 13 total and 10 active elements.
254  CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(13), _mesh->n_elem());
255  CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(10), _mesh->n_active_elem());
256 
257  // We should have 15 nodes
258  CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(15), _mesh->n_nodes());
259 
260  // EDGE2,id=11 should have same nodes of bottom of QUAD4, id=3
261  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(11).node_id(0),
262  _mesh->elem_ref(3).node_id(0) );
263  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(11).node_id(1),
264  _mesh->elem_ref(3).node_id(1) );
265 
266  // EDGE2,id=12 should have same nodes of bottom of QUAD4, id=4
267  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(12).node_id(0),
268  _mesh->elem_ref(4).node_id(0) );
269  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(12).node_id(1),
270  _mesh->elem_ref(4).node_id(1) );
271 
272  // EDGE2,id=11 should have same nodes of top of QUAD4, id=9
273  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(11).node_id(0),
274  _mesh->elem_ref(9).node_id(3) );
275  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(11).node_id(1),
276  _mesh->elem_ref(9).node_id(2) );
277 
278  // EDGE2,id=12 should have same nodes of top of QUAD4, id=10
279  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(12).node_id(0),
280  _mesh->elem_ref(10).node_id(3) );
281  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(12).node_id(1),
282  _mesh->elem_ref(10).node_id(2) );
283 
284  // Shared node between the EDGE2 elements should have the same global id
285  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(11).node_id(1),
286  _mesh->elem_ref(12).node_id(0) );
287 
288  // EDGE2 child elements should have the correct parent
289  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(11).parent(),
290  _mesh->elem_ptr(2) );
291  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(12).parent(),
292  _mesh->elem_ptr(2) );
293 
294  // EDGE2 child elements should have the correct interior_parent
295  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(11).interior_parent(),
296  _mesh->elem_ptr(3) );
297  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(12).interior_parent(),
298  _mesh->elem_ptr(4) );
299 #endif
300  }
std::unique_ptr< ReplicatedMesh > _mesh

◆ testPointLocatorTree()

void MixedDimensionMeshTest::testPointLocatorTree ( )
inlineinherited

Definition at line 168 of file mixed_dim_mesh_test.C.

References libMesh::DofObject::id().

169  {
170  LOG_UNIT_TEST;
171 
172  std::unique_ptr<PointLocatorBase> locator = _mesh->sub_point_locator();
173 
174  Point top_point(0.5, 0.5);
175  const Elem* top_elem = (*locator)(top_point);
176  CPPUNIT_ASSERT(top_elem);
177 
178  // We should have gotten back the top quad
179  CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(0), top_elem->id());
180 
181  Point bottom_point(0.5, -0.5);
182  const Elem* bottom_elem = (*locator)(bottom_point);
183  CPPUNIT_ASSERT(bottom_elem);
184 
185  // We should have gotten back the bottom quad
186  CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(1), bottom_elem->id());
187 
188  // Test getting back the edge
189  {
190  std::set<subdomain_id_type> subdomain_id; subdomain_id.insert(1);
191  Point interface_point( 0.5, 0.0 );
192  const Elem* interface_elem = (*locator)(interface_point, &subdomain_id);
193  CPPUNIT_ASSERT(interface_elem);
194 
195  // We should have gotten back the overlapping edge element
196  CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(2), interface_elem->id());
197  }
198  }
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
dof_id_type id() const
Definition: dof_object.h:823
std::unique_ptr< ReplicatedMesh > _mesh
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39

Member Data Documentation

◆ _mesh

std::unique_ptr<ReplicatedMesh> MixedDimensionMeshTest::_mesh
protectedinherited

Definition at line 39 of file mixed_dim_mesh_test.C.


The documentation for this class was generated from the following file: