diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 78d8f348..5bde113b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -111,7 +111,7 @@ if(Catch2_FOUND) test_mls_basis.cpp test_rbf_interp.cpp test_linear_solver.cpp - test_spr_meshfields.cpp) + ) endif () if (PCMS_ENABLE_MESHFIELDS) diff --git a/test/test_spr_meshfields.cpp b/test/test_spr_meshfields.cpp index 1f5f9a91..4d61b3c0 100644 --- a/test/test_spr_meshfields.cpp +++ b/test/test_spr_meshfields.cpp @@ -37,47 +37,6 @@ std::string getTestName(size_t interp_degree, size_t func_degree) { ", polynomial degree " + std::to_string(func_degree); } -Reals min_max_normalization_coordinates(const Reals& coordinates, int dim = 2) -{ - int num_points = coordinates.size() / dim; - - int coords_size = coordinates.size(); - - Write x_coordinates(num_points, 0, "x coordinates"); - - Write y_coordinates(num_points, 0, "y coordinates"); - - parallel_for( - "separates x and y coordinates", num_points, KOKKOS_LAMBDA(const int id) { - int index = id * dim; - x_coordinates[id] = coordinates[index]; - y_coordinates[id] = coordinates[index + 1]; - }); - - - const auto min_x = Omega_h::get_min(read(x_coordinates)); - const auto min_y = Omega_h::get_min(read(y_coordinates)); - - const auto max_x = Omega_h::get_max(read(x_coordinates)); - const auto max_y = Omega_h::get_max(read(y_coordinates)); - - const auto del_x = max_x - min_x; - const auto del_y = max_y - min_y; - - Write normalized_coordinates(coords_size, 0, - "stores scaled coordinates"); - - parallel_for( - "scale coordinates", num_points, KOKKOS_LAMBDA(const int id) { - int index = id * dim; - normalized_coordinates[index] = (x_coordinates[id] - min_x) / del_x; - normalized_coordinates[index + 1] = (y_coordinates[id] - min_y) / del_y; - }); - - return read(normalized_coordinates); -} - - KOKKOS_INLINE_FUNCTION double func(pcms::Coord& p, int degree) { @@ -104,7 +63,7 @@ void test(Mesh& mesh, Omega_h::Graph& patches, int degree, { int dim = mesh.dim(); - Real tolerance = 5e-4; + Real tolerance = 0.0005; Omega_h::Write ignored(patches.ab2b.size(), 1); SupportResults support{patches.a2ab,patches.ab2b,ignored}; @@ -129,9 +88,7 @@ void test(Mesh& mesh, Omega_h::Graph& patches, int degree, REQUIRE(m == n); for (size_t i = 0; i < m; ++i) { - //std::cout << "vtx " << i << "\n"; - CAPTURE( - host_exact_target_values[i], host_approx_target_values[i], tolerance); + std::cout << "vtx " << i << "\n"; CHECK_THAT( host_exact_target_values[i], Catch::Matchers::WithinAbs(host_approx_target_values[i], tolerance)); @@ -148,26 +105,18 @@ TEST_CASE("meshfields_spr_test") auto world = lib.world(); auto rank = lib.world()->rank(); const auto boxSize = 1.0; - //const auto nElms = 6; - //auto mesh = build_box(world, OMEGA_H_SIMPLEX, boxSize, boxSize, 0, nElms, nElms, 0, false); - - const auto thwaitesMeshFile = - "/lore/smithc11/projects/landice/thwaites_basal/thwaites_basalClass.osh"; - Omega_h::Mesh mesh(&lib); - Omega_h::binary::read(thwaitesMeshFile, lib.world(), &mesh); + const auto nElms = 6; + auto mesh = build_box(world, OMEGA_H_SIMPLEX, boxSize, boxSize, 0, nElms, nElms, 0, false); std::cout << "mesh: elms " << mesh.nelems() << " verts " << mesh.nverts() << "\n"; const auto dim = mesh.dim(); - const auto& target_coordinates_original = mesh.coords(); + const auto& target_coordinates = mesh.coords(); const auto& nfaces = mesh.nfaces(); const auto& ntargets = mesh.nverts(); - // min_max normalise target coordinates - auto target_coordinates = min_max_normalization_coordinates(target_coordinates_original, dim); - Write source_coordinates( dim * nfaces, 0, "stores coordinates of cell centroid of each tri element"); @@ -185,8 +134,6 @@ TEST_CASE("meshfields_spr_test") source_coordinates[index + 1] = centroid[1]; }); - - pcms::Points source_points; source_points.coordinates = @@ -215,11 +162,11 @@ TEST_CASE("meshfields_spr_test") std::cerr << "start " << interp_degree << ", " << func_degree << " \n"; int minPatchSize; if(interp_degree == 1) minPatchSize = 3; - if(interp_degree == 2) minPatchSize = 6; //why so large? + if(interp_degree == 2) minPatchSize = 8; //why so large? if(interp_degree == 3) minPatchSize = 10; //why so large? std::cerr << "minPatchSize " << minPatchSize << "\n"; auto patches = mesh.get_vtx_patches(minPatchSize); - // print_patches(patches); + print_patches(patches); Write source_values(nfaces, 0, "exact target values");