'plotD' and 'plotDmesh' don't work

Hello,
I have just started learning FreeFEM and have independently compiled FreeFEM on an Ubuntu 22.04 system. When studying the code, the plot function runs normally, but the following code does not display any image when run using FreeFem++-mpi, even though no error is reported. I also tried using other executables like ffglut and ffmaster, but they resulted in errors. Why doesn’t the program display the image? And I didn’t see functions ‘plotD’ and ‘plotDmesh’ on the Function page of the official website. Is there a page for their usage. Below are the program and its output. Any help would be greatly appreciated!

/*******************************************************
 *  This file is part of the FreeFEM tutorial made by  *
 *      Pierre Jolivet <pierre@joliv.et>               *
 *                                                     *
 *  See https://joliv.et/FreeFem-tutorial for more     *
 *                                                     *
 *   Description: Mat data structure and basic usage   *
 *******************************************************/

load "PETSc"
macro dimension()2// EOM
include "macro_ddm.idp"

func Pk = P1;

border upper(t=0, pi)    { x=cos(t); y=sin(t); label=1; }
border lower(t=pi, 2*pi) { x=cos(t); y=sin(t); label=2; }
mesh Th = buildmesh(upper(100) + lower(100));
Mat A;
MatCreate(Th, A, Pk);
plotDmesh(Th, cmm = "Domain decomposition");


fespace Vh(Th, Pk);
Vh u;
u[] = 0:Vh.ndof - 1;
plotD(Th, u, cmm = "Local numbering");

GlobalNumbering(A, u[]);
plotD(Th, u, cmm = "Global numbering");
$ FreeFem++-mpi example1.edp -v 0
WARNING! There are options you set that were not used!
WARNING! could be spelling mistake, etc!
There is one unused database option. It is:
Option left: name:-v value: 0 source: command line

When I replace plotDmesh(Th, cmm = "Domain decomposition") with plot(Th). It doesn’t work either.

You need to use the additional command-line parameter -wg (in parallel, by default, there is no plot).

Hello, Professor

I have recently been learning parallel programming with FreeFEM and wrote a script square_mpi.edp to test the functionality of plotD. In lines 52-53, plotD is only called by process 1, yet I find that the plotting at line 85 is incorrect as follows.


I wonder why this happens.

Run via command line ff-mpirun -np 2 square_mpi.edp -wg -ns -v 0 -pc_type lu -ksp_view_final_residual

Thanks in advance.

plotD() is a collective function, it doesn’t make sense to do things such as if (mpirank == 1) plotD().

Thank you, Professor.
I would like to know whether plotD affects the internal results, if I comment out if (mpirank == 1) plotD() on lines 52-53.

//if (mpirank == 1)  // plotD will leave the mesh of mpirank == 1 behind
//    plotD(Th, sol, plotParameter("sol by plotD for processor #1"));

and the final graph is correct as follows

It affects the final plotting result. So I think it does more than just plotting and displaying results, right?

No, it just does the plotting.