# HG changeset patch # User Eugenio Gianniti # Date 1400754887 -7200 # Node ID 72af6354bf02f2a54108cf45a5597489f9ea2dba # Parent a108a0bfe20158a8cd290c311979a33c54fb11c8 Compile right away after ufl end diff -r a108a0bfe201 -r 72af6354bf02 inst/ufl.m --- a/inst/ufl.m Thu May 22 11:43:44 2014 +0200 +++ b/inst/ufl.m Thu May 22 12:34:47 2014 +0200 @@ -20,15 +20,32 @@ ## @itemize @bullet ## @item start: opens an ufl file. It is possible to specify a name for it, ## otherwise 'default.ufl' will be used. -## @item end: closes an ufl file. +## @item end: closes the ufl file and compiles it. It is possible to +## specify its @var{content}, otherwise a complete problem is assumed. +## Possible options are: BilinearForm, Functional, FunctionSpace, LinearForm +## and Problem. ## @end itemize ## +## @example +## @code{ufl start fs.ufl} +## @code{ufl element = FunctionSpace ("Lagrange", triangle, 1)} +## @code{ufl end FunctionSpace} +## This way you can write a ufl file and compile it obtaining a FunctionSpace. +## @end example +## +## @seealso{import_ufl_Problem, import_ufl_BilinearForm, import_ufl_Functional, +## import_ufl_FunctionSpace, import_ufl_LinearForm} ## @end deftypefn function ufl (varargin) persistent fid = -1; - filename = "default.ufl"; + persistent filename = "default.ufl"; + persistent opts = {"BilinearForm", + "Functional", + "FunctionSpace", + "LinearForm", + "Problem"}; if (numel (varargin) < 1) if (! is_valid_file_id (fid)) @@ -65,6 +82,12 @@ fclose (fid); fid = -1; endif + compile = "Problem"; + if (numel (varargin) > 1) + compile = validatestring (varargin{2}, opts, "ufl", "content"); + endif + eval (["import_ufl_", compile, "(\"", filename(1:end-4), "\");"]); + filename = "default.ufl"; elseif (! is_valid_file_id (fid)) error ("ufl: no open file"); else