changeset 225:72af6354bf02

Compile right away after ufl end
author Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
date Thu, 22 May 2014 12:34:47 +0200
parents a108a0bfe201
children 043120f071de
files inst/ufl.m
diffstat 1 files changed, 25 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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