diff --git a/.gitlab/build_dane.yml b/.gitlab/build_dane.yml index bb9e41dcba..d54209640a 100644 --- a/.gitlab/build_dane.yml +++ b/.gitlab/build_dane.yml @@ -37,34 +37,37 @@ #### # PR Build jobs -dane-llvm_19_1_3-werror-debug-src: +dane-llvm_19_1_3-debug-werror-src: variables: COMPILER: "llvm@19.1.3" HOST_CONFIG: "dane-toss_4_x86_64_ib-${COMPILER}.cmake" + BUILD_TYPE: "Debug" EXTRA_CMAKE_OPTIONS: "-DENABLE_WARNINGS_AS_ERRORS:BOOL=ON" extends: .src_build_on_dane -dane-llvm_19_1_3-release-src: +dane-llvm_19_1_3-release-werror-src: variables: COMPILER: "llvm@19.1.3" HOST_CONFIG: "dane-toss_4_x86_64_ib-${COMPILER}.cmake" BUILD_TYPE: "Release" - EXTRA_CMAKE_OPTIONS: "-DAXOM_QUEST_ENABLE_EXTRA_REGRESSION_TESTS:BOOL=ON" + EXTRA_CMAKE_OPTIONS: "-DAXOM_QUEST_ENABLE_EXTRA_REGRESSION_TESTS:BOOL=ON -DENABLE_WARNINGS_AS_ERRORS:BOOL=ON" extends: .src_build_on_dane -dane-gcc_13_3_1-werror-src: +dane-gcc_13_3_1-release-werror-src: variables: COMPILER: "gcc@13.3.1" HOST_CONFIG: "dane-toss_4_x86_64_ib-${COMPILER}.cmake" + BUILD_TYPE: "Release" EXTRA_CMAKE_OPTIONS: "-DENABLE_WARNINGS_AS_ERRORS:BOOL=ON" extends: .src_build_on_dane -dane-sanitizers-gcc_13_3_1-src: +dane-sanitizers-gcc_13_3_1-debug-werror-src: variables: COMPILER: "gcc@13.3.1" HOST_CONFIG: "dane-toss_4_x86_64_ib-${COMPILER}.cmake" + BUILD_TYPE: "Debug" LSAN_OPTIONS: suppressions=${CI_PROJECT_DIR}/suppressions.asan - EXTRA_CMAKE_OPTIONS: "-DAXOM_ENABLE_ASAN=ON -DAXOM_ENABLE_UBSAN=ON" + EXTRA_CMAKE_OPTIONS: "-DAXOM_ENABLE_ASAN=ON -DAXOM_ENABLE_UBSAN=ON -DENABLE_WARNINGS_AS_ERRORS:BOOL=ON" extends: .src_build_on_dane # TODO: turn back on diff --git a/src/axom/bump/tests/bump_views.cpp b/src/axom/bump/tests/bump_views.cpp index 491691e866..2cdcb476cf 100644 --- a/src/axom/bump/tests/bump_views.cpp +++ b/src/axom/bump/tests/bump_views.cpp @@ -790,11 +790,25 @@ struct test_braid2d_mat eq_count += (end == end2) ? 1 : 0; count++; - // Make sure the iterator order is the same as for the values we got from zoneMaterials(). + // Test ArrayView version of zoneMaterials(). + using IndexType = typename MatsetView::IndexType; + using FloatType = typename MatsetView::FloatType; + constexpr int ARRAY_SIZE = 10; + IndexType idStorage[ARRAY_SIZE] = {}; + FloatType vfStorage[ARRAY_SIZE] = {}; + axom::ArrayView idView(idStorage, ARRAY_SIZE); + axom::ArrayView vfView(vfStorage, ARRAY_SIZE); + const auto nmats = deviceViews.matsetView.zoneMaterials(index, idView, vfView); + eq_count += (nmats == ids.size()) ? 1 : 0; + count++; + + // Compare against the zero-initialized ArrayView results instead of the StaticArray + // backing storage after zoneMaterials() fills the active prefix. int i = 0; for(auto it = deviceViews.matsetView.beginZone(index); it != end; it++, i++) { - eq_count += (vfs[i] == it.volume_fraction() && ids[i] == it.material_id()) ? 1 : 0; + eq_count += + (i < nmats && vfView[i] == it.volume_fraction() && idView[i] == it.material_id()) ? 1 : 0; count++; } @@ -812,23 +826,6 @@ struct test_braid2d_mat } } - // Test ArrayView version of zoneMaterials(). - using IndexType = typename MatsetView::IndexType; - using FloatType = typename MatsetView::FloatType; - constexpr int ARRAY_SIZE = 10; - IndexType idStorage[ARRAY_SIZE]; - FloatType vfStorage[ARRAY_SIZE]; - axom::ArrayView idView(idStorage, ARRAY_SIZE); - axom::ArrayView vfView(vfStorage, ARRAY_SIZE); - const auto nmats = deviceViews.matsetView.zoneMaterials(index, idView, vfView); - eq_count += (nmats == ids.size()) ? 1 : 0; - count++; - for(axom::IndexType j = 0; j < nmats; j++) - { - eq_count += (vfs[j] == vfView[j] && ids[j] == idView[j]) ? 1 : 0; - count++; - } - resultsView[index] = (eq_count == count) ? 1 : 0; }); diff --git a/src/axom/mint/execution/internal/for_all_cells.hpp b/src/axom/mint/execution/internal/for_all_cells.hpp index 869d3f118c..a0d1382169 100644 --- a/src/axom/mint/execution/internal/for_all_cells.hpp +++ b/src/axom/mint/execution/internal/for_all_cells.hpp @@ -33,6 +33,11 @@ namespace mint { namespace internal { +constexpr int STRUCTURED_CELL_NODES_1D = 2; +constexpr int STRUCTURED_CELL_NODES_2D = 4; +constexpr int STRUCTURED_CELL_NODES_3D = 8; +constexpr int STRUCTURED_MAX_CELL_NODES = STRUCTURED_CELL_NODES_3D; + //------------------------------------------------------------------------------ template inline void for_all_cells_impl(xargs::index, const Mesh& m, KernelType&& kernel) @@ -122,16 +127,15 @@ inline void for_all_cells_impl(xargs::nodeids, const StructuredMesh& m, KernelTy const IndexType nodeKp = m.nodeKp(); const StackArray& offsets = m.getCellNodeOffsetsArray(); - // Note: gcc@10.3.1 emits a '-Warray-bounds' warning in callers of this function - // about the sizes of nodeIds and coords not matching due to the runtime switch on dimension - if(dimension == 1) { for_all_cells_impl( xargs::index(), m, AXOM_LAMBDA(IndexType cellID) { - IndexType cell_connectivity[2] = {cellID, cellID + 1}; + IndexType cell_connectivity[STRUCTURED_MAX_CELL_NODES] = {0}; + cell_connectivity[0] = cellID; + cell_connectivity[1] = cellID + 1; kernel(cellID, cell_connectivity, 2); }); } @@ -142,7 +146,7 @@ inline void for_all_cells_impl(xargs::nodeids, const StructuredMesh& m, KernelTy m, AXOM_LAMBDA(IndexType cellID, IndexType i, IndexType j) { const IndexType n0 = i + j * nodeJp; - IndexType cell_connectivity[4]; + IndexType cell_connectivity[STRUCTURED_MAX_CELL_NODES] = {0}; for(int ii = 0; ii < 4; ++ii) { @@ -161,7 +165,7 @@ inline void for_all_cells_impl(xargs::nodeids, const StructuredMesh& m, KernelTy m, AXOM_LAMBDA(IndexType cellID, IndexType i, IndexType j, IndexType k) { const IndexType n0 = i + j * nodeJp + k * nodeKp; - IndexType cell_connectivity[8]; + IndexType cell_connectivity[STRUCTURED_MAX_CELL_NODES] = {0}; for(int ii = 0; ii < 8; ++ii) { @@ -421,17 +425,18 @@ inline void for_all_cells_impl(xargs::coords, const UniformMesh& m, KernelType&& const double z0 = origin[2]; const double dz = spacing[2]; - // Note: gcc@10.3.1 emits a '-Warray-bounds' warning in callers of this function - // about the sizes of nodeIds and coords not matching due to the runtime switch on dimension - if(dimension == 1) { for_all_cells_impl( xargs::index(), m, AXOM_LAMBDA(IndexType cellID) { - const IndexType nodeIDs[2] = {cellID, cellID + 1}; - double coords[2] = {x0 + nodeIDs[0] * dx, x0 + nodeIDs[1] * dx}; + IndexType nodeIDs[STRUCTURED_MAX_CELL_NODES] = {0}; + nodeIDs[0] = cellID; + nodeIDs[1] = cellID + 1; + double coords[3 * STRUCTURED_MAX_CELL_NODES] = {0.}; + coords[0] = x0 + nodeIDs[0] * dx; + coords[1] = x0 + nodeIDs[1] * dx; numerics::Matrix coordsMatrix(dimension, 2, coords, NO_COPY); kernel(cellID, coordsMatrix, nodeIDs); @@ -444,16 +449,21 @@ inline void for_all_cells_impl(xargs::coords, const UniformMesh& m, KernelType&& m, AXOM_LAMBDA(IndexType cellID, IndexType i, IndexType j) { const IndexType n0 = i + j * nodeJp; - const IndexType nodeIDs[4] = {n0, n0 + 1, n0 + 1 + nodeJp, n0 + nodeJp}; - - double coords[8] = {x0 + i * dx, - y0 + j * dy, - x0 + (i + 1) * dx, - y0 + j * dy, - x0 + (i + 1) * dx, - y0 + (j + 1) * dy, - x0 + i * dx, - y0 + (j + 1) * dy}; + IndexType nodeIDs[STRUCTURED_MAX_CELL_NODES] = {0}; + nodeIDs[0] = n0; + nodeIDs[1] = n0 + 1; + nodeIDs[2] = n0 + 1 + nodeJp; + nodeIDs[3] = n0 + nodeJp; + + double coords[3 * STRUCTURED_MAX_CELL_NODES] = {0.}; + coords[0] = x0 + i * dx; + coords[1] = y0 + j * dy; + coords[2] = x0 + (i + 1) * dx; + coords[3] = y0 + j * dy; + coords[4] = x0 + (i + 1) * dx; + coords[5] = y0 + (j + 1) * dy; + coords[6] = x0 + i * dx; + coords[7] = y0 + (j + 1) * dy; numerics::Matrix coordsMatrix(dimension, 4, coords, NO_COPY); kernel(cellID, coordsMatrix, nodeIDs); @@ -467,16 +477,17 @@ inline void for_all_cells_impl(xargs::coords, const UniformMesh& m, KernelType&& m, AXOM_LAMBDA(IndexType cellID, IndexType i, IndexType j, IndexType k) { const IndexType n0 = i + j * nodeJp + k * nodeKp; - const IndexType nodeIDs[8] = {n0, - n0 + 1, - n0 + 1 + nodeJp, - n0 + nodeJp, - n0 + nodeKp, - n0 + 1 + nodeKp, - n0 + 1 + nodeJp + nodeKp, - n0 + nodeJp + nodeKp}; - - double coords[24] = { + IndexType nodeIDs[STRUCTURED_MAX_CELL_NODES] = {0}; + nodeIDs[0] = n0; + nodeIDs[1] = n0 + 1; + nodeIDs[2] = n0 + 1 + nodeJp; + nodeIDs[3] = n0 + nodeJp; + nodeIDs[4] = n0 + nodeKp; + nodeIDs[5] = n0 + 1 + nodeKp; + nodeIDs[6] = n0 + 1 + nodeJp + nodeKp; + nodeIDs[7] = n0 + nodeJp + nodeKp; + + double coords[3 * STRUCTURED_MAX_CELL_NODES] = { x0 + i * dx, y0 + j * dy, z0 + k * dz, x0 + (i + 1) * dx, y0 + j * dy, z0 + k * dz, x0 + (i + 1) * dx, y0 + (j + 1) * dy, z0 + k * dz, x0 + i * dx, y0 + (j + 1) * dy, z0 + k * dz, @@ -518,8 +529,12 @@ inline void for_all_cells_impl(xargs::coords, const RectilinearMesh& m, KernelTy xargs::index(), m, AXOM_LAMBDA(IndexType cellID) { - const IndexType nodeIDs[2] = {cellID, cellID + 1}; - double coords[2] = {x_vals_view[nodeIDs[0]], x_vals_view[nodeIDs[1]]}; + IndexType nodeIDs[STRUCTURED_MAX_CELL_NODES] = {0}; + nodeIDs[0] = cellID; + nodeIDs[1] = cellID + 1; + double coords[3 * STRUCTURED_MAX_CELL_NODES] = {0.}; + coords[0] = x_vals_view[nodeIDs[0]]; + coords[1] = x_vals_view[nodeIDs[1]]; numerics::Matrix coordsMatrix(dimension, 2, coords, NO_COPY); kernel(cellID, coordsMatrix, nodeIDs); @@ -541,16 +556,21 @@ inline void for_all_cells_impl(xargs::coords, const RectilinearMesh& m, KernelTy m, AXOM_LAMBDA(IndexType cellID, IndexType i, IndexType j) { const IndexType n0 = i + j * nodeJp; - const IndexType nodeIDs[4] = {n0, n0 + 1, n0 + 1 + nodeJp, n0 + nodeJp}; - - double coords[8] = {x_vals_view[i], - y_vals_view[j], - x_vals_view[i + 1], - y_vals_view[j], - x_vals_view[i + 1], - y_vals_view[j + 1], - x_vals_view[i], - y_vals_view[j + 1]}; + IndexType nodeIDs[STRUCTURED_MAX_CELL_NODES] = {0}; + nodeIDs[0] = n0; + nodeIDs[1] = n0 + 1; + nodeIDs[2] = n0 + 1 + nodeJp; + nodeIDs[3] = n0 + nodeJp; + + double coords[3 * STRUCTURED_MAX_CELL_NODES] = {0.}; + coords[0] = x_vals_view[i]; + coords[1] = y_vals_view[j]; + coords[2] = x_vals_view[i + 1]; + coords[3] = y_vals_view[j]; + coords[4] = x_vals_view[i + 1]; + coords[5] = y_vals_view[j + 1]; + coords[6] = x_vals_view[i]; + coords[7] = y_vals_view[j + 1]; numerics::Matrix coordsMatrix(dimension, 4, coords, NO_COPY); kernel(cellID, coordsMatrix, nodeIDs); @@ -580,16 +600,17 @@ inline void for_all_cells_impl(xargs::coords, const RectilinearMesh& m, KernelTy m, AXOM_LAMBDA(IndexType cellID, IndexType i, IndexType j, IndexType k) { const IndexType n0 = i + j * nodeJp + k * nodeKp; - const IndexType nodeIDs[8] = {n0, - n0 + 1, - n0 + 1 + nodeJp, - n0 + nodeJp, - n0 + nodeKp, - n0 + 1 + nodeKp, - n0 + 1 + nodeJp + nodeKp, - n0 + nodeJp + nodeKp}; - - double coords[24] = { + IndexType nodeIDs[STRUCTURED_MAX_CELL_NODES] = {0}; + nodeIDs[0] = n0; + nodeIDs[1] = n0 + 1; + nodeIDs[2] = n0 + 1 + nodeJp; + nodeIDs[3] = n0 + nodeJp; + nodeIDs[4] = n0 + nodeKp; + nodeIDs[5] = n0 + 1 + nodeKp; + nodeIDs[6] = n0 + 1 + nodeJp + nodeKp; + nodeIDs[7] = n0 + nodeJp + nodeKp; + + double coords[3 * STRUCTURED_MAX_CELL_NODES] = { x_vals_view[i], y_vals_view[j], z_vals_view[k], x_vals_view[i + 1], y_vals_view[j], z_vals_view[k], x_vals_view[i + 1], y_vals_view[j + 1], z_vals_view[k], x_vals_view[i], y_vals_view[j + 1], z_vals_view[k], @@ -625,21 +646,24 @@ inline void for_all_cells_impl(xargs::coords, const CurvilinearMesh& m, KernelTy const int dimension = m.getDimension(); if(dimension == 1) { - for_all_coords(for_all_cell_nodes_functor(), - m, - std::forward(kernel)); + for_all_coords( + for_all_cell_nodes_functor(), + m, + std::forward(kernel)); } else if(dimension == 2) { - for_all_coords(for_all_cell_nodes_functor(), - m, - std::forward(kernel)); + for_all_coords( + for_all_cell_nodes_functor(), + m, + std::forward(kernel)); } else { - for_all_coords(for_all_cell_nodes_functor(), - m, - std::forward(kernel)); + for_all_coords( + for_all_cell_nodes_functor(), + m, + std::forward(kernel)); } } @@ -669,7 +693,9 @@ inline void for_all_cells_impl(xargs::coords, const UnstructuredMesh& m, K xargs::nodeids(), m, AXOM_LAMBDA(IndexType cellID, const IndexType* nodeIDs, IndexType AXOM_UNUSED_PARAM(numNodes)) { - double coords[2] = {x_vals_view[nodeIDs[0]], x_vals_view[nodeIDs[1]]}; + double coords[3 * MAX_CELL_NODES] = {0.}; + coords[0] = x_vals_view[nodeIDs[0]]; + coords[1] = x_vals_view[nodeIDs[1]]; numerics::Matrix coordsMatrix(dimension, 2, coords, NO_COPY); kernel(cellID, coordsMatrix, nodeIDs); @@ -690,7 +716,7 @@ inline void for_all_cells_impl(xargs::coords, const UnstructuredMesh& m, K xargs::nodeids(), m, AXOM_LAMBDA(IndexType cellID, const IndexType* nodeIDs, IndexType numNodes) { - double coords[2 * MAX_CELL_NODES]; + double coords[3 * MAX_CELL_NODES] = {0.}; for(int i = 0; i < numNodes; ++i) { const IndexType nodeID = nodeIDs[i]; @@ -725,7 +751,7 @@ inline void for_all_cells_impl(xargs::coords, const UnstructuredMesh& m, K xargs::nodeids(), m, AXOM_LAMBDA(IndexType cellID, const IndexType* nodeIDs, IndexType numNodes) { - double coords[3 * MAX_CELL_NODES]; + double coords[3 * MAX_CELL_NODES] = {0.}; for(int i = 0; i < numNodes; ++i) { const IndexType nodeID = nodeIDs[i]; diff --git a/src/axom/mint/execution/internal/for_all_faces.hpp b/src/axom/mint/execution/internal/for_all_faces.hpp index c24963e73e..4c77c2e80e 100644 --- a/src/axom/mint/execution/internal/for_all_faces.hpp +++ b/src/axom/mint/execution/internal/for_all_faces.hpp @@ -30,6 +30,10 @@ namespace mint { namespace internal { +constexpr int STRUCTURED_FACE_NODES_2D = 2; +constexpr int STRUCTURED_FACE_NODES_3D = 4; +constexpr int STRUCTURED_MAX_FACE_NODES = STRUCTURED_FACE_NODES_3D; + namespace helpers { //------------------------------------------------------------------------------ @@ -181,7 +185,7 @@ inline void for_all_faces_impl(xargs::nodeids, const StructuredMesh& m, KernelTy xargs::ij(), m, AXOM_LAMBDA(IndexType faceID, IndexType AXOM_UNUSED_PARAM(i), IndexType AXOM_UNUSED_PARAM(j)) { - IndexType nodes[2]; + IndexType nodes[STRUCTURED_MAX_FACE_NODES] = {0}; nodes[0] = faceID; nodes[1] = nodes[0] + cellNodeOffset3; kernel(faceID, nodes, 2); @@ -192,7 +196,7 @@ inline void for_all_faces_impl(xargs::nodeids, const StructuredMesh& m, KernelTy m, AXOM_LAMBDA(IndexType faceID, IndexType AXOM_UNUSED_PARAM(i), IndexType j) { const IndexType shiftedID = faceID - numIFaces; - IndexType nodes[2]; + IndexType nodes[STRUCTURED_MAX_FACE_NODES] = {0}; nodes[0] = shiftedID + j; nodes[1] = nodes[0] + 1; kernel(faceID, nodes, 2); @@ -221,7 +225,7 @@ inline void for_all_faces_impl(xargs::nodeids, const StructuredMesh& m, KernelTy IndexType AXOM_UNUSED_PARAM(i), IndexType AXOM_UNUSED_PARAM(j), IndexType k) { - IndexType nodes[4]; + IndexType nodes[STRUCTURED_MAX_FACE_NODES] = {0}; nodes[0] = faceID + k * INodeResolution; nodes[1] = nodes[0] + cellNodeOffset4; nodes[2] = nodes[0] + cellNodeOffset7; @@ -234,7 +238,7 @@ inline void for_all_faces_impl(xargs::nodeids, const StructuredMesh& m, KernelTy m, AXOM_LAMBDA(IndexType faceID, IndexType AXOM_UNUSED_PARAM(i), IndexType j, IndexType k) { const IndexType shiftedID = faceID - numIFaces; - IndexType nodes[4]; + IndexType nodes[STRUCTURED_MAX_FACE_NODES] = {0}; nodes[0] = shiftedID + j + k * JNodeResolution; nodes[1] = nodes[0] + 1; nodes[2] = nodes[0] + cellNodeOffset5; @@ -247,7 +251,7 @@ inline void for_all_faces_impl(xargs::nodeids, const StructuredMesh& m, KernelTy m, AXOM_LAMBDA(IndexType faceID, IndexType AXOM_UNUSED_PARAM(i), IndexType j, IndexType k) { const IndexType shiftedID = faceID - numIJFaces; - IndexType nodes[4]; + IndexType nodes[STRUCTURED_MAX_FACE_NODES] = {0}; nodes[0] = shiftedID + j + k * KFaceNodeStride; nodes[1] = nodes[0] + 1; nodes[2] = nodes[0] + cellNodeOffset2; @@ -548,9 +552,15 @@ inline void for_all_faces_impl(xargs::coords, const UniformMesh& m, KernelType&& m, AXOM_LAMBDA(IndexType faceID, IndexType i, IndexType j) { const IndexType n0 = i + j * nodeJp; - const IndexType nodeIDs[2] = {n0, n0 + nodeJp}; + IndexType nodeIDs[STRUCTURED_MAX_FACE_NODES] = {0}; + nodeIDs[0] = n0; + nodeIDs[1] = n0 + nodeJp; - double coords[4] = {x0 + i * dx, y0 + j * dy, x0 + i * dx, y0 + (j + 1) * dy}; + double coords[3 * STRUCTURED_MAX_FACE_NODES] = {0.}; + coords[0] = x0 + i * dx; + coords[1] = y0 + j * dy; + coords[2] = x0 + i * dx; + coords[3] = y0 + (j + 1) * dy; numerics::Matrix coordsMatrix(dimension, 2, coords, NO_COPY); kernel(faceID, coordsMatrix, nodeIDs); @@ -561,9 +571,15 @@ inline void for_all_faces_impl(xargs::coords, const UniformMesh& m, KernelType&& m, AXOM_LAMBDA(IndexType faceID, IndexType i, IndexType j) { const IndexType n0 = i + j * nodeJp; - const IndexType nodeIDs[2] = {n0, n0 + 1}; + IndexType nodeIDs[STRUCTURED_MAX_FACE_NODES] = {0}; + nodeIDs[0] = n0; + nodeIDs[1] = n0 + 1; - double coords[4] = {x0 + i * dx, y0 + j * dy, x0 + (i + 1) * dx, y0 + j * dy}; + double coords[3 * STRUCTURED_MAX_FACE_NODES] = {0.}; + coords[0] = x0 + i * dx; + coords[1] = y0 + j * dy; + coords[2] = x0 + (i + 1) * dx; + coords[3] = y0 + j * dy; numerics::Matrix coordsMatrix(dimension, 2, coords, NO_COPY); kernel(faceID, coordsMatrix, nodeIDs); @@ -576,20 +592,25 @@ inline void for_all_faces_impl(xargs::coords, const UniformMesh& m, KernelType&& m, AXOM_LAMBDA(IndexType faceID, IndexType i, IndexType j, IndexType k) { const IndexType n0 = i + j * nodeJp + k * nodeKp; - const IndexType nodeIDs[4] = {n0, n0 + nodeKp, n0 + nodeJp + nodeKp, n0 + nodeJp}; - - double coords[12] = {x0 + i * dx, - y0 + j * dy, - z0 + k * dz, - x0 + i * dx, - y0 + j * dy, - z0 + (k + 1) * dz, - x0 + i * dx, - y0 + (j + 1) * dy, - z0 + (k + 1) * dz, - x0 + i * dx, - y0 + (j + 1) * dy, - z0 + k * dz}; + IndexType nodeIDs[STRUCTURED_MAX_FACE_NODES] = {0}; + nodeIDs[0] = n0; + nodeIDs[1] = n0 + nodeKp; + nodeIDs[2] = n0 + nodeJp + nodeKp; + nodeIDs[3] = n0 + nodeJp; + + double coords[3 * STRUCTURED_MAX_FACE_NODES] = {0.}; + coords[0] = x0 + i * dx; + coords[1] = y0 + j * dy; + coords[2] = z0 + k * dz; + coords[3] = x0 + i * dx; + coords[4] = y0 + j * dy; + coords[5] = z0 + (k + 1) * dz; + coords[6] = x0 + i * dx; + coords[7] = y0 + (j + 1) * dy; + coords[8] = z0 + (k + 1) * dz; + coords[9] = x0 + i * dx; + coords[10] = y0 + (j + 1) * dy; + coords[11] = z0 + k * dz; numerics::Matrix coordsMatrix(dimension, 4, coords, NO_COPY); kernel(faceID, coordsMatrix, nodeIDs); @@ -600,20 +621,25 @@ inline void for_all_faces_impl(xargs::coords, const UniformMesh& m, KernelType&& m, AXOM_LAMBDA(IndexType faceID, IndexType i, IndexType j, IndexType k) { const IndexType n0 = i + j * nodeJp + k * nodeKp; - const IndexType nodeIDs[4] = {n0, n0 + 1, n0 + 1 + nodeKp, n0 + nodeKp}; - - double coords[12] = {x0 + i * dx, - y0 + j * dy, - z0 + k * dz, - x0 + (i + 1) * dx, - y0 + j * dy, - z0 + k * dz, - x0 + (i + 1) * dx, - y0 + j * dy, - z0 + (k + 1) * dz, - x0 + i * dx, - y0 + j * dy, - z0 + (k + 1) * dz}; + IndexType nodeIDs[STRUCTURED_MAX_FACE_NODES] = {0}; + nodeIDs[0] = n0; + nodeIDs[1] = n0 + 1; + nodeIDs[2] = n0 + 1 + nodeKp; + nodeIDs[3] = n0 + nodeKp; + + double coords[3 * STRUCTURED_MAX_FACE_NODES] = {0.}; + coords[0] = x0 + i * dx; + coords[1] = y0 + j * dy; + coords[2] = z0 + k * dz; + coords[3] = x0 + (i + 1) * dx; + coords[4] = y0 + j * dy; + coords[5] = z0 + k * dz; + coords[6] = x0 + (i + 1) * dx; + coords[7] = y0 + j * dy; + coords[8] = z0 + (k + 1) * dz; + coords[9] = x0 + i * dx; + coords[10] = y0 + j * dy; + coords[11] = z0 + (k + 1) * dz; numerics::Matrix coordsMatrix(dimension, 4, coords, NO_COPY); kernel(faceID, coordsMatrix, nodeIDs); @@ -624,20 +650,25 @@ inline void for_all_faces_impl(xargs::coords, const UniformMesh& m, KernelType&& m, AXOM_LAMBDA(IndexType faceID, IndexType i, IndexType j, IndexType k) { const IndexType n0 = i + j * nodeJp + k * nodeKp; - const IndexType nodeIDs[4] = {n0, n0 + 1, n0 + 1 + nodeJp, n0 + nodeJp}; - - double coords[12] = {x0 + i * dx, - y0 + j * dy, - z0 + k * dz, - x0 + (i + 1) * dx, - y0 + j * dy, - z0 + k * dz, - x0 + (i + 1) * dx, - y0 + (j + 1) * dy, - z0 + k * dz, - x0 + i * dx, - y0 + (j + 1) * dy, - z0 + k * dz}; + IndexType nodeIDs[STRUCTURED_MAX_FACE_NODES] = {0}; + nodeIDs[0] = n0; + nodeIDs[1] = n0 + 1; + nodeIDs[2] = n0 + 1 + nodeJp; + nodeIDs[3] = n0 + nodeJp; + + double coords[3 * STRUCTURED_MAX_FACE_NODES] = {0.}; + coords[0] = x0 + i * dx; + coords[1] = y0 + j * dy; + coords[2] = z0 + k * dz; + coords[3] = x0 + (i + 1) * dx; + coords[4] = y0 + j * dy; + coords[5] = z0 + k * dz; + coords[6] = x0 + (i + 1) * dx; + coords[7] = y0 + (j + 1) * dy; + coords[8] = z0 + k * dz; + coords[9] = x0 + i * dx; + coords[10] = y0 + (j + 1) * dy; + coords[11] = z0 + k * dz; numerics::Matrix coordsMatrix(dimension, 4, coords, NO_COPY); kernel(faceID, coordsMatrix, nodeIDs); @@ -681,9 +712,15 @@ inline void for_all_faces_impl(xargs::coords, const RectilinearMesh& m, KernelTy m, AXOM_LAMBDA(IndexType faceID, IndexType i, IndexType j) { const IndexType n0 = i + j * nodeJp; - const IndexType nodeIDs[2] = {n0, n0 + nodeJp}; + IndexType nodeIDs[STRUCTURED_MAX_FACE_NODES] = {0}; + nodeIDs[0] = n0; + nodeIDs[1] = n0 + nodeJp; - double coords[4] = {x_vals_view[i], y_vals_view[j], x_vals_view[i], y_vals_view[j + 1]}; + double coords[3 * STRUCTURED_MAX_FACE_NODES] = {0.}; + coords[0] = x_vals_view[i]; + coords[1] = y_vals_view[j]; + coords[2] = x_vals_view[i]; + coords[3] = y_vals_view[j + 1]; numerics::Matrix coordsMatrix(dimension, 2, coords, NO_COPY); kernel(faceID, coordsMatrix, nodeIDs); @@ -694,9 +731,15 @@ inline void for_all_faces_impl(xargs::coords, const RectilinearMesh& m, KernelTy m, AXOM_LAMBDA(IndexType faceID, IndexType i, IndexType j) { const IndexType n0 = i + j * nodeJp; - const IndexType nodeIDs[2] = {n0, n0 + 1}; + IndexType nodeIDs[STRUCTURED_MAX_FACE_NODES] = {0}; + nodeIDs[0] = n0; + nodeIDs[1] = n0 + 1; - double coords[4] = {x_vals_view[i], y_vals_view[j], x_vals_view[i + 1], y_vals_view[j]}; + double coords[3 * STRUCTURED_MAX_FACE_NODES] = {0.}; + coords[0] = x_vals_view[i]; + coords[1] = y_vals_view[j]; + coords[2] = x_vals_view[i + 1]; + coords[3] = y_vals_view[j]; numerics::Matrix coordsMatrix(dimension, 2, coords, NO_COPY); kernel(faceID, coordsMatrix, nodeIDs); @@ -718,20 +761,25 @@ inline void for_all_faces_impl(xargs::coords, const RectilinearMesh& m, KernelTy m, AXOM_LAMBDA(IndexType faceID, IndexType i, IndexType j, IndexType k) { const IndexType n0 = i + j * nodeJp + k * nodeKp; - const IndexType nodeIDs[4] = {n0, n0 + nodeKp, n0 + nodeJp + nodeKp, n0 + nodeJp}; - - double coords[12] = {x_vals_view[i], - y_vals_view[j], - z_vals_view[k], - x_vals_view[i], - y_vals_view[j], - z_vals_view[k + 1], - x_vals_view[i], - y_vals_view[j + 1], - z_vals_view[k + 1], - x_vals_view[i], - y_vals_view[j + 1], - z_vals_view[k]}; + IndexType nodeIDs[STRUCTURED_MAX_FACE_NODES] = {0}; + nodeIDs[0] = n0; + nodeIDs[1] = n0 + nodeKp; + nodeIDs[2] = n0 + nodeJp + nodeKp; + nodeIDs[3] = n0 + nodeJp; + + double coords[3 * STRUCTURED_MAX_FACE_NODES] = {0.}; + coords[0] = x_vals_view[i]; + coords[1] = y_vals_view[j]; + coords[2] = z_vals_view[k]; + coords[3] = x_vals_view[i]; + coords[4] = y_vals_view[j]; + coords[5] = z_vals_view[k + 1]; + coords[6] = x_vals_view[i]; + coords[7] = y_vals_view[j + 1]; + coords[8] = z_vals_view[k + 1]; + coords[9] = x_vals_view[i]; + coords[10] = y_vals_view[j + 1]; + coords[11] = z_vals_view[k]; numerics::Matrix coordsMatrix(dimension, 4, coords, NO_COPY); kernel(faceID, coordsMatrix, nodeIDs); @@ -742,20 +790,25 @@ inline void for_all_faces_impl(xargs::coords, const RectilinearMesh& m, KernelTy m, AXOM_LAMBDA(IndexType faceID, IndexType i, IndexType j, IndexType k) { const IndexType n0 = i + j * nodeJp + k * nodeKp; - const IndexType nodeIDs[4] = {n0, n0 + 1, n0 + 1 + nodeKp, n0 + nodeKp}; - - double coords[12] = {x_vals_view[i], - y_vals_view[j], - z_vals_view[k], - x_vals_view[i + 1], - y_vals_view[j], - z_vals_view[k], - x_vals_view[i + 1], - y_vals_view[j], - z_vals_view[k + 1], - x_vals_view[i], - y_vals_view[j], - z_vals_view[k + 1]}; + IndexType nodeIDs[STRUCTURED_MAX_FACE_NODES] = {0}; + nodeIDs[0] = n0; + nodeIDs[1] = n0 + 1; + nodeIDs[2] = n0 + 1 + nodeKp; + nodeIDs[3] = n0 + nodeKp; + + double coords[3 * STRUCTURED_MAX_FACE_NODES] = {0.}; + coords[0] = x_vals_view[i]; + coords[1] = y_vals_view[j]; + coords[2] = z_vals_view[k]; + coords[3] = x_vals_view[i + 1]; + coords[4] = y_vals_view[j]; + coords[5] = z_vals_view[k]; + coords[6] = x_vals_view[i + 1]; + coords[7] = y_vals_view[j]; + coords[8] = z_vals_view[k + 1]; + coords[9] = x_vals_view[i]; + coords[10] = y_vals_view[j]; + coords[11] = z_vals_view[k + 1]; numerics::Matrix coordsMatrix(dimension, 4, coords, NO_COPY); kernel(faceID, coordsMatrix, nodeIDs); @@ -766,20 +819,25 @@ inline void for_all_faces_impl(xargs::coords, const RectilinearMesh& m, KernelTy m, AXOM_LAMBDA(IndexType faceID, IndexType i, IndexType j, IndexType k) { const IndexType n0 = i + j * nodeJp + k * nodeKp; - const IndexType nodeIDs[4] = {n0, n0 + 1, n0 + 1 + nodeJp, n0 + nodeJp}; - - double coords[12] = {x_vals_view[i], - y_vals_view[j], - z_vals_view[k], - x_vals_view[i + 1], - y_vals_view[j], - z_vals_view[k], - x_vals_view[i + 1], - y_vals_view[j + 1], - z_vals_view[k], - x_vals_view[i], - y_vals_view[j + 1], - z_vals_view[k]}; + IndexType nodeIDs[STRUCTURED_MAX_FACE_NODES] = {0}; + nodeIDs[0] = n0; + nodeIDs[1] = n0 + 1; + nodeIDs[2] = n0 + 1 + nodeJp; + nodeIDs[3] = n0 + nodeJp; + + double coords[3 * STRUCTURED_MAX_FACE_NODES] = {0.}; + coords[0] = x_vals_view[i]; + coords[1] = y_vals_view[j]; + coords[2] = z_vals_view[k]; + coords[3] = x_vals_view[i + 1]; + coords[4] = y_vals_view[j]; + coords[5] = z_vals_view[k]; + coords[6] = x_vals_view[i + 1]; + coords[7] = y_vals_view[j + 1]; + coords[8] = z_vals_view[k]; + coords[9] = x_vals_view[i]; + coords[10] = y_vals_view[j + 1]; + coords[11] = z_vals_view[k]; numerics::Matrix coordsMatrix(dimension, 4, coords, NO_COPY); kernel(faceID, coordsMatrix, nodeIDs); @@ -811,15 +869,17 @@ inline void for_all_faces_impl(xargs::coords, const CurvilinearMesh& m, KernelTy const int dimension = m.getDimension(); if(dimension == 2) { - for_all_coords(for_all_face_nodes_functor(), - m, - std::forward(kernel)); + for_all_coords( + for_all_face_nodes_functor(), + m, + std::forward(kernel)); } else { - for_all_coords(for_all_face_nodes_functor(), - m, - std::forward(kernel)); + for_all_coords( + for_all_face_nodes_functor(), + m, + std::forward(kernel)); } } @@ -856,7 +916,7 @@ inline void for_all_faces_impl(xargs::coords, const UnstructuredMesh& m, K xargs::nodeids(), m, AXOM_LAMBDA(IndexType faceID, const IndexType* nodeIDs, IndexType numNodes) { - double coords[2 * MAX_FACE_NODES]; + double coords[3 * MAX_FACE_NODES] = {0.}; for(int i = 0; i < numNodes; ++i) { const IndexType nodeID = nodeIDs[i]; @@ -883,7 +943,7 @@ inline void for_all_faces_impl(xargs::coords, const UnstructuredMesh& m, K xargs::nodeids(), m, AXOM_LAMBDA(IndexType faceID, const IndexType* nodeIDs, IndexType numNodes) { - double coords[3 * MAX_FACE_NODES]; + double coords[3 * MAX_FACE_NODES] = {0.}; for(int i = 0; i < numNodes; ++i) { const IndexType nodeID = nodeIDs[i]; diff --git a/src/axom/mint/execution/internal/helpers.hpp b/src/axom/mint/execution/internal/helpers.hpp index af65d10b04..bcd5fbd4a7 100644 --- a/src/axom/mint/execution/internal/helpers.hpp +++ b/src/axom/mint/execution/internal/helpers.hpp @@ -40,7 +40,7 @@ namespace internal * */ -template +template inline void for_all_coords(const FOR_ALL_FUNCTOR& for_all_nodes, const MeshType& m, KernelType&& kernel) { SLIC_ERROR_IF(m.getMeshType() == STRUCTURED_UNIFORM_MESH, "Not valid for UniformMesh."); @@ -48,6 +48,7 @@ inline void for_all_coords(const FOR_ALL_FUNCTOR& for_all_nodes, const MeshType& AXOM_STATIC_ASSERT_MSG(NDIM >= 1 && NDIM <= 3, "NDIM must be a valid dimension."); AXOM_STATIC_ASSERT_MSG(NNODES > 0, "NNODES must be greater than zero."); + AXOM_STATIC_ASSERT_MSG(MAX_NODES >= NNODES, "MAX_NODES must cover the active node count."); constexpr bool valid_mesh_type = std::is_base_of::value; AXOM_STATIC_ASSERT(valid_mesh_type); @@ -88,7 +89,7 @@ inline void for_all_coords(const FOR_ALL_FUNCTOR& for_all_nodes, const MeshType& AXOM_UNUSED_VAR(numNodes); assert(numNodes == NNODES); - double localCoords[NDIM * NNODES]; + double localCoords[NDIM * MAX_NODES] = {0.}; for(int i = 0; i < NNODES; ++i) { const int i_offset = NDIM * i; diff --git a/src/axom/mint/mesh/Mesh.hpp b/src/axom/mint/mesh/Mesh.hpp index edb2cb7e07..676a23fbaf 100644 --- a/src/axom/mint/mesh/Mesh.hpp +++ b/src/axom/mint/mesh/Mesh.hpp @@ -857,14 +857,19 @@ inline bool Mesh::hasSidreGroup() const //------------------------------------------------------------------------------ inline const FieldData* Mesh::getFieldData(int association) const { - SLIC_ERROR_IF(association < 0 || association >= NUM_FIELD_ASSOCIATIONS, - "invalid field association [" << association << "]"); - SLIC_ERROR_IF(m_mesh_fields[association] == nullptr, + if(association < 0 || association >= NUM_FIELD_ASSOCIATIONS) + { + SLIC_ERROR("invalid field association [" << association << "]"); + return nullptr; + } + + const FieldData* field_data = m_mesh_fields[association]; + SLIC_ERROR_IF(field_data == nullptr, "null field data object w/association [" << association << "]"); SLIC_ERROR_IF(m_type == PARTICLE_MESH && association != NODE_CENTERED, "a particle mesh may only store node-centered fields"); - return m_mesh_fields[association]; + return field_data; } //------------------------------------------------------------------------------ diff --git a/src/axom/quest/PointInCell.hpp b/src/axom/quest/PointInCell.hpp index 5023596c7f..00a28235ff 100644 --- a/src/axom/quest/PointInCell.hpp +++ b/src/axom/quest/PointInCell.hpp @@ -189,21 +189,39 @@ class PointInCell { SLIC_ASSERT(pos != nullptr); + const int dim = m_meshWrapper.meshDimension(); IndexType cellIndex = MeshTraits::NO_CELL; + double posBuffer[3] = {0., 0., 0.}; + double isoparBuffer[3] = {0., 0., 0.}; - switch(m_meshWrapper.meshDimension()) + // Stage raw coordinates through local 3-entry buffers before the dimension switch, then + // copy back only the active prefix. + for(int i = 0; i < dim; ++i) + { + posBuffer[i] = pos[i]; + } + + switch(dim) { case 2: - cellIndex = m_pointFinder2D->locatePoint(pos, isopar); + cellIndex = m_pointFinder2D->locatePoint(posBuffer, isopar != nullptr ? isoparBuffer : nullptr); break; case 3: - cellIndex = m_pointFinder3D->locatePoint(pos, isopar); + cellIndex = m_pointFinder3D->locatePoint(posBuffer, isopar != nullptr ? isoparBuffer : nullptr); break; default: SLIC_ERROR("Point in Cell query only defined for 2D or 3D meshes."); break; } + if(isopar != nullptr) + { + for(int i = 0; i < dim; ++i) + { + isopar[i] = isoparBuffer[i]; + } + } + return cellIndex; } diff --git a/src/axom/quest/detail/PointInCellMeshWrapper_mfem.hpp b/src/axom/quest/detail/PointInCellMeshWrapper_mfem.hpp index 4651f0e8fe..11ba8de087 100644 --- a/src/axom/quest/detail/PointInCellMeshWrapper_mfem.hpp +++ b/src/axom/quest/detail/PointInCellMeshWrapper_mfem.hpp @@ -290,7 +290,14 @@ class PointInCellMeshWrapper m_mesh->GetElementTransformation(eltIdx, &tr); mfem::IntegrationPoint ip; - ip.Set(isopar, dim); + // MFEM's IntegrationPoint::Set/Get touch a 3-entry buffer even for 2D elements. + // Stage 2D isoparametric coordinates through a local 3-vector before copying the active prefix. + double mfemIsopar[3] = {0., 0., 0.}; + for(int i = 0; i < dim; ++i) + { + mfemIsopar[i] = isopar[i]; + } + ip.Set(mfemIsopar, dim); mfem::Vector v(pt, dim); tr.Transform(ip, v); @@ -328,7 +335,12 @@ class PointInCellMeshWrapper // Status codes: {0 -> successful; 1 -> outside elt; 2-> did not converge} int err = invTrans.Transform(ptSpace, ipRef); - ipRef.Get(isopar, dim); + double mfemIsopar[3] = {0., 0., 0.}; + ipRef.Get(mfemIsopar, dim); + for(int i = 0; i < dim; ++i) + { + isopar[i] = mfemIsopar[i]; + } return (err == 0); } diff --git a/src/axom/slam/tests/slam_make_helpers.cpp b/src/axom/slam/tests/slam_make_helpers.cpp index fcef536507..d2f0fa28dd 100644 --- a/src/axom/slam/tests/slam_make_helpers.cpp +++ b/src/axom/slam/tests/slam_make_helpers.cpp @@ -255,7 +255,6 @@ TEST(slam_make_helpers, make_constant_relation_rejects_undersized_indices) // A stride-2 constant relation over a size-3 from-set needs 6 indices but we supply 4 here. Pos indices[4] = {0, 1, 2, 3}; - EXPECT_DEATH_IF_SUPPORTED(slam::make_constant_relation(&fromSet, &toSet, Pos {2}, indices, Pos {4}), ""); #else