GFem language documentation -- 3.8.1 plot, savemesh, save, load, loadmesh

Up: 3.8 Results
Next: 3.8.2 Saveall()

### 3.8.1 plot, savemesh, save, load, loadmesh

Within a program the keyword `plot(u)` will display `u` .

Instruction `save('filename',u)` will save the data array `u` on disk. If `u` is a scalar variable then the (single) value of `u` is appended to the file (this is useful for time dependent problems or any problem with iteration loop.).

Instruction `savemesh('filename')` will save the triangulation on disk.

Similarly for reading data with `load('filename',u)` and `loadmesh('filename')`.

The file must be in the default directory, else it won't be found. The file format is best seen by opening them with a text editor. For a data array `f` it is:

    ns
    f[0]
    ....
    f[ns-1]

(`ns` is the number of vertices)

If `f` is a constant, its single value is appended to the end of the file; this is useful for time dependent problems or any problem with iteration loop.

If `precise` is set still the function stored by save is interpolated on the vertices as the P1 continuous function given by mass lumping (see above).

For triangulations the file format is (`nt` = number of triangles):

    ns nt
    q[0].x q[0].y ib[i]
    ...
    q[n-1].x q[n-1].y ib[n-1]
    me[0][0] me[0][1]  me[0][2] ngt[0]
    ...
    me[n-1][0] me[n-1][1]  me[n-1][2] ngt[n-1]

##### 5 Remark:

Gfem uses the Fortran standard for `me[][]` and numbers the vertices starting from number 1 instead of 0 as in the C-standard. Thus in C-programs one must use `me[][]-1` .

##### 6 Remark:

Other formats are also recognized by freefem via their file name extensions for our own internal use we have defined `.amdba` and `.am_fmt`. You can do the same if your format is not ours.

            loadmesh('mesh.amdba'); /* amdba format (Dassault aviation) */
            loadmesh('mesh.am_fmt'); /* am_fmt format of MODULEF */

##### 7 Remark:

There is an optional arguments for the functions `load`, `save`, `loadmesh`, `savemesh`. This is the 2nd or 3rd argument of these functions. Here are the prototypes:

    save(<filename>, <function name>
        [,<variable counter: integer or converted to integer>])
    load(<filename>, <function name>
        [,<variable counter: integer or converted to integer>])
    savemesh(<filename>[,<variable counter:
                          integer or converted to integer>])
    loadmesh(<filename>[,<variable counter:
                          integer or converted to integer>])

As an example see `nsstepad.pde` which use this feature to save the mesh and the solution at each adaptation of the mesh. This special feature allows you to save or load a generic filename with a counter, the final filename is built like this `'<generic filename>-<counter>'`.