Name

gf_workspace — Getfem workspace management function.

Calling Sequence

gf_workspace('push') 
gf_workspace('pop' [,hobj i, hobj j,..])  
gf_workspace('stat') 
gf_workspace('stats')
gf_workspace('keep', hobj i[,hobj j, hobj k..]) 
gf_workspace('clear')
gf_workspace('clear all')
gf_workspace('class name', hobj i)
  

Description

Getfem uses its own workspaces in Scilab, independently of the scilab workspaces (this is due to some limitations in the memory management of scilab objects). By default, all getfem variables belong to the root getfem workspace. A function can create its own workspace by invoking gf_workspace('push') at its beginning. When exiting, this function MUST invoke gf_workspace('pop') (you can use scilab exceptions handling to do this cleanly when the function exits on an error).

  • gf_workspace('push'): Create a new temporary workspace on the workspace stack.

  • gf_workspace('pop' [,i,j,..]): Leave the current workspace, destroying all getfem objects belonging to it, except the one listed after 'pop', and the ones moved to parent workspace by gf_workspace('keep').

  • gf_workspace('stat'): Print informations about variables in current workspace.

  • gf_workspace('stats'): Print informations about all getfem variables.

  • gf_workspace('keep', i[,j,k..]): prevent the listed variables i from being deleted when gf_workspace("pop") will be called by moving this variable in the parent workspace.

  • gf_workspace('clear'): Clear the current workspace.

  • gf_workspace('clear all'): Clear every workspace, and returns to the main workspace (you should not need this command).

  • S=gf_workspace('class name', i): Return the class name of object i (if I is a mesh handle, it return gfMesh etc..)

Examples

If you want to create getfem-matlab object within one of your own m-files, you should follow this template in order to avoid memory leaks.

 
// First example
function [a]=foo(x,y,z)
gf_workspace('push');
try
  ...                      // some work here ...
  a = gf_mesh_fem(m);      // create a  getfem++ object
  b = gf_mesh(x);
  gf_workspace('keep', a); // b will be automatically destroyed at the 'pop'
  ...                      // other work...
catch
  gf_workspace('pop');     // cleanup before error
  error(lasterror);
end
gf_workspace('pop');
endfunction

// Second example
m  = gf_mesh('cartesian',[0:.1:1],[0:.1:1]); 
gf_workspace('stats');
 

See Also

gf_delete, gf_mesh, gf_mesh_fem

Authors

Y. Collette