Skip to content

Commit c479314

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

8 files changed

+66
-0
lines changed

tests/Makefile.am

+7
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

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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( CopyNodesAndElementsTest );
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+
template <typename T>
27+
void test(const std::string in_file, const std::string gold_file, bool move_nodes)
28+
{
29+
Mesh in_mesh(*TestCommWorld);
30+
ExodusII_IO exii(in_mesh);
31+
if (in_mesh.processor_id() == 0)
32+
exii.read(in_file);
33+
MeshCommunication().broadcast(in_mesh);
34+
in_mesh.prepare_for_use();
35+
36+
Mesh gold_mesh(*TestCommWorld);
37+
ExodusII_IO exii(gold_mesh);
38+
if (gold_mesh.processor_id() == 0)
39+
exii.read(gold_file);
40+
MeshCommunication().broadcast(gold_mesh);
41+
gold_mesh.prepare_for_use();
42+
43+
LaplaceMeshSmoother lms(static_cast<UnstructuredMesh &>(in_mesh), move_nodes);
44+
lms.smooth(_iterations);
45+
}
46+
47+
public:
48+
void setUp() {}
49+
50+
void tearDown() {}
51+
52+
void laplace_smooth_2d_fixed_boundary_nodes() { LOG_UNIT_TEST; test("meshes/smooth2d_in.e", "smooth2d_nomove.e", false); }
53+
void laplace_smooth_2d_movable_boundary_nodes() { LOG_UNIT_TEST; test("meshes/smooth2d_in.e", "smooth2d_move.e", true); }
54+
void laplace_smooth_3d_fixed_boundary_nodes() { LOG_UNIT_TEST; test("meshes/smooth3d_in.e", "smooth3d_nomove.e", false); }
55+
void laplace_smooth_3d_movable_boundary_nodes() { LOG_UNIT_TEST; test("meshes/smooth3d_in.e", "smooth3d_move.e", true); }
56+
};
57+
58+
59+
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)