Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
67 changes: 7 additions & 60 deletions test/test_spr_meshfields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Real> x_coordinates(num_points, 0, "x coordinates");

Write<Real> 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<Real> 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)
{
Expand All @@ -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<Real> ignored(patches.ab2b.size(), 1);
SupportResults support{patches.a2ab,patches.ab2b,ignored};
Expand All @@ -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));
Expand All @@ -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<Real> source_coordinates(
dim * nfaces, 0, "stores coordinates of cell centroid of each tri element");

Expand All @@ -185,8 +134,6 @@ TEST_CASE("meshfields_spr_test")
source_coordinates[index + 1] = centroid[1];
});



pcms::Points source_points;

source_points.coordinates =
Expand Down Expand Up @@ -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<Real> source_values(nfaces, 0, "exact target values");

Expand Down