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 209 of file mixed_dim_mesh_test.C.

Member Function Documentation

void MixedDimensionMeshTest::build_mesh ( )
protectedinherited

Definition at line 51 of file mixed_dim_mesh_test.C.

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.

52  {
54 
55  // (0,1) (1,1)
56  // x---------------x
57  // | |
58  // | |
59  // | |
60  // | |
61  // | |
62  // x---------------x
63  // (0,0) (1,0)
64  // | |
65  // | |
66  // | |
67  // | |
68  // x---------------x
69  // (0,-1) (1,-1)
70 
72 
73  _mesh->add_point( Point(0.0,-1.0), 4 );
74  _mesh->add_point( Point(1.0,-1.0), 5 );
75  _mesh->add_point( Point(1.0, 0.0), 1 );
76  _mesh->add_point( Point(1.0, 1.0), 2 );
77  _mesh->add_point( Point(0.0, 1.0), 3 );
78  _mesh->add_point( Point(0.0, 0.0), 0 );
79 
80  {
81  Elem* elem_top = _mesh->add_elem( new Quad4 );
82  elem_top->set_node(0) = _mesh->node_ptr(0);
83  elem_top->set_node(1) = _mesh->node_ptr(1);
84  elem_top->set_node(2) = _mesh->node_ptr(2);
85  elem_top->set_node(3) = _mesh->node_ptr(3);
86 
87  Elem* elem_bottom = _mesh->add_elem( new Quad4 );
88  elem_bottom->set_node(0) = _mesh->node_ptr(4);
89  elem_bottom->set_node(1) = _mesh->node_ptr(5);
90  elem_bottom->set_node(2) = _mesh->node_ptr(1);
91  elem_bottom->set_node(3) = _mesh->node_ptr(0);
92 
93  Elem* edge = _mesh->add_elem( new Edge2 );
94  edge->set_node(0) = _mesh->node_ptr(0);
95  edge->set_node(1) = _mesh->node_ptr(1);
96 
97  // 2D elements will have subdomain id 0, this one will have 1
98  edge->subdomain_id() = 1;
99  }
100 
101  // libMesh will renumber, but we numbered according to its scheme
102  // anyway. We do this because when we call uniformly_refine subsequently,
103  // it's going use skip_renumber=false.
104  _mesh->prepare_for_use(false /*skip_renumber*/);
105  }
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) libmesh_override
functions for adding /deleting nodes elements.
virtual const Node * node_ptr(const dof_id_type i) const libmesh_override
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
virtual Node *& set_node(const unsigned int i)
Definition: elem.h:1941
The QUAD4 is an element in 2D composed of 4 nodes.
Definition: face_quad4.h:49
virtual Elem * add_elem(Elem *e) libmesh_override
Add elem e to the end of the element array.
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:28
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
void prepare_for_use(const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
Prepare a newly created (or read) mesh for use.
Definition: mesh_base.C:174
subdomain_id_type subdomain_id() const
Definition: elem.h:1951
void set_mesh_dimension(unsigned char d)
Resets the logical dimension of the mesh.
Definition: mesh_base.h:199
The Edge2 is an element in 1D composed of 2 nodes.
Definition: edge_edge2.h:43
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
MixedDimensionMeshTest::CPPUNIT_TEST ( testPointLocatorTree  )
inherited
MixedDimensionRefinedMeshTest::CPPUNIT_TEST ( testMesh  )
MixedDimensionRefinedMeshTest::CPPUNIT_TEST ( testDofOrdering  )
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.

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.

MixedDimensionRefinedMeshTest::CPPUNIT_TEST_SUITE_END ( )
void MixedDimensionRefinedMeshTest::setUp ( )

Definition at line 227 of file mixed_dim_mesh_test.C.

References libMesh::MeshRefinement::uniformly_refine().

228  {
229  // 3-------10------2
230  // | | |
231  // | 5 | 6 |
232  // 8-------7-------9
233  // | | |
234  // | 3 | 4 |
235  // 0-------6-------1
236  // | | |
237  // | 9 | 10 |
238  // 13------12-------14
239  // | | |
240  // | 7 | 8 |
241  // 4-------11------5
242  this->build_mesh();
243 
244 #ifdef LIBMESH_ENABLE_AMR
245  MeshRefinement(*_mesh).uniformly_refine(1);
246 #endif
247  }
This is the MeshRefinement class.
void uniformly_refine(unsigned int n=1)
Uniformly refines the mesh n times.
void MixedDimensionMeshTest::tearDown ( )
inherited

Definition at line 113 of file mixed_dim_mesh_test.C.

114  {
115  delete _mesh;
116  }
void MixedDimensionRefinedMeshTest::testDofOrdering ( )

Definition at line 301 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().

302  {
303 #ifdef LIBMESH_ENABLE_AMR
304  EquationSystems es(*_mesh);
305  es.add_system<LinearImplicitSystem>("TestDofSystem");
306  es.get_system("TestDofSystem").add_variable("u",FIRST);
307  es.init();
308 
309  DofMap& dof_map = es.get_system("TestDofSystem").get_dof_map();
310 
311  std::vector<dof_id_type> top_quad3_dof_indices, top_quad4_dof_indices;
312  std::vector<dof_id_type> bottom_quad9_dof_indices, bottom_quad10_dof_indices;
313  std::vector<dof_id_type> edge11_dof_indices, edge12_dof_indices;
314 
315  dof_map.dof_indices( _mesh->elem_ptr(3), top_quad3_dof_indices );
316  dof_map.dof_indices( _mesh->elem_ptr(4), top_quad4_dof_indices );
317  dof_map.dof_indices( _mesh->elem_ptr(9), bottom_quad9_dof_indices );
318  dof_map.dof_indices( _mesh->elem_ptr(10), bottom_quad10_dof_indices );
319  dof_map.dof_indices( _mesh->elem_ptr(11), edge11_dof_indices );
320  dof_map.dof_indices( _mesh->elem_ptr(12), edge12_dof_indices );
321 
322  // EDGE2,id=11 should have same dofs as of bottom of QUAD4, id=3
323  CPPUNIT_ASSERT_EQUAL( edge11_dof_indices[0], top_quad3_dof_indices[0] );
324  CPPUNIT_ASSERT_EQUAL( edge11_dof_indices[1], top_quad3_dof_indices[1] );
325 
326  // EDGE2,id=12 should have same dofs of bottom of QUAD4, id=4
327  CPPUNIT_ASSERT_EQUAL( edge12_dof_indices[0], top_quad4_dof_indices[0] );
328  CPPUNIT_ASSERT_EQUAL( edge12_dof_indices[1], top_quad4_dof_indices[1] );
329 
330  // EDGE2,id=11 should have same dofs of top of QUAD4, id=9
331  CPPUNIT_ASSERT_EQUAL( edge11_dof_indices[0], bottom_quad9_dof_indices[3] );
332  CPPUNIT_ASSERT_EQUAL( edge11_dof_indices[1], bottom_quad9_dof_indices[2] );
333 
334  // EDGE2,id=12 should have same dofs of top of QUAD4, id=10
335  CPPUNIT_ASSERT_EQUAL( edge12_dof_indices[0], bottom_quad10_dof_indices[3] );
336  CPPUNIT_ASSERT_EQUAL( edge12_dof_indices[1], bottom_quad10_dof_indices[2] );
337 
338  //EDGE2 elements should have same shared dof number
339  CPPUNIT_ASSERT_EQUAL( edge11_dof_indices[1], edge12_dof_indices[0] );
340 #endif
341  }
virtual const Elem * elem_ptr(const dof_id_type i) const libmesh_override
This is the EquationSystems class.
This class provides a specific system class.
unsigned int add_variable(const std::string &var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=libmesh_nullptr)
Adds the variable var to the list of variables for this system.
Definition: system.C:1101
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:167
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:1917
void MixedDimensionRefinedMeshTest::testMesh ( )

Definition at line 249 of file mixed_dim_mesh_test.C.

250  {
251 #ifdef LIBMESH_ENABLE_AMR
252  // We should have 13 total and 10 active elements.
253  CPPUNIT_ASSERT_EQUAL( (dof_id_type)13, _mesh->n_elem() );
254  CPPUNIT_ASSERT_EQUAL( (dof_id_type)10, _mesh->n_active_elem() );
255 
256  // We should have 15 nodes
257  CPPUNIT_ASSERT_EQUAL( (dof_id_type)15, _mesh->n_nodes() );
258 
259  // EDGE2,id=11 should have same nodes of bottom of QUAD4, id=3
260  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(11).node_id(0),
261  _mesh->elem_ref(3).node_id(0) );
262  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(11).node_id(1),
263  _mesh->elem_ref(3).node_id(1) );
264 
265  // EDGE2,id=12 should have same nodes of bottom of QUAD4, id=4
266  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(12).node_id(0),
267  _mesh->elem_ref(4).node_id(0) );
268  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(12).node_id(1),
269  _mesh->elem_ref(4).node_id(1) );
270 
271  // EDGE2,id=11 should have same nodes of top of QUAD4, id=9
272  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(11).node_id(0),
273  _mesh->elem_ref(9).node_id(3) );
274  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(11).node_id(1),
275  _mesh->elem_ref(9).node_id(2) );
276 
277  // EDGE2,id=12 should have same nodes of top of QUAD4, id=10
278  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(12).node_id(0),
279  _mesh->elem_ref(10).node_id(3) );
280  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(12).node_id(1),
281  _mesh->elem_ref(10).node_id(2) );
282 
283  // Shared node between the EDGE2 elements should have the same global id
284  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(11).node_id(1),
285  _mesh->elem_ref(12).node_id(0) );
286 
287  // EDGE2 child elements should have the correct parent
288  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(11).parent(),
289  _mesh->elem_ptr(2) );
290  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(12).parent(),
291  _mesh->elem_ptr(2) );
292 
293  // EDGE2 child elements should have the correct interior_parent
294  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(11).interior_parent(),
295  _mesh->elem_ptr(3) );
296  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(12).interior_parent(),
297  _mesh->elem_ptr(4) );
298 #endif
299  }
virtual const Elem * elem_ptr(const dof_id_type i) const libmesh_override
const Elem * parent() const
Definition: elem.h:2346
const Elem * interior_parent() const
Definition: elem.C:951
virtual dof_id_type n_elem() const libmesh_override
virtual const Elem & elem_ref(const dof_id_type i) const
Definition: mesh_base.h:490
virtual dof_id_type n_nodes() const libmesh_override
virtual dof_id_type n_active_elem() const libmesh_override
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:1831
uint8_t dof_id_type
Definition: id_types.h:64
void MixedDimensionMeshTest::testPointLocatorTree ( )
inherited

Definition at line 177 of file mixed_dim_mesh_test.C.

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

178  {
180 
181  Point top_point(0.5, 0.5);
182  const Elem* top_elem = (*locator)(top_point);
183  CPPUNIT_ASSERT(top_elem);
184 
185  // We should have gotten back the top quad
186  CPPUNIT_ASSERT_EQUAL( (dof_id_type)0, top_elem->id() );
187 
188  Point bottom_point(0.5, -0.5);
189  const Elem* bottom_elem = (*locator)(bottom_point);
190  CPPUNIT_ASSERT(bottom_elem);
191 
192  // We should have gotten back the bottom quad
193  CPPUNIT_ASSERT_EQUAL( (dof_id_type)1, bottom_elem->id() );
194 
195  // Test getting back the edge
196  {
197  std::set<subdomain_id_type> subdomain_id; subdomain_id.insert(1);
198  Point interface_point( 0.5, 0.0 );
199  const Elem* interface_elem = (*locator)(interface_point, &subdomain_id);
200  CPPUNIT_ASSERT(interface_elem);
201 
202  // We should have gotten back the overlapping edge element
203  CPPUNIT_ASSERT_EQUAL( (dof_id_type)2, interface_elem->id() );
204  }
205  }
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
dof_id_type id() const
Definition: dof_object.h:632
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
UniquePtr< PointLocatorBase > sub_point_locator() const
Definition: mesh_base.C:534
uint8_t dof_id_type
Definition: id_types.h:64

Member Data Documentation

ReplicatedMesh* MixedDimensionMeshTest::_mesh
protectedinherited

Definition at line 49 of file mixed_dim_mesh_test.C.


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