# Integration over a part of the big domain

**URL:** <https://community.freefem.org/t/integration-over-a-part-of-the-big-domain/435>\
**Category:** General Discussion\
**Created:** [May 26, 2020, 5:25pm UTC](https://community.freefem.org/t/integration-over-a-part-of-the-big-domain/435 "2020-05-26T17:25:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sgkkr](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@sgkkr](https://community.freefem.org/u/sgkkr)\
**Post date:** [May 26, 2020, 5:25pm UTC](https://community.freefem.org/t/integration-over-a-part-of-the-big-domain/435/1 "2020-05-26T17:25:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [May 26, 2020, 5:39pm UTC](https://community.freefem.org/t/integration-over-a-part-of-the-big-domain/435/2 "2020-05-26T17:39:34Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![sgkkr](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@sgkkr](https://community.freefem.org/u/sgkkr)\
**Post date:** [May 26, 2020, 5:50pm UTC](https://community.freefem.org/t/integration-over-a-part-of-the-big-domain/435/3 "2020-05-26T17:50:22Z")

</div>

It works. Thank you very much @prj

---

<div class="post-metadata">

**Author:** ![sgkkr](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@sgkkr](https://community.freefem.org/u/sgkkr)\
**Post date:** [June 9, 2020, 5:47pm UTC](https://community.freefem.org/t/integration-over-a-part-of-the-big-domain/435/4 "2020-06-09T17:47:30Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [June 9, 2020, 6:35pm UTC](https://community.freefem.org/t/integration-over-a-part-of-the-big-domain/435/5 "2020-06-09T18:35:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sgkkr](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@sgkkr](https://community.freefem.org/u/sgkkr)\
**Post date:** [June 10, 2020, 5:05pm UTC](https://community.freefem.org/t/integration-over-a-part-of-the-big-domain/435/6 "2020-06-10T17:05:38Z")

</div>

Thanks @prj for pointing out the reference.

---

<div class="post-metadata">

**Author:** ![sgkkr](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@sgkkr](https://community.freefem.org/u/sgkkr)\
**Post date:** [October 27, 2020, 11:22pm UTC](https://community.freefem.org/t/integration-over-a-part-of-the-big-domain/435/7 "2020-10-27T23:22:39Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [October 28, 2020, 5:49am UTC](https://community.freefem.org/t/integration-over-a-part-of-the-big-domain/435/8 "2020-10-28T05:49:00Z")

</div>

How is that related to this topic?

---

<div class="post-metadata">

**Author:** ![sgkkr](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@sgkkr](https://community.freefem.org/u/sgkkr)\
**Post date:** [October 28, 2020, 10:28am UTC](https://community.freefem.org/t/integration-over-a-part-of-the-big-domain/435/9 "2020-10-28T10:28:01Z")

</div>

@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.
