libMesh
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. More...
 
 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 81 of file boundary_mesh.C.

Member Function Documentation

◆ build_mesh()

void BoundaryMesh0DTest::build_mesh ( )
inlineprotected

Definition at line 102 of file boundary_mesh.C.

References libMesh::BoundaryInfo::add_side(), libMesh::MeshTools::Generation::build_line(), and libMesh::EDGE3.

103  {
104  _mesh = std::make_unique<Mesh>(*TestCommWorld);
105  _replicated_boundary_mesh = std::make_unique<ReplicatedMesh>(*TestCommWorld);
106  _distributed_boundary_mesh = std::make_unique<DistributedMesh>(*TestCommWorld);
107  _interior_node_mesh = std::make_unique<Mesh>(*TestCommWorld);
108 
110  0.2, 0.8, EDGE3);
111 
112  static constexpr boundary_id_type bid_int = 2;
113 
114  // Add an interior boundary too
115  BoundaryInfo & bi = _mesh->get_boundary_info();
116  for (auto & elem : _mesh->active_element_ptr_range())
117  {
118  const Point c = elem->vertex_average();
119  if (c(0) > 0.6)
120  bi.add_side(elem, 0, bid_int);
121  }
122 
123  // We'll need to skip most repartitioning with DistributedMesh for
124  // now; otherwise the boundary meshes' interior parents might get
125  // shuffled off to different processors.
126  if (!_mesh->is_serial())
127  {
128  _mesh->skip_noncritical_partitioning(true);
129  _replicated_boundary_mesh->skip_noncritical_partitioning(true);
130  _distributed_boundary_mesh->skip_noncritical_partitioning(true);
131  }
132  }
std::unique_ptr< UnstructuredMesh > _replicated_boundary_mesh
Definition: boundary_mesh.C:98
std::unique_ptr< UnstructuredMesh > _distributed_boundary_mesh
Definition: boundary_mesh.C:99
int8_t boundary_id_type
Definition: id_types.h:51
The BoundaryInfo class contains information relevant to boundary conditions including storing faces...
Definition: boundary_info.h:57
std::unique_ptr< UnstructuredMesh > _interior_node_mesh
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...
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.
std::unique_ptr< UnstructuredMesh > _mesh
Definition: boundary_mesh.C:97
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39

◆ 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 228 of file boundary_mesh.C.

References libMesh::EDGE3, and libMesh::NODEELEM.

229  {
230  sanity_check_mesh(*_mesh, NODEELEM, EDGE3, true);
231 
232  sanity_check_mesh(*_replicated_boundary_mesh, NODEELEM, EDGE3, false);
233  sanity_check_mesh(*_distributed_boundary_mesh, NODEELEM, EDGE3, false);
234  sanity_check_mesh(*_interior_node_mesh, NODEELEM, EDGE3, false);
235  }
std::unique_ptr< UnstructuredMesh > _replicated_boundary_mesh
Definition: boundary_mesh.C:98
std::unique_ptr< UnstructuredMesh > _distributed_boundary_mesh
Definition: boundary_mesh.C:99
std::unique_ptr< UnstructuredMesh > _interior_node_mesh
std::unique_ptr< UnstructuredMesh > _mesh
Definition: boundary_mesh.C:97

◆ setUp()

void BoundaryMesh0DTest::setUp ( )
inline

Definition at line 165 of file boundary_mesh.C.

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

◆ sync_and_test_meshes()

void BoundaryMesh0DTest::sync_and_test_meshes ( )
inlineprotected

Definition at line 134 of file boundary_mesh.C.

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

◆ testBoundarySerialization()

void BoundaryMesh0DTest::testBoundarySerialization ( )
inline

Definition at line 207 of file boundary_mesh.C.

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

◆ testMesh()

void BoundaryMesh0DTest::testMesh ( )
inline

Definition at line 173 of file boundary_mesh.C.

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

Member Data Documentation

◆ _distributed_boundary_mesh

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

Definition at line 99 of file boundary_mesh.C.

◆ _interior_node_mesh

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

Definition at line 100 of file boundary_mesh.C.

◆ _mesh

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

Definition at line 97 of file boundary_mesh.C.

◆ _replicated_boundary_mesh

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

Definition at line 98 of file boundary_mesh.C.


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