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

Improve formatting
author Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
date Thu, 14 Aug 2014 12:26:55 +0200
parents a61fc34334ca
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_lhs (ufl_name) 21 function output = generate_lhs (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/form.h>\n\ 25 #include <fem-fenics/form.h>\n\
26 #include <fem-fenics/function.h>\n\ 27 #include <fem-fenics/function.h>\n\
27 #include <fem-fenics/functionspace.h>\n\ 28 #include <fem-fenics/functionspace.h>\n\
28 #include <fem-fenics/meshfunction.h>\n\ 29 #include <fem-fenics/meshfunction.h>\n\
29 #include <fem-fenics/dolfin_compat.h>\n\ 30 #include <fem-fenics/dolfin_compat.h>\n\
30 \n\ 31 \n\
31 DEFUN_DLD (@@UFL_NAME@@_LinearForm, args, , "" b = fem_lhs_@@UFL_NAME@@ (FUNCTIONAL SPACE, COEFF)"")\n\ 32 DEFUN_DLD (@@UFL_NAME@@_LinearForm, args, ,\
33 "" b = fem_lhs_@@UFL_NAME@@ (FUNCTIONAL SPACE, COEFF)"")\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\
36 if (nargin < 1)\n\ 38 if (nargin < 1)\n\
100 {\n\ 102 {\n\
101 const function & fun\n\ 103 const function & fun\n\
102 = static_cast <const function&> (args(i).get_rep ());\n\ 104 = static_cast <const function&> (args(i).get_rep ());\n\
103 \n\ 105 \n\
104 std::size_t n = L.coefficient_number (fun.get_str ());\n\ 106 std::size_t n = L.coefficient_number (fun.get_str ());\n\
105 const SHARED_PTR <const dolfin::Function> & pfun = fun.get_pfun ();\n\ 107 const SHARED_PTR <const dolfin::Function> & pfun =\
108 fun.get_pfun ();\n\
106 L.set_coefficient (n, pfun);\n\ 109 L.set_coefficient (n, pfun);\n\
107 ++nc;\n\ 110 ++nc;\n\
108 }\n\ 111 }\n\
109 \n\ 112 \n\
110 if (args(i).type_id () == meshfunction::static_type_id ())\n\ 113 if (args(i).type_id () == meshfunction::static_type_id ())\n\
111 {\n\ 114 {\n\
112 meshfunction const & mf_arg\n\ 115 meshfunction const & mf_arg =\n\
113 = static_cast <meshfunction const &> (args(i).get_rep ());\n\ 116 static_cast <meshfunction const &> (args(i).get_rep ());\n\
114 \n\ 117 \n\
115 std::string type = mf_arg.get_str ();\n\ 118 std::string type = mf_arg.get_str ();\n\
116 dolfin::MeshFunction <std::size_t> const &\n\ 119 dolfin::MeshFunction <std::size_t> const &\n\
117 mf = mf_arg.get_mf ();\n\ 120 mf = mf_arg.get_mf ();\n\
118 if (type == ""dx"")\n\ 121 if (type == ""dx"")\n\
134 }\n\ 137 }\n\
135 }\n\ 138 }\n\
136 return retval;\n\ 139 return retval;\n\
137 }"; 140 }";
138 141
139 STRING = strrep (STRING, "@@UFL_NAME@@", ufl_name); 142 STRING = strrep (STRING, "@@UFL_NAME@@", ufl_name);
140 143
141 fid = fopen (sprintf ("%s_LinearForm.cc", ufl_name), 'w'); 144 fid = fopen (sprintf ("%s_LinearForm.cc", ufl_name), "w");
142 if (fid >= 0) 145 if (fid >= 0)
143 fputs (fid, STRING); 146 fputs (fid, STRING);
144 output = fclose (fid); 147 output = fclose (fid);
145 else 148 else
146 error ("cannot open file"); 149 error ("cannot open file");