# Integration over a part of the big domain

I have a mesh defined on x as (-20,20) and y as (-20,20). The mesh space is defined on this domain lengths. However I would like to integrate a P2 variable over a certain part of the domain given by x’=(-2,10) and y’=(-2,2). Is there a specific way to integrate over this specific part of domain? Any help is appreciated.

``````fespace Ph(Th, P0);
Ph chi = (x > -2 && x < 10 && y > -2 && y < 2);
real myInt = int2d(Th)(chi * u);
``````
1 Like

It works. Thank you very much @prj

@prj Continuing on the above question, I would like to ask if there is also a way to obtain a solution variable over a certain part of the domain? I have the 2-dimensional solution field over the entire domain but I would like to store the 2-dimensional solution on a part of the domain given by x’=(-2,10) and y’=(-2,2). Thanks in advance.

I’d advise you to read the documentation. It can be easily achieved, for example by using the `trunc` function, followed by an interpolation from your orginal `fespace` to a newly defined `fespace` on your `trunc`'ed mesh.

Thanks @prj for pointing out the reference.

@prj I have 1-dimensional velocity field, defined in a finite difference space and I would like to import the 1-D velocity field and use it as a boundary condition on the inlet of the finite element mesh defined by a label. Is there is an easy way of performing this operation in Freefem++? Any help will be appreciated.

How is that related to this topic?

@prj It is not related to the topic. I posted this as a separate question but never got any suggestions and hence just asked the question directly to you.