How can I plot an element table with averaged values in PyMAPDL?
Mike Rife
Member, Employee Posts: 52
✭✭✭✭
PyVista has a method to convert cell data (one value per element) to point data (averaged value at nodes). The example is a solid mesh of a short stubby beam; and skipping the modeling and solution:
import matplotlib as mpl cmap1 = (mpl.colors.ListedColormap(['blue','royalblue', 'cyan', '#00FA9A','#7CFC00', '#ADFF2F','yellow', 'orange','red']) .with_extremes()) mapdl.post1() mapdl.set('last') mapdl.etable('sy','s','y') mapdl.view(1,1,1,1) cmd = ''' /show,png pletab,sy pletab,sy,avg /show /replot ''' _ = mapdl.run_multiline(cmd) cell_data = mapdl.pretab('sy').to_list() cell_sy = [] for item in cell_data: cell_sy.append(item[1]) mesh = mapdl.mesh.grid mesh["StressY"] = cell_sy mesh.plot(scalars = "StressY", cpos = 'iso', cmap = cmap1) mesh2 = mesh.cell_data_to_point_data() mesh2.plot(scalars = 'StressY', cpos = 'iso', cmap = cmap1)
The aveaged Etable Plot:
And the PyVista version:
Pretty close! Mike
Tagged:
0
Best Answer
-
@Mike Rife Nice example! Would you write it up as a blog for the portal?
0