Mercurial > fem-fenics-eugenio
diff src/Function.cc @ 268:61830a4f9ab9
Improve formatting
author | Eugenio Gianniti <eugenio.gianniti@mail.polimi.it> |
---|---|
date | Thu, 14 Aug 2014 12:26:55 +0200 |
parents | 8fe68d94ab76 |
children | f4d6ae912a08 |
line wrap: on
line diff
--- 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 <boost/serialization/utility.hpp> #endif -void copy_vector (Array <double> const&, SHARED_PTR <dolfin::GenericVector>); +void copy_vector (Array <double> const &, SHARED_PTR <dolfin::GenericVector>); 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<const functionspace&> (args(1).get_rep ()); + static_cast<const functionspace &> (args(1).get_rep ()); Array <double> 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 <dolfin::Function const> 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<const function&> (args(1).get_rep ()); + static_cast<const function &> (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 <const dolfin::Function> - 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 <double> const& arr, SHARED_PTR <dolfin::GenericVector> vec) +copy_vector (Array <double> const & arr, SHARED_PTR <dolfin::GenericVector> 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 <std::size_t, std::size_t> range; if (p == 0) - range = loc_range; + { range = loc_range; } else - world.recv (p, p, range); + { world.recv (p, p, range); } std::vector <double> 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");