Integrate Solution over an interior "Slice"

Dear All,

I am interested in finding the average value of a “slice”, where it cuts through the middle of my mesh.
I am aware that FreeFEM allows you to integrate functions over borders using int2D for a 3D mesh or int1D for a 2D mesh. But this integral would be in the interior of the mesh, and would represent a vertical slice.

I have tried something like this, but the error induced is a bit too much due to gradients in my solution.

  fespace Ph(Th3, P0);
  Ph2 chi = (x > -0.01  && x < 0.01 ; // I want the 2D average at x = 0, all values of y, all values of z.
  real avgProbAtCenter = int3d(Th3)(chi*uh) /  int3d(Th3)(chi) ;

If I make the range too small or too large around 0, errors are compounded. Is there a better way to get the 2D integral at just x = 0 instead of a region around it?

Hi wouldn’t the keyword levelset would do the job for what you want?
Something like

int2d(Th3, levelset=x)(uh)

or

int3d(Th3, levelset=x)(uh)

Or something like this… Maybe check the documentation here

Hi Julien,

Thank you! That does seem to work well. With using

int3d(Th3, levelset=x)(uh)

And I can just change x to x+3 to do the levelset at x = -3 which works great.