Skip to content

Commit

Permalink
forward declare elementsection
Browse files Browse the repository at this point in the history
  • Loading branch information
akaszynski committed Sep 6, 2024
1 parent b25f24a commit bcbc6f6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/testing-and-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

- uses: actions/upload-artifact@v4
with:
name: mapdl-archive-wheels-${{ matrix.os }}
name: lsdyna-mesh-reader-wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl

build_sdist:
Expand All @@ -46,7 +46,7 @@ jobs:
run: pipx run build --sdist

- name: Install from sdist
run: pip install dist/mapdl*.tar.gz
run: pip install dist/lsdyna*.tar.gz

- name: Run tests
run: |
Expand All @@ -55,7 +55,7 @@ jobs:
- uses: actions/upload-artifact@v4
with:
name: mapdl-archive-sdist
name: lsdyna-mesh-reader-sdist
path: dist/*.tar.gz

release:
Expand Down
7 changes: 4 additions & 3 deletions src/deck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
#include <vector>

#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
#include <nanobind/stl/string.h>
#include <nanobind/stl/unordered_map.h>
#include <nanobind/stl/vector.h>

#include "array_support.h"
Expand All @@ -34,6 +32,8 @@ using namespace nb::literals;
#define NNUM_RESERVE 16384
#define ENUM_RESERVE 16384

struct ElementSection;

static const double DIV_OF_TEN[] = {
1.0e-0, 1.0e-1, 1.0e-2, 1.0e-3, 1.0e-4, 1.0e-5, 1.0e-6,
1.0e-7, 1.0e-8, 1.0e-9, 1.0e-10, 1.0e-11, 1.0e-12, 1.0e-13,
Expand Down Expand Up @@ -632,6 +632,7 @@ NB_MODULE(_deck, m) {
.def_ro("node_sections", &Deck::node_sections)
.def_ro("element_solid_sections", &Deck::element_solid_sections)
.def("read_line", &Deck::ReadLine)
.def("read_element_section", &Deck::ReadElementSolidSection)
.def("read_element_solid_section", &Deck::ReadElementSolidSection)
// .def("read_element_beam_section", &Deck::ReadElementBeamSection)
.def("read_node_section", &Deck::ReadNodeSection);
}
2 changes: 1 addition & 1 deletion src/lsdyna_mesh_reader/_deck.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ class Deck:
@property
def element_solid_sections(self) -> List[ElementSection]: ...
def read_line(self) -> int: ...
def read_element_section(self) -> None: ...
def read_element_solid_section(self) -> None: ...
def read_node_section(self) -> None: ...
26 changes: 24 additions & 2 deletions tests/test_deck.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ def test_node_section(tmp_path: Path) -> None:
assert np.allclose(node_section.rc, [0, 3, 4, 0, 0])


def test_element_section(tmp_path: Path) -> None:
def test_element_solid_section(tmp_path: Path) -> None:
filename = str(tmp_path / "tmp.k")
with open(filename, "w") as fid:
fid.write(ELEMENT_SECTION)

deck = Deck(filename)
deck.read_line()
deck.read_element_section()
deck.read_element_solid_section()

assert len(deck.element_solid_sections) == 1
element_section = deck.element_solid_sections[0]
Expand All @@ -81,3 +81,25 @@ def test_element_section(tmp_path: Path) -> None:

offsets = np.cumsum([0] + [len(element) for element in ELEMENT_SECTION_ELEMS])
assert np.allclose(element_section.node_id_offsets, offsets)


# def test_element_beam_section(tmp_path: Path) -> None:
# filename = str(tmp_path / "tmp.k")
# with open(filename, "w") as fid:
# fid.write(ELEMENT_SECTION)

# deck = Deck(filename)
# deck.read_line()
# deck.read_element_beam_section()

# assert len(deck.element_beam_sections) == 1
# element_section = deck.element_beam_sections[0]

# assert "ElementBeam containing 5 elements" in str(element_section)

# assert np.allclose(element_section.eid, range(1, 6))
# assert np.allclose(element_section.pid, [1] * 5)
# assert np.allclose(element_section.node_ids, np.array(ELEMENT_SECTION_ELEMS).ravel())

# offsets = np.cumsum([0] + [len(element) for element in ELEMENT_SECTION_ELEMS])
# assert np.allclose(element_section.node_id_offsets, offsets)

0 comments on commit bcbc6f6

Please sign in to comment.