Skip to content

Fixing plotting elements with midnodes #1988

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

Merged
merged 6 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
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
14 changes: 10 additions & 4 deletions src/ansys/mapdl/core/mesh/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ def _parse_vtk(
tshape_label = SHAPE_MAP[tshape_num]
type_ref[etype_ind] = TARGE170_MAP.get(tshape_label, 0)

nodes, angles, nnum = mesh.nodes, mesh.node_angles, mesh.nnum

offset, celltypes, cells = _reader.ans_vtk_convert(
mesh._elem, mesh._elem_off, type_ref, mesh.nnum, True
mesh._elem, mesh._elem_off, type_ref, nnum, True
) # for reset_midside

nodes, angles, nnum = mesh.nodes, mesh.node_angles, mesh.nnum

# fix missing midside
if np.any(cells == -1):
if fix_midside:
Expand All @@ -158,7 +158,13 @@ def _parse_vtk(
grid = pv.UnstructuredGrid(offset, cells, celltypes, nodes, deep=True)

# Store original ANSYS element and node information
grid.point_data["ansys_node_num"] = nnum
try:
grid.point_data["ansys_node_num"] = nnum
except ValueError:
grid.point_data["ansys_node_num"] = (
mesh._mapdl.nlist(kinternal="internal").to_array()[:, 0].astype(np.int32)
)

grid.cell_data["ansys_elem_num"] = mesh.enum
grid.cell_data["ansys_real_constant"] = mesh.elem_real_constant
grid.cell_data["ansys_material_type"] = mesh.material_type
Expand Down
79 changes: 79 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,3 +869,82 @@ def contact_solve(mapdl):
mapdl.allsel()
mapdl.set("last")
mapdl.mute = False


@pytest.fixture(scope="function")
def cuadratic_beam_problem(mapdl):
mapdl.clear()

# Enter verification example mode and the pre-processing routine.
mapdl.prep7()

# Type of analysis: static.
mapdl.antype("STATIC")

# Element type: BEAM188.
mapdl.et(1, "BEAM188")

# Special Features are defined by keyoptions of beam element:

# KEYOPT(3)
# Shape functions along the length:
# Cubic
mapdl.keyopt(1, 3, 3) # Cubic shape function

# KEYOPT(9)
# Output control for values extrapolated to the element
# and section nodes:
# Same as KEYOPT(9) = 1 plus stresses and strains at all section nodes
mapdl.keyopt(1, 9, 3, mute=True)

mapdl.mp("EX", 1, 30e6)
mapdl.mp("PRXY", 1, 0.3)
print(mapdl.mplist())

w_f = 1.048394965
w_w = 0.6856481
sec_num = 1
mapdl.sectype(sec_num, "BEAM", "I", "ISection")
mapdl.secdata(15, 15, 28 + (2 * w_f), w_f, w_f, w_w)

# Define nodes
for node_num in range(1, 6):
mapdl.n(node_num, (node_num - 1) * 120, 0, 0)

# Define one node for the orientation of the beam cross-section.
orient_node = mapdl.n(6, 60, 1)

# Print the list of the created nodes.
print(mapdl.nlist())

for elem_num in range(1, 5):
mapdl.e(elem_num, elem_num + 1, orient_node)

# Print the list of the created elements.
print(mapdl.elist())

# Display elements with their nodes numbers.
mapdl.eplot(show_node_numbering=True, line_width=5, cpos="xy", font_size=40)

# BC for the beams seats
mapdl.d(2, "UX", lab2="UY")
mapdl.d(4, "UY")

# BC for all nodes of the beam
mapdl.nsel("S", "LOC", "Y", 0)
mapdl.d("ALL", "UZ")
mapdl.d("ALL", "ROTX")
mapdl.d("ALL", "ROTY")
mapdl.nsel("ALL")

# Parametrization of the distributed load.
w = 10000 / 12

# Application of the surface load to the beam element.
mapdl.sfbeam(1, 1, "PRES", w)
mapdl.sfbeam(4, 1, "PRES", w)
mapdl.finish()

mapdl.run("/SOLU")
mapdl.solve()
mapdl.finish()
11 changes: 11 additions & 0 deletions tests/test_mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1890,3 +1890,14 @@ def test_igesin_whitespace(mapdl, cleared, tmpdir):
out = mapdl.igesin(dest)
n_ent = re.findall(r"TOTAL NUMBER OF ENTITIES \s*=\s*(\d*)", out)
assert int(n_ent[0]) > 0


def test_cuadratic_beam(mapdl, cuadratic_beam_problem):
mapdl.post1()
mapdl.set(1)
assert (
mapdl.post_processing.plot_nodal_displacement(
"NORM", line_width=10, render_lines_as_tubes=True, smooth_shading=True
)
is None
)