Re: Numerical integration over an arbitrary 2D domain

• To: mathgroup at smc.vnet.net
• Subject: [mg127167] Re: Numerical integration over an arbitrary 2D domain
• From: Fred Bartoli <""@news.free.fr>
• Date: Mon, 2 Jul 2012 22:22:35 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• References: <jsopu3\$12g\$1@smc.vnet.net>

```Alfonso Pagani a écrit :
> Hi all,
> I am a new user of Wolfram Mathematica. I need to integrate
> (numerically of course) generic functions above complex 2D domains.
> For example, i would like to find the moments of inertia of an airfoil
> cross-section. Is it possible?
> My idea was to import a triangular mesh (list of nodes and element
> connectivity) of the integration domain. Then integrate my functions
> using a trapezoidal integration. How could i do this?
> Thank you very much,
>
> Alfonso
>

Alfonso,

No need to mess with that.
Just use a weighting function and then integrate the weighted function
over a simple rectangular region that contains all your shape:

(* First define the integrating region *)
weightFunc[x_, y_] =
Piecewise[{{1, x^2 + y^2 <= 2 && x >= 0}, {1,
y >= 0 && y <= Sqrt[2] (x + 1)^2 && x >= -1 && x <= 0}, {1,
y <= 0 && y >= -Sqrt[2] (x + 1) && x >= -1 && x <= 0}}, 0];

(* Then plot it and check its shape *)
toLogic[v_] = Switch[v, 1, True, 0, False];
RegionPlot[toLogic@weightFunc[x, y], {x, -2, 2}, {y, -2, 2}]

(* Finally integrate the moment inertia about the (1/2,0) point *)
NIntegrate[((x - 1/2)^2 + y^2) weightFunc[x, y], {x, -2, 2}, {y, -2,
2}]
Integrate[((x - 1/2)^2 + y^2) weightFunc[x, y], {x, -2, 2}, {y, -2, 2}]
N[% - %%]

--
Thanks,
Fred.

```

• Prev by Date: Re: How to rectify the error for NDSolve ?
• Next by Date: Re: An easier functional way to divide each Column of matrix by a
• Previous by thread: Re: Numerical integration over an arbitrary 2D domain
• Next by thread: Re: Numerical integration over an arbitrary 2D domain