Mercurial > fem-fenics-eugenio
comparison inst/import_meshfunction_type.m @ 261:f22588ae37af
Improve template meshfunction implementation
* inst/import_meshfunction_type.m: provide to the auxiliary functions a type name and
a valid identifier
* inst/private/generate_mf_*.m: add space before closing angle bracket to avoid parse
errors
author | Eugenio Gianniti <eugenio.gianniti@mail.polimi.it> |
---|---|
date | Thu, 07 Aug 2014 11:13:54 +0200 |
parents | 1e2a9be8083a |
children | 61830a4f9ab9 |
comparison
equal
deleted
inserted
replaced
260:1e2a9be8083a | 261:f22588ae37af |
---|---|
14 ## this program; if not, see <http://www.gnu.org/licenses/>. | 14 ## this program; if not, see <http://www.gnu.org/licenses/>. |
15 | 15 |
16 ## -*- texinfo -*- | 16 ## -*- texinfo -*- |
17 ## @deftypefn {Function File} {} import_meshfunction_type (@var{typename}) | 17 ## @deftypefn {Function File} {} import_meshfunction_type (@var{typename}) |
18 ## Add a wrapper for dolfin::MeshFunction <@var{typename}> | 18 ## Add a wrapper for dolfin::MeshFunction <@var{typename}> |
19 ## @seealso {MeshFunction} | |
19 ## @end deftypefn | 20 ## @end deftypefn |
20 | 21 |
21 function import_meshfunction_type (typename) | 22 function import_meshfunction_type (typename) |
22 | 23 |
23 if (is_master_node ()) | 24 if (is_master_node ()) |
25 error ("import_meshfunction_type: wrong number of input parameters."); | 26 error ("import_meshfunction_type: wrong number of input parameters."); |
26 elseif (! ischar (typename)) | 27 elseif (! ischar (typename)) |
27 error ("import_meshfunction_type: first argument is not a valid string"); | 28 error ("import_meshfunction_type: first argument is not a valid string"); |
28 endif | 29 endif |
29 | 30 |
30 # Ensure that the typename does not contain whitespace | |
31 typename = strtrim (typename); | 31 typename = strtrim (typename); |
32 typename = strjoin (strsplit (typename), ""); | 32 |
33 # Ensure that the label does not contain whitespace or symbols | |
34 label = genvarname (strjoin (strsplit (typename), "")); | |
33 | 35 |
34 if (! check_mf_files (typename)) | 36 if (! check_mf_files (typename)) |
35 n = length (mfilename ("fullpath")) - length (mfilename()); | 37 n = length (mfilename ("fullpath")) - length (mfilename()); |
36 path = strtrunc(mfilename ("fullpath"), n); | 38 path = strtrunc(mfilename ("fullpath"), n); |
37 | 39 |
38 private = fullfile (path, "include/"); | 40 private = fullfile (path, "include/"); |
39 output = generate_mf_header (typename); | 41 output = generate_mf_header (typename, label); |
40 output += generate_mf_constructor (typename); | 42 output += generate_mf_constructor (label); |
41 output += generate_mf_save (typename); | 43 output += generate_mf_save (typename, label); |
42 output += generate_mf_makefile (typename, private); | 44 output += generate_mf_makefile (label, private); |
43 if (output != 0) | 45 if (output != 0) |
44 error ("compilation failed"); | 46 error ("compilation failed"); |
45 else | 47 else |
46 [output, textfile] = system (["make -f Makefile_", typename, " all"]); | 48 [output, textfile] = system (["make -f Makefile_", label, " all"]); |
47 if (output != 0) | 49 if (output != 0) |
48 display (text); | 50 display (text); |
49 error ("compilation failed"); | 51 error ("compilation failed"); |
50 endif | 52 endif |
51 [output, textfile] = system (["make -f Makefile_", typename, " clean"]); | 53 [output, textfile] = system (["make -f Makefile_", label, " clean"]); |
52 if (output != 0) | 54 if (output != 0) |
53 display (text); | 55 display (text); |
54 error ("compilation failed"); | 56 error ("compilation failed"); |
55 endif | 57 endif |
56 endif | 58 endif |