# HG changeset patch # User Eugenio Gianniti # Date 1408012015 -7200 # Node ID 61830a4f9ab9084fb3fef01ee08de1294f2d1c99 # Parent 53039ac903687f1904c170ba3593ffc98a6d08f0 Improve formatting diff -r 53039ac90368 -r 61830a4f9ab9 inst/import_meshfunction_type.m --- a/inst/import_meshfunction_type.m Tue Aug 12 15:42:50 2014 +0200 +++ b/inst/import_meshfunction_type.m Thu Aug 14 12:26:55 2014 +0200 @@ -34,8 +34,8 @@ label = genvarname (strjoin (strsplit (typename), "")); if (! check_mf_files (typename)) - n = length (mfilename ("fullpath")) - length (mfilename()); - path = strtrunc(mfilename ("fullpath"), n); + n = length (mfilename ("fullpath")) - length (mfilename ()); + path = strtrunc (mfilename ("fullpath"), n); private = fullfile (path, "include/"); output = generate_mf_header (typename, label); diff -r 53039ac90368 -r 61830a4f9ab9 inst/import_ufl_BilinearForm.m --- a/inst/import_ufl_BilinearForm.m Tue Aug 12 15:42:50 2014 +0200 +++ b/inst/import_ufl_BilinearForm.m Thu Aug 14 12:26:55 2014 +0200 @@ -13,6 +13,7 @@ ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . + ## -*- texinfo -*- ## @deftypefn {Function File} {} = import_ufl_BilinearForm (@var{myproblem}) ## Import a BilinearForm from a ufl file. @@ -30,29 +31,29 @@ function import_ufl_BilinearForm (var_prob) if (is_master_node ()) - if nargin != 1 + if (nargin != 1) error ("import_ufl_BilinearForm: wrong number of input parameters."); - elseif ! ischar (var_prob) + elseif (! ischar (var_prob)) error ("import_ufl_BilinearForm: first argument is not a valid string"); endif if (check_hash (var_prob) || ! check_oct_files (var_prob, "BilinearForm")) - n = length (mfilename ("fullpath")) - length (mfilename()); - path = strtrunc(mfilename ("fullpath"), n); + n = length (mfilename ("fullpath")) - length (mfilename ()); + path = strtrunc (mfilename ("fullpath"), n); private = fullfile (path, "include/"); output = generate_rhs (var_prob); output += generate_makefile (var_prob, private); - if output != 0 + if (output != 0) error ("Compilation failed"); else [output, textfile] = system (sprintf ("make -f Makefile_%s rhs", var_prob)); - if output != 0 + if (output != 0) display (text); error ("Compilation failed"); endif [output, textfile] = system (sprintf ("make -f Makefile_%s clean", var_prob)); - if output != 0 + if (output != 0) display (text); error ("Compilation failed"); endif diff -r 53039ac90368 -r 61830a4f9ab9 inst/import_ufl_FunctionSpace.m --- a/inst/import_ufl_FunctionSpace.m Tue Aug 12 15:42:50 2014 +0200 +++ b/inst/import_ufl_FunctionSpace.m Thu Aug 14 12:26:55 2014 +0200 @@ -13,6 +13,7 @@ ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . + ## -*- texinfo -*- ## @deftypefn {Function File} {} = import_ufl_FunctionSpace (@var{myproblem}) ## Import a FunctionSpace from a ufl file. @@ -28,29 +29,29 @@ function import_ufl_FunctionSpace (var_prob) if (is_master_node ()) - if nargin != 1 + if (nargin != 1) error ("import_ufl_FunctionSpace: wrong number of input parameters."); - elseif ! ischar (var_prob) + elseif (! ischar (var_prob)) error ("import_ufl_FunctionSpace: first argument is not a valid string"); endif if (check_hash (var_prob) || ! check_oct_files (var_prob, "FunctionSpace")) - n = length (mfilename ("fullpath")) - length (mfilename()); - path = strtrunc(mfilename ("fullpath"), n); + n = length (mfilename ("fullpath")) - length (mfilename ()); + path = strtrunc (mfilename ("fullpath"), n); private = fullfile (path, "include/"); output = generate_fs (var_prob); output += generate_makefile (var_prob, private); - if output != 0 + if (output != 0) error ("Compilation failed"); else [output, textfile] = system (sprintf ("make -f Makefile_%s fs", var_prob)); - if output != 0 + if (output != 0) display (text); error ("Compilation failed"); endif [output, textfile] = system (sprintf ("make -f Makefile_%s clean", var_prob)); - if output != 0 + if (output != 0) display (text); error ("Compilation failed"); endif diff -r 53039ac90368 -r 61830a4f9ab9 inst/import_ufl_Functional.m --- a/inst/import_ufl_Functional.m Tue Aug 12 15:42:50 2014 +0200 +++ b/inst/import_ufl_Functional.m Thu Aug 14 12:26:55 2014 +0200 @@ -13,6 +13,7 @@ ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . + ## -*- texinfo -*- ## @deftypefn {Function File} {} = import_ufl_Functional (@var{myproblem}) ## Import a Functional from a ufl file. @@ -24,32 +25,33 @@ ## @seealso{import_ufl_Problem, FunctionSpace, BilinearForm, LinearForm, ## Functional} ## @end deftypefn + function import_ufl_Functional (var_prob) if (is_master_node ()) - if nargin != 1 + if (nargin != 1) error ("import_ufl_Functional: wrong number of input parameters."); - elseif ! ischar (var_prob) + elseif (! ischar (var_prob)) error ("import_ufl_Functional: first argument is not a valid string"); endif if (check_hash (var_prob) || ! check_oct_files (var_prob, "Functional")) - n = length (mfilename ("fullpath")) - length (mfilename()); - path = strtrunc(mfilename ("fullpath"), n); + n = length (mfilename ("fullpath")) - length (mfilename ()); + path = strtrunc (mfilename ("fullpath"), n); private = fullfile (path, "include/"); output = generate_fun (var_prob); output += generate_makefile (var_prob, private); - if output != 0 + if (output != 0) error ("Compilation failed"); else [output, textfile] = system (sprintf ("make -f Makefile_%s fun", var_prob)); - if output != 0 + if (output != 0) display (text); error ("Compilation failed"); endif [output, textfile] = system (sprintf ("make -f Makefile_%s clean", var_prob)); - if output != 0 + if (output != 0) display (text); error ("Compilation failed"); endif diff -r 53039ac90368 -r 61830a4f9ab9 inst/import_ufl_LinearForm.m --- a/inst/import_ufl_LinearForm.m Tue Aug 12 15:42:50 2014 +0200 +++ b/inst/import_ufl_LinearForm.m Thu Aug 14 12:26:55 2014 +0200 @@ -13,6 +13,7 @@ ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . + ## -*- texinfo -*- ## @deftypefn {Function File} {} = import_ufl_LinearForm (@var{myproblem}) ## Import a LinearForm from a ufl file. @@ -28,30 +29,30 @@ function import_ufl_LinearForm (var_prob) if (is_master_node ()) - if nargin != 1 + if (nargin != 1) error ("import_ufl_LinearForm: wrong number of input parameters."); - elseif ! ischar (var_prob) + elseif (! ischar (var_prob)) error ("import_ufl_LinearForm: first argument is not a valid string"); endif if (check_hash (var_prob) || ! check_oct_files (var_prob, "LinearForm")) - n = length (mfilename ("fullpath")) - length (mfilename()); - path = strtrunc(mfilename ("fullpath"), n); + n = length (mfilename ("fullpath")) - length (mfilename ()); + path = strtrunc (mfilename ("fullpath"), n); private = fullfile (path, "include/"); output = generate_lhs (var_prob); output += generate_makefile (var_prob, private); - if output != 0 + if (output != 0) error ("Compilation failed"); else [output, textfile] = system (sprintf ("make -f Makefile_%s lhs", var_prob)); - if output != 0 + if (output != 0) display (text); error ("Compilation failed"); endif [output, textfile] = system (sprintf ("make -f Makefile_%s clean", var_prob)); - if output != 0 + if (output != 0) display (text); error ("Compilation failed"); endif diff -r 53039ac90368 -r 61830a4f9ab9 inst/import_ufl_Problem.m --- a/inst/import_ufl_Problem.m Tue Aug 12 15:42:50 2014 +0200 +++ b/inst/import_ufl_Problem.m Thu Aug 14 12:26:55 2014 +0200 @@ -13,6 +13,7 @@ ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . + ## -*- texinfo -*- ## @deftypefn {Function File} {} = import_ufl_Problem (@var{myproblem}) ## Import a Variational Problem from a ufl file. @@ -27,31 +28,31 @@ function import_ufl_Problem (var_prob) if (is_master_node ()) - if nargin != 1 + if (nargin != 1) error ("import_ufl_Problem: wrong number of input parameters."); - elseif ! ischar (var_prob) + elseif (! ischar (var_prob)) error ("import_ufl_Problem: first argument is not a valid string"); endif if (check_hash (var_prob) || ! check_oct_files (var_prob, "Problem")) - n = length (mfilename ("fullpath")) - length (mfilename()); - path = strtrunc(mfilename ("fullpath"), n); + n = length (mfilename ("fullpath")) - length (mfilename ()); + path = strtrunc (mfilename ("fullpath"), n); private = fullfile (path, "include/"); output = generate_fs (var_prob); output += generate_rhs (var_prob); output += generate_lhs (var_prob); output += generate_makefile (var_prob, private); - if output != 0 + if (output != 0) error ("Compilation failed"); else [output, textfile] = system (sprintf ("make -f Makefile_%s all", var_prob)); - if output != 0 + if (output != 0) display (text); error ("Compilation failed"); endif [output, textfile] = system (sprintf ("make -f Makefile_%s clean", var_prob)); - if output != 0 + if (output != 0) display (text); error ("Compilation failed"); endif diff -r 53039ac90368 -r 61830a4f9ab9 inst/linear_algebra_backend.m --- a/inst/linear_algebra_backend.m Tue Aug 12 15:42:50 2014 +0200 +++ b/inst/linear_algebra_backend.m Thu Aug 14 12:26:55 2014 +0200 @@ -13,6 +13,7 @@ ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . + ## -*- texinfo -*- ## @deftypefn {Function File} @var{val} = linear_algebra_backend () ## @deftypefnx {Function File} @var{old_val} = linear_algebra_backend (@var{new_val}) diff -r 53039ac90368 -r 61830a4f9ab9 inst/private/generate_fs.m --- a/inst/private/generate_fs.m Tue Aug 12 15:42:50 2014 +0200 +++ b/inst/private/generate_fs.m Thu Aug 14 12:26:55 2014 +0200 @@ -17,6 +17,7 @@ ## -*- texinfo -*- ## function for internal usage only ## @end deftypefn + function output = generate_fs (ufl_name) STRING ="\n\ @@ -25,7 +26,8 @@ #include ""@@UFL_NAME@@.h""\n\ #include \n\ \n\ -DEFUN_DLD (@@UFL_NAME@@_FunctionSpace, args, , ""initialize a fs from a mesh declared with fem_init_mesh"")\n\ +DEFUN_DLD (@@UFL_NAME@@_FunctionSpace, args, ,\ + ""initialize a fs from a mesh declared with fem_init_mesh"")\n\ {\n\ int nargin = args.length ();\n\ octave_value retval;\n\ @@ -46,7 +48,8 @@ {\n\ const mesh & msho = static_cast (args(0).get_rep ());\n\ const dolfin::Mesh & mshd = msho.get_msh ();\n\ - SHARED_PTR g (new @@UFL_NAME@@::FunctionSpace (mshd));\n\ + SHARED_PTR \ + g (new @@UFL_NAME@@::FunctionSpace (mshd));\n\ \n\ if (! functionspace_type_loaded)\n\ {\n\ @@ -61,9 +64,9 @@ return retval;\n\ }"; -STRING = strrep (STRING, "@@UFL_NAME@@", ufl_name); +STRING = strrep (STRING, "@@UFL_NAME@@", ufl_name); -fid = fopen (sprintf ("%s_FunctionSpace.cc", ufl_name), 'w'); +fid = fopen (sprintf ("%s_FunctionSpace.cc", ufl_name), "w"); if (fid >= 0) fputs (fid, STRING); output = fclose (fid); diff -r 53039ac90368 -r 61830a4f9ab9 inst/private/generate_fun.m --- a/inst/private/generate_fun.m Tue Aug 12 15:42:50 2014 +0200 +++ b/inst/private/generate_fun.m Thu Aug 14 12:26:55 2014 +0200 @@ -17,6 +17,7 @@ ## -*- texinfo -*- ## function for internal usage only ## @end deftypefn + function output = generate_fun (ufl_name) STRING ="\n\ @@ -27,7 +28,8 @@ #include \n\ #include \n\ \n\ -DEFUN_DLD (@@UFL_NAME@@_Functional, args, , ""A = fem_rhs_@@UFL_NAME@@ (FUNCTIONAL SPACE, COEFF)"")\n\ +DEFUN_DLD (@@UFL_NAME@@_Functional, args, ,\ + ""A = fem_rhs_@@UFL_NAME@@ (FUNCTIONAL SPACE, COEFF)"")\n\ {\n\ \n\ int nargin = args.length ();\n\ @@ -94,7 +96,8 @@ = static_cast (args(i).get_rep ());\n\ \n\ std::size_t n = M.coefficient_number (fun.get_str ());\n\ - const SHARED_PTR & pfun = fun.get_pfun ();\n\ + const SHARED_PTR & pfun =\ + fun.get_pfun ();\n\ M.set_coefficient (n, pfun);\n\ ++nc;\n\ }\n\ @@ -112,9 +115,9 @@ return retval;\n\ }"; -STRING = strrep (STRING, "@@UFL_NAME@@", ufl_name); +STRING = strrep (STRING, "@@UFL_NAME@@", ufl_name); -fid = fopen (sprintf ("%s_Functional.cc", ufl_name), 'w'); +fid = fopen (sprintf ("%s_Functional.cc", ufl_name), "w"); if (fid >= 0) fputs (fid, STRING); output = fclose (fid); diff -r 53039ac90368 -r 61830a4f9ab9 inst/private/generate_lhs.m --- a/inst/private/generate_lhs.m Tue Aug 12 15:42:50 2014 +0200 +++ b/inst/private/generate_lhs.m Thu Aug 14 12:26:55 2014 +0200 @@ -17,6 +17,7 @@ ## -*- texinfo -*- ## function for internal usage only ## @end deftypefn + function output = generate_lhs (ufl_name) STRING ="\n\ @@ -28,7 +29,8 @@ #include \n\ #include \n\ \n\ -DEFUN_DLD (@@UFL_NAME@@_LinearForm, args, , "" b = fem_lhs_@@UFL_NAME@@ (FUNCTIONAL SPACE, COEFF)"")\n\ +DEFUN_DLD (@@UFL_NAME@@_LinearForm, args, ,\ + "" b = fem_lhs_@@UFL_NAME@@ (FUNCTIONAL SPACE, COEFF)"")\n\ {\n\ int nargin = args.length ();\n\ octave_value retval;\n\ @@ -102,15 +104,16 @@ = static_cast (args(i).get_rep ());\n\ \n\ std::size_t n = L.coefficient_number (fun.get_str ());\n\ - const SHARED_PTR & pfun = fun.get_pfun ();\n\ + const SHARED_PTR & pfun =\ + fun.get_pfun ();\n\ L.set_coefficient (n, pfun);\n\ ++nc;\n\ }\n\ \n\ if (args(i).type_id () == meshfunction::static_type_id ())\n\ {\n\ - meshfunction const & mf_arg\n\ - = static_cast (args(i).get_rep ());\n\ + meshfunction const & mf_arg =\n\ + static_cast (args(i).get_rep ());\n\ \n\ std::string type = mf_arg.get_str ();\n\ dolfin::MeshFunction const &\n\ @@ -136,9 +139,9 @@ return retval;\n\ }"; -STRING = strrep (STRING, "@@UFL_NAME@@", ufl_name); +STRING = strrep (STRING, "@@UFL_NAME@@", ufl_name); -fid = fopen (sprintf ("%s_LinearForm.cc", ufl_name), 'w'); +fid = fopen (sprintf ("%s_LinearForm.cc", ufl_name), "w"); if (fid >= 0) fputs (fid, STRING); output = fclose (fid); diff -r 53039ac90368 -r 61830a4f9ab9 inst/private/generate_makefile.m --- a/inst/private/generate_makefile.m Tue Aug 12 15:42:50 2014 +0200 +++ b/inst/private/generate_makefile.m Thu Aug 14 12:26:55 2014 +0200 @@ -17,6 +17,7 @@ ## -*- texinfo -*- ## function for internal usage only ## @end deftypefn + function output = generate_makefile (ufl_name, path) STRING ="\n\ @@ -52,19 +53,19 @@ .PHONY: clean\n\ \n\ clean:\n\ - rm -f @@UFL_NAME@@_FunctionSpace.o @@UFL_NAME@@_FunctionSpace.cc @@UFL_NAME@@.h\n\ - rm -f @@UFL_NAME@@_BilinearForm.o @@UFL_NAME@@_BilinearForm.cc\n\ - rm -f @@UFL_NAME@@_LinearForm.o @@UFL_NAME@@_LinearForm.cc\n\ - rm -f @@UFL_NAME@@_Functional.o @@UFL_NAME@@_Functional.cc\n\ - rm -f Makefile_@@UFL_NAME@@\n\ + $(RM) @@UFL_NAME@@_FunctionSpace.o @@UFL_NAME@@_FunctionSpace.cc @@UFL_NAME@@.h\n\ + $(RM) @@UFL_NAME@@_BilinearForm.o @@UFL_NAME@@_BilinearForm.cc\n\ + $(RM) @@UFL_NAME@@_LinearForm.o @@UFL_NAME@@_LinearForm.cc\n\ + $(RM) @@UFL_NAME@@_Functional.o @@UFL_NAME@@_Functional.cc\n\ + $(RM) Makefile_@@UFL_NAME@@\n\ "; -STRING = strrep (STRING, "@@UFL_NAME@@", ufl_name); -STRING = strrep (STRING, "@@PATH@@", path); +STRING = strrep (STRING, "@@UFL_NAME@@", ufl_name); +STRING = strrep (STRING, "@@PATH@@", path); STRING = strrep (STRING, "@@FF_CPPFLAGS@@", get_vars ("CPPFLAGS")); STRING = strrep (STRING, "@@FF_LIBS@@", get_vars ("LIBS")); -fid = fopen (sprintf ("Makefile_%s", ufl_name), 'w'); +fid = fopen (sprintf ("Makefile_%s", ufl_name), "w"); if (fid >= 0) fputs (fid, STRING); output = fclose (fid); diff -r 53039ac90368 -r 61830a4f9ab9 inst/private/generate_mf_constructor.m --- a/inst/private/generate_mf_constructor.m Tue Aug 12 15:42:50 2014 +0200 +++ b/inst/private/generate_mf_constructor.m Thu Aug 14 12:26:55 2014 +0200 @@ -26,7 +26,8 @@ #include ""meshfunction_@@LABEL@@.h""\n\ #include \n\ \n\ -DEFUN_DLD (MeshFunction_@@LABEL@@, args, nargout, ""MF = MeshFunction_@@LABEL@@ (TYPE, MESH, FILENAME)"")\n\ +DEFUN_DLD (MeshFunction_@@LABEL@@, args, nargout,\ + ""MF = MeshFunction_@@LABEL@@ (TYPE, MESH, FILENAME)"")\n\ {\n\ \n\ int nargin = args.length ();\n\ diff -r 53039ac90368 -r 61830a4f9ab9 inst/private/generate_mf_header.m --- a/inst/private/generate_mf_header.m Tue Aug 12 15:42:50 2014 +0200 +++ b/inst/private/generate_mf_header.m Thu Aug 14 12:26:55 2014 +0200 @@ -30,7 +30,7 @@ \n\ class meshfunction_@@LABEL@@ : public octave_base_value\n\ {\n\ - public:\n\ +public:\n\ \n\ meshfunction_@@LABEL@@ (void)\n\ : octave_base_value () {}\n\ @@ -39,28 +39,28 @@ : octave_base_value (), pmf (new dolfin::MeshFunction <@@TYPENAME@@ > (_mf)) {}\n\ \n\ meshfunction_@@LABEL@@ (SHARED_PTR mesh,\n\ - std::string const & filename)\n\ + std::string const & filename)\n\ : octave_base_value (),\n\ pmf (new dolfin::MeshFunction <@@TYPENAME@@ > (mesh, filename)) {}\n\ \n\ bool\n\ is_defined (void) const\n\ - { return true; }\n\ + { return true; }\n\ \n\ void\n\ print (std::ostream& os, bool pr_as_read_syntax = false) const\n\ - { os << ""MeshFunction <@@TYPENAME@@ >: ""\n\ - << get_pmf ()->str (@@VERBOSE@@) << std::endl; }\n\ + { os << ""MeshFunction <@@TYPENAME@@ >: ""\n\ + << get_pmf ()->str (@@VERBOSE@@) << std::endl; }\n\ \n\ dolfin::MeshFunction <@@TYPENAME@@ > const &\n\ get_mf (void) const\n\ - { return *pmf; }\n\ + { return *pmf; }\n\ \n\ SHARED_PTR const> const &\n\ get_pmf (void) const\n\ - { return pmf; }\n\ + { return pmf; }\n\ \n\ - private:\n\ +private:\n\ \n\ SHARED_PTR const> pmf;\n\ \n\ diff -r 53039ac90368 -r 61830a4f9ab9 inst/private/generate_rhs.m --- a/inst/private/generate_rhs.m Tue Aug 12 15:42:50 2014 +0200 +++ b/inst/private/generate_rhs.m Thu Aug 14 12:26:55 2014 +0200 @@ -17,6 +17,7 @@ ## -*- texinfo -*- ## function for internal usage only ## @end deftypefn + function output = generate_rhs (ufl_name) STRING ="\n\ @@ -28,7 +29,8 @@ #include \n\ #include \n\ \n\ -DEFUN_DLD (@@UFL_NAME@@_BilinearForm, args, , ""A = fem_rhs_@@UFL_NAME@@ (FUNCTIONAL SPACE, COEFF)"")\n\ +DEFUN_DLD (@@UFL_NAME@@_BilinearForm, args, ,\ + ""A = fem_rhs_@@UFL_NAME@@ (FUNCTIONAL SPACE, COEFF)"")\n\ {\n\ \n\ int nargin = args.length ();\n\ @@ -140,9 +142,9 @@ return retval;\n\ }"; -STRING = strrep (STRING, "@@UFL_NAME@@", ufl_name); +STRING = strrep (STRING, "@@UFL_NAME@@", ufl_name); -fid = fopen (sprintf ("%s_BilinearForm.cc", ufl_name), 'w'); +fid = fopen (sprintf ("%s_BilinearForm.cc", ufl_name), "w"); if (fid >= 0) fputs (fid, STRING); output = fclose (fid); diff -r 53039ac90368 -r 61830a4f9ab9 inst/ufl.m --- a/inst/ufl.m Tue Aug 12 15:42:50 2014 +0200 +++ b/inst/ufl.m Thu Aug 14 12:26:55 2014 +0200 @@ -13,6 +13,7 @@ ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . + ## -*- texinfo -*- ## @deftypefn {Function File} ufl [command] line ## diff -r 53039ac90368 -r 61830a4f9ab9 src/DirichletBC.cc --- a/src/DirichletBC.cc Tue Aug 12 15:42:50 2014 +0200 +++ b/src/DirichletBC.cc Thu Aug 14 12:26:55 2014 +0200 @@ -48,7 +48,7 @@ octave_value retval; if (nargin < 3 || nargin > 4) - print_usage (); + { print_usage (); } else { @@ -75,8 +75,8 @@ if (args(0).type_id () == functionspace::static_type_id ()) { - const functionspace & fspo = - static_cast (args(0).get_rep ()); + const functionspace & fspo = + static_cast (args(0).get_rep ()); octave_fcn_handle * fh = args(1).fcn_handle_value (); if (nargin == 3) @@ -95,16 +95,16 @@ expression * pf; if (l > 1) - pf = new expression (*fh, l); + { pf = new expression (*fh, l); } else - pf = new expression (*fh); + { pf = new expression (*fh); } SHARED_PTR f (pf); boundarycondition * pbc = new boundarycondition (); for (octave_idx_type i = 0; i < side.length (); ++i) - pbc->add_bc (V, f, side(i)); + { pbc->add_bc (V, f, side(i)); } retval = octave_value (pbc); } } @@ -126,9 +126,9 @@ expression * pf; if (l > 1) - pf = new expression (*fh, l); + { pf = new expression (*fh, l); } else - pf = new expression (*fh); + { pf = new expression (*fh); } SHARED_PTR f (pf); boundarycondition * pbc = new boundarycondition (); @@ -138,7 +138,7 @@ for (octave_idx_type i = 0; i < side.length (); ++i) - pbc->add_bc (V, f, subdomains, side(i)); + { pbc->add_bc (V, f, subdomains, side (i)); } retval = octave_value (pbc); } } diff -r 53039ac90368 -r 61830a4f9ab9 src/Function.cc --- a/src/Function.cc Tue Aug 12 15:42:50 2014 +0200 +++ b/src/Function.cc Thu Aug 14 12:26:55 2014 +0200 @@ -25,7 +25,7 @@ #include #endif -void copy_vector (Array const&, SHARED_PTR ); +void copy_vector (Array const &, SHARED_PTR ); DEFUN_DLD (Function, args, , "-*- texinfo -*-\n\ @deftypefn {Function File} {[@var{func}]} = \ @@ -61,9 +61,9 @@ int nargin = args.length (); octave_value retval; - + if (nargin < 3 || nargin > 3) - print_usage (); + { print_usage (); } else { if (! functionspace_type_loaded) @@ -84,7 +84,7 @@ { std::string str = args(0).string_value (); const functionspace & fspo = - static_cast (args(1).get_rep ()); + static_cast (args(1).get_rep ()); Array myu = args(2).array_value (); if (!error_state) @@ -93,8 +93,10 @@ & V = fspo.get_pfsp (); if (V->dim () != myu.length ()) - error("The size of the functional space \ - and of the vector must agree"); + { + error ("The size of the functional space \ + and of the vector must agree"); + } else { dolfin::Function aux (V); @@ -103,14 +105,14 @@ SHARED_PTR u (new dolfin::Function (aux)); retval = new function (str, u); - } + } } } else if (args(1).type_id () == function::static_type_id ()) { std::string str = args(0).string_value (); const function & fspo = - static_cast (args(1).get_rep ()); + static_cast (args(1).get_rep ()); int idx = args(2).int_value (); if (!error_state) @@ -124,14 +126,14 @@ else { if (idx < 1 || idx > f->value_dimension (0)) - error ("Function: index out of bounds"); - else - { + { error ("Function: index out of bounds"); } + else + { SHARED_PTR - u (new dolfin::Function((*f)[idx - 1])); + u (new dolfin::Function ((*f)[idx - 1])); retval = new function (str, u); - } + } } } } @@ -140,7 +142,7 @@ } void -copy_vector (Array const& arr, SHARED_PTR vec) +copy_vector (Array const & arr, SHARED_PTR vec) { unsigned const size = #ifdef LATEST_DOLFIN @@ -160,7 +162,7 @@ for (unsigned p = 1; p < size; ++p) if (rank == p) - world.send (0, p, loc_range); + { world.send (0, p, loc_range); } if (rank == 0) { @@ -168,32 +170,32 @@ { std::pair range; if (p == 0) - range = loc_range; + { range = loc_range; } else - world.recv (p, p, range); + { world.recv (p, p, range); } std::vector entries; for (std::size_t i = range.first; i < range.second; ++i) - entries.push_back (arr(i)); + { entries.push_back (arr(i)); } if (p == 0) - locvals = entries; + { locvals = entries; } else - world.send (p, p, entries); + { world.send (p, p, entries); } } } for (unsigned p = 1; p < size; ++p) { if (rank == p) - world.recv (0, p, locvals); + { world.recv (0, p, locvals); } } vec->set_local (locvals); } else for (std::size_t i = 0; i < arr.length (); ++i) - vec->setitem (i, arr(i)); + { vec->setitem (i, arr (i)); } vec->apply ("insert"); diff -r 53039ac90368 -r 61830a4f9ab9 src/Mesh.cc --- a/src/Mesh.cc Tue Aug 12 15:42:50 2014 +0200 +++ b/src/Mesh.cc Thu Aug 14 12:26:55 2014 +0200 @@ -29,7 +29,7 @@ compute_cell_markers (dolfin::Mesh const &, Array const &, std::size_t const); -DEFUN_DLD (Mesh, args, nargout,"-*- texinfo -*-\n\ +DEFUN_DLD (Mesh, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Function File} {[@var{mesh_out}, \ @var{facet_markers}, @var{cell_markers}]} = \ Mesh (@var{mesh_in}) \n\ @@ -55,7 +55,7 @@ octave_value_list retval; if (nargin < 1 || nargin > 1 || nargout > 3) - print_usage (); + { print_usage (); } else { if (!error_state) @@ -102,26 +102,26 @@ retval(1) = compute_facet_markers (msh, e, D); if (nargout == 3) - retval(2) = compute_cell_markers (msh, t, D); + { retval(2) = compute_cell_markers (msh, t, D); } } } } else - error ("Mesh: the argument you provide is invalid"); + { error ("Mesh: the argument you provide is invalid"); } } } return retval; } -mesh::mesh (Array& p, - Array& e, - Array& t) +mesh::mesh (Array & p, + Array & e, + Array & t) { std::size_t D = p.rows (); if (D < 2 || D > 3) - error ("Mesh constructor: only 2D or 3D meshes are supported"); + { error ("Mesh constructor: only 2D or 3D meshes are supported"); } else { dolfin::MeshEditor editor; @@ -164,7 +164,7 @@ // store information associated with e msh->init (D - 1); - dolfin::MeshValueCollection facet(*msh, D - 1); + dolfin::MeshValueCollection facet (*msh, D - 1); std::size_t num_side_edges = e.cols (); unsigned const size = @@ -223,7 +223,7 @@ && (*f).entities(0)[1] == e.xelem (1, i) - 1 && (*f).entities(0)[2] == e.xelem (0, i) - 1) { - std::pair + std::pair idxvl ((*f).index (), e.xelem (9, i)); msh->domains ().set_marker (idxvl, D - 1); break; @@ -400,14 +400,14 @@ Array const & e, std::size_t const D) { - dolfin::MeshFunction facet (_msh, D-1, + dolfin::MeshFunction facet (_msh, D - 1, std::numeric_limits ::max ()); std::size_t const num_side_edges = e.cols (); std::vector const & global_vertices = _msh.topology ().global_indices (0); std::vector const & global_facets = - _msh.topology ().global_indices (D-1); + _msh.topology ().global_indices (D - 1); if (D == 2) { @@ -417,7 +417,7 @@ std::size_t const e_index = e.xelem (0, i) - 1; while (local_vertex < global_vertices.size () && e_index != global_vertices[local_vertex]) - ++local_vertex; + { ++local_vertex; } if (local_vertex < global_vertices.size ()) { @@ -450,7 +450,7 @@ std::size_t const e_index = e.xelem (0, i) - 1; while (local_vertex < global_vertices.size () && e_index != global_vertices[local_vertex]) - ++local_vertex; + { ++local_vertex; } if (local_vertex < global_vertices.size ()) { @@ -464,7 +464,7 @@ std::size_t const & vertex2 = global_vertices[f->entities(0)[2]]; - if (vertex0 == e(0, i) - 1 + if (vertex0 == e.xelem (0, i) - 1 && vertex1 == e.xelem (1, i) - 1 && vertex2 == e.xelem (2, i) - 1 || vertex0 == e.xelem (0, i) - 1 @@ -517,7 +517,7 @@ std::size_t const t_index = t.xelem (0, i) - 1; while (local_vertex < global_vertices.size () && t_index != global_vertices[local_vertex]) - ++local_vertex; + { ++local_vertex; } if (local_vertex < global_vertices.size ()) { @@ -566,7 +566,7 @@ std::size_t const t_index = t.xelem (0, i) - 1; while (local_vertex < global_vertices.size () && t_index != global_vertices[local_vertex]) - ++local_vertex; + { ++local_vertex; } if (local_vertex < global_vertices.size ()) { @@ -583,104 +583,104 @@ global_vertices[f->entities(0)[3]]; if (vertex0 == t.xelem (0, i) - 1 - && vertex1 == t.xelem (1, i) - 1 - && vertex2 == t.xelem (2, i) - 1 - && vertex3 == t.xelem (3, i) - 1 - || vertex0 == t.xelem (0, i) - 1 - && vertex1 == t.xelem (1, i) - 1 - && vertex2 == t.xelem (3, i) - 1 - && vertex3 == t.xelem (2, i) - 1 - || vertex0 == t.xelem (0, i) - 1 - && vertex1 == t.xelem (2, i) - 1 - && vertex2 == t.xelem (1, i) - 1 - && vertex3 == t.xelem (3, i) - 1 - || vertex0 == t.xelem (0, i) - 1 - && vertex1 == t.xelem (2, i) - 1 - && vertex2 == t.xelem (3, i) - 1 - && vertex3 == t.xelem (1, i) - 1 - || vertex0 == t.xelem (0, i) - 1 - && vertex1 == t.xelem (3, i) - 1 - && vertex2 == t.xelem (1, i) - 1 - && vertex3 == t.xelem (2, i) - 1 - || vertex0 == t.xelem (0, i) - 1 - && vertex1 == t.xelem (3, i) - 1 - && vertex2 == t.xelem (2, i) - 1 - && vertex3 == t.xelem (1, i) - 1 + && vertex1 == t.xelem (1, i) - 1 + && vertex2 == t.xelem (2, i) - 1 + && vertex3 == t.xelem (3, i) - 1 + || vertex0 == t.xelem (0, i) - 1 + && vertex1 == t.xelem (1, i) - 1 + && vertex2 == t.xelem (3, i) - 1 + && vertex3 == t.xelem (2, i) - 1 + || vertex0 == t.xelem (0, i) - 1 + && vertex1 == t.xelem (2, i) - 1 + && vertex2 == t.xelem (1, i) - 1 + && vertex3 == t.xelem (3, i) - 1 + || vertex0 == t.xelem (0, i) - 1 + && vertex1 == t.xelem (2, i) - 1 + && vertex2 == t.xelem (3, i) - 1 + && vertex3 == t.xelem (1, i) - 1 + || vertex0 == t.xelem (0, i) - 1 + && vertex1 == t.xelem (3, i) - 1 + && vertex2 == t.xelem (1, i) - 1 + && vertex3 == t.xelem (2, i) - 1 + || vertex0 == t.xelem (0, i) - 1 + && vertex1 == t.xelem (3, i) - 1 + && vertex2 == t.xelem (2, i) - 1 + && vertex3 == t.xelem (1, i) - 1 - || vertex0 == t.xelem (1, i) - 1 - && vertex1 == t.xelem (0, i) - 1 - && vertex2 == t.xelem (2, i) - 1 - && vertex3 == t.xelem (3, i) - 1 - || vertex0 == t.xelem (1, i) - 1 - && vertex1 == t.xelem (0, i) - 1 - && vertex2 == t.xelem (3, i) - 1 - && vertex3 == t.xelem (2, i) - 1 - || vertex0 == t.xelem (1, i) - 1 - && vertex1 == t.xelem (2, i) - 1 - && vertex2 == t.xelem (0, i) - 1 - && vertex3 == t.xelem (3, i) - 1 - || vertex0 == t.xelem (1, i) - 1 - && vertex1 == t.xelem (2, i) - 1 - && vertex2 == t.xelem (3, i) - 1 - && vertex3 == t.xelem (0, i) - 1 - || vertex0 == t.xelem (1, i) - 1 - && vertex1 == t.xelem (3, i) - 1 - && vertex2 == t.xelem (0, i) - 1 - && vertex3 == t.xelem (2, i) - 1 - || vertex0 == t.xelem (1, i) - 1 - && vertex1 == t.xelem (3, i) - 1 - && vertex2 == t.xelem (2, i) - 1 - && vertex3 == t.xelem (0, i) - 1 + || vertex0 == t.xelem (1, i) - 1 + && vertex1 == t.xelem (0, i) - 1 + && vertex2 == t.xelem (2, i) - 1 + && vertex3 == t.xelem (3, i) - 1 + || vertex0 == t.xelem (1, i) - 1 + && vertex1 == t.xelem (0, i) - 1 + && vertex2 == t.xelem (3, i) - 1 + && vertex3 == t.xelem (2, i) - 1 + || vertex0 == t.xelem (1, i) - 1 + && vertex1 == t.xelem (2, i) - 1 + && vertex2 == t.xelem (0, i) - 1 + && vertex3 == t.xelem (3, i) - 1 + || vertex0 == t.xelem (1, i) - 1 + && vertex1 == t.xelem (2, i) - 1 + && vertex2 == t.xelem (3, i) - 1 + && vertex3 == t.xelem (0, i) - 1 + || vertex0 == t.xelem (1, i) - 1 + && vertex1 == t.xelem (3, i) - 1 + && vertex2 == t.xelem (0, i) - 1 + && vertex3 == t.xelem (2, i) - 1 + || vertex0 == t.xelem (1, i) - 1 + && vertex1 == t.xelem (3, i) - 1 + && vertex2 == t.xelem (2, i) - 1 + && vertex3 == t.xelem (0, i) - 1 - || vertex0 == t.xelem (2, i) - 1 - && vertex1 == t.xelem (0, i) - 1 - && vertex2 == t.xelem (1, i) - 1 - && vertex3 == t.xelem (3, i) - 1 - || vertex0 == t.xelem (2, i) - 1 - && vertex1 == t.xelem (0, i) - 1 - && vertex2 == t.xelem (3, i) - 1 - && vertex3 == t.xelem (1, i) - 1 - || vertex0 == t.xelem (2, i) - 1 - && vertex1 == t.xelem (1, i) - 1 - && vertex2 == t.xelem (0, i) - 1 - && vertex3 == t.xelem (3, i) - 1 - || vertex0 == t.xelem (2, i) - 1 - && vertex1 == t.xelem (1, i) - 1 - && vertex2 == t.xelem (3, i) - 1 - && vertex3 == t.xelem (0, i) - 1 - || vertex0 == t.xelem (2, i) - 1 - && vertex1 == t.xelem (3, i) - 1 - && vertex2 == t.xelem (0, i) - 1 - && vertex3 == t.xelem (1, i) - 1 - || vertex0 == t.xelem (2, i) - 1 - && vertex1 == t.xelem (3, i) - 1 - && vertex2 == t.xelem (1, i) - 1 - && vertex3 == t.xelem (0, i) - 1 + || vertex0 == t.xelem (2, i) - 1 + && vertex1 == t.xelem (0, i) - 1 + && vertex2 == t.xelem (1, i) - 1 + && vertex3 == t.xelem (3, i) - 1 + || vertex0 == t.xelem (2, i) - 1 + && vertex1 == t.xelem (0, i) - 1 + && vertex2 == t.xelem (3, i) - 1 + && vertex3 == t.xelem (1, i) - 1 + || vertex0 == t.xelem (2, i) - 1 + && vertex1 == t.xelem (1, i) - 1 + && vertex2 == t.xelem (0, i) - 1 + && vertex3 == t.xelem (3, i) - 1 + || vertex0 == t.xelem (2, i) - 1 + && vertex1 == t.xelem (1, i) - 1 + && vertex2 == t.xelem (3, i) - 1 + && vertex3 == t.xelem (0, i) - 1 + || vertex0 == t.xelem (2, i) - 1 + && vertex1 == t.xelem (3, i) - 1 + && vertex2 == t.xelem (0, i) - 1 + && vertex3 == t.xelem (1, i) - 1 + || vertex0 == t.xelem (2, i) - 1 + && vertex1 == t.xelem (3, i) - 1 + && vertex2 == t.xelem (1, i) - 1 + && vertex3 == t.xelem (0, i) - 1 - || vertex0 == t.xelem (3, i) - 1 - && vertex1 == t.xelem (0, i) - 1 - && vertex2 == t.xelem (1, i) - 1 - && vertex3 == t.xelem (2, i) - 1 - || vertex0 == t.xelem (3, i) - 1 - && vertex1 == t.xelem (0, i) - 1 - && vertex2 == t.xelem (2, i) - 1 - && vertex3 == t.xelem (1, i) - 1 - || vertex0 == t.xelem (3, i) - 1 - && vertex1 == t.xelem (1, i) - 1 - && vertex2 == t.xelem (0, i) - 1 - && vertex3 == t.xelem (2, i) - 1 - || vertex0 == t.xelem (3, i) - 1 - && vertex1 == t.xelem (1, i) - 1 - && vertex2 == t.xelem (2, i) - 1 - && vertex3 == t.xelem (0, i) - 1 - || vertex0 == t.xelem (3, i) - 1 - && vertex1 == t.xelem (2, i) - 1 - && vertex2 == t.xelem (0, i) - 1 - && vertex3 == t.xelem (1, i) - 1 - || vertex0 == t.xelem (3, i) - 1 - && vertex1 == t.xelem (2, i) - 1 - && vertex2 == t.xelem (1, i) - 1 - && vertex3 == t.xelem (0, i) - 1) + || vertex0 == t.xelem (3, i) - 1 + && vertex1 == t.xelem (0, i) - 1 + && vertex2 == t.xelem (1, i) - 1 + && vertex3 == t.xelem (2, i) - 1 + || vertex0 == t.xelem (3, i) - 1 + && vertex1 == t.xelem (0, i) - 1 + && vertex2 == t.xelem (2, i) - 1 + && vertex3 == t.xelem (1, i) - 1 + || vertex0 == t.xelem (3, i) - 1 + && vertex1 == t.xelem (1, i) - 1 + && vertex2 == t.xelem (0, i) - 1 + && vertex3 == t.xelem (2, i) - 1 + || vertex0 == t.xelem (3, i) - 1 + && vertex1 == t.xelem (1, i) - 1 + && vertex2 == t.xelem (2, i) - 1 + && vertex3 == t.xelem (0, i) - 1 + || vertex0 == t.xelem (3, i) - 1 + && vertex1 == t.xelem (2, i) - 1 + && vertex2 == t.xelem (0, i) - 1 + && vertex3 == t.xelem (1, i) - 1 + || vertex0 == t.xelem (3, i) - 1 + && vertex1 == t.xelem (2, i) - 1 + && vertex2 == t.xelem (1, i) - 1 + && vertex3 == t.xelem (0, i) - 1) { cell[*f] = t.xelem (4, i); break; diff -r 53039ac90368 -r 61830a4f9ab9 src/MeshFunction.cc --- a/src/MeshFunction.cc Tue Aug 12 15:42:50 2014 +0200 +++ b/src/MeshFunction.cc Thu Aug 14 12:26:55 2014 +0200 @@ -44,9 +44,9 @@ int nargin = args.length (); octave_value retval; - + if (nargin < 2 || nargin > 4 || nargout > 1) - print_usage (); + { print_usage (); } else { if (! mesh_type_loaded) @@ -106,10 +106,10 @@ } } else - error ("invalid input arguments"); + { error ("invalid input arguments"); } } else - error ("invalid input arguments"); + { error ("invalid input arguments"); } } return retval; diff -r 53039ac90368 -r 61830a4f9ab9 src/PETSc_factory.cc --- a/src/PETSc_factory.cc Tue Aug 12 15:42:50 2014 +0200 +++ b/src/PETSc_factory.cc Thu Aug 14 12:26:55 2014 +0200 @@ -21,240 +21,238 @@ #include #endif -femfenics_base_factory const& +femfenics_base_factory const & PETSc_factory::instance (void) - { - static PETSc_factory const theinstance; - return theinstance; - } +{ + static PETSc_factory const theinstance; + return theinstance; +} octave_value -PETSc_factory::matrix (dolfin::Matrix const& A) const - { - octave_value retval; +PETSc_factory::matrix (dolfin::Matrix const & A) const +{ + octave_value retval; - unsigned const size = + unsigned const size = #ifdef LATEST_DOLFIN - dolfin::MPI::size (MPI_COMM_WORLD); + dolfin::MPI::size (MPI_COMM_WORLD); #else - dolfin::MPI::num_processes (); + dolfin::MPI::num_processes (); #endif - if (size > 1) - retval = do_matrix_parallel (A); - else - retval = do_matrix_serial (A); + if (size > 1) + { retval = do_matrix_parallel (A); } + else + { retval = do_matrix_serial (A); } - return retval; - } + return retval; +} octave_value -PETSc_factory::vector (dolfin::Vector const& b) const - { - octave_value retval; +PETSc_factory::vector (dolfin::Vector const & b) const +{ + octave_value retval; - unsigned const size = + unsigned const size = #ifdef LATEST_DOLFIN - dolfin::MPI::size (MPI_COMM_WORLD); + dolfin::MPI::size (MPI_COMM_WORLD); #else - dolfin::MPI::num_processes (); + dolfin::MPI::num_processes (); #endif - if (size > 1) - retval = do_vector_parallel (b); - else - retval = do_vector_serial (b); + if (size > 1) + { retval = do_vector_parallel (b); } + else + { retval = do_vector_serial (b); } - return retval; - } + return retval; +} void PETSc_factory::add_to_arrays (Array & ridx, Array & cidx, Array & values, - std::vector const& row, - std::vector const& col, - std::vector const& val) - { - octave_idx_type pos = cidx.numel (); + std::vector const & row, + std::vector const & col, + std::vector const & val) +{ + octave_idx_type pos = cidx.numel (); - dim_vector dims = cidx.dims (); - if (dims(1) == 1) - dims(0) += col.size (); - else - dims(1) += col.size (); - ridx.resize (dims, 0); - cidx.resize (dims, 0); - values.resize (dims, 0); + dim_vector dims = cidx.dims (); + if (dims(1) == 1) + { dims(0) += col.size (); } + else + { dims(1) += col.size (); } + ridx.resize (dims, 0); + cidx.resize (dims, 0); + values.resize (dims, 0); - std::vector ::const_iterator rit = row.begin (), - cit = col.begin (); - std::vector ::const_iterator vit = val.begin (); + std::vector ::const_iterator rit = row.begin (), + cit = col.begin (); + std::vector ::const_iterator vit = val.begin (); - while (cit != col.end ()) - { - ridx(pos) = *rit; - cidx(pos) = *cit; - values(pos) = *vit; + while (cit != col.end ()) + { + ridx(pos) = *rit; + cidx(pos) = *cit; + values(pos) = *vit; - ++rit; - ++cit; - ++vit; - ++pos; - } + ++rit; + ++cit; + ++vit; + ++pos; + } - return; - } + return; +} octave_value -PETSc_factory::do_matrix_serial (dolfin::Matrix const& A) const - { - octave_value retval; - - std::size_t nr = A.size (0), nc = A.size (1); +PETSc_factory::do_matrix_serial (dolfin::Matrix const & A) const +{ + octave_value retval; - dim_vector dims (0, 1); - Array - ridx (dims, 0), - cidx (dims, 0); - Array data (dims, 0); + std::size_t nr = A.size (0), nc = A.size (1); + + dim_vector dims (0, 1); + Array ridx (dims, 0), cidx (dims, 0); + Array data (dims, 0); - for (std::size_t i = 0; i < nr; ++i) - { - std::vector data_tmp; - std::vector cidx_tmp; - A.getrow (i, cidx_tmp, data_tmp); - std::vector ridx_tmp (cidx_tmp.size (), i); - add_to_arrays (ridx, cidx, data, ridx_tmp, cidx_tmp, data_tmp); - } + for (std::size_t i = 0; i < nr; ++i) + { + std::vector data_tmp; + std::vector cidx_tmp; + A.getrow (i, cidx_tmp, data_tmp); + std::vector ridx_tmp (cidx_tmp.size (), i); + add_to_arrays (ridx, cidx, data, ridx_tmp, cidx_tmp, data_tmp); + } - SparseMatrix sm (data, ridx, cidx, nr, nc); - retval = sm; + SparseMatrix sm (data, ridx, cidx, nr, nc); + retval = sm; - return retval; - } + return retval; +} octave_value -PETSc_factory::do_matrix_parallel (dolfin::Matrix const& A) const - { - octave_value retval; +PETSc_factory::do_matrix_parallel (dolfin::Matrix const & A) const +{ + octave_value retval; - std::vector rows, cols; - std::vector vals; - std::size_t const nrows = A.size (0), ncols = A.size (1); + std::vector rows, cols; + std::vector vals; + std::size_t const nrows = A.size (0), ncols = A.size (1); - std::pair const range = A.local_range (0); - for (std::size_t i = range.first; i < range.second; ++i) - { - std::vector cols_tmp; - std::vector vals_tmp; - A.getrow (i, cols_tmp, vals_tmp); - cols.insert (cols.end (), cols_tmp.begin (), cols_tmp.end ()); - vals.insert (vals.end (), vals_tmp.begin (), vals_tmp.end ()); - for (std::size_t j = 0; j < cols_tmp.size (); ++j) - rows.push_back (i); - } + std::pair const range = A.local_range (0); + for (std::size_t i = range.first; i < range.second; ++i) + { + std::vector cols_tmp; + std::vector vals_tmp; + A.getrow (i, cols_tmp, vals_tmp); + cols.insert (cols.end (), cols_tmp.begin (), cols_tmp.end ()); + vals.insert (vals.end (), vals_tmp.begin (), vals_tmp.end ()); + for (std::size_t j = 0; j < cols_tmp.size (); ++j) + { rows.push_back (i); } + } - boost::mpi::communicator world; + boost::mpi::communicator world; - unsigned const size = world.size (); - unsigned const rank = world.rank (); + unsigned const size = world.size (); + unsigned const rank = world.rank (); - for (unsigned p = 1; p < size; ++p) - { - if (rank == p) - { - unsigned const tag = 3*(p-1); - world.send (0, tag, rows); - world.send (0, tag+1, cols); - world.send (0, tag+2, vals); - } - } + for (unsigned p = 1; p < size; ++p) + { + if (rank == p) + { + unsigned const tag = 3 * (p - 1); + world.send (0, tag, rows); + world.send (0, tag + 1, cols); + world.send (0, tag + 2, vals); + } + } - if (rank == 0) - { - dim_vector dims (0, 1); - Array ridx (dims, 0), cidx (dims, 0); - Array data (dims, 0); - add_to_arrays (ridx, cidx, data, rows, cols, vals); + if (rank == 0) + { + dim_vector dims (0, 1); + Array ridx (dims, 0), cidx (dims, 0); + Array data (dims, 0); + add_to_arrays (ridx, cidx, data, rows, cols, vals); - for (unsigned p = 1; p < size; ++p) - { - std::vector new_vals; - std::vector new_rows, new_cols; - unsigned const tag = 3*(p-1); + for (unsigned p = 1; p < size; ++p) + { + std::vector new_vals; + std::vector new_rows, new_cols; + unsigned const tag = 3 * (p - 1); - world.recv (p, tag, new_rows); - world.recv (p, tag+1, new_cols); - world.recv (p, tag+2, new_vals); + world.recv (p, tag, new_rows); + world.recv (p, tag + 1, new_cols); + world.recv (p, tag + 2, new_vals); - add_to_arrays (ridx, cidx, data, new_rows, new_cols, new_vals); - } + add_to_arrays (ridx, cidx, data, new_rows, new_cols, new_vals); + } - SparseMatrix sm (data, ridx, cidx, nrows, ncols); - retval = sm; - } - else - // Return an identity matrix just to avoid warnings or errors - { - dim_vector dims (nrows, 1); - Array ridx (dims), cidx (dims); - Array data (dims, 1); + SparseMatrix sm (data, ridx, cidx, nrows, ncols); + retval = sm; + } + else + // Return an identity matrix just to avoid warnings or errors + { + dim_vector dims (nrows, 1); + Array ridx (dims), cidx (dims); + Array data (dims, 1); - for (std::size_t i = 0; i < nrows; ++i) - { - ridx.xelem (i) = i; - cidx.xelem (i) = i; - } + for (std::size_t i = 0; i < nrows; ++i) + { + ridx.xelem (i) = i; + cidx.xelem (i) = i; + } - SparseMatrix sm (data, ridx, cidx, nrows, ncols); - retval = sm; - } + SparseMatrix sm (data, ridx, cidx, nrows, ncols); + retval = sm; + } - return retval; - } + return retval; +} octave_value -PETSc_factory::do_vector_serial (dolfin::Vector const& b) const - { - octave_value retval; +PETSc_factory::do_vector_serial (dolfin::Vector const & b) const +{ + octave_value retval; - dim_vector dims; - dims.resize (2); - dims(0) = b.size (); - dims(1) = 1; - Array myb (dims); + dim_vector dims; + dims.resize (2); + dims(0) = b.size (); + dims(1) = 1; + Array myb (dims); - for (std::size_t i = 0; i < b.size (); ++i) - myb.xelem (i) = b[i]; + for (std::size_t i = 0; i < b.size (); ++i) + { myb.xelem (i) = b[i]; } - retval = myb; + retval = myb; - return retval; - } + return retval; +} octave_value -PETSc_factory::do_vector_parallel (dolfin::Vector const& b) const - { - octave_value retval; +PETSc_factory::do_vector_parallel (dolfin::Vector const & b) const +{ + octave_value retval; - std::size_t const length = b.size (); - dim_vector dims (length, 1); - Array vec (dims, 0); + std::size_t const length = b.size (); + dim_vector dims (length, 1); + Array vec (dims, 0); - std::vector entries; - b.gather_on_zero (entries); + std::vector entries; + b.gather_on_zero (entries); #ifdef LATEST_DOLFIN - if (dolfin::MPI::rank (MPI_COMM_WORLD) == 0) + if (dolfin::MPI::rank (MPI_COMM_WORLD) == 0) #else - if (dolfin::MPI::process_number () == 0) + if (dolfin::MPI::process_number () == 0) #endif - for (std::size_t i = 0; i < length; ++i) - vec.xelem (i) = entries[i]; + for (std::size_t i = 0; i < length; ++i) + { vec.xelem (i) = entries[i]; } - // On nodes other than zero, return an all zero vector of the right length - retval = vec; + // On nodes other than zero, return an all zero vector of the right length + retval = vec; - return retval; - } + return retval; +} diff -r 53039ac90368 -r 61830a4f9ab9 src/PETSc_factory.h --- a/src/PETSc_factory.h Tue Aug 12 15:42:50 2014 +0200 +++ b/src/PETSc_factory.h Thu Aug 14 12:26:55 2014 +0200 @@ -22,32 +22,32 @@ class PETSc_factory : public femfenics_base_factory { - public: +public: virtual ~PETSc_factory () {} - octave_value matrix (dolfin::Matrix const&) const; - octave_value vector (dolfin::Vector const&) const; + octave_value matrix (dolfin::Matrix const &) const; + octave_value vector (dolfin::Vector const &) const; - static femfenics_base_factory const& instance (void); + static femfenics_base_factory const & instance (void); - private: +private: PETSc_factory () {} - PETSc_factory (PETSc_factory const&); - PETSc_factory & operator = (PETSc_factory const&); + PETSc_factory (PETSc_factory const &); + PETSc_factory & operator = (PETSc_factory const &); static void add_to_arrays (Array &, Array &, Array &, - std::vector const&, - std::vector const&, - std::vector const&); + std::vector const &, + std::vector const &, + std::vector const &); - octave_value do_matrix_serial (dolfin::Matrix const&) const; - octave_value do_matrix_parallel (dolfin::Matrix const&) const; - octave_value do_vector_serial (dolfin::Vector const&) const; - octave_value do_vector_parallel (dolfin::Vector const&) const; + octave_value do_matrix_serial (dolfin::Matrix const &) const; + octave_value do_matrix_parallel (dolfin::Matrix const &) const; + octave_value do_vector_serial (dolfin::Vector const &) const; + octave_value do_vector_parallel (dolfin::Vector const &) const; }; #endif diff -r 53039ac90368 -r 61830a4f9ab9 src/SubDomain.cc --- a/src/SubDomain.cc Tue Aug 12 15:42:50 2014 +0200 +++ b/src/SubDomain.cc Thu Aug 14 12:26:55 2014 +0200 @@ -32,7 +32,7 @@ octave_value retval; if (nargin < 2 || nargin > 2 || nargout > 1) - print_usage (); + { print_usage (); } else { if (args(0).is_function_handle () && args(1).is_bool_scalar ()) @@ -49,7 +49,7 @@ retval = new subdomain (*pfh, on_boundary); } else - error ("invalid input arguments"); + { error ("invalid input arguments"); } } return retval; diff -r 53039ac90368 -r 61830a4f9ab9 src/assemble.cc --- a/src/assemble.cc Tue Aug 12 15:42:50 2014 +0200 +++ b/src/assemble.cc Thu Aug 14 12:26:55 2014 +0200 @@ -20,7 +20,7 @@ #include "femfenics_factory.h" #include "dolfin_compat.h" -DEFUN_DLD (assemble, args, nargout, +DEFUN_DLD (assemble, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Function File} {[@var{A}], [@var{x}(Optional)]} = \ assemble (@var{form_a}, @var{DirichletBC}) \n\ @@ -67,12 +67,12 @@ if (nargout == 1) { if (nargin < 1) - print_usage (); + { print_usage (); } else { if (args(0).type_id () == form::static_type_id ()) { - const form & frm = static_cast (args(0).get_rep ()); + const form & frm = static_cast (args(0).get_rep ()); if (! error_state) { @@ -88,23 +88,22 @@ for (std::size_t i = 1; i < nargin; ++i) { - if (args(i).type_id () == + if (args(i).type_id () == boundarycondition::static_type_id ()) { const boundarycondition & bc - = static_cast - (args(i).get_rep ()); + = static_cast + (args(i).get_rep ()); - const - std::vector > + const std::vector > & pbc = bc.get_bc (); - + for (std::size_t j = 0; j < pbc.size (); ++j) - pbc[j]->apply(A); + { pbc[j]->apply (A); } } else - error ("assemble: unknown argument type"); + { error ("assemble: unknown argument type"); } } retval(0) = factory.matrix (A); @@ -119,22 +118,22 @@ for (std::size_t i = 1; i < nargin; ++i) { - if (args(i).type_id () == + if (args(i).type_id () == boundarycondition::static_type_id ()) { const boundarycondition & bc - = static_cast - (args(i).get_rep ()); + = static_cast + (args(i).get_rep ()); - const std::vector > + const std::vector > & pbc = bc.get_bc (); for (std::size_t j = 0; j < pbc.size (); ++j) - pbc[j]->apply(A); + { pbc[j]->apply (A); } } else - error ("assemble: unknown argument type"); + { error ("assemble: unknown argument type"); } } retval(0) = factory.vector (A); @@ -147,7 +146,7 @@ } else - error ("assemble: unknown form size"); + { error ("assemble: unknown form size"); } } } } @@ -155,12 +154,12 @@ else if (nargout == 2) { if (nargin < 2) - print_usage (); + { print_usage (); } else { if (args(0).type_id () == form::static_type_id ()) { - const form & frm = + const form & frm = static_cast (args(0).get_rep ()); const Array myx = args(1).array_value (); @@ -182,27 +181,27 @@ dolfin::Vector x (myx.length ()); #endif for (std::size_t i = 0; i < myx.length (); ++i) - x.setitem (i, myx.xelem (i)); + { x.setitem (i, myx.xelem (i)); } for (std::size_t i = 2; i < nargin; ++i) { - if (args(i).type_id () == + if (args(i).type_id () == boundarycondition::static_type_id ()) { const boundarycondition & bc - = static_cast - (args(i).get_rep ()); + = static_cast + (args(i).get_rep ()); - const std::vector > + const std::vector > & pbc = bc.get_bc (); - for (std::size_t j = 0; + for (std::size_t j = 0; j < pbc.size (); ++j) - pbc[j]->apply(A, x); + { pbc[j]->apply (A, x); } } else - error ("assemble: unknown argument type"); + { error ("assemble: unknown argument type"); } } retval(0) = factory.vector (A); @@ -210,7 +209,7 @@ } else - error ("assemble: unknown size"); + { error ("assemble: unknown size"); } } } } diff -r 53039ac90368 -r 61830a4f9ab9 src/assemble_system.cc --- a/src/assemble_system.cc Tue Aug 12 15:42:50 2014 +0200 +++ b/src/assemble_system.cc Thu Aug 14 12:26:55 2014 +0200 @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Marco Vassallo + Copyright (C) 2013 Marco Vassallo This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -60,7 +60,7 @@ if (nargout == 2) { if (nargin < 2) - print_usage (); + { print_usage (); } else { @@ -68,9 +68,9 @@ && args(1).type_id () == form::static_type_id ()) { const form & frm1 = - static_cast (args(0).get_rep ()); + static_cast (args(0).get_rep ()); const form & frm2 = - static_cast (args(1).get_rep ()); + static_cast (args(1).get_rep ()); if (! error_state) { @@ -94,18 +94,18 @@ boundarycondition::static_type_id ()) { const boundarycondition & bc - = static_cast - (args(i).get_rep ()); + = static_cast + (args(i).get_rep ()); - const std::vector > - & pbc = bc.get_bc (); + const std::vector > + & pbc = bc.get_bc (); for (std::size_t j = 0; j < pbc.size (); ++j) - pbc[j]->apply(A, B); + { pbc[j]->apply (A, B); } } else - error ("assemble_system: unknown argument type"); + { error ("assemble_system: unknown argument type"); } } retval(0) = factory.matrix (A); @@ -113,23 +113,23 @@ } } else - error ("assemble_system: unknown size"); + { error ("assemble_system: unknown size"); } } } } else if (nargout == 3) { if (nargin < 3) - print_usage (); + { print_usage (); } else { if (args(0).type_id () == form::static_type_id () && args(1).type_id () == form::static_type_id ()) { const form & frm1 = - static_cast (args(0).get_rep ()); + static_cast (args(0).get_rep ()); const form & frm2 = - static_cast (args(1).get_rep ()); + static_cast (args(1).get_rep ()); const Array myx = args(2).array_value (); if (! error_state) @@ -154,28 +154,28 @@ #endif for (std::size_t i = 0; i < myx.length (); ++i) - x.setitem (i, myx.xelem (i)); + { x.setitem (i, myx.xelem (i)); } for (std::size_t i = 3; i < nargin; ++i) { - if (args(i).type_id () == + if (args(i).type_id () == boundarycondition::static_type_id ()) { const boundarycondition & bc - = static_cast + = static_cast (args(i).get_rep ()); - const std::vector > - & pbc = bc.get_bc (); + const std::vector > + & pbc = bc.get_bc (); for (std::size_t j = 0; j < pbc.size (); ++j) - pbc[j]->apply(A, B, x); + { pbc[j]->apply (A, B, x); } } else - error ("assemble_system: unknown argument type"); + { error ("assemble_system: unknown argument type"); } } retval(0) = factory.matrix (A); @@ -184,7 +184,7 @@ } } else - error ("assemble_system: unknown size"); + { error ("assemble_system: unknown size"); } } } } diff -r 53039ac90368 -r 61830a4f9ab9 src/barrier.cc --- a/src/barrier.cc Tue Aug 12 15:42:50 2014 +0200 +++ b/src/barrier.cc Thu Aug 14 12:26:55 2014 +0200 @@ -30,7 +30,7 @@ int nargin = args.length (); if (nargin > 0 || nargout > 0) - print_usage (); + { print_usage (); } else { dolfin::MPI::barrier ( diff -r 53039ac90368 -r 61830a4f9ab9 src/boundarycondition.h --- a/src/boundarycondition.h Tue Aug 12 15:42:50 2014 +0200 +++ b/src/boundarycondition.h Thu Aug 14 12:26:55 2014 +0200 @@ -27,54 +27,54 @@ class boundarycondition : public octave_base_value { - public: +public: - boundarycondition () + boundarycondition () : octave_base_value () {} void - print (std::ostream& os, bool pr_as_read_syntax = false) const + print (std::ostream & os, bool pr_as_read_syntax = false) const { - for (std::size_t i = 0; i < bcu.size (); ++i) - os << "Boundary condition : " << bcu[i]->str (true) << std::endl; + for (std::size_t i = 0; i < bcu.size (); ++i) + { os << "Boundary condition : " << bcu[i]->str (true) << std::endl; } } ~boundarycondition (void) {} bool is_defined (void) const - { return true; } + { return true; } - const std::vector< SHARED_PTR - > & - get_bc (void) const - { return bcu; } + const std::vector< SHARED_PTR + > & + get_bc (void) const + { return bcu; } void add_bc (const SHARED_PTR & V, SHARED_PTR f, std::size_t n) - { - SHARED_PTR - p (new dolfin::DirichletBC (V, f, n)); - bcu.push_back(p); - } + { + SHARED_PTR + p (new dolfin::DirichletBC (V, f, n)); + bcu.push_back (p); + } void add_bc (SHARED_PTR const & V, SHARED_PTR f, SHARED_PTR const> const & sd, std::size_t n) - { - SHARED_PTR - p (new dolfin::DirichletBC (V, f, sd, n)); - bcu.push_back(p); - } + { + SHARED_PTR + p (new dolfin::DirichletBC (V, f, sd, n)); + bcu.push_back (p); + } - private: +private: - std::vector > bcu; + std::vector > bcu; DECLARE_OCTAVE_ALLOCATOR; DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA; @@ -85,6 +85,6 @@ DEFINE_OCTAVE_ALLOCATOR (boundarycondition); DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (boundarycondition, - "boundarycondition", - "boundarycondition"); + "boundarycondition", + "boundarycondition"); #endif diff -r 53039ac90368 -r 61830a4f9ab9 src/femfenics_base_factory.h --- a/src/femfenics_base_factory.h Tue Aug 12 15:42:50 2014 +0200 +++ b/src/femfenics_base_factory.h Thu Aug 14 12:26:55 2014 +0200 @@ -23,13 +23,13 @@ class femfenics_base_factory { - public: +public: femfenics_base_factory () {} virtual ~femfenics_base_factory () {} - virtual octave_value matrix (dolfin::Matrix const&) const =0; - virtual octave_value vector (dolfin::Vector const&) const =0; + virtual octave_value matrix (dolfin::Matrix const &) const = 0; + virtual octave_value vector (dolfin::Vector const &) const = 0; }; #endif \ No newline at end of file diff -r 53039ac90368 -r 61830a4f9ab9 src/femfenics_factory.cc --- a/src/femfenics_factory.cc Tue Aug 12 15:42:50 2014 +0200 +++ b/src/femfenics_factory.cc Thu Aug 14 12:26:55 2014 +0200 @@ -20,22 +20,22 @@ #include "PETSc_factory.h" #include -femfenics_base_factory const& +femfenics_base_factory const & femfenics_factory::factory (void) const - { - std::string backend = linear_algebra_backend (); +{ + std::string backend = linear_algebra_backend (); - if (backend == "uBLAS") - return uBLAS_factory::instance (); + if (backend == "uBLAS") + { return uBLAS_factory::instance (); } - // Default back-end - return PETSc_factory::instance (); - } + // Default back-end + return PETSc_factory::instance (); +} std::string femfenics_factory::linear_algebra_backend (void) const - { - octave_value_list ovl = feval ("linear_algebra_backend"); - std::string retval = ovl(0).string_value (); - return retval; - } \ No newline at end of file +{ + octave_value_list ovl = feval ("linear_algebra_backend"); + std::string retval = ovl (0).string_value (); + return retval; +} \ No newline at end of file diff -r 53039ac90368 -r 61830a4f9ab9 src/femfenics_factory.h --- a/src/femfenics_factory.h Tue Aug 12 15:42:50 2014 +0200 +++ b/src/femfenics_factory.h Thu Aug 14 12:26:55 2014 +0200 @@ -23,25 +23,26 @@ class femfenics_factory : public femfenics_base_factory { - public: +public: femfenics_factory () - { dolfin::parameters["linear_algebra_backend"] = linear_algebra_backend (); } + { dolfin::parameters["linear_algebra_backend"] = linear_algebra_backend (); } + virtual ~femfenics_factory () {} - virtual inline octave_value matrix (dolfin::Matrix const& A) const - { return factory ().matrix (A); } + virtual inline octave_value matrix (dolfin::Matrix const & A) const + { return factory ().matrix (A); } - virtual inline octave_value vector (dolfin::Vector const& b) const - { return factory ().vector (b); } + virtual inline octave_value vector (dolfin::Vector const & b) const + { return factory ().vector (b); } - private: +private: - femfenics_factory (femfenics_factory const&); - femfenics_factory operator = (femfenics_factory const&); + femfenics_factory (femfenics_factory const &); + femfenics_factory operator = (femfenics_factory const &); std::string linear_algebra_backend (void) const; - femfenics_base_factory const& factory (void) const; + femfenics_base_factory const & factory (void) const; }; #endif \ No newline at end of file diff -r 53039ac90368 -r 61830a4f9ab9 src/feval.cc --- a/src/feval.cc Tue Aug 12 15:42:50 2014 +0200 +++ b/src/feval.cc Thu Aug 14 12:26:55 2014 +0200 @@ -39,7 +39,7 @@ int nargin = args.length (); octave_value_list retval; - + if (! function_type_loaded) { function::register_type (); @@ -50,16 +50,16 @@ if (args(0).type_id () == function::static_type_id ()) { const function & fspo = - static_cast (args(0).get_rep ()); + static_cast (args(0).get_rep ()); if (!error_state) { - const SHARED_PTR + const SHARED_PTR & f = fspo.get_pfun (); octave_idx_type pdim = f->geometric_dimension (); if (nargin != pdim + 1) - print_usage (); + { print_usage (); } else { std::vector coordinates; @@ -68,12 +68,12 @@ for (octave_idx_type in = 1; in <= pdim; ++in) { if (! args(in).is_real_type ()) - error ("invalid argument"); + { error ("invalid argument"); } else { Matrix aux = args(in).matrix_value (); if (in == 1) - dims = aux.dims (); + { dims = aux.dims (); } else { dim_vector newdims = aux.dims (); @@ -93,23 +93,23 @@ { octave_idx_type vdim = f->value_dimension (0); if (nargout != vdim) - error ("wrong number of output arguments"); + { error ("wrong number of output arguments"); } else { std::vector evaluations; for (octave_idx_type out = 0; out < vdim; ++out) - evaluations.push_back (Matrix (dims)); + { evaluations.push_back (Matrix (dims)); } for (octave_idx_type k = 0; k < dims.numel (); ++k) { Array point (dim_vector (pdim, 1)); for (octave_idx_type el = 0; el < pdim; ++el) - point (el) = coordinates[el] (k); - dolfin::Array + { point (el) = coordinates[el] (k); } + dolfin::Array x (point.length (), point.fortran_vec ()); Array res (dim_vector (vdim, 1)); - dolfin::Array + dolfin::Array values (res.length (), res.fortran_vec ()); try { @@ -124,15 +124,15 @@ } for (octave_idx_type el = 0; el < vdim; ++el) - evaluations[el] (k) = res (el); + { evaluations[el] (k) = res (el); } } if (! error_state) { for (std::vector::iterator it = - evaluations.begin (); + evaluations.begin (); it != evaluations.end (); ++it) - retval.append (octave_value (*it)); + { retval.append (octave_value (*it)); } } } } diff -r 53039ac90368 -r 61830a4f9ab9 src/function.h --- a/src/function.h Tue Aug 12 15:42:50 2014 +0200 +++ b/src/function.h Thu Aug 14 12:26:55 2014 +0200 @@ -28,98 +28,98 @@ class function : public octave_base_value { - public: +public: function () : octave_base_value (), fun () {} - function (std::string & _str, + function (std::string & _str, SHARED_PTR _fun) - : octave_base_value (), str(_str), fun (_fun) {} + : octave_base_value (), str (_str), fun (_fun) {} - function (function const& _func) + function (function const & _func) : octave_base_value (), str (_func.get_str ()), fun (_func.get_pfun ()) {} - void - print (std::ostream& os, + void + print (std::ostream & os, bool pr_as_read_syntax = false) const - { os << "Function " << str << ": " << fun->str (true) << std::endl; } + { os << "Function " << str << ": " << fun->str (true) << std::endl; } - ~function(void) {} + ~function (void) {} - bool + bool is_defined (void) const - { return true; } + { return true; } const dolfin::Function & get_fun (void) const - { return (*fun); } + { return (*fun); } const SHARED_PTR & get_pfun (void) const - { return fun; } + { return fun; } - void + void set_fun (dolfin::Function & _fun) - { - dolfin::Function * p = new dolfin::Function (_fun); - fun = SHARED_PTR (p); - } + { + dolfin::Function * p = new dolfin::Function (_fun); + fun = SHARED_PTR (p); + } - const std::string & + const std::string & get_str (void) const - { return str; } + { return str; } octave_value - subsref (const std::string& type, - const std::list& idx) - { - octave_value retval; - retval = subsref (type, idx, 1); - return retval; - } + subsref (const std::string & type, + const std::list & idx) + { + octave_value retval; + retval = subsref (type, idx, 1); + return retval; + } octave_value_list - subsref (const std::string& type, - const std::list& idx, + subsref (const std::string & type, + const std::list & idx, int nargout) - { - octave_value_list retval; + { + octave_value_list retval; - switch (type[0]) + switch (type[0]) + { + case '(': { - case '(': - { - retval = do_multi_index_op (nargout, idx.front ()); - } - break; + retval = do_multi_index_op (nargout, idx.front ()); + } + break; - case '{': - case '.': - { - std::string nm = type_name (); - error ("%s cannot be indexed with %c", nm.c_str (), type[0]); - } - break; + case '{': + case '.': + { + std::string nm = type_name (); + error ("%s cannot be indexed with %c", nm.c_str (), type[0]); + } + break; - default: - panic_impossible (); - } + default: + { panic_impossible (); } + } - return retval; - } + return retval; + } octave_value_list - do_multi_index_op (int nargout, const octave_value_list& idx) - { - octave_value_list retval; - std::list args (1, idx); - args.push_front (octave_value (new function (*this))); - retval = feval ("feval", args, nargout); - return retval; - } + do_multi_index_op (int nargout, const octave_value_list & idx) + { + octave_value_list retval; + std::list args (1, idx); + args.push_front (octave_value (new function (*this))); + retval = feval ("feval", args, nargout); + return retval; + } - private: +private: std::string str; SHARED_PTR fun; diff -r 53039ac90368 -r 61830a4f9ab9 src/interpolate.cc --- a/src/interpolate.cc Tue Aug 12 15:42:50 2014 +0200 +++ b/src/interpolate.cc Thu Aug 14 12:26:55 2014 +0200 @@ -37,9 +37,9 @@ int nargin = args.length (); octave_value retval; - + if (nargin < 2 || nargin > 3 || nargout > 1) - print_usage (); + { print_usage (); } else { if (! function_type_loaded) @@ -71,20 +71,20 @@ offset = 1; } - if (args(1+offset).type_id () == functionspace::static_type_id ()) + if (args(1 + offset).type_id () == functionspace::static_type_id ()) { const functionspace & u1 = - static_cast (args(1+offset).get_rep ()); + static_cast (args(1 + offset).get_rep ()); if (! error_state) { SHARED_PTR output (new dolfin::Function (u1.get_pfsp ())); - if (args(0+offset).type_id () == function::static_type_id ()) + if (args(0 + offset).type_id () == function::static_type_id ()) { const function & u0 = - static_cast (args(0+offset).get_rep ()); + static_cast (args(0 + offset).get_rep ()); if (! error_state) { @@ -96,16 +96,16 @@ if (! error_state) { if (name.empty ()) - name = u0.get_str (); + { name = u0.get_str (); } retval = new function (name, output); } } } - else if (args(0+offset).type_id () == + else if (args(0 + offset).type_id () == coefficient::static_type_id ()) { const coefficient & u0 = - static_cast (args(0+offset).get_rep ()); + static_cast (args(0 + offset).get_rep ()); if (! error_state) { @@ -117,29 +117,29 @@ if (! error_state) { if (name.empty ()) - name = u0.get_str (); + { name = u0.get_str (); } retval = new function (name, output); } } } else - error ("interpolate: invalid arguments"); + { error ("interpolate: invalid arguments"); } } } - else if (args(1+offset).type_id () == function::static_type_id ()) + else if (args(1 + offset).type_id () == function::static_type_id ()) { const function & u0 = - static_cast (args(1+offset).get_rep ()); + static_cast (args(1 + offset).get_rep ()); if (! error_state) { SHARED_PTR output (new dolfin::Function (u0.get_fun ())); - if (args(0+offset).type_id () == function::static_type_id ()) + if (args(0 + offset).type_id () == function::static_type_id ()) { const function & u1 = - static_cast (args(0+offset).get_rep ()); + static_cast (args(0 + offset).get_rep ()); if (! error_state) { @@ -151,16 +151,16 @@ if (! error_state) { if (name.empty ()) - name = u1.get_str (); + { name = u1.get_str (); } retval = new function (name, output); } } } - else if (args(0+offset).type_id () == + else if (args(0 + offset).type_id () == coefficient::static_type_id ()) { const coefficient & u1 = - static_cast (args(0+offset).get_rep ()); + static_cast (args(0 + offset).get_rep ()); if (! error_state) { @@ -172,17 +172,17 @@ if (! error_state) { if (name.empty ()) - name = u1.get_str (); + { name = u1.get_str (); } retval = new function (name, output); } } } else - error ("interpolate: invalid arguments"); + { error ("interpolate: invalid arguments"); } } } else - error ("interpolate: invalid arguments"); + { error ("interpolate: invalid arguments"); } } return retval; } diff -r 53039ac90368 -r 61830a4f9ab9 src/is_master_node.cc --- a/src/is_master_node.cc Tue Aug 12 15:42:50 2014 +0200 +++ b/src/is_master_node.cc Thu Aug 14 12:26:55 2014 +0200 @@ -30,7 +30,7 @@ int nargin = args.length (); if (nargin > 0 || nargout > 1) - print_usage (); + { print_usage (); } else { #ifdef LATEST_DOLFIN diff -r 53039ac90368 -r 61830a4f9ab9 src/mark.cc --- a/src/mark.cc Tue Aug 12 15:42:50 2014 +0200 +++ b/src/mark.cc Thu Aug 14 12:26:55 2014 +0200 @@ -33,8 +33,8 @@ int nargin = args.length (); octave_value retval; - if (nargin < 3 || nargin > 3 ||nargout > 1) - print_usage (); + if (nargin < 3 || nargin > 3 || nargout > 1) + { print_usage (); } else { if (! meshfunction_type_loaded) @@ -70,7 +70,7 @@ } } else - error ("invalid input arguments"); + { error ("invalid input arguments"); } } return retval; diff -r 53039ac90368 -r 61830a4f9ab9 src/meshfunction.h --- a/src/meshfunction.h Tue Aug 12 15:42:50 2014 +0200 +++ b/src/meshfunction.h Thu Aug 14 12:26:55 2014 +0200 @@ -24,7 +24,7 @@ class meshfunction : public octave_base_value { - public: +public: meshfunction (void) : octave_base_value () {} @@ -50,25 +50,25 @@ bool is_defined (void) const - { return true; } + { return true; } void - print (std::ostream& os, bool pr_as_read_syntax = false) const - { os << "MeshFunction : " << get_pmf ()->str (true) << std::endl; } + print (std::ostream & os, bool pr_as_read_syntax = false) const + { os << "MeshFunction : " << get_pmf ()->str (true) << std::endl; } dolfin::MeshFunction const & get_mf (void) const - { return *pmf; } + { return *pmf; } SHARED_PTR const> const & get_pmf (void) const - { return pmf; } + { return pmf; } std::string const & get_str (void) const - { return str; } + { return str; } - private: +private: SHARED_PTR const> pmf; std::string str; diff -r 53039ac90368 -r 61830a4f9ab9 src/save_func.cc --- a/src/save_func.cc Tue Aug 12 15:42:50 2014 +0200 +++ b/src/save_func.cc Thu Aug 14 12:26:55 2014 +0200 @@ -13,7 +13,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . -*/ +*/ + #include "function.h" #include "dolfin_compat.h" @@ -33,9 +34,9 @@ int nargin = args.length (); octave_value retval; - + if (nargin < 2 || nargin > 2) - print_usage (); + { print_usage (); } else { if (! function_type_loaded) @@ -47,7 +48,7 @@ if (args(0).type_id () == function::static_type_id ()) { const function & uo = - static_cast (args(0).get_rep ()); + static_cast (args(0).get_rep ()); std::string str = args(1).string_value (); if (!error_state) diff -r 53039ac90368 -r 61830a4f9ab9 src/save_mesh.cc --- a/src/save_mesh.cc Tue Aug 12 15:42:50 2014 +0200 +++ b/src/save_mesh.cc Thu Aug 14 12:26:55 2014 +0200 @@ -34,7 +34,7 @@ octave_value retval; if (nargin < 2 || nargin > 2 || nargout > 1) - print_usage (); + { print_usage (); } else { if (! mesh_type_loaded) @@ -66,7 +66,7 @@ } } else - error ("invalid input arguments"); + { error ("invalid input arguments"); } } return retval; diff -r 53039ac90368 -r 61830a4f9ab9 src/save_mf.cc --- a/src/save_mf.cc Tue Aug 12 15:42:50 2014 +0200 +++ b/src/save_mf.cc Thu Aug 14 12:26:55 2014 +0200 @@ -34,7 +34,7 @@ octave_value retval; if (nargin < 2 || nargin > 2 || nargout > 1) - print_usage (); + { print_usage (); } else { if (! meshfunction_type_loaded) @@ -67,7 +67,7 @@ } } else - error ("invalid input arguments"); + { error ("invalid input arguments"); } } return retval; diff -r 53039ac90368 -r 61830a4f9ab9 src/subdomain.h --- a/src/subdomain.h Tue Aug 12 15:42:50 2014 +0200 +++ b/src/subdomain.h Thu Aug 14 12:26:55 2014 +0200 @@ -23,7 +23,7 @@ class subdomain : public octave_base_value { - public: +public: subdomain () : octave_base_value () {} @@ -34,20 +34,18 @@ ~subdomain (void) {} void - print (std::ostream& os, bool pr_as_read_syntax = false) const - { - os << "SubDomain" << std::endl; - } + print (std::ostream & os, bool pr_as_read_syntax = false) const + { os << "SubDomain" << std::endl; } bool - is_defined (void) const - { return true; } + is_defined (void) const + { return true; } SHARED_PTR const & get_psd (void) const - { return rep; } + { return rep; } - private: +private: SHARED_PTR rep; diff -r 53039ac90368 -r 61830a4f9ab9 src/subdomain_rep.h --- a/src/subdomain_rep.h Tue Aug 12 15:42:50 2014 +0200 +++ b/src/subdomain_rep.h Thu Aug 14 12:26:55 2014 +0200 @@ -28,7 +28,7 @@ class subdomain_rep : public dolfin::SubDomain { - public: +public: subdomain_rep (void) : dolfin::SubDomain (), pfh (NULL) {} @@ -39,21 +39,21 @@ ~subdomain_rep (void) { delete pfh; } - bool + bool inside (dolfin::Array const & x, bool on_boundary) const - { - octave_value_list b; - b.resize (x.size ()); - for (std::size_t i = 0; i < x.size (); ++i) - b(i) = x[i]; - octave_value_list tmp = feval (pfh->function_value (), b); - bool retval = tmp(0).bool_value (); - if (check_boundary) - retval = retval && on_boundary; - return retval; - } + { + octave_value_list b; + b.resize (x.size ()); + for (std::size_t i = 0; i < x.size (); ++i) + { b(i) = x[i]; } + octave_value_list tmp = feval (pfh->function_value (), b); + bool retval = tmp(0).bool_value (); + if (check_boundary) + { retval = retval && on_boundary; } + return retval; + } - private: +private: octave_fcn_handle * pfh; bool check_boundary; diff -r 53039ac90368 -r 61830a4f9ab9 src/uBLAS_factory.cc --- a/src/uBLAS_factory.cc Tue Aug 12 15:42:50 2014 +0200 +++ b/src/uBLAS_factory.cc Thu Aug 14 12:26:55 2014 +0200 @@ -17,82 +17,80 @@ #include "uBLAS_factory.h" -femfenics_base_factory const& +femfenics_base_factory const & uBLAS_factory::instance (void) - { - static uBLAS_factory const theinstance; - return theinstance; - } +{ + static uBLAS_factory const theinstance; + return theinstance; +} octave_value -uBLAS_factory::matrix (dolfin::Matrix const& A) const - { - octave_value retval; +uBLAS_factory::matrix (dolfin::Matrix const & A) const +{ + octave_value retval; - // Get capacity of the dolfin sparse matrix - boost::tuples::tuple - aa = A.data (); + // Get capacity of the dolfin sparse matrix + boost::tuples::tuple + aa = A.data (); - int nnz = aa.get<3> (); - std::size_t nr = A.size (0), nc = A.size (1); - std::vector data_tmp; - std::vector cidx_tmp; + int nnz = aa.get<3> (); + std::size_t nr = A.size (0), nc = A.size (1); + std::vector data_tmp; + std::vector cidx_tmp; - dim_vector dims (nnz, 1); - octave_idx_type nz = 0, ii = 0; - Array - ridx (dims, 0), - cidx (dims, 0); - Array data (dims, 0); + dim_vector dims (nnz, 1); + octave_idx_type nz = 0, ii = 0; + Array ridx (dims, 0), cidx (dims, 0); + Array data (dims, 0); - octave_idx_type* orow = ridx.fortran_vec (); - octave_idx_type* oc = cidx.fortran_vec (); - double* ov = data.fortran_vec (); + octave_idx_type * orow = ridx.fortran_vec (); + octave_idx_type * oc = cidx.fortran_vec (); + double * ov = data.fortran_vec (); - for (std::size_t i = 0; i < nr; ++i) - { - A.getrow (i, cidx_tmp, data_tmp); - nz += cidx_tmp.size (); + for (std::size_t i = 0; i < nr; ++i) + { + A.getrow (i, cidx_tmp, data_tmp); + nz += cidx_tmp.size (); - for (octave_idx_type j = 0; - j < cidx_tmp.size (); ++j) - { - orow [ii + j] = i; - oc [ii + j] = cidx_tmp [j]; - ov [ii + j] = data_tmp [j]; - } + for (octave_idx_type j = 0; + j < cidx_tmp.size (); ++j) + { + orow[ii + j] = i; + oc[ii + j] = cidx_tmp[j]; + ov[ii + j] = data_tmp[j]; + } - ii = nz; - } + ii = nz; + } - dims(0) = ii; - ridx.resize (dims); - cidx.resize (dims); - data.resize (dims); + dims(0) = ii; + ridx.resize (dims); + cidx.resize (dims); + data.resize (dims); - SparseMatrix sm (data, ridx, cidx, nr, nc); - retval = sm; + SparseMatrix sm (data, ridx, cidx, nr, nc); + retval = sm; - return retval; - } + return retval; +} octave_value -uBLAS_factory::vector (dolfin::Vector const& b) const - { - octave_value retval; +uBLAS_factory::vector (dolfin::Vector const & b) const +{ + octave_value retval; - dim_vector dims; - dims.resize (2); - dims(0) = b.size (); - dims(1) = 1; - Array myb (dims); + dim_vector dims; + dims.resize (2); + dims(0) = b.size (); + dims(1) = 1; + Array myb (dims); - for (std::size_t i = 0; i < b.size (); ++i) - myb.xelem (i) = b[i]; + for (std::size_t i = 0; i < b.size (); ++i) + { myb.xelem (i) = b[i]; } - retval = myb; + retval = myb; - return retval; - } \ No newline at end of file + return retval; +} \ No newline at end of file diff -r 53039ac90368 -r 61830a4f9ab9 src/uBLAS_factory.h --- a/src/uBLAS_factory.h Tue Aug 12 15:42:50 2014 +0200 +++ b/src/uBLAS_factory.h Thu Aug 14 12:26:55 2014 +0200 @@ -22,20 +22,20 @@ class uBLAS_factory : public femfenics_base_factory { - public: +public: virtual ~uBLAS_factory () {} - octave_value matrix (dolfin::Matrix const&) const; - octave_value vector (dolfin::Vector const&) const; + octave_value matrix (dolfin::Matrix const &) const; + octave_value vector (dolfin::Vector const &) const; - static femfenics_base_factory const& instance (void); + static femfenics_base_factory const & instance (void); - private: +private: uBLAS_factory () {} - uBLAS_factory (uBLAS_factory const&); - uBLAS_factory & operator = (uBLAS_factory const&); + uBLAS_factory (uBLAS_factory const &); + uBLAS_factory & operator = (uBLAS_factory const &); }; #endif \ No newline at end of file