diff --git a/src/mesh/SubItemArrayPerItem.hpp b/src/mesh/SubItemArrayPerItem.hpp index 9fd488bc5e6ebe3ea189368de8eeb67073e590ec..8c8b1724cd1bc8ea019af7349aee17f9ac64c87b 100644 --- a/src/mesh/SubItemArrayPerItem.hpp +++ b/src/mesh/SubItemArrayPerItem.hpp @@ -142,7 +142,7 @@ class SubItemArrayPerItem void fill(const DataType& data) const noexcept { - static_assert(not std::is_const_v<DataType>, "Cannot modify ItemValue of const"); + static_assert(not std::is_const_v<DataType>, "Cannot modify SubItemArrayPerItem of const"); m_values.fill(data); } diff --git a/tests/test_SubItemArrayPerItem.cpp b/tests/test_SubItemArrayPerItem.cpp index c72f98b76de01f6562aac21c5cc008716606a0a5..23be4a345906919286bb5d35b14fcfdd3f83de80 100644 --- a/tests/test_SubItemArrayPerItem.cpp +++ b/tests/test_SubItemArrayPerItem.cpp @@ -874,6 +874,117 @@ TEST_CASE("SubItemArrayPerItem", "[mesh]") } } + SECTION("fill") + { + std::array mesh_list = MeshDataBaseForTests::get().all3DMeshes(); + + for (auto named_mesh : mesh_list) { + SECTION(named_mesh.name()) + { + auto mesh_3d = named_mesh.mesh(); + + const Connectivity<3>& connectivity = mesh_3d->connectivity(); + + SECTION("classic") + { + NodeArrayPerCell<size_t> node_array_per_cell{connectivity, 3}; + { + size_t k = 0; + for (size_t i = 0; i < node_array_per_cell.numberOfArrays(); ++i) { + for (size_t j = 0; j < node_array_per_cell.sizeOfArrays(); ++j, ++k) { + node_array_per_cell[i][j] = k; + } + } + } + NodeArrayPerCell<size_t> copy_node_array_per_cell = copy(node_array_per_cell); + { + bool is_same = true; + for (size_t i = 0; i < copy_node_array_per_cell.numberOfArrays(); ++i) { + for (size_t j = 0; j < node_array_per_cell.sizeOfArrays(); ++j) { + is_same &= (copy_node_array_per_cell[i][j] == node_array_per_cell[i][j]); + } + } + + REQUIRE(is_same); + } + + node_array_per_cell.fill(11); + + { + bool is_same = true; + for (size_t i = 0; i < copy_node_array_per_cell.numberOfArrays(); ++i) { + for (size_t j = 0; j < copy_node_array_per_cell.sizeOfArrays(); ++j) { + is_same &= (copy_node_array_per_cell[i][j] == node_array_per_cell[i][j]); + } + } + + REQUIRE(not is_same); + } + + { + bool is_filled_with_11 = true; + for (size_t i = 0; i < copy_node_array_per_cell.numberOfArrays(); ++i) { + for (size_t j = 0; j < copy_node_array_per_cell.sizeOfArrays(); ++j) { + is_filled_with_11 &= (node_array_per_cell[i][j] == 11); + } + } + + REQUIRE(is_filled_with_11); + } + } + + SECTION("from weak") + { + WeakNodeArrayPerCell<size_t> node_array_per_cell{connectivity, 3}; + { + size_t k = 0; + for (size_t i = 0; i < node_array_per_cell.numberOfArrays(); ++i) { + for (size_t j = 0; j < node_array_per_cell.sizeOfArrays(); ++j, ++k) { + node_array_per_cell[i][j] = k; + } + } + } + + NodeArrayPerCell<size_t> copy_node_array_per_cell = copy(node_array_per_cell); + { + bool is_same = true; + for (size_t i = 0; i < copy_node_array_per_cell.numberOfArrays(); ++i) { + for (size_t j = 0; j < node_array_per_cell.sizeOfArrays(); ++j) { + is_same &= (copy_node_array_per_cell[i][j] == node_array_per_cell[i][j]); + } + } + + REQUIRE(is_same); + } + + node_array_per_cell.fill(13); + + { + bool is_same = true; + for (size_t i = 0; i < copy_node_array_per_cell.numberOfArrays(); ++i) { + for (size_t j = 0; j < node_array_per_cell.sizeOfArrays(); ++j) { + is_same &= (copy_node_array_per_cell[i][j] == node_array_per_cell[i][j]); + } + } + + REQUIRE(not is_same); + } + + { + bool is_filled_with_13 = true; + for (size_t i = 0; i < copy_node_array_per_cell.numberOfArrays(); ++i) { + for (size_t j = 0; j < copy_node_array_per_cell.sizeOfArrays(); ++j) { + is_filled_with_13 &= (node_array_per_cell[i][j] == 13); + } + } + + REQUIRE(is_filled_with_13); + } + } + } + } + } + SECTION("WeakSubItemArrayPerItem") { std::array mesh_list = MeshDataBaseForTests::get().all2DMeshes();