|
| 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 ); |
0 commit comments