Error using restrict() with -np 1

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:

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.

Thank you for reporting this. This should be fixed in Fixes n2o in loadDmesh with a single process. · FreeFem/FreeFem-sources@8ff29e1 · GitHub.

1 Like

Thanks for the quick fix!