# How to define a plane region with polygonal boundaries for 2D integration?

Posted 9 years ago
5880 Views
|
7 Replies
|
2 Total Likes
|
 Hello Everyone,I calculated the charge density over a plane with a finite element method , so I get a function like sigma=f[x,y].Now I need to integrate the charge over a finite area (electrode) in order to calculate the collected charge by the electrode. The electrode has a closed polygonal contour like the example below: In[267]:= fff Out[267]= {{-6.17, -33.75}, {-9.35, -33.75}, {-9.35, -33.78}, {-9.35, \ -39.375}, {-9.35, -45.435}, {-9.35, -45.45}, {-9.22, -45.45}, {-9.22, \ -39.375}, {-6.17, -39.375}, {-6.17, -33.78}, {-6.17, -33.75}} I think need to define a Boole function that is True when a point {x,y} belongs to the interior of the closed polygonal contour in order to Integrate f[x,y] as showed in the On line help: Integrals over Regions This does an integral over the interior of the unit circle. In[1]:= Integrate[If[x^2 + y^2 < 1, 1, 0], {x, -1, 1}, {y, -1, 1}] Out[1]= \[Pi] Here is an equivalent form. In[2]:= Integrate[Boole[x^2 + y^2 < 1], {x, -1, 1}, {y, -1, 1}] Out[2]= \[Pi] So my question is: what is the simplest way to express the fact that the current point {x,y} is inside my polygonal region (can be non-convex) ?Thanks for your suggestionsChristian
7 Replies
Sort By:
Posted 9 years ago
 Thanks again guys, got V10 now, it's a dream!Christian
Posted 9 years ago
 Also in V10, Integrate[1, {x, y} \[Element] Polygon[points]] NIntegrate[Cos[x] Sin[y], {x, y} \[Element] Polygon[points]] 
Posted 9 years ago
 Hi Ilian,Thanks also for this other solution.And I thought Polygon was only a graphic primitive...:-)Definitively another good reason to switch to V10! *Christian*= incidentally i just got an upgrade proposal in my mailbox this morning :)
Posted 9 years ago
 Hi, Christian,If you have V10, then you can define more or less arbitrary regions, see documentation for ParametricRegion[] and ImplicitRegion[] as well. points = { {-6.17, -33.75}, {-9.35, -33.75}, {-9.35, -33.78}, {-9.35, -39.375}, {-9.35, -45.435}, {-9.35, -45.45}, {-9.22, -45.45}, {-9.22, -39.375}, {-6.17, -39.375}, {-6.17, -33.78}, {-6.17, -33.75} }; R = BoundaryMeshRegion[points, Line[{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1}]] Integrate[1, {x, y} \[Element] R] NIntegrate[Cos[x] Sin[y], {x, y} \[Element] R] I.M.
Posted 9 years ago
 Hi Ivan,Thanks for this tip! Great feature! I am currently working with a 8.04 but this is the opportunity to jump to V10!Christian
Posted 9 years ago
 In general I think you will have to break up the region into convex regions. I don't know if there is a routine that will triangulate it. Maybe if you gave a practical but more generic case?However, in the case you present it is quite simple. vertexPoints = {{-6.17, -33.75}, {-9.35, -33.75}, {-9.35, -33.78}, {-9.35, -39.375}, {-9.35, -45.435}, {-9.35, -45.45}, {-9.22, -45.45}, {-9.22, -39.375}, {-6.17, -39.375}, {-6.17, -33.78}, {-6.17, -33.75}}; which plots as: Graphics[ {Line[vertexPoints], AbsolutePointSize[5], Point /@ vertexPoints}, AspectRatio -> 1, PlotRange -> {{-10, -5}, {-50, -30}}, Frame -> True, ImageSize -> 300] The Boole function for the electrode region is given by: inElectrode[x_, y_] := (-9.35 <= x <= -6.17) \[And] (-39.735 <= y <= -33.78) \[Or] (-9.35 <= x <= -9.22) \[And] (-45.45 <= y <= -39.735) which plots as: RegionPlot[inElectrode[x, y], {x, -10, -5}, {y, -50, -30}, PlotPoints -> 30] 
Posted 9 years ago
 Thank you for the example David, I think you are right since at the present level of my design the electrodes are mostly built with a main rectangular collecting plate attached to a thin track, so every electrode can be partitioned exactly in two rectangles as you did. I think I'll try to build a routine to do the partitioning automatically because the rectangles are all parallel to axes. For the future I'll need to look for a more generic method because the more advanced designs of electrodes (which I am studying) will be more corrugated and extracted from CAD files (DXF) so I will have no clue to automatize the process. So I guess you suggestion of triangularization will be one good option (at least will allow automatic processing).Thanks again!Christian