Averaging element values (saved as Numpy array) at common nodes #2463
-
Hello, I have element values saved as numpy array. To plot the element values graphically, I have done something like this (thanks to @germa89 for input from a previous discussion)
Now I would like to average the values at the common nodes. Previously this is possible in APDL when using PLETAB, where one can choose to average at common nodes. Is there any pymapdl that can peform this? If not, any ideas on how i could do this? Arun |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
I'm not sure about his one. Pinging @mikerife for the MAPDL side and @AlejandroFernandezLuces for the pyvista side. To summarise you want to average the elements (cells) values in the nodes (points) and plot its results. However, I believe you could accomplish something similar by just using nodal values in the ...
import pyvista as pv
grid = mapdl.mesh._grid
nodal_values = mapdl.post_processing.nodal_displacement()
pl = pv.Plotter()
pl.add_mesh(grid, scalars = nodal_values, camp="bwr")
pl.show() |
Beta Was this translation helpful? Give feedback.
-
Hi @arun-maniam & @germa89 I was testing a simple model and the results looked good (except for derived). 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 two averaged plots are then: They are a little different but I'm not sure if the difference is much of an issue. Mike |
Beta Was this translation helpful? Give feedback.
I'm not sure about his one. Pinging @mikerife for the MAPDL side and @AlejandroFernandezLuces for the pyvista side.
To summarise you want to average the elements (cells) values in the nodes (points) and plot its results.
However, I believe you could accomplish something similar by just using nodal values in the
scalar
field inadd_mesh
, instead of using the elemental values. I do not think the nodal values are the average in the nodes of the elemental values (what you want), but, it should be close to, specially if the nodal values are elemental derived quantities (stresses, strains, etc)