Skip to content

Commit

Permalink
Added more unit tests to cover more complex meshes
Browse files Browse the repository at this point in the history
  • Loading branch information
ddement committed Nov 5, 2024
1 parent 0c09c63 commit 547d0fc
Showing 1 changed file with 78 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,82 @@ TEST(TestCreateElementFreedomTable, TwoBeamsOneNode) {
}
}


TEST(TestCreateElementFreedomTable, TwoBeamsTwoNodesShared) {
auto state = State(3U);
constexpr auto host_node_freedom_map_table_data = std::array{0UL, 6UL, 12UL};
const auto host_node_freedom_map_table = Kokkos::View<size_t[3], Kokkos::HostSpace>::const_type(
host_node_freedom_map_table_data.data()
);
const auto mirror_node_freedom_map_table = Kokkos::create_mirror(state.node_freedom_map_table);
Kokkos::deep_copy(mirror_node_freedom_map_table, host_node_freedom_map_table);
Kokkos::deep_copy(state.node_freedom_map_table, mirror_node_freedom_map_table);

auto beams = Beams(2U, 2U, 1U);
constexpr auto host_node_state_indices_data = std::array{0UL, 1UL, 1UL, 2UL};
const auto host_node_state_indices =
Kokkos::View<size_t[2][2], Kokkos::HostSpace>::const_type(host_node_state_indices_data.data()
);
const auto mirror_node_state_indices = Kokkos::create_mirror(beams.node_state_indices);
Kokkos::deep_copy(mirror_node_state_indices, host_node_state_indices);
Kokkos::deep_copy(beams.node_state_indices, mirror_node_state_indices);
Kokkos::deep_copy(beams.num_nodes_per_element, 2U);

create_element_freedom_table(beams, state);

const auto host_element_freedom_table = Kokkos::create_mirror(beams.element_freedom_table);
Kokkos::deep_copy(host_element_freedom_table, beams.element_freedom_table);

for (auto k = 0U; k < 6U; ++k) {
EXPECT_EQ(host_element_freedom_table(0, 0, k), k);
}
for (auto k = 0U; k < 6U; ++k) {
EXPECT_EQ(host_element_freedom_table(0, 1, k), k + 6U);
}
for (auto k = 0U; k < 6U; ++k) {
EXPECT_EQ(host_element_freedom_table(1, 0, k), k + 6U);
}
for (auto k = 0U; k < 6U; ++k) {
EXPECT_EQ(host_element_freedom_table(1, 1, k), k + 12U);
}
}

TEST(TestCreateElementFreedomTable, TwoBeamsTwoNodesShared_Flipped) {
auto state = State(3U);
constexpr auto host_node_freedom_map_table_data = std::array{0UL, 6UL, 12UL};
const auto host_node_freedom_map_table = Kokkos::View<size_t[3], Kokkos::HostSpace>::const_type(
host_node_freedom_map_table_data.data()
);
const auto mirror_node_freedom_map_table = Kokkos::create_mirror(state.node_freedom_map_table);
Kokkos::deep_copy(mirror_node_freedom_map_table, host_node_freedom_map_table);
Kokkos::deep_copy(state.node_freedom_map_table, mirror_node_freedom_map_table);

auto beams = Beams(2U, 2U, 1U);
constexpr auto host_node_state_indices_data = std::array{1UL, 2UL, 0UL, 1UL};
const auto host_node_state_indices =
Kokkos::View<size_t[2][2], Kokkos::HostSpace>::const_type(host_node_state_indices_data.data()
);
const auto mirror_node_state_indices = Kokkos::create_mirror(beams.node_state_indices);
Kokkos::deep_copy(mirror_node_state_indices, host_node_state_indices);
Kokkos::deep_copy(beams.node_state_indices, mirror_node_state_indices);
Kokkos::deep_copy(beams.num_nodes_per_element, 2U);

create_element_freedom_table(beams, state);

const auto host_element_freedom_table = Kokkos::create_mirror(beams.element_freedom_table);
Kokkos::deep_copy(host_element_freedom_table, beams.element_freedom_table);

for (auto k = 0U; k < 6U; ++k) {
EXPECT_EQ(host_element_freedom_table(1, 0, k), k);
}
for (auto k = 0U; k < 6U; ++k) {
EXPECT_EQ(host_element_freedom_table(1, 1, k), k + 6U);
}
for (auto k = 0U; k < 6U; ++k) {
EXPECT_EQ(host_element_freedom_table(0, 0, k), k + 6U);
}
for (auto k = 0U; k < 6U; ++k) {
EXPECT_EQ(host_element_freedom_table(0, 1, k), k + 12U);
}
}
} // namespace openturbine::tests

0 comments on commit 547d0fc

Please sign in to comment.