# Error using restrict() with -np 1

**URL:** <https://community.freefem.org/t/error-using-restrict-with-np-1/1845>\
**Category:** General Discussion\
**Created:** [June 23, 2022, 12:12pm UTC](https://community.freefem.org/t/error-using-restrict-with-np-1/1845 "2022-06-23T12:12:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aszaboa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aszaboa/32/2918_2.png) [@aszaboa](https://community.freefem.org/u/aszaboa)\
**Post date:** [June 23, 2022, 12:12pm UTC](https://community.freefem.org/t/error-using-restrict-with-np-1/1845/1 "2022-06-23T12:12:53Z")

</div>

Dear FreeFem users,

I found that using FreeFem the parallel capabilities of FreeFem, but running with np=1, when I save and load both a distributed and a non-distributed mesh, the command `restrict()` throws an error. The following MWE illustrates this behavior:

```auto
load "PETSc"

int[int] n2oSaved;
int[int] n2oLoaded;

{
    macro dimension()2//
    include "macro_ddm.idp"
    int[int] n2oTh;
    macro ThN2O()n2oTh//
    mesh Th = square(40, 40);
    mesh ThGlobal = Th;
    Mat A;
    createMat(Th, A, P1)
    saveDmesh(Th, "dump-2d")
    savemesh(ThGlobal, "dump-2d-G.mesh"); 
    fespace VhC(Th,P0);
    fespace VhCGlob(ThGlobal,P0);
    int[int] rest = restrict(VhC, VhCGlob, n2oTh);
}
{
    macro dimension()2//
    include "macro_ddm.idp"
    int[int] n2oTh;
    macro ThN2O()n2oTh//
    mesh Th,ThGlobal;
    Mat A;
    loadDmesh(Th, "dump-2d")
    ThGlobal = readmesh("dump-2d-G.mesh");
    createMat(Th, A, P0)
    fespace VhC(Th,P0);
    fespace VhCGlob(ThGlobal,P0);
    int[int] rest = restrict(VhC, VhCGlob, n2oTh); /*The error occurs here */
}

```

Of course, this can be circumvent in multiple ways (saving and loading the indices, or just handling the `mpisize=1` case manually); however, I think it would be nicer if this was addressed in the source code. I tried to find the definition of `restrict()` in the source code, but I did not succeed. Could someone sort this out, or help me out where the source code should be modified? Any help is appretiated.

---

<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 23, 2022, 12:43pm UTC](https://community.freefem.org/t/error-using-restrict-with-np-1/1845/2 "2022-06-23T12:43:19Z")

</div>

Thank you for reporting this. This should be fixed in [Fixes n2o in loadDmesh with a single process. · FreeFem/FreeFem-sources@8ff29e1 · GitHub](https://github.com/FreeFem/FreeFem-sources/commit/8ff29e17efbcb57a88792fd93845360148423c24).

---

<div class="post-metadata">

**Author:** ![aszaboa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aszaboa/32/2918_2.png) [@aszaboa](https://community.freefem.org/u/aszaboa)\
**Post date:** [June 23, 2022, 12:48pm UTC](https://community.freefem.org/t/error-using-restrict-with-np-1/1845/3 "2022-06-23T12:48:18Z")

</div>

Thanks for the quick fix!
