annotate inst/import_ufl_BilinearForm.m @ 231:e3f57f92fa66

Avoid just-in-time compilation when not needed * inst/private/check_hash.m: check whether the previous compilation used the same ufl file * inst/private/save_hash.m: save to disk ufl file's md5sum for future comparison * inst/private/check_oct_files.m: ensure the expected oct files are present * inst/import_ufl_*.m: add checks using the logic above
author Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
date Sat, 14 Jun 2014 15:27:43 +0200
parents 0de6ca5e31a2
children 072aee55bb75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
152
1dbe146bff03 Update license to gpl v3
gedeone-octave <marcovass89@hotmail.it>
parents: 148
diff changeset
1 ## Copyright (C) 2013 Marco Vassallo <gedeone-octave@users.sourceforge.net>
148
f2193e825ad7 Maint: update copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 136
diff changeset
2 ##
53
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
3 ## This program is free software; you can redistribute it and/or modify it under
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
4 ## the terms of the GNU General Public License as published by the Free Software
152
1dbe146bff03 Update license to gpl v3
gedeone-octave <marcovass89@hotmail.it>
parents: 148
diff changeset
5 ## Foundation; either version 3 of the License, or (at your option) any later
53
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
6 ## version.
148
f2193e825ad7 Maint: update copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 136
diff changeset
7 ##
53
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
11 ## details.
148
f2193e825ad7 Maint: update copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 136
diff changeset
12 ##
53
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
13 ## You should have received a copy of the GNU General Public License along with
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
15
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
16 ## -*- texinfo -*-
181
0de6ca5e31a2 Fix error in the previously modified documentation.
gedeone-octave <marcovass89@hotmail.it>
parents: 179
diff changeset
17 ## @deftypefn {Function File} {} = import_ufl_BilinearForm (@var{myproblem})
179
8190736845fe Update the Function description for the code release.
gedeone-octave <marcovass89@hotmail.it>
parents: 154
diff changeset
18 ## Import a BilinearForm from a ufl file.
181
0de6ca5e31a2 Fix error in the previously modified documentation.
gedeone-octave <marcovass89@hotmail.it>
parents: 179
diff changeset
19 ##
179
8190736845fe Update the Function description for the code release.
gedeone-octave <marcovass89@hotmail.it>
parents: 154
diff changeset
20 ## @var{myproblem} is the name of the ufl file where
181
0de6ca5e31a2 Fix error in the previously modified documentation.
gedeone-octave <marcovass89@hotmail.it>
parents: 179
diff changeset
21 ## the BilinearForm is defined.
0de6ca5e31a2 Fix error in the previously modified documentation.
gedeone-octave <marcovass89@hotmail.it>
parents: 179
diff changeset
22 ##
0de6ca5e31a2 Fix error in the previously modified documentation.
gedeone-octave <marcovass89@hotmail.it>
parents: 179
diff changeset
23 ## This function creates in the pwd a file called
0de6ca5e31a2 Fix error in the previously modified documentation.
gedeone-octave <marcovass89@hotmail.it>
parents: 179
diff changeset
24 ## @var{myproblem_BilinearForm.oct}.
0de6ca5e31a2 Fix error in the previously modified documentation.
gedeone-octave <marcovass89@hotmail.it>
parents: 179
diff changeset
25 ##
179
8190736845fe Update the Function description for the code release.
gedeone-octave <marcovass89@hotmail.it>
parents: 154
diff changeset
26 ## @seealso{import_ufl_Problem, FunctionSpace, BilinearForm, LinearForm,
8190736845fe Update the Function description for the code release.
gedeone-octave <marcovass89@hotmail.it>
parents: 154
diff changeset
27 ## Functional}
53
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
28 ## @end deftypefn
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
29
136
c445cdf36fb1 Fix new naming convention for the generation of the problem from .ufl file.
gedeone-octave <marcovass89@hotmail.it>
parents: 135
diff changeset
30 function import_ufl_BilinearForm (var_prob)
53
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
31
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
32 if nargin != 1
136
c445cdf36fb1 Fix new naming convention for the generation of the problem from .ufl file.
gedeone-octave <marcovass89@hotmail.it>
parents: 135
diff changeset
33 error ("import_ufl_BilinearForm: wrong number of input parameters.");
53
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
34 elseif ! ischar (var_prob)
136
c445cdf36fb1 Fix new naming convention for the generation of the problem from .ufl file.
gedeone-octave <marcovass89@hotmail.it>
parents: 135
diff changeset
35 error ("import_ufl_BilinearForm: first argument is not a valid string");
53
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
36 endif
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
37
231
e3f57f92fa66 Avoid just-in-time compilation when not needed
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 181
diff changeset
38 if (check_hash (var_prob) || ! check_oct_files (var_prob, "BilinearForm"))
e3f57f92fa66 Avoid just-in-time compilation when not needed
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 181
diff changeset
39 n = length (mfilename ("fullpath")) - length (mfilename());
e3f57f92fa66 Avoid just-in-time compilation when not needed
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 181
diff changeset
40 path = strtrunc(mfilename ("fullpath"), n);
53
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
41
231
e3f57f92fa66 Avoid just-in-time compilation when not needed
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 181
diff changeset
42 private = fullfile (path, "include/");
e3f57f92fa66 Avoid just-in-time compilation when not needed
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 181
diff changeset
43 output = generate_rhs (var_prob);
e3f57f92fa66 Avoid just-in-time compilation when not needed
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 181
diff changeset
44 output += generate_makefile (var_prob, private);
67
5a781e79bee1 Call new octave script instead of python script
gedeone-octave <marco.vassallo@outlook.com>
parents: 53
diff changeset
45 if output != 0
5a781e79bee1 Call new octave script instead of python script
gedeone-octave <marco.vassallo@outlook.com>
parents: 53
diff changeset
46 error ("Compilation failed");
231
e3f57f92fa66 Avoid just-in-time compilation when not needed
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 181
diff changeset
47 else
e3f57f92fa66 Avoid just-in-time compilation when not needed
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 181
diff changeset
48 [output, textfile] = system (sprintf ("make -f Makefile_%s rhs", var_prob));
e3f57f92fa66 Avoid just-in-time compilation when not needed
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 181
diff changeset
49 if output != 0
e3f57f92fa66 Avoid just-in-time compilation when not needed
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 181
diff changeset
50 display (text);
e3f57f92fa66 Avoid just-in-time compilation when not needed
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 181
diff changeset
51 error ("Compilation failed");
e3f57f92fa66 Avoid just-in-time compilation when not needed
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 181
diff changeset
52 endif
e3f57f92fa66 Avoid just-in-time compilation when not needed
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 181
diff changeset
53 [output, textfile] = system (sprintf ("make -f Makefile_%s clean", var_prob));
e3f57f92fa66 Avoid just-in-time compilation when not needed
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 181
diff changeset
54 if output != 0
e3f57f92fa66 Avoid just-in-time compilation when not needed
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 181
diff changeset
55 display (text);
e3f57f92fa66 Avoid just-in-time compilation when not needed
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 181
diff changeset
56 error ("Compilation failed");
e3f57f92fa66 Avoid just-in-time compilation when not needed
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 181
diff changeset
57 endif
e3f57f92fa66 Avoid just-in-time compilation when not needed
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 181
diff changeset
58 save_hash (var_prob);
67
5a781e79bee1 Call new octave script instead of python script
gedeone-octave <marco.vassallo@outlook.com>
parents: 53
diff changeset
59 endif
53
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
60 endif
78448b5c6df6 New function for the creation of the lhs/rhs based on user's problem.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
61 endfunction