diff src/assemble_system.cc @ 173:9e944b0d0fc8

Some Formatting improvements (?)
author gedeone-octave <marcovass89@hotmail.it>
date Sat, 12 Oct 2013 16:06:00 +0100
parents f65252c56853
children 66071811eef8
line wrap: on
line diff
--- a/src/assemble_system.cc	Mon Oct 07 21:52:17 2013 +0200
+++ b/src/assemble_system.cc	Sat Oct 12 16:06:00 2013 +0100
@@ -18,9 +18,11 @@
 #include "form.h"
 #include "boundarycondition.h"
 
-DEFUN_DLD (assemble_system, args, nargout, "-*- texinfo -*-\n\
+DEFUN_DLD (assemble_system, args, nargout,
+"-*- texinfo -*-\n\
 @deftypefn {Function File} {[@var{A}], [@var{b}], [@var{x}(Optional)]} = \
-assemble_system (@var{form a}, @var{form L}, @var{DirichletBC}(Optional), @var{...}) \n\
+assemble_system (@var{form a}, @var{form L}, @var{DirichletBC}(Optional), \
+                 @var{...}) \n\
 The input arguments are\n\
 @itemize @bullet\n\
 @item @var{form a} the bilinear form to assemble.\n\
@@ -34,9 +36,9 @@
 @item @var{A} is the Vector corresponding to the @var{form L}\n\
 @end itemize \n\
 If you need to apply boundary condition to a system for a nonlinear problem \n\
-then you should provide as 3rd argument the vector and you will receive it back\n\
-as the third output argument. For an example of this situation, you can look\n\
-the example HyperElasticity.m\n\
+then you should provide as 3rd argument the vector and you will receive it \n\
+back as the third output argument.\n\
+For an example of this situation, you can look the example HyperElasticity.m\n\
 @seealso{BilinearForm, LinearForm, ResidualForm, JacobianForm}\n\
 @end deftypefn")
 {
@@ -66,8 +68,10 @@
           if (args(0).type_id () == form::static_type_id ()
               && args(1).type_id () == form::static_type_id ())
             {
-              const form & frm1 = static_cast<const form&> (args(0).get_rep ());
-              const form & frm2 = static_cast<const form&> (args(1).get_rep ());
+              const form & frm1 =
+                static_cast<const form&> (args(0).get_rep ());
+              const form & frm2 =
+                static_cast<const form&> (args(1).get_rep ());
 
               if (! error_state)
                 {
@@ -86,13 +90,16 @@
 
                       for (std::size_t i = 2; i < nargin; ++i)
                         {
-                          if (args(i).type_id () == boundarycondition::static_type_id ())
+                          if (args(i).type_id () ==
+                              boundarycondition::static_type_id ())
                             {
                               const boundarycondition & bc
-                                = static_cast<const boundarycondition&> (args(i).get_rep ());
+                                = static_cast<const boundarycondition&> 
+                                (args(i).get_rep ());
 
-                              const std::vector<boost::shared_ptr <const dolfin::DirichletBC> > & pbc
-                                    = bc.get_bc ();
+                              const std::vector<boost::shared_ptr 
+                                                <const dolfin::DirichletBC> > 
+                              & pbc = bc.get_bc ();
 
                               for (std::size_t j = 0; j < pbc.size (); ++j)
                                 pbc[j]->apply(A, B);
@@ -101,8 +108,12 @@
                             error ("assemble_system: unknown argument type");
                         }
 
-//                    It provides an upper boung for the nnz elements
-                      boost::tuples::tuple<const std::size_t*, const std::size_t*, const double*, int> aa = A.data ();
+                      // Get capacity of the dolfin sparse matrix
+                      boost::tuples::tuple<const std::size_t*,
+                                           const std::size_t*,
+                                           const double*, int>
+                      aa = A.data ();
+
                       int nnz = aa.get<3> ();
                       std::size_t nr = A.size (0), nc = A.size (1);
                       std::vector<double> data_tmp;
@@ -110,7 +121,9 @@
 
                       dim_vector dims (nnz, 1);
                       octave_idx_type nz = 0, ii = 0;
-                      Array<octave_idx_type> ridx (dims, 0), cidx (dims, 0);
+                      Array<octave_idx_type> 
+                        ridx (dims, 0),
+                        cidx (dims, 0);
                       Array<double> data (dims, 0);
 
                       octave_idx_type* orow = ridx.fortran_vec ();
@@ -122,7 +135,8 @@
                          A.getrow (i, cidx_tmp, data_tmp);
                          nz += cidx_tmp.size ();
 
-                         for (octave_idx_type j = 0; j < cidx_tmp.size (); ++j)
+                         for (octave_idx_type j = 0;
+                              j < cidx_tmp.size (); ++j)
                            {
                              orow [ii + j] = i;
                              oc [ii + j] = cidx_tmp [j];
@@ -166,8 +180,10 @@
           if (args(0).type_id () == form::static_type_id ()
               && args(1).type_id () == form::static_type_id ())
             {
-              const form & frm1 = static_cast<const form&> (args(0).get_rep ());
-              const form & frm2 = static_cast<const form&> (args(1).get_rep ());
+              const form & frm1 =
+                static_cast<const form&> (args(0).get_rep ());
+              const form & frm2 =
+                static_cast<const form&> (args(1).get_rep ());
               const Array<double> myx = args(2).array_value ();
 
               if (! error_state)
@@ -191,23 +207,31 @@
 
                       for (std::size_t i = 3; i < nargin; ++i)
                         {
-                          if (args(i).type_id () == boundarycondition::static_type_id ())
+                          if (args(i).type_id () == 
+                              boundarycondition::static_type_id ())
                             {
                               const boundarycondition & bc
-                                = static_cast<const boundarycondition&> (args(i).get_rep ());
+                                = static_cast<const boundarycondition&> 
+                                  (args(i).get_rep ());
 
-                              const std::vector<boost::shared_ptr <const dolfin::DirichletBC> > & pbc
-                                = bc.get_bc ();
+                              const std::vector<boost::shared_ptr 
+                                               <const dolfin::DirichletBC> >
+                              & pbc = bc.get_bc ();
 
-                              for (std::size_t j = 0; j < pbc.size (); ++j)
+                              for (std::size_t j = 0;
+                                   j < pbc.size (); ++j)
                                 pbc[j]->apply(A, B, x);
+
                             }
                           else
                             error ("assemble_system: unknown argument type");
                         }
 
-//                    It provides an upper boung for the nnz elements
-                      boost::tuples::tuple<const std::size_t*, const std::size_t*, const double*, int> aa = A.data ();
+                      // Get capacity of the dolfin sparse matrix
+                      boost::tuples::tuple<const std::size_t*,
+                                           const std::size_t*,
+                                           const double*, int>
+                      aa = A.data ();
                       int nnz = aa.get<3> ();
                       std::size_t nr = A.size (0), nc = A.size (1);
                       std::vector<double> data_tmp;
@@ -215,7 +239,9 @@
 
                       dim_vector dims (nnz, 1);
                       octave_idx_type nz = 0, ii = 0;
-                      Array<octave_idx_type> ridx (dims, 0), cidx (dims, 0);
+                      Array<octave_idx_type>
+                        ridx (dims, 0),
+                        cidx (dims, 0);
                       Array<double> data (dims, 0);
 
                       octave_idx_type* orow = ridx.fortran_vec ();
@@ -227,7 +253,8 @@
                          A.getrow (i, cidx_tmp, data_tmp);
                          nz += cidx_tmp.size ();
 
-                         for (octave_idx_type j = 0; j < cidx_tmp.size (); ++j)
+                         for (octave_idx_type j = 0;
+                              j < cidx_tmp.size (); ++j)
                            {
                              orow [ii + j] = i;
                              oc [ii + j] = cidx_tmp [j];