# Average stress for element set

Is it possible in CalculiX to obtain a single average stress value for an element set (average max principal, or average Szz for instance)?

Thereâs no such built-in option in CalculiX (and even in Abaqus). To do this you could use:

``````*EL PRINT, ELSET=âŚ
S
``````

and then average the values from the .dat file using a spreadsheet or another tool. Scripting could be useful too.

Averaging of stress and strain fields is sometimes needed when analyzing RVE models for example.

1 Like

Thank you @Calc_em! Scripting is certainly needed for element sets with large element numbers, and there may be multiple element sets as well. One down side of this approach may be the element size differences within the set. Larger elements will have less impact, so elements sizes need to be similar. Or maybe you can extract nodal coordinates and try to do an area averaged stress/strain calculation within the script. I think Ansys generates average stress output, but I am not sure about its specifics. I wish CalculiX had this functionality, it would be very useful.

Indeed, in such cases volume average is usually used. You can request the EVOL variable which will give you the volume of each element and then you just have to post-process the data properly.

Thanks for the EVOL info. My specific case is 2D, do we have a similar variable for element area?

In a 2D case, if you divide EVOL by thickness (or use unit thickness) you will get the area of the element.

You may use cgx. There you create a set of elements, select the dataset and entity you want to average and then you type

volu setname

You get the volume, the center of gravity and the averaged value.

Best regards,
Klaus

3 Likes

@klaus.wittig, I tried to apply this within a .fbd post-processing script where it reads both solution file .frd and inut file .inp. However, volu elementSet returns an error: âERROR: type:10 of elem:32 not known. Interrupt.â Does this approach work for interactive element selection in cgx post-processing?

My aim is to create the elements sets in a pre-processing .fbd script, write them to a file with send, include them in the input file .inp, then after solution, read solution file .frd and input file .inp by a post-processing .fbd file. Within the post-processing fdb file, I would like to obtain the average values for each element set and have them written to separate files with send command. Can this be done with cgx? Is it possible to store volu elementSet results in a variable and then have it written to a file? Or is there an alternate way of achieving the same end result?

Following are my example files.

rotating_annular_disk_axisymmetric_pre.fbd

``````#
## Rotating annular disk 2D axisymmetric analysis.
##
#

#
## Geometry.
#

valu ro 200 # Outer radius of the disk.
valu ri 100 # Inner radius of the disk.
valu h 5 # Width of the disk.

valu hh * 0.5 h # Half width of the disk.
valu mh * -0.5 h # Half width of the disk.

valu dy 8 # Division on x axis.
valu dx 64 # Division on z axis.

# Element type parameterization.
valu Etyp qu8cr

# Create nodes.
pnt p1 ro mh 0
pnt p2 ro hh 0
pnt p3 ri hh 0
pnt p4 ri mh 0

# Plot all nodes.
plot pa all

# Create line.
line L1 p1 p2 dy
line L2 p2 p3 dx
line L3 p3 p4 dy
line L4 p4 p1 dx
# Plot line
plus la all

# Create line set to be used in surface crreation.
seta sur_lines l L1 L2 L3 L4

# Create surface.
surf surf sur_lines

# Make sure that all surfaces share the common normal direction.
flip s1_surf auto

# Contain all surfaces in a set.
seta surf_all s all

# Plot all surfaces with IDs.
plus sa all

#
## Meshing.
#

# Element type is assigned to all entities.
elty all Etyp
# Mesh the geometry.
mesh all
# Mesh is plotted.
plot m all

# Select elements and export element set.
SETA elemLine l L3
SETA elems n elemLine
COMP elems u
SEND elems abq nam

# All nodes are stored in a set.
seta nodes n all
# Boundary condition nodes are selected from the all nodes and stored in a set.
enq nodes fix rec ri hh 0 0.001 a

# Node set containing boundary condition nodes are written to a file.
send fix abq nam

seta po l L1
comp po do
comp po do
send po abq sur

seta pi l L3
comp pi do
comp pi do
send pi abq sur

# Finite element model (nodes and elements) are written to a file.
send all abq

``````

rotating_annular_disk_axisymmetric.inp

``````*INCLUDE, INPUT=all.msh
*INCLUDE, INPUT=fix.nam
*INCLUDE, INPUT=po.sur
*INCLUDE, INPUT=pi.sur
*INCLUDE, INPUT=elems.nam

*BOUNDARY
Nfix,2,2

*MATERIAL,NAME=EL
*ELASTIC
2.1E5,.3
*DENSITY
8.304E-9

*SOLID SECTION,ELSET=Eall,MATERIAL=EL

**
*STEP
*STATIC
Spo, P, -143.24
Spi, P, 1e-5
Eall,CENTRIF,490000,0.,0.,0.,0.,1.,0.
*NODE PRINT,NSET=Nall
U
*EL PRINT,ELSET=Eall
S
*EL FILE
U,S
*END STEP
``````

rotating_annular_disk_axisymmetric_post.fbd

``````# Read the finite element solution data.

plot e Eelems

ds 2 e 3

volu Eelems

``````

You use an shell element type (qu8, or âtype 10â). The âvoluâ command works only with volume elements. If you need the area of the shell elements you may use the âareaâ command.

Best regards,
Klaus

Thank you @klaus.wittig. I tried area command before and it gave me this error: ERROR: set:Eelems does not contain faces. I wasnât sure of the best way to introduce faces in the post-processing session, but I just tried to read the pre-processing script in. It works only if the read order is result .frd first, input .inp second, and pre-processing script .fbd third.

rotating_annular_disk_axisymmetric_post.fbd

``````read rotating_annular_disk_axisymmetric.frd
plot e Eelems
ds 2 e 3
area Eelems
``````

Output

``````AREA:1.562500e+01  CENTER OF GRAVITY: 1.015625e+02 1.136868e-16 0.000000e+00 AVERAGE-VALUE:5.151725e+02

``````

Can I get this output string written to a file with cgx?

At the end of post-processing, maximum stress and area of the model are written to a text file.

to add the faces you just need to complete the set downwards:
comp setname do
area setname

To write the output to a file you need to activate the stack
stack on
area setname

To see the content of the stack
prnt st

How to deal with the content is a bit complicated.
Store the fourth value from the stack in a variable
valu stress pop 4

write to file with a system command like âechoâ or âprintfâ (linux)
sys echo stress > bla

Best regards,
Klaus

Thank you @mkraska and @klaus.wittig! I modified my script per your guidance and it works just fine. This is a very powerful and useful feature. Executing sys initially prompted a warning where manual input was requested: either s, c, or e. Entering e prevented future warnings. Below is my modified post-processing script.

rotating_annular_disk_axisymmetric_post.fbd

``````read rotating_annular_disk_axisymmetric.frd
ds 2 e 3
comp Eelems1 do
stack on
area Eelems1
prnt st
valu stress pop 5
sys echo stress > Eelems1.txt

comp Eelems3 do
area Eelems3
prnt st
valu stress pop 5
sys echo stress > Eelems3.txt
``````

Kind regards
SĂźleyman