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

Public Member Functions

 CPPUNIT_TEST_SUITE (SlitMeshTest)
 The goal of this test is to ensure that a 2D mesh with nodes overlapping on opposite sides of an internal, "slit" edge is usable. More...
 
 CPPUNIT_TEST (testMesh)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void testMesh ()
 

Protected Member Functions

void build_mesh ()
 

Protected Attributes

Mesh_mesh
 

Detailed Description

Definition at line 75 of file slit_mesh_test.C.

Member Function Documentation

void SlitMeshTest::build_mesh ( )
protected

Definition at line 91 of file slit_mesh_test.C.

References libMesh::DistributedMesh::add_elem(), libMesh::DistributedMesh::add_point(), libMesh::MeshBase::allow_renumbering(), libMesh::DistributedMesh::node_ptr(), libMesh::MeshBase::prepare_for_use(), libMesh::DofObject::set_id(), libMesh::MeshBase::set_mesh_dimension(), libMesh::Elem::set_node(), and TestCommWorld.

92  {
93  _mesh = new Mesh(*TestCommWorld);
94 
95  // (0,1) (1,1) (2,1)
96  // x---------------x---------------x
97  // | | |
98  // | | |
99  // | | |
100  // | | |
101  // | | |
102  // x---------------x---------------x
103  // (0,0) (1,0) (2,0)
104  // | | |
105  // | | |
106  // | | |
107  // | | |
108  // x---------------x---------------x
109  // (0,-1) (1,-1) (2,-1)
110 
112 
113  _mesh->add_point( Point(0.0, 0.0), 0 );
114  _mesh->add_point( Point(1.0, 0.0), 1 );
115  _mesh->add_point( Point(1.0, 1.0), 2 );
116  _mesh->add_point( Point(0.0, 1.0), 3 );
117  _mesh->add_point( Point(0.0,-1.0), 4 );
118  _mesh->add_point( Point(1.0,-1.0), 5 );
119  _mesh->add_point( Point(1.0, 0.0), 6 );
120  _mesh->add_point( Point(2.0, 0.0), 7 );
121  _mesh->add_point( Point(2.0, 1.0), 8 );
122  _mesh->add_point( Point(2.0,-1.0), 9 );
123 
124  {
125  Elem* elem_top_left = new Quad4;
126  elem_top_left->set_node(0) = _mesh->node_ptr(0);
127  elem_top_left->set_node(1) = _mesh->node_ptr(1);
128  elem_top_left->set_node(2) = _mesh->node_ptr(2);
129  elem_top_left->set_node(3) = _mesh->node_ptr(3);
130  elem_top_left->set_id() = 0;
131  _mesh->add_elem(elem_top_left);
132 
133  Elem* elem_bottom_left = new Quad4;
134  elem_bottom_left->set_node(0) = _mesh->node_ptr(4);
135  elem_bottom_left->set_node(1) = _mesh->node_ptr(5);
136  elem_bottom_left->set_node(2) = _mesh->node_ptr(6);
137  elem_bottom_left->set_node(3) = _mesh->node_ptr(0);
138  elem_bottom_left->set_id() = 1;
139  _mesh->add_elem(elem_bottom_left);
140 
141  Elem* elem_top_right = new Quad4;
142  elem_top_right->set_node(0) = _mesh->node_ptr(1);
143  elem_top_right->set_node(1) = _mesh->node_ptr(7);
144  elem_top_right->set_node(2) = _mesh->node_ptr(8);
145  elem_top_right->set_node(3) = _mesh->node_ptr(2);
146  elem_top_right->set_id() = 2;
147  _mesh->add_elem(elem_top_right);
148 
149  Elem* elem_bottom_right = new Quad4;
150  elem_bottom_right->set_node(0) = _mesh->node_ptr(5);
151  elem_bottom_right->set_node(1) = _mesh->node_ptr(9);
152  elem_bottom_right->set_node(2) = _mesh->node_ptr(7);
153  elem_bottom_right->set_node(3) = _mesh->node_ptr(6);
154  elem_bottom_right->set_id() = 3;
155  _mesh->add_elem(elem_bottom_right);
156  }
157 
158  // libMesh shouldn't renumber, or our based-on-initial-id
159  // assertions later may fail.
160  _mesh->allow_renumbering(false);
161 
163  }
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
void allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use...
Definition: mesh_base.h:749
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
dof_id_type & set_id()
Definition: dof_object.h:641
virtual const Node * node_ptr(const dof_id_type i) const libmesh_override
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
void set_mesh_dimension(unsigned char d)
Resets the logical dimension of the mesh.
Definition: mesh_base.h:199
virtual Elem * add_elem(Elem *e) libmesh_override
Add elem e to the end of the element array.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
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.
SlitMeshTest::CPPUNIT_TEST ( testMesh  )
SlitMeshTest::CPPUNIT_TEST_SUITE ( SlitMeshTest  )

The goal of this test is to ensure that a 2D mesh with nodes overlapping on opposite sides of an internal, "slit" edge is usable.

SlitMeshTest::CPPUNIT_TEST_SUITE_END ( )
void SlitMeshTest::setUp ( )

Definition at line 166 of file slit_mesh_test.C.

167  {
168  this->build_mesh();
169  }
void build_mesh()
void SlitMeshTest::tearDown ( )

Definition at line 171 of file slit_mesh_test.C.

172  {
173  delete _mesh;
174  }
void SlitMeshTest::testMesh ( )

Definition at line 176 of file slit_mesh_test.C.

References libMesh::MeshBase::elem_ref(), libMesh::DistributedMesh::n_elem(), libMesh::DistributedMesh::n_nodes(), libMesh::Elem::node_id(), and libMesh::DistributedMesh::query_elem_ptr().

177  {
178  // There'd better be 4 elements
179  CPPUNIT_ASSERT_EQUAL( (dof_id_type)4, _mesh->n_elem() );
180 
181  // There'd better still be a full 10 nodes
182  CPPUNIT_ASSERT_EQUAL( (dof_id_type)10, _mesh->n_nodes() );
183 
184  /* The middle nodes should still be distinct between the top and
185  * bottom elements */
186  if (_mesh->query_elem_ptr(0) && _mesh->query_elem_ptr(1))
187  CPPUNIT_ASSERT( _mesh->elem_ref(0).node_id(1) != _mesh->elem_ref(1).node_id(2) );
188  if (_mesh->query_elem_ptr(2) && _mesh->query_elem_ptr(3))
189  CPPUNIT_ASSERT( _mesh->elem_ref(2).node_id(0) != _mesh->elem_ref(3).node_id(3) );
190 
191  /* The middle nodes should still be shared between left and right
192  * elements on top and bottom */
193  if (_mesh->query_elem_ptr(0) && _mesh->query_elem_ptr(2))
194  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(0).node_id(1),
195  _mesh->elem_ref(2).node_id(0) );
196  if (_mesh->query_elem_ptr(1) && _mesh->query_elem_ptr(3))
197  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(1).node_id(2),
198  _mesh->elem_ref(3).node_id(3) );
199  }
virtual dof_id_type n_elem() const libmesh_override
virtual const Elem * query_elem_ptr(const dof_id_type i) const libmesh_override
virtual dof_id_type n_nodes() const libmesh_override
virtual const Elem & elem_ref(const dof_id_type i) const
Definition: mesh_base.h:490
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:1831
uint8_t dof_id_type
Definition: id_types.h:64

Member Data Documentation

Mesh* SlitMeshTest::_mesh
protected

Definition at line 89 of file slit_mesh_test.C.


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