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

Post-processing not plotting results #2288

Closed
germa89 opened this issue Aug 31, 2023 · 2 comments · Fixed by #2295
Closed

Post-processing not plotting results #2288

germa89 opened this issue Aug 31, 2023 · 2 comments · Fixed by #2295

Comments

@germa89
Copy link
Collaborator

germa89 commented Aug 31, 2023

"""
.. _ref_tors_load:
==============================================
Torsional load on a bar using SURF154 elements
==============================================
This Ansys PyMAPDL script builds a bar and applies torque to it using
SURF154 elements. This is a static analysis example.
"""

##############################################################################
# Script initialization
# ---------------------

import os

import numpy as np

from ansys.mapdl.core import launch_mapdl

# start Ansys in the current working directory with default jobname "file"
mapdl = launch_mapdl(start_instance=False)


##############################################################################
# Define cylinder and mesh parameters

torque = 100
radius = 2
h_tip = 2
height = 20
elemsize = 0.5
pi = np.arccos(-1)
force = 100 / radius
pressure = force / (h_tip * 2 * np.pi * radius)

##############################################################################
# Model creation
# --------------

# Define higher-order SOLID186
# Define surface effect elements SURF154 to apply torque
# as a tangential pressure
mapdl.prep7()
mapdl.et(1, 186)
mapdl.et(2, 154)
mapdl.r(1)
mapdl.r(2)

##############################################################################
# Aluminum properties (or something)
mapdl.mp("ex", 1, 10e6)
mapdl.mp("nuxy", 1, 0.3)
mapdl.mp("dens", 1, 0.1 / 386.1)
mapdl.mp("dens", 2, 0)

# Simple cylinder
for i in range(4):
    mapdl.cylind(radius, "", "", height, 90 * (i - 1), 90 * i)

mapdl.nummrg("kp")

# interactive volume plot (optional)
mapdl.vplot()


##############################################################################
# Mesh cylinder
mapdl.lsel("s", "loc", "x", 0)
mapdl.lsel("r", "loc", "y", 0)
mapdl.lsel("r", "loc", "z", 0, height - h_tip)
mapdl.lesize("all", elemsize * 2)
mapdl.mshape(0)
mapdl.mshkey(1)
mapdl.esize(elemsize)
mapdl.allsel("all")
mapdl.vsweep("ALL")
mapdl.csys(1)
mapdl.asel("s", "loc", "z", "", height - h_tip + 0.0001)
mapdl.asel("r", "loc", "x", radius)
mapdl.local(11, 1)
mapdl.csys(0)
mapdl.aatt(2, 2, 2, 11)
mapdl.amesh("all")
mapdl.finish()

# plot elements
mapdl.eplot()

##############################################################################
# Solution
# --------

mapdl.slashsolu()  # Using Slash instead of / due to duplicate SOLU command
mapdl.antype("static", "new")
mapdl.eqslv("pcg", 1e-8)

# Apply tangential pressure
mapdl.esel("s", "type", "", 2)
mapdl.sfe("all", 2, "pres", "", pressure)

# Constrain bottom of cylinder/rod
mapdl.asel("s", "loc", "z", 0)
mapdl.nsla("s", 1)

mapdl.d("all", "all")
mapdl.allsel()
mapdl.psf("pres", "", 2)
mapdl.pbc("u", 1)
mapdl.solve()


##############################################################################
# Alternatively, you can access the same results directly from MAPDL
# using the :attr:`Mapdl.post_processing <ansys.mapdl.core.Mapdl.post_processing>`
# attribute:

# Enter post-processor
mapdl.post1()

mapdl.set(1, 1)
mapdl.post_processing.plot_nodal_displacement(cmap="bwr")
mapdl.post_processing.plot_nodal_component_stress("x", cmap="bwr")
mapdl.post_processing.plot_nodal_eqv_stress(cmap="bwr")

the plots are empty:

image
@germa89
Copy link
Collaborator Author

germa89 commented Aug 31, 2023

It seems the problem is with the masking in _plot_point_scalars.

mask = self.selected_nodes

@germa89
Copy link
Collaborator Author

germa89 commented Sep 1, 2023

It seems the problem is with the masking in _plot_point_scalars.

mask = self.selected_nodes

It is not that.... I think there is a miss matching between the UnstructuredGrid and the data returned by MAPDL.

For example:

>>> self._mapdl.mesh._surf # Used for plotting
PolyData (0x1628e8640)
  N Cells:    1272
  N Points:   714
  N Strips:   0
  X Bounds:   -2.000e+00, 2.000e+00
  Y Bounds:   -2.000e+00, 2.000e+00
  Z Bounds:   0.000e+00, 2.000e+01
  N Arrays:   11
>>> self._mapdl.mesh.grid # the real mesh?
UnstructuredGrid (0x162930b20)
  N Cells:    2080
  N Points:   7217
  X Bounds:   -2.000e+00, 2.000e+00
  Y Bounds:   -2.000e+00, 2.000e+00
  Z Bounds:   0.000e+00, 2.000e+01
  N Arrays:   10

surf is the "outlayer" of the plot. It is useful because it reduces its size. However, the data input in here is all the nodes.

Something is made here to match both. But probably is not longer valid since the latest PyVista changes. Probably because of changing the way the points/cells are ordered internally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant