next up previous contents
Next: Complement: the debugger gdb Up: LESSON on freefem and Previous: Display a Triangulation with

Vizualisation of a function

Gnuplot is capable of 3D plot of straight lines. But then each segment is described by two points with 3 coordinates each. To break the plot of a polygonal line (i.e. insert a moveto) we need here too an empty blank line, but it seems that some machine need 2. So we get the following example which plots tex2html_wrap_inline391:

void main()
{
  Triangulation g("micro.msh");
  ofstream f("fmicro.gnu");
  float *u = new float[g.nv];

  for(int i=0; i<g.nv; i++)
        u[i] = g.v[i].x*g.v[i].x + g.v[i].y*g.v[i].y;

  for(int i=0; i<nt; i++)
    {
      for(int i=0; i<3; i++)
          f << g.v[t[i].v[i]].x <<"\t"<< g.v[t[i].v[i]].y <<"\t"
                                << u[t[i].v[i]] << endl; 
      f << g.v[t[i].v[0]].x << "\t" << g.v[t[i].v[0]].y <<"\t"
                            << u[t[i].v[0]] <<endl<<endl<<endl;
    }   
}
Then gnuplot must be launched as follows:
gnuplot 
set parametric
splot "fmicro.gnu" w l



Pironneau Olivier
Jeudi 12 mars 1998 16:06:41