From 8e98132d46e0ccb7625be11448a1c0705bae4993 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Sat, 7 Sep 2024 16:07:39 -0600 Subject: [PATCH 1/6] add debug printing to output --- src/deck.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/deck.cpp b/src/deck.cpp index d455f25..34b34d3 100644 --- a/src/deck.cpp +++ b/src/deck.cpp @@ -552,6 +552,7 @@ struct ElementSolidSection : public ElementSection { } // for each cell + std::cout << "cell array size: " << c << std::endl; NDArray cells_arr = WrapNDarray(cells, {c}); return nb::make_tuple(cells_arr, offsets_arr, celltypes_arr); } // to vtk @@ -865,7 +866,7 @@ NB_MODULE(_deck, m) { .def(nb::init()) .def("__repr__", &ElementSolidSection::ToString) .def("__len__", &ElementSolidSection::Length) - .def("to_vtk", &ElementSolidSection::ToVTK, nb::rv_policy::automatic) + .def("to_vtk", &ElementSolidSection::ToVTK) .def_ro("eid", &ElementSolidSection::eid, nb::rv_policy::automatic) .def_ro("pid", &ElementSolidSection::pid, nb::rv_policy::automatic) .def_ro("node_ids", &ElementSolidSection::node_ids, @@ -877,7 +878,7 @@ NB_MODULE(_deck, m) { .def(nb::init()) .def("__repr__", &ElementShellSection::ToString) .def("__len__", &ElementShellSection::Length) - .def("to_vtk", &ElementShellSection::ToVTK, nb::rv_policy::automatic) + .def("to_vtk", &ElementShellSection::ToVTK) .def_ro("eid", &ElementShellSection::eid, nb::rv_policy::automatic) .def_ro("pid", &ElementShellSection::pid, nb::rv_policy::automatic) .def_ro("node_ids", &ElementShellSection::node_ids, From 0458a72f62cd510df1539d0f21a75eb06658a453 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Sat, 7 Sep 2024 17:01:37 -0600 Subject: [PATCH 2/6] debug commit --- src/deck.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/deck.cpp b/src/deck.cpp index 34b34d3..583d763 100644 --- a/src/deck.cpp +++ b/src/deck.cpp @@ -552,8 +552,7 @@ struct ElementSolidSection : public ElementSection { } // for each cell - std::cout << "cell array size: " << c << std::endl; - NDArray cells_arr = WrapNDarray(cells, {c}); + c = 18 NDArray cells_arr = WrapNDarray(cells, {c}); return nb::make_tuple(cells_arr, offsets_arr, celltypes_arr); } // to vtk }; From 4d5ca5774a8f237ff66b3ede326e8b42adba6267 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Sat, 7 Sep 2024 17:02:18 -0600 Subject: [PATCH 3/6] debug commit --- src/deck.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/deck.cpp b/src/deck.cpp index 583d763..767472b 100644 --- a/src/deck.cpp +++ b/src/deck.cpp @@ -552,7 +552,8 @@ struct ElementSolidSection : public ElementSection { } // for each cell - c = 18 NDArray cells_arr = WrapNDarray(cells, {c}); + c = 18; + NDArray cells_arr = WrapNDarray(cells, {c}); return nb::make_tuple(cells_arr, offsets_arr, celltypes_arr); } // to vtk }; From 058061bab05d93f831525a631ae8008c37186e26 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Sat, 7 Sep 2024 17:05:48 -0600 Subject: [PATCH 4/6] throw on no elements --- src/deck.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/deck.cpp b/src/deck.cpp index 767472b..64e804b 100644 --- a/src/deck.cpp +++ b/src/deck.cpp @@ -508,6 +508,10 @@ struct ElementSolidSection : public ElementSection { NDArray offsets_arr = MakeNDArray({(int)(n_elem + 1)}); + if (n_elem == 0) { + throw std::runtime_error("No cells to map to VTK cell types."); + } + uint8_t *celltypes = celltypes_arr.data(); int64_t *offsets = offsets_arr.data(); int64_t *cells = AllocateArray(node_ids.size()); From 0a83b48b527f6cc0a9e25948ce2afcee2b19a4d2 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Sat, 7 Sep 2024 17:09:27 -0600 Subject: [PATCH 5/6] fix unitialized loop variable --- src/deck.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/deck.cpp b/src/deck.cpp index 64e804b..2e2bd13 100644 --- a/src/deck.cpp +++ b/src/deck.cpp @@ -522,7 +522,7 @@ struct ElementSolidSection : public ElementSection { int c = 0; offsets[0] = 0; uint8_t celltype = VTK_EMPTY_CELL; - for (int i; i < n_elem; i++) { + for (int i = 0; i < n_elem; i++) { int el_sz = 0; int offset = node_id_offsets_data[i]; @@ -556,7 +556,6 @@ struct ElementSolidSection : public ElementSection { } // for each cell - c = 18; NDArray cells_arr = WrapNDarray(cells, {c}); return nb::make_tuple(cells_arr, offsets_arr, celltypes_arr); } // to vtk From 5a5d3f91067c92e615bd2ff8526a1873ab9b928a Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Sat, 7 Sep 2024 17:14:33 -0600 Subject: [PATCH 6/6] fix unitialized loop variable again --- src/deck.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/deck.cpp b/src/deck.cpp index 2e2bd13..7e25245 100644 --- a/src/deck.cpp +++ b/src/deck.cpp @@ -588,7 +588,7 @@ struct ElementShellSection : public ElementSection { int c = 0; offsets[0] = 0; uint8_t celltype = VTK_EMPTY_CELL; - for (int i; i < n_elem; i++) { + for (int i = 0; i < n_elem; i++) { // determine if the cell is a quad or triangle int offset = node_id_offsets_data[i]; if (node_ids_data[offset + 2] == node_ids_data[offset + 3]) {