# 'plotD' and 'plotDmesh' don't work

**URL:** <https://community.freefem.org/t/plotd-and-plotdmesh-dont-work/3602>\
**Category:** General Discussion\
**Created:** [November 26, 2024, 2:10am UTC](https://community.freefem.org/t/plotd-and-plotdmesh-dont-work/3602 "2024-11-26T02:10:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![QZH\_xia](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/qzh_xia/32/2612_2.png) [@QZH\_xia](https://community.freefem.org/u/QZH_xia)\
**Post date:** [November 26, 2024, 2:10am UTC](https://community.freefem.org/t/plotd-and-plotdmesh-dont-work/3602/1 "2024-11-26T02:10:44Z")

</div>

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!

```auto
/ *******************************************************
 * 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");

```

```auto
$ 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

```

---

<div class="post-metadata">

**Author:** ![QZH\_xia](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/qzh_xia/32/2612_2.png) [@QZH\_xia](https://community.freefem.org/u/QZH_xia)\
**Post date:** [November 26, 2024, 2:32am UTC](https://community.freefem.org/t/plotd-and-plotdmesh-dont-work/3602/2 "2024-11-26T02:32:19Z")

</div>

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

---

<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:** [November 26, 2024, 7:58am UTC](https://community.freefem.org/t/plotd-and-plotdmesh-dont-work/3602/3 "2024-11-26T07:58:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![RYP](https://avatars.discourse-cdn.com/v4/letter/r/b9e5f3/32.png) [@RYP](https://community.freefem.org/u/RYP)\
**Post date:** [July 25, 2026, 3:04am UTC](https://community.freefem.org/t/plotd-and-plotdmesh-dont-work/3602/4 "2026-07-25T03:04:44Z")

</div>

Hello, Professor

I have recently been learning parallel programming with FreeFEM and wrote a script [square\_mpi.edp](https://community.freefem.org/uploads/short-url/3XXDmWeo1bJ64oF7RdgPuT1rpzW.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.

 ![pic1](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/a/ac6934a8a8ed958990fe3505a1f76b8de3e2e3b0.png)  
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.

---

<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:** [July 25, 2026, 5:03am UTC](https://community.freefem.org/t/plotd-and-plotdmesh-dont-work/3602/5 "2026-07-25T05:03:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![RYP](https://avatars.discourse-cdn.com/v4/letter/r/b9e5f3/32.png) [@RYP](https://community.freefem.org/u/RYP)\
**Post date:** [July 25, 2026, 6:21am UTC](https://community.freefem.org/t/plotd-and-plotdmesh-dont-work/3602/6 "2026-07-25T06:21:05Z")

</div>

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.

```cpp
//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

 ![pic2](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/7/7603ceaa0a0eee80773633cdbf784e86b4feabcb.png)

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

---

<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:** [July 25, 2026, 7:36am UTC](https://community.freefem.org/t/plotd-and-plotdmesh-dont-work/3602/7 "2026-07-25T07:36:47Z")

</div>

No, it just does the plotting.
