Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Numerical integration over an arbitrary 2D domain

503 views
Skip to first unread message

Alfonso Pagani

unread,
Jul 1, 2012, 2:15:31 AM7/1/12
to
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

Alexei Boulbitch

unread,
Jul 2, 2012, 5:29:19 AM7/2/12
to
Hi, Alfonso,

Mathematica can solve multiple integrals, and there are function NIntegrate=
[ ] doing them numerically with a possibility to use various numeric metho=
ds and precisions. Check Menu/Help/NIntegrate.

You can, of course, also do a custom program, but I recommend to first try =
this function. If you already have done so and faced difficulties, post det=
ails of your integrand and domain. Otherwise your question is too general t=
o help you.

Have fun, Alexei


Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone : +352-2454-2566
Office fax: +352-2454-3566
mobile phone: +49 151 52 40 66 44

e-mail: alexei.b...@iee.lu<mailto:alexei.b...@iee.lu>

Fred Bartoli

unread,
Jul 2, 2012, 10:24:48 PM7/2/12
to
Alfonso Pagani a écrit :
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.

alfonso...@gmail.com

unread,
Jul 2, 2012, 10:16:09 PM7/2/12
to
Il giorno luned=EC 2 luglio 2012 11:29:19 UTC+2, Alexei Boulbitch ha scritt=
o:
> 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
>
>
> Hi, Alfonso,
>
> Mathematica can solve multiple integrals, and there are function NIntegra=
te=
> [ ] doing them numerically with a possibility to use various numeric met=
ho=
> ds and precisions. Check Menu/Help/NIntegrate.
>
> You can, of course, also do a custom program, but I recommend to first tr=
y =
> this function. If you already have done so and faced difficulties, post d=
et=
> ails of your integrand and domain. Otherwise your question is too general=
t=
> o help you.
>
> Have fun, Alexei
>
>
> Alexei BOULBITCH, Dr., habil.
> IEE S.A.
> ZAE Weiergewan,
> 11, rue Edmond Reuter,
> L-5326 Contern, LUXEMBOURG
>
> Office phone : +352-2454-2566
> Office fax: +352-2454-3566
> mobile phone: +49 151 52 40 66 44
>
> e-mail: alexei.b...@iee.lu<mailto:alexei.b...@iee.lu>

Hi Alexei,
thanks for your prompt answer.
Before posting my question I already checked NIntegrate.
Moreover I read "ADVANCED NUMERICAL INTEGRATION IN MATHEMATICA" from Wolfram Mathematica Tutorial Collection.
However I have not found yet the solution to my problem.
My integrands are the product of very simple functions of x and y.

Subscript[F[x_,y_],s]:=x^l y^m;

Where l and m depend on s. For the sake of simplicity, let F_1 and F_2 be as follows:

Subscript[F[x_,y_],1]:=x;
Subscript[F[x_,y_],2]:=y^2;

For example, if I had a rectangular integration domain I would write as follows:

Subscript[E,1,2] = Integrate[(Subscript[F, 1][x, y] Subscript[F, 2][x, y]), {x, -b/2, b/2}, {y, -h/2, h/2}]

The problem is that I need to integrate F_1 * F_2 over an arbitrary complex domain (such as a potato section!).
As a further complication, my domain could also be not simply connected.
Therefore I need necessarily to import my domain in Mathematica.
That's why my idea was to import a numerical mesh of the domain, ei to define my domain as composed by elementary (triangular) elements.

I hope I was sufficiently clear. Thank you for your help,

Alfonso

0 new messages