Skip to content

Commit

Permalink
Add tests (libMesh#3385)
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwen committed Sep 16, 2022
1 parent 2b95a30 commit c479314
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ unit_tests_sources = \
mesh/mesh_function_dfem.C \
mesh/mesh_generation_test.C \
mesh/mesh_input.C \
mesh/mesh_smoother.C \
mesh/mesh_stitch.C \
mesh/mesh_triangulation.C \
mesh/mixed_dim_mesh_test.C \
Expand Down Expand Up @@ -144,6 +145,12 @@ data = meshes/1_quad.bxt.gz \
meshes/good_32bit_elem_integers.e \
meshes/mesh_assign_test_mesh.xda \
meshes/shark_tooth_tri6.xda.gz \
meshes/smooth2d_in.e \
meshes/smooth2d_move.e \
meshes/smooth2d_nomove.e \
meshes/smooth3d_in.e \
meshes/smooth3d_move.e \
meshes/smooth3d_nomove.e \
meshes/tetgen_one_tet10.ele \
meshes/tetgen_one_tet10.node

Expand Down
59 changes: 59 additions & 0 deletions tests/mesh/mesh_smoother.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include <libmesh/replicated_mesh.h>
#include <libmesh/distributed_mesh.h>
#include <libmesh/mesh_generation.h>
#include <libmesh/libmesh_config.h>
#include <libmesh/mesh_modification.h>
#include <libmesh/mesh_smoother_laplace.h>

#include "test_comm.h"
#include "libmesh_cppunit.h"

using namespace libMesh;

class SmoothMeshTest : public CppUnit::TestCase
{
public:
LIBMESH_CPPUNIT_TEST_SUITE( CopyNodesAndElementsTest );

CPPUNIT_TEST( laplace_smooth_2d_fixed_boundary_nodes );
CPPUNIT_TEST( laplace_smooth_2d_movable_boundary_nodes );
CPPUNIT_TEST( laplace_smooth_3d_fixed_boundary_nodes );
CPPUNIT_TEST( laplace_smooth_3d_movable_boundary_nodes );

CPPUNIT_TEST_SUITE_END();

private:
template <typename T>
void test(const std::string in_file, const std::string gold_file, bool move_nodes)
{
Mesh in_mesh(*TestCommWorld);
ExodusII_IO exii(in_mesh);
if (in_mesh.processor_id() == 0)
exii.read(in_file);
MeshCommunication().broadcast(in_mesh);
in_mesh.prepare_for_use();

Mesh gold_mesh(*TestCommWorld);
ExodusII_IO exii(gold_mesh);
if (gold_mesh.processor_id() == 0)
exii.read(gold_file);
MeshCommunication().broadcast(gold_mesh);
gold_mesh.prepare_for_use();

LaplaceMeshSmoother lms(static_cast<UnstructuredMesh &>(in_mesh), move_nodes);
lms.smooth(_iterations);
}

public:
void setUp() {}

void tearDown() {}

void laplace_smooth_2d_fixed_boundary_nodes() { LOG_UNIT_TEST; test("meshes/smooth2d_in.e", "smooth2d_nomove.e", false); }
void laplace_smooth_2d_movable_boundary_nodes() { LOG_UNIT_TEST; test("meshes/smooth2d_in.e", "smooth2d_move.e", true); }
void laplace_smooth_3d_fixed_boundary_nodes() { LOG_UNIT_TEST; test("meshes/smooth3d_in.e", "smooth3d_nomove.e", false); }
void laplace_smooth_3d_movable_boundary_nodes() { LOG_UNIT_TEST; test("meshes/smooth3d_in.e", "smooth3d_move.e", true); }
};


CPPUNIT_TEST_SUITE_REGISTRATION( CopyNodesAndElementsTest );
Binary file added tests/meshes/smooth2d_in.e
Binary file not shown.
Binary file added tests/meshes/smooth2d_move.e
Binary file not shown.
Binary file added tests/meshes/smooth2d_nomove.e
Binary file not shown.
Binary file added tests/meshes/smooth3d_in.e
Binary file not shown.
Binary file added tests/meshes/smooth3d_move.e
Binary file not shown.
Binary file added tests/meshes/smooth3d_nomove.e
Binary file not shown.

0 comments on commit c479314

Please sign in to comment.