libMesh
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
BoundaryMesh0DTest Class Reference
Inheritance diagram for BoundaryMesh0DTest:
[legend]

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (BoundaryMesh0DTest)
 The goal of this test is to ensure that a 1D mesh generates boundary meshes correctly.
 
 CPPUNIT_TEST (testMesh)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void testMesh ()
 
void testBoundarySerialization ()
 
void sanityCheck ()
 

Protected Member Functions

void build_mesh ()
 
void sync_and_test_meshes ()
 

Protected Attributes

std::unique_ptr< UnstructuredMesh_mesh
 
std::unique_ptr< UnstructuredMesh_replicated_boundary_mesh
 
std::unique_ptr< UnstructuredMesh_distributed_boundary_mesh
 
std::unique_ptr< UnstructuredMesh_interior_node_mesh
 

Detailed Description

Definition at line 83 of file boundary_mesh.C.

Member Function Documentation

◆ build_mesh()

void BoundaryMesh0DTest::build_mesh ( )
inlineprotected

Definition at line 104 of file boundary_mesh.C.

105 {
106 _mesh = std::make_unique<Mesh>(*TestCommWorld);
107 _replicated_boundary_mesh = std::make_unique<ReplicatedMesh>(*TestCommWorld);
108 _distributed_boundary_mesh = std::make_unique<DistributedMesh>(*TestCommWorld);
109 _interior_node_mesh = std::make_unique<Mesh>(*TestCommWorld);
110
112 0.2, 0.8, EDGE3);
113
114 static constexpr boundary_id_type bid_int = 2;
115
116 // Add an interior boundary too
117 BoundaryInfo & bi = _mesh->get_boundary_info();
118 for (auto & elem : _mesh->active_element_ptr_range())
119 {
120 const Point c = elem->vertex_average();
121 if (c(0) > 0.6)
122 bi.add_side(elem, 0, bid_int);
123 }
124
125 // We'll need to skip most repartitioning with DistributedMesh for
126 // now; otherwise the boundary meshes' interior parents might get
127 // shuffled off to different processors.
128 if (!_mesh->is_serial())
129 {
130 _mesh->skip_noncritical_partitioning(true);
131 _replicated_boundary_mesh->skip_noncritical_partitioning(true);
132 _distributed_boundary_mesh->skip_noncritical_partitioning(true);
133 }
134 }
std::unique_ptr< UnstructuredMesh > _replicated_boundary_mesh
std::unique_ptr< UnstructuredMesh > _mesh
std::unique_ptr< UnstructuredMesh > _distributed_boundary_mesh
std::unique_ptr< UnstructuredMesh > _interior_node_mesh
The BoundaryInfo class contains information relevant to boundary conditions including storing faces,...
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
Add side side of element number elem with boundary id id to the boundary information data structure.
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
void build_line(UnstructuredMesh &mesh, const unsigned int nx, const Real xmin=0., const Real xmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 1D meshes.
int8_t boundary_id_type
Definition id_types.h:51

References _distributed_boundary_mesh, _interior_node_mesh, _mesh, _replicated_boundary_mesh, libMesh::BoundaryInfo::add_side(), libMesh::MeshTools::Generation::build_line(), libMesh::EDGE3, and TestCommWorld.

Referenced by setUp().

◆ CPPUNIT_TEST()

BoundaryMesh0DTest::CPPUNIT_TEST ( testMesh  )

◆ CPPUNIT_TEST_SUITE_END()

BoundaryMesh0DTest::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

BoundaryMesh0DTest::LIBMESH_CPPUNIT_TEST_SUITE ( BoundaryMesh0DTest  )

The goal of this test is to ensure that a 1D mesh generates boundary meshes correctly.

◆ sanityCheck()

void BoundaryMesh0DTest::sanityCheck ( )
inline

Definition at line 230 of file boundary_mesh.C.

231 {
232 sanity_check_mesh(*_mesh, NODEELEM, EDGE3, true);
233
234 sanity_check_mesh(*_replicated_boundary_mesh, NODEELEM, EDGE3, false);
235 sanity_check_mesh(*_distributed_boundary_mesh, NODEELEM, EDGE3, false);
236 sanity_check_mesh(*_interior_node_mesh, NODEELEM, EDGE3, false);
237 }

References _distributed_boundary_mesh, _interior_node_mesh, _mesh, _replicated_boundary_mesh, libMesh::EDGE3, and libMesh::NODEELEM.

Referenced by testBoundarySerialization(), and testMesh().

◆ setUp()

void BoundaryMesh0DTest::setUp ( )
inline

Definition at line 167 of file boundary_mesh.C.

168 {
169#if LIBMESH_DIM > 1
170 this->build_mesh();
171 this->sync_and_test_meshes();
172#endif
173 }

References build_mesh(), and sync_and_test_meshes().

◆ sync_and_test_meshes()

void BoundaryMesh0DTest::sync_and_test_meshes ( )
inlineprotected

Definition at line 136 of file boundary_mesh.C.

137 {
138 // Get the border of the line
139 const std::set<boundary_id_type> exterior_boundaries {0, 1};
140
141 _mesh->get_boundary_info().sync(exterior_boundaries,
143 check_parent_side_index_tag(*_replicated_boundary_mesh);
144
145 _mesh->get_boundary_info().sync(exterior_boundaries,
147 check_parent_side_index_tag(*_distributed_boundary_mesh);
148
149 const std::set<boundary_id_type> interior_boundaries {2};
150 _mesh->get_boundary_info().sync(interior_boundaries,
152 check_parent_side_index_tag(*_interior_node_mesh);
153
154 // Add the right side of the square to the square; this should
155 // make it a mixed dimension mesh. We skip storing the parent
156 // side ids (which is the default) since they are not needed
157 // in this particular test.
158 std::set<boundary_id_type> right_id;
159 right_id.insert(1);
160
161 _mesh->get_boundary_info().add_elements
162 (right_id, *_mesh, /*store_parent_side_ids=*/false);
163 _mesh->prepare_for_use();
164 }
static const boundary_id_type right_id

References _distributed_boundary_mesh, _interior_node_mesh, _mesh, _replicated_boundary_mesh, and right_id.

Referenced by setUp().

◆ testBoundarySerialization()

void BoundaryMesh0DTest::testBoundarySerialization ( )
inline

Definition at line 209 of file boundary_mesh.C.

210 {
211 LOG_UNIT_TEST;
212
213 MeshSerializer internal_serializer(*_distributed_boundary_mesh);
214
215 // There'd better be 2 elements on the exterior boundary
216 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(2),
217 _replicated_boundary_mesh->n_elem());
218 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(2),
220
221 // There'd better be 2 nodes on the exterior boundary
222 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(2),
223 _replicated_boundary_mesh->n_nodes());
224 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(2),
225 _distributed_boundary_mesh->n_nodes());
226
227 this->sanityCheck();
228 }
Temporarily serialize a DistributedMesh for non-distributed-mesh capable code paths.
uint8_t dof_id_type
Definition id_types.h:67

References _distributed_boundary_mesh, _replicated_boundary_mesh, and sanityCheck().

◆ testMesh()

void BoundaryMesh0DTest::testMesh ( )
inline

Definition at line 175 of file boundary_mesh.C.

176 {
177 LOG_UNIT_TEST;
178
179 // There'd better be 3 + 1 elements in the interior plus right
180 // boundary
181 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(4),
182 _mesh->n_elem());
183
184 // There'd better be 7 nodes in the interior
185 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(7),
186 _mesh->n_nodes());
187
188 // There'd better be 2 elements on the exterior boundary
189 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(2),
190 _replicated_boundary_mesh->n_elem());
191 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(2),
193
194 // There'd better be 2 nodes on the exterior boundary
195 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(2),
196 _replicated_boundary_mesh->n_nodes());
197 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(2),
198 _distributed_boundary_mesh->n_nodes());
199
200 // There'd better be 1 nodeelem on the interior boundary
201 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(1),
202 _interior_node_mesh->n_elem());
203 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(1),
204 _interior_node_mesh->n_nodes());
205
206 this->sanityCheck();
207 }

References _distributed_boundary_mesh, _interior_node_mesh, _mesh, _replicated_boundary_mesh, and sanityCheck().

Member Data Documentation

◆ _distributed_boundary_mesh

std::unique_ptr<UnstructuredMesh> BoundaryMesh0DTest::_distributed_boundary_mesh
protected

◆ _interior_node_mesh

std::unique_ptr<UnstructuredMesh> BoundaryMesh0DTest::_interior_node_mesh
protected

Definition at line 102 of file boundary_mesh.C.

Referenced by build_mesh(), sanityCheck(), sync_and_test_meshes(), and testMesh().

◆ _mesh

std::unique_ptr<UnstructuredMesh> BoundaryMesh0DTest::_mesh
protected

Definition at line 99 of file boundary_mesh.C.

Referenced by build_mesh(), sanityCheck(), sync_and_test_meshes(), and testMesh().

◆ _replicated_boundary_mesh

std::unique_ptr<UnstructuredMesh> BoundaryMesh0DTest::_replicated_boundary_mesh
protected

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