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

Public Member Functions

 CPPUNIT_TEST_SUITE (SlitMeshRefinedMeshTest)
 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_SUITE_END ()
 
void setUp ()
 
void testMesh ()
 
 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...
 
void tearDown ()
 

Protected Member Functions

void build_mesh ()
 

Protected Attributes

Mesh_mesh
 

Detailed Description

Definition at line 203 of file slit_mesh_test.C.

Member Function Documentation

void SlitMeshTest::build_mesh ( )
protectedinherited

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.
SlitMeshRefinedMeshTest::CPPUNIT_TEST ( testMesh  )
SlitMeshTest::CPPUNIT_TEST_SUITE ( SlitMeshTest  )
inherited

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.

SlitMeshRefinedMeshTest::CPPUNIT_TEST_SUITE ( SlitMeshRefinedMeshTest  )

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.

SlitMeshRefinedMeshTest::CPPUNIT_TEST_SUITE_END ( )
void SlitMeshRefinedMeshTest::setUp ( )

Definition at line 220 of file slit_mesh_test.C.

References libMesh::MeshRefinement::uniformly_refine().

221  {
222  this->build_mesh();
223 
224 #ifdef LIBMESH_ENABLE_AMR
225  MeshRefinement(*_mesh).uniformly_refine(1);
226 #endif
227  }
This is the MeshRefinement class.
void build_mesh()
void uniformly_refine(unsigned int n=1)
Uniformly refines the mesh n times.
void SlitMeshTest::tearDown ( )
inherited

Definition at line 171 of file slit_mesh_test.C.

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

Definition at line 229 of file slit_mesh_test.C.

230  {
231 #ifdef LIBMESH_ENABLE_AMR
232  // We should have 20 total and 16 active elements.
233  CPPUNIT_ASSERT_EQUAL( (dof_id_type)20, _mesh->n_elem() );
234  CPPUNIT_ASSERT_EQUAL( (dof_id_type)16, _mesh->n_active_elem() );
235 
236  // We should have 28 nodes, not 25 or 26
237  CPPUNIT_ASSERT_EQUAL( (dof_id_type)28, _mesh->n_nodes() );
238 #endif
239  }
virtual dof_id_type n_elem() const libmesh_override
virtual dof_id_type n_active_elem() const libmesh_override
virtual dof_id_type n_nodes() const libmesh_override
uint8_t dof_id_type
Definition: id_types.h:64

Member Data Documentation

Mesh* SlitMeshTest::_mesh
protectedinherited

Definition at line 89 of file slit_mesh_test.C.


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