Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Averaging only positive values of a parameter

Please login with a confirmed email address before reporting spam

Hello everyone,

I have a question about post processing:
Is it possible to only average the positive (or negative) values of a parameter over a surface?
For example, in my special case, I have a 3D velocity field on a cut plane which in some areas of this plane goes into positive and in some areas goes into negative x, y, and z-direction.
Now I want to determine the average velocity only in positive x-direction and neglect the negative values.
I know how to integrate or average a parameter with "Global Evaluation" -> "Surface Average" etc., but do not know how to express, that only the positive values (like u>0) shall be evaluated.
Mayby it is quite simple, but I don't see it.

Thank you in advance for any suggestions.

Best Regards
Markus

2 Replies Last Post Aug 3, 2017, 4:32 a.m. EDT
Jeff Hiller COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 7 years ago Jul 28, 2017, 9:46 a.m. EDT
Updated: 7 years ago Jul 28, 2017, 4:30 p.m. EDT
Hi Markus,
In COMSOL, you can include boolean expressions in the expressions to integrate, so you can specify that you want to integrate
u*(u>0)
by typing that in the Expression field in your Surface Integral.
For the average, you can't simply type the expression above in the integration tool because that would return the integral of the positive part of u divided by the entire surface area (as opposed to divided by only the surface area of the part of the boundary where u is positive). A workaround is to integrate u*(u>0) and to divide the result by the integral of (u>0).
Best,
Jeff
Hi Markus, In COMSOL, you can include boolean expressions in the expressions to integrate, so you can specify that you want to integrate u*(u>0) by typing that in the Expression field in your Surface Integral. For the average, you can't simply type the expression above in the integration tool because that would return the integral of the positive part of u divided by the entire surface area (as opposed to divided by only the surface area of the part of the boundary where u is positive). A workaround is to integrate u*(u>0) and to divide the result by the integral of (u>0). Best, Jeff

Please login with a confirmed email address before reporting spam

Posted: 7 years ago Aug 3, 2017, 4:32 a.m. EDT
Thank You very much, Jeff! This is exactly what I needed.
What would be the right expression in the surface integration tool, if I wanted to calculate the mass flow in positive x-direction? spf.rho*(u*(u>0)*nx) or spf.rho*(u*(u>0)) do not work.
Is it maybe not possible to do this in a single calulation step directly in the Integration tool and I have to calculate the integral of u*(u>0) and then multiply this by spf.rho afterwards?
Thanks in advance
Markus
Thank You very much, Jeff! This is exactly what I needed. What would be the right expression in the surface integration tool, if I wanted to calculate the mass flow in positive x-direction? spf.rho*(u*(u>0)*nx) or spf.rho*(u*(u>0)) do not work. Is it maybe not possible to do this in a single calulation step directly in the Integration tool and I have to calculate the integral of u*(u>0) and then multiply this by spf.rho afterwards? Thanks in advance Markus

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.