easy way to calculate an average value over a tagged mask?

Asked by Louise Olsen-Kettle

Is there an easy way to calculate the average stress over a tagged mask in eScript?

Tag_x_impact_output = whereZero(mesh[0]-R00)

stress00_nodes=proj(stress[0,0])

Normal_orthogonal_stress_xx_impact = Average of these values: stress00_nodes*Tag_x_impact_output

Any help would be appreciated, thanks, Louise

Question information

Language:
English Edit question
Status:
Solved
For:
esys-escript Edit question
Assignee:
No assignee Edit question
Solved by:
Lutz Gross
Solved:
Last query:
Last reply:
Revision history for this message
Best Lutz Gross (l-gross) said :
#1

I assume you want to do this for stress[0,0]:

If mask is the mask of the region you want to average over then

average=integrate(mask*stress[0,0])/integrate(mask)

make sure that mask is defined with Function(dom) attribute.

If you want to do this over a surface then mask needs to have the FunctionOnBoundary(dom) attribute and
you need to project back to FE nodes (stress00_nodes=proj(stress[0,0]))

Revision history for this message
Louise Olsen-Kettle (lokettle) said :
#2

Thanks Lutz Gross, that solved my question.