Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

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.

Integrating over a portion of a 3D domain?

Please login with a confirmed email address before reporting spam

Is it possible to integrate over a portion of a 3D domain? I can easily integrate over a whole domain, but if I want a small section of a domain, is there an easy way to do this? I'm working with the Wave Optics module if that matters and am looking for a way to integrate the total power dissipation density at the end of my structure.

7 Replies Last Post 2015年9月16日 GMT-4 08:17
Jeff Hiller COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 2015年9月14日 GMT-4 17:22
For best accuracy, we recommend adding a domain to your geometry to coincide with the region over which you want to integrate.

If it is not possible to add such a region and high accuracy is not crucial, integrate over a larger domain while using a boolean expression in your integrand.
Jeff
For best accuracy, we recommend adding a domain to your geometry to coincide with the region over which you want to integrate. If it is not possible to add such a region and high accuracy is not crucial, integrate over a larger domain while using a boolean expression in your integrand. Jeff

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 2015年9月15日 GMT-4 10:41
Is it possible to add a domain after the calculation has completed? This integration wasn't originally planned for, and I would like to avoid having to rerun my models if that's possible.

I'll also have to look into how to add a boolean to the integrand. That's new territory for me.

Thanks,
Paul
Is it possible to add a domain after the calculation has completed? This integration wasn't originally planned for, and I would like to avoid having to rerun my models if that's possible. I'll also have to look into how to add a boolean to the integrand. That's new territory for me. Thanks, Paul

Henrik Sönnerlind COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 2015年9月15日 GMT-4 11:28
Hi,

Say that you want to integrate u^2 but not over the whole domain. You only want the integration where X>17 and Y<4711. Then you can integrate the expression

(X>17)*(Y<4711)*u^2

The logical expressions evaluate to either 1 or 0.

Regards,
Henrik
Hi, Say that you want to integrate u^2 but not over the whole domain. You only want the integration where X>17 and Y17)*(Y

Edgar J. Kaiser Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 2015年9月15日 GMT-4 11:32
Hi Jeff, Henrik,

in which way is using the boolean expression in the integrand affecting precision?

Cheers
Edgar

--
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Hi Jeff, Henrik, in which way is using the boolean expression in the integrand affecting precision? Cheers Edgar -- Edgar J. Kaiser emPhys Physical Technology http://www.emphys.com

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 2015年9月15日 GMT-4 11:39
Henrik,

That makes that nice and simple! Thank you.

Paul
Henrik, That makes that nice and simple! Thank you. Paul

Jeff Hiller COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 2015年9月15日 GMT-4 20:51
Hello Edgar,
When carrying out numerical integration by Gaussian quadrature, if you use the boolean expression approach instead of the separate domain approach you're putting yourself at the mercy of elements that sit on both sides of the boolean condition: how many of their quadrature points are on each side and what their weights are is rather unpredictable.

Example: Set up a Laplace equation model on the canonical square [0,1]x[0,1], so that the solution is u=1. Mesh it with a single rectangular element. COMSOL captures the trivial solution perfectly, of course. But compute the integral of u over [0,.6]x[0,1] using the boolean approach and you'll get ~.722 because of where the Gauss points are and of their weights. ( As a side note, if you reduce the quadrature order from the default 4 to 3, you'll get .5 because then half the Gauss points and half the weights sit on each side of the x=.6 line).
On the other hand, if you split the domain into two at x=.6, you'll get the correct solution: .6.
Jeff
Hello Edgar, When carrying out numerical integration by Gaussian quadrature, if you use the boolean expression approach instead of the separate domain approach you're putting yourself at the mercy of elements that sit on both sides of the boolean condition: how many of their quadrature points are on each side and what their weights are is rather unpredictable. Example: Set up a Laplace equation model on the canonical square [0,1]x[0,1], so that the solution is u=1. Mesh it with a single rectangular element. COMSOL captures the trivial solution perfectly, of course. But compute the integral of u over [0,.6]x[0,1] using the boolean approach and you'll get ~.722 because of where the Gauss points are and of their weights. ( As a side note, if you reduce the quadrature order from the default 4 to 3, you'll get .5 because then half the Gauss points and half the weights sit on each side of the x=.6 line). On the other hand, if you split the domain into two at x=.6, you'll get the correct solution: .6. Jeff

Edgar J. Kaiser Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 2015年9月16日 GMT-4 08:17
Hi Jeff,

thanks for the explanation. So, small domains with few inner and relatively many edge (at the boolean edge) elements are more susceptible to this kind of numerical error.

Cheers
Edgar

--
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Hi Jeff, thanks for the explanation. So, small domains with few inner and relatively many edge (at the boolean edge) elements are more susceptible to this kind of numerical error. Cheers Edgar -- Edgar J. Kaiser emPhys Physical Technology http://www.emphys.com

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.