comparison inst/private/generate_fun.m @ 268:61830a4f9ab9

Improve formatting
author Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
date Thu, 14 Aug 2014 12:26:55 +0200
parents 5e9b5bbdc56b
children
comparison
equal deleted inserted replaced
267:53039ac90368 268:61830a4f9ab9
15 15
16 16
17 ## -*- texinfo -*- 17 ## -*- texinfo -*-
18 ## function for internal usage only 18 ## function for internal usage only
19 ## @end deftypefn 19 ## @end deftypefn
20
20 function output = generate_fun (ufl_name) 21 function output = generate_fun (ufl_name)
21 22
22 STRING ="\n\ 23 STRING ="\n\
23 #include ""@@UFL_NAME@@.h""\n\ 24 #include ""@@UFL_NAME@@.h""\n\
24 #include <fem-fenics/mesh.h>\n\ 25 #include <fem-fenics/mesh.h>\n\
25 #include <fem-fenics/form.h>\n\ 26 #include <fem-fenics/form.h>\n\
26 #include <fem-fenics/coefficient.h>\n\ 27 #include <fem-fenics/coefficient.h>\n\
27 #include <fem-fenics/function.h>\n\ 28 #include <fem-fenics/function.h>\n\
28 #include <fem-fenics/dolfin_compat.h>\n\ 29 #include <fem-fenics/dolfin_compat.h>\n\
29 \n\ 30 \n\
30 DEFUN_DLD (@@UFL_NAME@@_Functional, args, , ""A = fem_rhs_@@UFL_NAME@@ (FUNCTIONAL SPACE, COEFF)"")\n\ 31 DEFUN_DLD (@@UFL_NAME@@_Functional, args, ,\
32 ""A = fem_rhs_@@UFL_NAME@@ (FUNCTIONAL SPACE, COEFF)"")\n\
31 {\n\ 33 {\n\
32 \n\ 34 \n\
33 int nargin = args.length ();\n\ 35 int nargin = args.length ();\n\
34 octave_value retval;\n\ 36 octave_value retval;\n\
35 \n\ 37 \n\
92 {\n\ 94 {\n\
93 const function & fun\n\ 95 const function & fun\n\
94 = static_cast <const function&> (args(i).get_rep ());\n\ 96 = static_cast <const function&> (args(i).get_rep ());\n\
95 \n\ 97 \n\
96 std::size_t n = M.coefficient_number (fun.get_str ());\n\ 98 std::size_t n = M.coefficient_number (fun.get_str ());\n\
97 const SHARED_PTR <const dolfin::Function> & pfun = fun.get_pfun ();\n\ 99 const SHARED_PTR <const dolfin::Function> & pfun =\
100 fun.get_pfun ();\n\
98 M.set_coefficient (n, pfun);\n\ 101 M.set_coefficient (n, pfun);\n\
99 ++nc;\n\ 102 ++nc;\n\
100 }\n\ 103 }\n\
101 }\n\ 104 }\n\
102 \n\ 105 \n\
110 }\n\ 113 }\n\
111 }\n\ 114 }\n\
112 return retval;\n\ 115 return retval;\n\
113 }"; 116 }";
114 117
115 STRING = strrep (STRING, "@@UFL_NAME@@", ufl_name); 118 STRING = strrep (STRING, "@@UFL_NAME@@", ufl_name);
116 119
117 fid = fopen (sprintf ("%s_Functional.cc", ufl_name), 'w'); 120 fid = fopen (sprintf ("%s_Functional.cc", ufl_name), "w");
118 if (fid >= 0) 121 if (fid >= 0)
119 fputs (fid, STRING); 122 fputs (fid, STRING);
120 output = fclose (fid); 123 output = fclose (fid);
121 else 124 else
122 error ("cannot open file"); 125 error ("cannot open file");