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

Public Member Functions

 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 ()
 
 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

ReplicatedMesh_mesh
 

Detailed Description

Definition at line 201 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.

42  {
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 
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( new 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( new 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( new 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  // libMesh will renumber, but we numbered according to its scheme
92  // anyway. We do this because when we call uniformly_refine subsequently,
93  // it's going use skip_renumber=false.
94  _mesh->prepare_for_use(false /*skip_renumber*/);
95  }

References libMesh::ReplicatedMesh::add_elem(), libMesh::ReplicatedMesh::add_point(), libMesh::ReplicatedMesh::node_ptr(), libMesh::MeshBase::prepare_for_use(), libMesh::MeshBase::set_mesh_dimension(), libMesh::Elem::set_node(), libMesh::Elem::subdomain_id(), and TestCommWorld.

◆ CPPUNIT_TEST() [1/3]

MixedDimensionRefinedMeshTest::CPPUNIT_TEST ( testDofOrdering  )

◆ CPPUNIT_TEST() [2/3]

MixedDimensionRefinedMeshTest::CPPUNIT_TEST ( testMesh  )

◆ CPPUNIT_TEST() [3/3]

MixedDimensionMeshTest::CPPUNIT_TEST ( testPointLocatorTree  )
inherited

◆ CPPUNIT_TEST_SUITE() [1/2]

MixedDimensionMeshTest::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.

◆ CPPUNIT_TEST_SUITE() [2/2]

MixedDimensionRefinedMeshTest::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.

◆ CPPUNIT_TEST_SUITE_END()

MixedDimensionRefinedMeshTest::CPPUNIT_TEST_SUITE_END ( )

◆ setUp()

void MixedDimensionRefinedMeshTest::setUp ( )
inline

Definition at line 223 of file mixed_dim_mesh_test.C.

224  {
225  // 3-------10------2
226  // | | |
227  // | 5 | 6 |
228  // 8-------7-------9
229  // | | |
230  // | 3 | 4 |
231  // 0-------6-------1
232  // | | |
233  // | 9 | 10 |
234  // 13------12-------14
235  // | | |
236  // | 7 | 8 |
237  // 4-------11------5
238 #if LIBMESH_DIM > 1
239  this->build_mesh();
240 
241 #ifdef LIBMESH_ENABLE_AMR
242  MeshRefinement(*_mesh).uniformly_refine(1);
243 #endif
244 #endif
245  }

References libMesh::MeshRefinement::uniformly_refine().

◆ tearDown()

void MixedDimensionMeshTest::tearDown ( )
inlineinherited

Definition at line 105 of file mixed_dim_mesh_test.C.

106  {
107  delete _mesh;
108  }

◆ testDofOrdering()

void MixedDimensionRefinedMeshTest::testDofOrdering ( )
inline

Definition at line 299 of file mixed_dim_mesh_test.C.

300  {
301 #ifdef LIBMESH_ENABLE_AMR
302  EquationSystems es(*_mesh);
303  es.add_system<LinearImplicitSystem>("TestDofSystem");
304  es.get_system("TestDofSystem").add_variable("u",FIRST);
305  es.init();
306 
307  DofMap& dof_map = es.get_system("TestDofSystem").get_dof_map();
308 
309  std::vector<dof_id_type> top_quad3_dof_indices, top_quad4_dof_indices;
310  std::vector<dof_id_type> bottom_quad9_dof_indices, bottom_quad10_dof_indices;
311  std::vector<dof_id_type> edge11_dof_indices, edge12_dof_indices;
312 
313  dof_map.dof_indices( _mesh->elem_ptr(3), top_quad3_dof_indices );
314  dof_map.dof_indices( _mesh->elem_ptr(4), top_quad4_dof_indices );
315  dof_map.dof_indices( _mesh->elem_ptr(9), bottom_quad9_dof_indices );
316  dof_map.dof_indices( _mesh->elem_ptr(10), bottom_quad10_dof_indices );
317  dof_map.dof_indices( _mesh->elem_ptr(11), edge11_dof_indices );
318  dof_map.dof_indices( _mesh->elem_ptr(12), edge12_dof_indices );
319 
320  // EDGE2,id=11 should have same dofs as of bottom of QUAD4, id=3
321  CPPUNIT_ASSERT_EQUAL( edge11_dof_indices[0], top_quad3_dof_indices[0] );
322  CPPUNIT_ASSERT_EQUAL( edge11_dof_indices[1], top_quad3_dof_indices[1] );
323 
324  // EDGE2,id=12 should have same dofs of bottom of QUAD4, id=4
325  CPPUNIT_ASSERT_EQUAL( edge12_dof_indices[0], top_quad4_dof_indices[0] );
326  CPPUNIT_ASSERT_EQUAL( edge12_dof_indices[1], top_quad4_dof_indices[1] );
327 
328  // EDGE2,id=11 should have same dofs of top of QUAD4, id=9
329  CPPUNIT_ASSERT_EQUAL( edge11_dof_indices[0], bottom_quad9_dof_indices[3] );
330  CPPUNIT_ASSERT_EQUAL( edge11_dof_indices[1], bottom_quad9_dof_indices[2] );
331 
332  // EDGE2,id=12 should have same dofs of top of QUAD4, id=10
333  CPPUNIT_ASSERT_EQUAL( edge12_dof_indices[0], bottom_quad10_dof_indices[3] );
334  CPPUNIT_ASSERT_EQUAL( edge12_dof_indices[1], bottom_quad10_dof_indices[2] );
335 
336  //EDGE2 elements should have same shared dof number
337  CPPUNIT_ASSERT_EQUAL( edge11_dof_indices[1], edge12_dof_indices[0] );
338 #endif
339  }

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

◆ testMesh()

void MixedDimensionRefinedMeshTest::testMesh ( )
inline

Definition at line 247 of file mixed_dim_mesh_test.C.

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

◆ testPointLocatorTree()

void MixedDimensionMeshTest::testPointLocatorTree ( )
inlineinherited

Definition at line 169 of file mixed_dim_mesh_test.C.

170  {
171  std::unique_ptr<PointLocatorBase> locator = _mesh->sub_point_locator();
172 
173  Point top_point(0.5, 0.5);
174  const Elem* top_elem = (*locator)(top_point);
175  CPPUNIT_ASSERT(top_elem);
176 
177  // We should have gotten back the top quad
178  CPPUNIT_ASSERT_EQUAL( (dof_id_type)0, top_elem->id() );
179 
180  Point bottom_point(0.5, -0.5);
181  const Elem* bottom_elem = (*locator)(bottom_point);
182  CPPUNIT_ASSERT(bottom_elem);
183 
184  // We should have gotten back the bottom quad
185  CPPUNIT_ASSERT_EQUAL( (dof_id_type)1, bottom_elem->id() );
186 
187  // Test getting back the edge
188  {
189  std::set<subdomain_id_type> subdomain_id; subdomain_id.insert(1);
190  Point interface_point( 0.5, 0.0 );
191  const Elem* interface_elem = (*locator)(interface_point, &subdomain_id);
192  CPPUNIT_ASSERT(interface_elem);
193 
194  // We should have gotten back the overlapping edge element
195  CPPUNIT_ASSERT_EQUAL( (dof_id_type)2, interface_elem->id() );
196  }
197  }

References libMesh::DofObject::id(), and libMesh::MeshBase::sub_point_locator().

Member Data Documentation

◆ _mesh

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:
libMesh::dof_id_type
uint8_t dof_id_type
Definition: id_types.h:67
libMesh::DofMap::dof_indices
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:1967
libMesh::ReplicatedMesh::node_ptr
virtual const Node * node_ptr(const dof_id_type i) const override
Definition: replicated_mesh.C:182
libMesh::MeshBase::elem_ref
virtual const Elem & elem_ref(const dof_id_type i) const
Definition: mesh_base.h:521
libMesh::ReplicatedMesh::add_elem
virtual Elem * add_elem(Elem *e) override
Add elem e to the end of the element array.
Definition: replicated_mesh.C:282
libMesh::ReplicatedMesh
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
Definition: replicated_mesh.h:47
libMesh::MeshRefinement
Implements (adaptive) mesh refinement algorithms for a MeshBase.
Definition: mesh_refinement.h:61
MixedDimensionMeshTest::build_mesh
void build_mesh()
Definition: mixed_dim_mesh_test.C:41
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
TestCommWorld
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:111
libMesh::Point
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
libMesh::ReplicatedMesh::n_nodes
virtual dof_id_type n_nodes() const override
Definition: replicated_mesh.h:104
libMesh::Quad4
The QUAD4 is an element in 2D composed of 4 nodes.
Definition: face_quad4.h:51
MixedDimensionMeshTest::_mesh
ReplicatedMesh * _mesh
Definition: mixed_dim_mesh_test.C:39
libMesh::EquationSystems
This is the EquationSystems class.
Definition: equation_systems.h:74
libMesh::Elem::set_node
virtual Node *& set_node(const unsigned int i)
Definition: elem.h:2059
libMesh::Elem::parent
const Elem * parent() const
Definition: elem.h:2434
libMesh::Elem::interior_parent
const Elem * interior_parent() const
Definition: elem.C:749
libMesh::MeshBase::sub_point_locator
std::unique_ptr< PointLocatorBase > sub_point_locator() const
Definition: mesh_base.C:672
libMesh::ReplicatedMesh::n_elem
virtual dof_id_type n_elem() const override
Definition: replicated_mesh.h:116
libMesh::DofMap
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:176
libMesh::Elem::subdomain_id
subdomain_id_type subdomain_id() const
Definition: elem.h:2069
libMesh::DofObject::id
dof_id_type id() const
Definition: dof_object.h:767
libMesh::ReplicatedMesh::elem_ptr
virtual const Elem * elem_ptr(const dof_id_type i) const override
Definition: replicated_mesh.C:232
libMesh::Edge2
The Edge2 is an element in 1D composed of 2 nodes.
Definition: edge_edge2.h:43
libMesh::Elem
This is the base class from which all geometric element types are derived.
Definition: elem.h:100
libMesh::Elem::node_id
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:1977
libMesh::MeshBase::prepare_for_use
void prepare_for_use(const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
Prepare a newly ecreated (or read) mesh for use.
Definition: mesh_base.C:318
libMesh::LinearImplicitSystem
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
Definition: linear_implicit_system.h:55
libMesh::MeshBase::set_mesh_dimension
void set_mesh_dimension(unsigned char d)
Resets the logical dimension of the mesh.
Definition: mesh_base.h:218
libMesh::MeshRefinement::uniformly_refine
void uniformly_refine(unsigned int n=1)
Uniformly refines the mesh n times.
Definition: mesh_refinement.C:1678
libMesh::FIRST
Definition: enum_order.h:42
libMesh::ReplicatedMesh::add_point
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id) override
functions for adding /deleting nodes elements.
Definition: replicated_mesh.C:417
libMesh::ReplicatedMesh::n_active_elem
virtual dof_id_type n_active_elem() const override
Definition: replicated_mesh.C:1424