Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Mac and Windows memory error #1

Merged
merged 6 commits into from
Sep 8, 2024
Merged
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
12 changes: 8 additions & 4 deletions src/deck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,10 @@ struct ElementSolidSection : public ElementSection {
NDArray<int64_t, 1> offsets_arr =
MakeNDArray<int64_t, 1>({(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<int64_t>(node_ids.size());
Expand All @@ -518,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];
Expand Down Expand Up @@ -584,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]) {
Expand Down Expand Up @@ -865,7 +869,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,
Expand All @@ -877,7 +881,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,
Expand Down
Loading