Skip to content

Commit 85db35c

Browse files
committed
Add tests (libMesh#3385)
1 parent 2b95a30 commit 85db35c

8 files changed

+64
-0
lines changed

tests/Makefile.am

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ unit_tests_sources = \
6868
mesh/mesh_function_dfem.C \
6969
mesh/mesh_generation_test.C \
7070
mesh/mesh_input.C \
71+
mesh/mesh_smoother.C \
7172
mesh/mesh_stitch.C \
7273
mesh/mesh_triangulation.C \
7374
mesh/mixed_dim_mesh_test.C \
@@ -144,6 +145,12 @@ data = meshes/1_quad.bxt.gz \
144145
meshes/good_32bit_elem_integers.e \
145146
meshes/mesh_assign_test_mesh.xda \
146147
meshes/shark_tooth_tri6.xda.gz \
148+
meshes/smooth2d_in.e \
149+
meshes/smooth2d_move.e \
150+
meshes/smooth2d_nomove.e \
151+
meshes/smooth3d_in.e \
152+
meshes/smooth3d_move.e \
153+
meshes/smooth3d_nomove.e \
147154
meshes/tetgen_one_tet10.ele \
148155
meshes/tetgen_one_tet10.node
149156

tests/mesh/mesh_smoother.C

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#include <libmesh/replicated_mesh.h>
2+
#include <libmesh/distributed_mesh.h>
3+
#include <libmesh/mesh_generation.h>
4+
#include <libmesh/libmesh_config.h>
5+
#include <libmesh/mesh_modification.h>
6+
#include <libmesh/mesh_smoother_laplace.h>
7+
8+
#include "test_comm.h"
9+
#include "libmesh_cppunit.h"
10+
11+
using namespace libMesh;
12+
13+
class SmoothMeshTest : public CppUnit::TestCase
14+
{
15+
public:
16+
LIBMESH_CPPUNIT_TEST_SUITE(SmoothMeshTest);
17+
18+
CPPUNIT_TEST(laplace_smooth_2d_fixed_boundary_nodes);
19+
CPPUNIT_TEST(laplace_smooth_2d_movable_boundary_nodes);
20+
CPPUNIT_TEST(laplace_smooth_3d_fixed_boundary_nodes);
21+
CPPUNIT_TEST(laplace_smooth_3d_movable_boundary_nodes);
22+
23+
CPPUNIT_TEST_SUITE_END();
24+
25+
private:
26+
void test(const std::string in_file, const std::string gold_file, bool move_nodes)
27+
{
28+
Mesh in_mesh(*TestCommWorld);
29+
ExodusII_IO exii(in_mesh);
30+
if (in_mesh.processor_id() == 0)
31+
exii.read(in_file);
32+
MeshCommunication().broadcast(in_mesh);
33+
in_mesh.prepare_for_use();
34+
35+
Mesh gold_mesh(*TestCommWorld);
36+
ExodusII_IO exii(gold_mesh);
37+
if (gold_mesh.processor_id() == 0)
38+
exii.read(gold_file);
39+
MeshCommunication().broadcast(gold_mesh);
40+
gold_mesh.prepare_for_use();
41+
42+
LaplaceMeshSmoother lms(static_cast<UnstructuredMesh &>(in_mesh), move_nodes);
43+
lms.smooth(_iterations);
44+
}
45+
46+
public:
47+
void setUp() {}
48+
49+
void tearDown() {}
50+
51+
void laplace_smooth_2d_fixed_boundary_nodes() { LOG_UNIT_TEST; test("meshes/smooth2d_in.e", "smooth2d_nomove.e", false); }
52+
void laplace_smooth_2d_movable_boundary_nodes() { LOG_UNIT_TEST; test("meshes/smooth2d_in.e", "smooth2d_move.e", true); }
53+
void laplace_smooth_3d_fixed_boundary_nodes() { LOG_UNIT_TEST; test("meshes/smooth3d_in.e", "smooth3d_nomove.e", false); }
54+
void laplace_smooth_3d_movable_boundary_nodes() { LOG_UNIT_TEST; test("meshes/smooth3d_in.e", "smooth3d_move.e", true); }
55+
};
56+
57+
CPPUNIT_TEST_SUITE_REGISTRATION(CopyNodesAndElementsTest);

tests/meshes/smooth2d_in.e

7.38 KB
Binary file not shown.

tests/meshes/smooth2d_move.e

7.38 KB
Binary file not shown.

tests/meshes/smooth2d_nomove.e

7.38 KB
Binary file not shown.

tests/meshes/smooth3d_in.e

23 KB
Binary file not shown.

tests/meshes/smooth3d_move.e

23 KB
Binary file not shown.

tests/meshes/smooth3d_nomove.e

23 KB
Binary file not shown.

0 commit comments

Comments
 (0)