1
$\begingroup$

I have been trying to integrate over a surface of a 3D Mesh. The sample code looks like this

l0 = 0.1;
COD = 0.2;
X1 = 0.0;
Y1 = 0.0;
Z1 = 0.0;
X2 = 1.0;
Y2 = 8.0;
Z2 = 1.0;
Ymid = 0.5 (Y2 + Y1);
aDim = 0.5;
reg1=Rectangle[{X1,Y1},{X2,Y2}];
reg2=Triangle[{{X1,Ymid+COD},{X1,Ymid-COD},{aDim,Ymid}}];
reg3=RegionDifference[reg1,reg2];
reg4=RegionProduct[reg3,Line[{{Z1},{Z2}}]];
elVol =5(l0/2)^3/(6\[Sqrt]2);
MeshIn = ToElementMesh[reg4, MaxCellMeasure -> {"Volume" -> 0.0125}, 
"MeshOrder" -> 1, 
MeshRefinementFunction -> 
Function[{vertices, Vol}, 
Block[{x, y, z, tol}, {x, y, z} = Mean[vertices]; tol = 0.05; 
If[y < Ymid + tol && y > Ymid - tol && x > aDim - tol , 
 Vol > elVol, Vol > 5]]]]

I want to integrate a function

f[x_,y_,z_] = x y^2 + z^2;

over the surface x = 1. I can directly integrate using the command

NIntegrate[f[x,y,z],{y,0,8},{z,0,1}];

Is it possible to integrate over the finite element mesh using something like this

NIntegrate[f[x,y,z], {x, y, z} \[Element] MeshIn]

and I also want to choose x = 1. I need this because i want to integrate the finite element solution which is a global interpolation function over the surface of the mesh. I would appreciate any help in this regard.

Thanks

$\endgroup$
4
  • $\begingroup$ what is the value for COD? $\endgroup$ Commented Apr 24, 2018 at 18:26
  • $\begingroup$ @JoséAntonioDíazNavas my apologies i missed it. I have edited my question now. $\endgroup$
    – KVK318
    Commented Apr 24, 2018 at 19:06
  • $\begingroup$ I get compile messages. I'd fix those since I assume the resulting mesh is not what you want otherwise. $\endgroup$
    – user21
    Commented Apr 25, 2018 at 7:06
  • $\begingroup$ @user21 I am sorry for the sloppy posting. The mesh generation works now. $\endgroup$
    – KVK318
    Commented Apr 25, 2018 at 19:29

1 Answer 1

6
$\begingroup$

You could use:

NIntegrate[f[1, y, z], {x, y, z} \[Element] MeshIn]
172.063
$\endgroup$
1
  • $\begingroup$ Thank you, this works correctly. $\endgroup$
    – KVK318
    Commented Apr 25, 2018 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.