FreeFem / FreeFem-docker

FreeFEM Docker image
Other
4 stars 7 forks source link

How to activate plotting with docker #5

Open silgon opened 4 years ago

silgon commented 4 years ago

X11 can be used within docker with the options -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix within the docker run command and enabling it with xhost +local:root. However, in this docker image I'm not able to display the first tutorial code:

// Define mesh boundary
border C(t=0, 2*pi){x=cos(t); y=sin(t);}
// The triangulated domain Th is on the left side of its boundary
mesh Th = buildmesh(C(50));
// The finite element space defined over Th is called here Vh
fespace Vh(Th, P1);
Vh u, v;// Define u and v as piecewise-P1 continuous functions
// Define a function f
func f= x*y;
// Get the clock in second
real cpu=clock();
// Define the PDE
solve Poisson(u, v, solver=LU)
    = int2d(Th)(    // The bilinear part
          dx(u)*dx(v)
        + dy(u)*dy(v)
    )
    - int2d(Th)(    // The right hand side
          f*v
    )
    + on(C, u=0);   // The Dirichlet boundary condition
// Plot the result
plot(u);
// Display the total computational time
cout << "CPU time = " << (clock()-cpu) << endl;

I know that X11 is working because I test it with the command xeyes (after installing x11-apps in the container), however the plot of the previous code is not being displayed.

One hint that I have is when I type FreeFem++ alone, there is a line after the help that says without default ffglut: ffglut. However I do not know how to install it or what flag to activate to be able to install it.

Any ideas?

prj- commented 4 years ago

I'd recommend just using ParaView.

silgon commented 4 years ago

I don't understand how using ParaView can help. Could you be more specific @prj- ? Thanks

prj- commented 4 years ago

You can output your results using the .vtu format. Then, transfer between the container and the host. And open your transferred files with ParaView?

silgon commented 4 years ago

Oops.... sorry my question sounded so naive. I wanted to know if that's the only way. I actually thought that the output would be an image that I'm unable to zoom in. I suppose that vtu is a kind of mesh file with the information of the analysis. I'll give it a try either tomorrow or the beginning of next week. I was really looking forward to have the visualization in the same docker container, but if that is the way you people who develop the software use, that should be good enough =).

Thanks for the reply @prj- and I'll either close the issue once I tested or I'll come back with more questions. =D

prj- commented 4 years ago

We don't really use the Docker image to be perfectly honest. Why don't you compile FreeFEM or use a prebuilt image? But ParaView is really nice, much much better than ffglut, so you are not missing out on anything!

silgon commented 4 years ago

I use a lot docker because you don't have to compile anything and it's really convenient for a lot of repeatability task (I use it in my every day personal and professional projects). However, I gave it a shot to the FreeFEM installation, I got some dependency problems that I tried to solve for probably an hour and I wasn't willing to spend a lot of time seeing why, since I'm using FreeFEM out of curiosity and it's not a requirement for anything I'm doing. =)

PierreMarchand20 commented 4 years ago

... I was really looking forward to have the visualization in the same docker container, ...

If you really do not want to install anything on your computer, you could also try to install paraview in the same docker image. Or you could use the docker image of FreeFEM and the one of paraview, and share a volume between those two.

But just sharing a folder between the host and the docker container to recover the output of freefem (vtu files), and then call paraview on your computer may be the easiest way.