# Interpolation and prolongation/restriction

**URL:** <https://community.freefem.org/t/interpolation-and-prolongation-restriction/3459>\
**Category:** General Discussion\
**Created:** [August 29, 2024, 7:42am UTC](https://community.freefem.org/t/interpolation-and-prolongation-restriction/3459 "2024-08-29T07:42:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![etj](https://avatars.discourse-cdn.com/v4/letter/e/a698b9/32.png) [@etj](https://community.freefem.org/u/etj)\
**Post date:** [August 29, 2024, 7:42am UTC](https://community.freefem.org/t/interpolation-and-prolongation-restriction/3459/1 "2024-08-29T07:42:45Z")

</div>

Hello,

Is is possible to do both (1) interpolation to/from a boundary and (2) restriction/prolongation between FE spaces with different numbers of components? For example, switch between [P2,P1] on Th and [P2] on a boundary of Th?  
Should one use two distinct matrices or can a single matrix do both operations simultaneously?

Is there any example showing how to achieve that?  
I have found several examples that do either (1) or (2), but I could not find one with (1)+(2).

Thank you.

---

<div class="post-metadata">

**Author:** ![etj](https://avatars.discourse-cdn.com/v4/letter/e/a698b9/32.png) [@etj](https://community.freefem.org/u/etj)\
**Post date:** [August 29, 2024, 9:20am UTC](https://community.freefem.org/t/interpolation-and-prolongation-restriction/3459/2 "2024-08-29T09:20:17Z")

</div>

To be more specific: actually [this example in the section “Finite Element → Interpolation Matrix” of the documentation](https://doc.freefem.org/documentation/finite-element.html#interpolation-matrix) does (1)+(2) in a serial setting.

What is the correct way to translate that in a parallel setting (to use PETSc for example)? Can one use something like `Mat B(A,restriction=...);` to create a distributed parallel matrix?

---

<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:** [August 30, 2024, 7:13pm UTC](https://community.freefem.org/t/interpolation-and-prolongation-restriction/3459/3 "2024-08-30T19:13:36Z")

</div>

```auto
$ git grep -n "restriction =" examples/hpddm/
examples/hpddm/elasticity-block-hpddm-2d-PETSc.edp:48: int[int] restriction = restrict(Wh, WhUnneeded, n2o);
examples/hpddm/elasticity-block-hpddm-2d-PETSc.edp:55:Mat A(AUnneeded, restriction = two2one); // proper Mat for the velocity with a single layer of overlap
examples/hpddm/helmholtz-coupled-2d-PETSc-complex.edp:119:Mat<complex> ASurf(A, restriction = RVtoS);
examples/hpddm/helmholtz-coupled-2d-PETSc-complex.edp:123: Mat<complex> TSurf(T, restriction = PVtoS);
examples/hpddm/mf-2d-SLEPc.edp:33:Mat B(A, restriction = R); // if the above condition is not met,
examples/hpddm/restriction-2d-PETSc.edp:63:Mat B(A, restriction = R);
$ git grep MatInterpolate examples/hpddm/
examples/hpddm/PtAP-2d-PETSc.edp:MatInterpolate(ThNew, Pk, B, Th, Pk, A, P);
examples/hpddm/diffusion-mg-2d-PETSc.edp: MatInterpolate(Th1, Pk, A[1], Th0, Pk, A[0], P[0]);
examples/hpddm/diffusion-mg-2d-PETSc.edp: MatInterpolate(Th2, Pk, A[2], Th1, Pk, A[1], P[1]);
examples/hpddm/diffusion-mg-2d-PETSc.edp: MatInterpolate(Th1, Pk, A[1], Th0, Pk, A[0], P[0]);
examples/hpddm/diffusion-mg-2d-PETSc.edp: MatInterpolate(Th2, Pk, A[2], Th1, Pk, A[1], P[1]);
examples/hpddm/diffusion-mg-2d-PETSc.edp: MatInterpolate(Th1, Pk, B, Th0, Pk, A[0], P[0]);
examples/hpddm/diffusion-mg-2d-PETSc.edp: MatInterpolate(Th2, Pk, C, Th1, Pk, B, P[1]);
examples/hpddm/diffusion-mg-2d-PETSc.edp: MatInterpolate(Th1, Pk, B, Th0, Pk, A[0], P[0]);
examples/hpddm/diffusion-mg-2d-PETSc.edp: MatInterpolate(Th2, Pk, C, Th1, Pk, B, P[1]);

```
