]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Reduce the scope of some variables.
authorDavid Wells <wellsd2@rpi.edu>
Tue, 3 Jan 2017 17:05:37 +0000 (12:05 -0500)
committerDavid Wells <wellsd2@rpi.edu>
Wed, 4 Jan 2017 00:54:48 +0000 (19:54 -0500)
This was caught by cppcheck.

18 files changed:
include/deal.II/lac/full_matrix.templates.h
include/deal.II/lac/solver_cg.h
include/deal.II/lac/solver_minres.h
include/deal.II/lac/solver_qmrs.h
include/deal.II/matrix_free/dof_info.templates.h
include/deal.II/matrix_free/matrix_free.h
source/base/data_out_base.cc
source/base/function_lib.cc
source/base/function_lib_cutoff.cc
source/base/quadrature_lib.cc
source/distributed/p4est_wrappers.cc
source/fe/fe_q_hierarchical.cc
source/grid/grid_in.cc
source/grid/grid_out.cc
source/grid/grid_tools.cc
source/lac/trilinos_sparse_matrix.cc
source/lac/trilinos_sparsity_pattern.cc
source/opencascade/utilities.cc

index e2311beab7e267e85871880dfde923510f128c50..d941e38acbc505c744a028bc21267189ff33e9ef 100644 (file)
@@ -915,13 +915,12 @@ FullMatrix<number>::matrix_norm_square (const Vector<number2> &v) const
   number2 sum = 0.;
   const size_type n_rows = m();
   const number *val_ptr = &this->values[0];
-  const number2 *v_ptr;
 
   for (size_type row=0; row<n_rows; ++row)
     {
       number s = 0.;
       const number *const val_end_of_row = val_ptr+n_rows;
-      v_ptr = v.begin();
+      const number2 *v_ptr = v.begin();
       while (val_ptr != val_end_of_row)
         s += number(*val_ptr++) * number(*v_ptr++);
 
@@ -947,13 +946,12 @@ FullMatrix<number>::matrix_scalar_product (const Vector<number2> &u,
   const size_type n_rows = m();
   const size_type n_cols = n();
   const number *val_ptr = &this->values[0];
-  const number2 *v_ptr;
 
   for (size_type row=0; row<n_rows; ++row)
     {
       number s = 0.;
       const number *const val_end_of_row = val_ptr+n_cols;
-      v_ptr = v.begin();
+      const number2 *v_ptr = v.begin();
       while (val_ptr != val_end_of_row)
         s += number(*val_ptr++) * number(*v_ptr++);
 
@@ -1466,13 +1464,12 @@ FullMatrix<number>::cholesky (const FullMatrix<number2> &A)
       /* reinit *this to 0 */
       this->reinit(A.m(), A.n());
 
-      double SLik2 = 0.0, SLikLjk = 0.0;
       for (size_type i=0; i< this->n_cols(); i++)
         {
-          SLik2 = 0.0;
+          double SLik2 = 0.0;
           for (size_type j = 0; j < i; j++)
             {
-              SLikLjk = 0.0;
+              double SLikLjk = 0.0;
               for (size_type k =0; k<j; k++)
                 {
                   SLikLjk += (*this)(i,k)*(*this)(j,k);
index 3f552cafaa96eeabdebb9e4ac82f33522bb0fe46..574ded4a2963065a096850f6f38241cb31a683c4 100644 (file)
@@ -452,7 +452,6 @@ SolverCG<VectorType>::solve (const MatrixType         &A,
                               | additional_data.compute_condition_number
                               | additional_data.compute_all_condition_numbers
                               | additional_data.compute_eigenvalues;
-  double eigen_beta_alpha = 0;
 
   // vectors used for eigenvalue
   // computations
@@ -464,6 +463,8 @@ SolverCG<VectorType>::solve (const MatrixType         &A,
 
   try
     {
+      double eigen_beta_alpha = 0;
+
       // define some aliases for simpler access
       VectorType &g = *Vr;
       VectorType &d = *Vz;
@@ -475,7 +476,7 @@ SolverCG<VectorType>::solve (const MatrixType         &A,
       d.reinit(x, true);
       h.reinit(x, true);
 
-      double gh,alpha,beta;
+      double gh,beta;
 
       // compute residual. if vector is
       // zero, then short-circuit the
@@ -515,7 +516,7 @@ SolverCG<VectorType>::solve (const MatrixType         &A,
           it++;
           A.vmult(h,d);
 
-          alpha = d*h;
+          double alpha = d*h;
           Assert(alpha != 0., ExcDivideByZero());
           alpha = gh/alpha;
 
index e790f8efeeae9d2520328f7e16fe0f33e87da56e..49d1a31139916367c2945391c7bac797728560c1 100644 (file)
@@ -236,12 +236,10 @@ SolverMinRes<VectorType>::solve (const MatrixType         &A,
 
   double r_l2 = 0;
   double r0   = 0;
-  double tau = 0;
+  double tau  = 0;
   double c    = 0;
-  double gamma = 0;
-  double s = 0;
-  double d_ = 0;
-  double d = 0;
+  double s    = 0;
+  double d_   = 0;
 
   // The iteration step.
   unsigned int j = 1;
@@ -283,7 +281,7 @@ SolverMinRes<VectorType>::solve (const MatrixType         &A,
       A.vmult(*u[2],v);
       u[2]->add (-std::sqrt(delta[1]/delta[0]), *u[0]);
 
-      gamma = *u[2] * v;
+      const double gamma = *u[2] * v;
       u[2]->add (-gamma / std::sqrt(delta[1]), *u[1]);
       *m[0] = v;
 
@@ -309,7 +307,7 @@ SolverMinRes<VectorType>::solve (const MatrixType         &A,
           e[1] = -c * std::sqrt(delta[2]);
         }
 
-      d = std::sqrt (d_*d_ + delta[2]);
+      const double d = std::sqrt (d_*d_ + delta[2]);
 
       if (j>1)
         tau *= s / c;
index 412d2372bbbd539bc2590e59a8ed32cb260d487d..ab11191a2c41b2f914614ea7036e98181faf3cd3 100644 (file)
@@ -346,7 +346,7 @@ SolverQMRS<VectorType>::iterate(const MatrixType         &A,
 
   int  it=0;
 
-  double tau, rho, theta=0, sigma, alpha, psi, theta_old, rho_old, beta;
+  double tau, rho, theta=0;
   double res;
 
   d.reinit(x);
@@ -375,19 +375,19 @@ SolverQMRS<VectorType>::iterate(const MatrixType         &A,
       // Step 1
       A.vmult(t,q);
       // Step 2
-      sigma = q*t;
+      const double sigma = q*t;
 
 //TODO:[?] Find a really good breakdown criterion. The absolute one detects breakdown instead of convergence
       if (std::fabs(sigma/rho) < additional_data.breakdown)
         return IterationResult(SolverControl::iterate, std::fabs(sigma/rho));
       // Step 3
-      alpha = rho/sigma;
+      const double alpha = rho/sigma;
 
       v.add(-alpha,t);
       // Step 4
-      theta_old = theta;
+      const double theta_old = theta;
       theta = v*v/tau;
-      psi = 1./(1.+theta);
+      const double psi = 1./(1.+theta);
       tau *= theta*psi;
 
       d.sadd(psi*theta_old, psi*alpha, p);
@@ -411,11 +411,11 @@ SolverQMRS<VectorType>::iterate(const MatrixType         &A,
       if (std::fabs(rho) < additional_data.breakdown)
         return IterationResult(SolverControl::iterate, std::fabs(rho));
       // Step 7
-      rho_old = rho;
+      const double rho_old = rho;
       precondition.vmult(q,v);
       rho = q*v;
 
-      beta = rho/rho_old;
+      const double beta = rho/rho_old;
       p.sadd(beta,v);
       precondition.vmult(q,p);
     }
index fcff576996f489f85880e3057bf3b31556f28ce9..6d7f74de14c7a687067b8bcc90cf4df4a19169f6 100644 (file)
@@ -338,7 +338,6 @@ no_constraint:
       const unsigned int n_owned  = (vector_partitioner->local_range().second-
                                      vector_partitioner->local_range().first);
       const std::size_t n_ghosts = ghost_dofs.size();
-      unsigned int      n_unique_ghosts= 0;
 #ifdef DEBUG
       for (std::vector<unsigned int>::iterator dof = dof_indices.begin();
            dof!=dof_indices.end(); ++dof)
@@ -349,6 +348,7 @@ no_constraint:
       IndexSet ghost_indices (vector_partitioner->size());
       if (n_ghosts > 0)
         {
+          unsigned int n_unique_ghosts = 0;
           // since we need to go back to the local_to_global indices and
           // replace the temporary numbering of ghosts by the real number in
           // the index set, we need to store these values
index b9515d756af6cf38df1cf428e278b2382bb6c5e8..89ff4fe744f7223203d91d57cf4ab0fa8c35e2bb 100644 (file)
@@ -2382,7 +2382,7 @@ MatrixFree<dim, Number>::cell_loop
               std::vector<internal::color::PartitionWork<Worker>*> worker(n_workers);
               std::vector<internal::color::PartitionWork<Worker>*> blocked_worker(n_blocked_workers);
               unsigned int worker_index = 0, slice_index = 0;
-              unsigned int spawn_index =  0, spawn_index_new = 0;
+              unsigned int spawn_index =  0;
               int spawn_index_child = -2;
               internal::MPIComCompress<OutVector> *worker_compr = new(root->allocate_child())
               internal::MPIComCompress<OutVector>(dst);
@@ -2390,7 +2390,7 @@ MatrixFree<dim, Number>::cell_loop
               for (unsigned int part=0;
                    part<task_info.partition_color_blocks_row_index.size()-1; part++)
                 {
-                  spawn_index_new = worker_index;
+                  const unsigned int spawn_index_new = worker_index;
                   if (part == 0)
                     worker[worker_index] = new(worker_compr->allocate_child())
                     internal::color::PartitionWork<Worker>(func,slice_index,task_info,false);
index dcf22b37231150a15dbd1296f90c949c66726102..8feddae285e4dcb769bbad12be1fddf49a6c5835 100644 (file)
@@ -7002,13 +7002,13 @@ void DataOutBase::write_hdf5_parallel (const std::vector<Patch<dim,spacedim> > &
   // all vector data, then handle the
   // scalar data sets that have been
   // left over
-  unsigned int    i, pt_data_vector_dim;
+  unsigned int    i;
   std::string     vector_name;
   for (i=0; i<data_filter.n_data_sets(); ++i)
     {
       // Allocate space for the point data
       // Must be either 1D or 3D
-      pt_data_vector_dim = data_filter.get_data_set_dim(i);
+      const unsigned int pt_data_vector_dim = data_filter.get_data_set_dim(i);
       vector_name = data_filter.get_data_set_name(i);
 
       // Create the dataspace for the point data
index a2f3b0e244591ae2c7ee91c1d075789441411e56..2e69cb322631e06037673898afe901d48267afb0 100644 (file)
@@ -2616,11 +2616,10 @@ namespace Functions
     (void)component;
     Assert (component==0, ExcIndexRange(component,0,1));
 
-    double prod;
     double sum = 0;
     for (unsigned int monom = 0; monom < exponents.n_rows(); ++monom)
       {
-        prod = 1;
+        double prod = 1;
         for (unsigned int s=0; s< dim; ++s)
           {
             if (p[s] < 0)
index 46141d799610c15d51a8a16f67a5326c66d25062..3b1c254f677876d578bf640cfd5a3b69ce329496 100644 (file)
@@ -273,11 +273,10 @@ namespace Functions
       {
         const double d = this->center.distance(points[k]);
         const double r = this->radius;
-        double e = 0.;
         double val = 0.;
         if (d<this->radius)
           {
-            e = -r*r/(r*r-d*d);
+            const double e = -r*r/(r*r-d*d);
             if (e>-50)
               val = numbers::E * exp(e);
           }
index 19d292f61e7d58daed0f87179cd434a49d296e85..43328dd17045ebffa195517c5e4049c13e9084c8 100644 (file)
@@ -133,17 +133,17 @@ QGauss<1>::QGauss (const unsigned int n)
       long double z = std::cos(numbers::PI * (i-.25)/(n+.5));
 
       long double pp;
-      long double p1, p2, p3;
+      long double p1;
 
       // Newton iteration
       do
         {
           // compute L_n (z)
           p1 = 1.;
-          p2 = 0.;
+          long double p2 = 0.;
           for (unsigned int j=0; j<n; ++j)
             {
-              p3 = p2;
+              const long double p3 = p2;
               p2 = p1;
               p1 = ((2.*j+1.)*z*p2-j*p3)/(j+1);
             }
@@ -228,11 +228,11 @@ compute_quadrature_points(const unsigned int q,
   for (unsigned int i=0; i<m; ++i)
     x[i] = - std::cos( (long double) (2*i+1)/(2*m) * numbers::PI );
 
-  long double r, s, J_x, f, delta;
+  long double s, J_x, f, delta;
 
   for (unsigned int k=0; k<m; ++k)
     {
-      r = x[k];
+      long double r = x[k];
       if (k>0)
         r = (r + x[k-1])/2;
 
@@ -297,7 +297,6 @@ long double QGaussLobatto<1>::JacobiP(const long double x,
   // the Jacobi polynomial is evaluated
   // using a recursion formula.
   std::vector<long double> p(n+1);
-  int v, a1, a2, a3, a4;
 
   // initial values P_0(x), P_1(x):
   p[0] = 1.0L;
@@ -307,11 +306,11 @@ long double QGaussLobatto<1>::JacobiP(const long double x,
 
   for (unsigned int i=1; i<=(n-1); ++i)
     {
-      v  = 2*i + alpha + beta;
-      a1 = 2*(i+1)*(i + alpha + beta + 1)*v;
-      a2 = (v + 1)*(alpha*alpha - beta*beta);
-      a3 = v*(v + 1)*(v + 2);
-      a4 = 2*(i+alpha)*(i+beta)*(v + 2);
+      const int v  = 2*i + alpha + beta;
+      const int a1 = 2*(i+1)*(i + alpha + beta + 1)*v;
+      const int a2 = (v + 1)*(alpha*alpha - beta*beta);
+      const int a3 = v*(v + 1)*(v + 2);
+      const int a4 = 2*(i+alpha)*(i+beta)*(v + 2);
 
       p[i+1] = static_cast<long double>( (a2 + a3*x)*p[i] - a4*p[i-1])/a1;
     } // for
@@ -816,14 +815,13 @@ QGaussOneOverR<2>::QGaussOneOverR(const unsigned int n,
 
   double eps = 1e-8;
   unsigned int q_id = 0; // Current quad point index.
-  double area = 0;
   Tensor<1,2> dist;
 
   for (unsigned int box=0; box<4; ++box)
     {
       dist = (singularity-GeometryInfo<2>::unit_cell_vertex(box));
       dist = Point<2>(std::abs(dist[0]), std::abs(dist[1]));
-      area = dist[0]*dist[1];
+      double area = dist[0]*dist[1];
       if (area > eps)
         for (unsigned int q=0; q<quads[box].size(); ++q, ++q_id)
           {
index c88da22d20eacd6a67d6bb5593433632e812b3fd..94518a90954532d3e276460bfd25ec4d7247b836 100644 (file)
@@ -19,14 +19,13 @@ namespace internal
        typename dealii::internal::p4est::types<dim>::quadrant &quad)
       {
         int i, l = quad.level;
-        int child_id;
         dealii::types::global_dof_index dealii_index =
           triangulation->get_p4est_tree_to_coarse_cell_permutation()[treeidx];
 
         for (i = 0; i < l; i++)
           {
             typename dealii::Triangulation<dim,spacedim>::cell_iterator cell (triangulation, i, dealii_index);
-            child_id = dealii::internal::p4est::functions<dim>::quadrant_ancestor_id (&quad, i + 1);
+            const int child_id = dealii::internal::p4est::functions<dim>::quadrant_ancestor_id (&quad, i + 1);
             Assert (cell->has_children (), ExcMessage ("p4est quadrant does not correspond to a cell!"));
             dealii_index = cell->child_index(child_id);
           }
index 59e0bd630b2a1aea0c06c3c4480149369946bc92..a8e8f7b4bcdfba3b465d9af97d9174dda21785e2 100644 (file)
@@ -993,15 +993,13 @@ get_subface_interpolation_matrix (const FiniteElement<dim> &x_source_fe,
             }
 
           int factorial_i = 1;
-          int factorial_ij;
-          int factorial_j;
 
           for (int i = 2; i < (int) this->dofs_per_face; ++i)
             {
               interpolation_matrix (i, i) = std::pow (0.5, i);
               factorial_i *= i;
-              factorial_j = factorial_i;
-              factorial_ij = 1;
+              int factorial_j = factorial_i;
+              int factorial_ij = 1;
 
               for (int j = i + 1; j < (int) this->dofs_per_face; ++j)
                 {
@@ -1037,15 +1035,13 @@ get_subface_interpolation_matrix (const FiniteElement<dim> &x_source_fe,
           interpolation_matrix (1, 1) = 1.0;
 
           int factorial_i = 1;
-          int factorial_ij;
-          int factorial_j;
 
           for (int i = 2; i < (int) this->dofs_per_face; ++i)
             {
               interpolation_matrix (i, i) = std::pow (0.5, i);
               factorial_i *= i;
-              factorial_j = factorial_i;
-              factorial_ij = 1;
+              int factorial_j = factorial_i;
+              int factorial_ij = 1;
 
               for (int j = i + 1; j < (int) this->dofs_per_face; ++j)
                 {
@@ -1093,11 +1089,6 @@ get_subface_interpolation_matrix (const FiniteElement<dim> &x_source_fe,
             interpolation_matrix (3, vertex) = 0.25;
 
           int factorial_i = 1;
-          int factorial_ij;
-          int factorial_j;
-          int factorial_k;
-          int factorial_kl;
-          int factorial_l;
 
           for (int i = 2; i <= (int) this->degree; ++i)
             {
@@ -1118,14 +1109,14 @@ get_subface_interpolation_matrix (const FiniteElement<dim> &x_source_fe,
                   j = j + 2;
                 }
 
-              factorial_k = 1;
+              int factorial_k = 1;
 
               for (int j = 2; j <= (int) this->degree; ++j)
                 {
                   interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (j + 2) * this->degree - j) = std::pow (0.5, i + j);
                   factorial_k *= j;
-                  factorial_kl = 1;
-                  factorial_l = factorial_k;
+                  int factorial_kl = 1;
+                  int factorial_l = factorial_k;
 
                   for (int k = j + 1; k < (int) this->degree; ++k)
                     {
@@ -1141,8 +1132,8 @@ get_subface_interpolation_matrix (const FiniteElement<dim> &x_source_fe,
                 }
 
               factorial_i *= i;
-              factorial_j = factorial_i;
-              factorial_ij = 1;
+              int factorial_j = factorial_i;
+              int factorial_ij = 1;
 
               for (int j = i + 1; j <= (int) this->degree; ++j)
                 {
@@ -1160,8 +1151,8 @@ get_subface_interpolation_matrix (const FiniteElement<dim> &x_source_fe,
                         {
                           interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (k + 2) * this->degree - k) = tmp * std::pow (0.5, k);
                           factorial_k *= k;
-                          factorial_l = factorial_k;
-                          factorial_kl = 1;
+                          int factorial_l = factorial_k;
+                          int factorial_kl = 1;
 
                           for (int l = k + 1; l <= (int) this->degree; ++l)
                             {
@@ -1201,8 +1192,8 @@ get_subface_interpolation_matrix (const FiniteElement<dim> &x_source_fe,
                         {
                           interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (k + 2) * this->degree - k) = tmp * std::pow (0.5, k);
                           factorial_k *= k;
-                          factorial_l = factorial_k;
-                          factorial_kl = 1;
+                          int factorial_l = factorial_k;
+                          int factorial_kl = 1;
 
                           for (int l = k + 1; l <= (int) this->degree; ++l)
                             {
@@ -1265,11 +1256,6 @@ get_subface_interpolation_matrix (const FiniteElement<dim> &x_source_fe,
             interpolation_matrix (2, vertex) = 0.25;
 
           int factorial_i = 1;
-          int factorial_ij;
-          int factorial_j;
-          int factorial_k;
-          int factorial_kl;
-          int factorial_l;
 
           for (int i = 2; i <= (int) this->degree; ++i)
             {
@@ -1291,8 +1277,8 @@ get_subface_interpolation_matrix (const FiniteElement<dim> &x_source_fe,
               interpolation_matrix (i + source_fe.degree + 1, i + this->degree + 1) = tmp;
               interpolation_matrix (i + 2 * source_fe.degree, i + 2 * this->degree) = tmp;
               factorial_i *= i;
-              factorial_j = factorial_i;
-              factorial_ij = 1;
+              int factorial_j = factorial_i;
+              int factorial_ij = 1;
 
               for (int j = i + 1; j <= (int) this->degree; ++j)
                 {
@@ -1300,14 +1286,14 @@ get_subface_interpolation_matrix (const FiniteElement<dim> &x_source_fe,
                   factorial_j *= j;
                   tmp = std::pow (0.5, j) * factorial_j / (factorial_i * factorial_ij);
                   interpolation_matrix (i + 2 * source_fe.degree, j + 2 * this->degree) = tmp;
-                  factorial_k = 1;
+                  int factorial_k = 1;
 
                   for (int k = 2; k <= (int) this->degree; ++k)
                     {
                       interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (k + 2) * this->degree - k) = tmp * std::pow (0.5, k);
                       factorial_k *= k;
-                      factorial_l = factorial_k;
-                      factorial_kl = 1;
+                      int factorial_l = factorial_k;
+                      int factorial_kl = 1;
 
                       for (int l = k + 1; l <= (int) this->degree; ++l)
                         {
@@ -1349,14 +1335,14 @@ get_subface_interpolation_matrix (const FiniteElement<dim> &x_source_fe,
                     }
                 }
 
-              factorial_k = 1;
+              int factorial_k = 1;
 
               for (int j = 2; j <= (int) this->degree; ++j)
                 {
                   interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (j + 2) * this->degree - j) = std::pow (0.5, i + j);
                   factorial_k *= j;
-                  factorial_l = factorial_k;
-                  factorial_kl = 1;
+                  int factorial_l = factorial_k;
+                  int factorial_kl = 1;
 
                   for (int k = j + 1; k <= (int) this->degree; ++k)
                     {
@@ -1403,11 +1389,6 @@ get_subface_interpolation_matrix (const FiniteElement<dim> &x_source_fe,
             interpolation_matrix (1, vertex) = 0.25;
 
           int factorial_i = 1;
-          int factorial_ij;
-          int factorial_j;
-          int factorial_k;
-          int factorial_kl;
-          int factorial_l;
 
           for (int i = 2; i <= (int) this->degree; ++i)
             {
@@ -1428,14 +1409,14 @@ get_subface_interpolation_matrix (const FiniteElement<dim> &x_source_fe,
                   j = j + 2;
                 }
 
-              factorial_k = 1;
+              int factorial_k = 1;
 
               for (int j = 2; j <= (int) this->degree; ++j)
                 {
                   interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (j + 2) * this->degree - j) = std::pow (0.5, i + j);
                   factorial_k *= j;
-                  factorial_l = factorial_k;
-                  factorial_kl = 1;
+                  int factorial_kl = 1;
+                  int factorial_l = factorial_k;
 
                   for (int k = j + 1; k <= (int) this->degree; ++k)
                     {
@@ -1446,8 +1427,8 @@ get_subface_interpolation_matrix (const FiniteElement<dim> &x_source_fe,
                 }
 
               factorial_i *= i;
-              factorial_j = factorial_i;
-              factorial_ij = 1;
+              int factorial_j = factorial_i;
+              int factorial_ij = 1;
 
               for (int j = i + 1; j <= (int) this->degree; ++j)
                 {
@@ -1474,14 +1455,14 @@ get_subface_interpolation_matrix (const FiniteElement<dim> &x_source_fe,
                   interpolation_matrix (i + 2 * source_fe.degree, j + 3 * this->degree - 1) = tmp;
                   tmp *= 2.0;
                   interpolation_matrix (i + 3 * source_fe.degree - 1, j + 3 * this->degree - 1) = tmp;
-                  factorial_k = 1;
+                  int factorial_k = 1;
 
                   for (int k = 2; k <= (int) this->degree; ++k)
                     {
                       interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (k + 2) * this->degree - k) = tmp * std::pow (0.5, k);
                       factorial_k *= k;
-                      factorial_l = factorial_k;
-                      factorial_kl = 1;
+                      int factorial_l = factorial_k;
+                      int factorial_kl = 1;
 
                       for (int l = k + 1; l <= (int) this->degree; ++l)
                         {
@@ -1532,11 +1513,6 @@ get_subface_interpolation_matrix (const FiniteElement<dim> &x_source_fe,
           interpolation_matrix (3, 3) = 1.0;
 
           int factorial_i = 1;
-          int factorial_ij;
-          int factorial_j;
-          int factorial_k;
-          int factorial_kl;
-          int factorial_l;
 
           for (int i = 2; i <= (int) this->degree; ++i)
             {
@@ -1557,14 +1533,14 @@ get_subface_interpolation_matrix (const FiniteElement<dim> &x_source_fe,
               tmp *= -1.0;
               interpolation_matrix (i + source_fe.degree + 1, i + this->degree + 1) = tmp;
               interpolation_matrix (i + 3 * source_fe.degree - 1, i + 3 * this->degree - 1) = tmp;
-              factorial_k = 1;
+              int factorial_k = 1;
 
               for (int j = 2; j <= (int) this->degree; ++j)
                 {
                   interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (j + 2) * this->degree - j) = std::pow (0.5, i + j);
                   factorial_k *= j;
-                  factorial_l = factorial_k;
-                  factorial_kl = 1;
+                  int factorial_l = factorial_k;
+                  int factorial_kl = 1;
 
                   for (int k = j + 1; k <= (int) this->degree; ++k)
                     {
@@ -1575,8 +1551,8 @@ get_subface_interpolation_matrix (const FiniteElement<dim> &x_source_fe,
                 }
 
               factorial_i *= i;
-              factorial_j = factorial_i;
-              factorial_ij = 1;
+              int factorial_j = factorial_i;
+              int factorial_ij = 1;
 
               for (int j = i + 1; j <= (int) this->degree; ++j)
                 {
@@ -1590,14 +1566,14 @@ get_subface_interpolation_matrix (const FiniteElement<dim> &x_source_fe,
                   tmp *= 2.0;
                   interpolation_matrix (i + source_fe.degree + 1, j + this->degree + 1) = tmp;
                   interpolation_matrix (i + 3 * source_fe.degree - 1, j + 3 * this->degree - 1) = tmp;
-                  factorial_k = 1;
+                  int factorial_k = 1;
 
                   for (int k = 2; k <= (int) this->degree; ++k)
                     {
                       interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (k + 2) * this->degree - k) = tmp * std::pow (0.5, k);
                       factorial_k *= k;
-                      factorial_l = factorial_k;
-                      factorial_kl = 1;
+                      int factorial_l = factorial_k;
+                      int factorial_kl = 1;
 
                       for (int l = k + 1; l <= (int) this->degree; ++l)
                         {
index 29801b640f33beb0a524883eebafadff0170c373..822dd56522b214041c3acca5eed1fa47a6c949f5 100644 (file)
@@ -3095,7 +3095,6 @@ namespace
                 // Surface can be created from ELSET, or directly from cells
                 // If elsets_list contains a key with specific name - refers to that ELSET, otherwise refers to cell
                 std::istringstream iss (line);
-                char comma;
                 int el_idx;
                 int face_number;
                 char temp;
@@ -3122,6 +3121,7 @@ namespace
                 else
                   {
                     // Surface refers directly to elements
+                    char comma;
                     iss >> el_idx >> comma >> temp >> face_number;
                     quad_node_list = get_global_node_numbers (el_idx, face_number);
                     quad_node_list.insert (quad_node_list.begin(), b_indicator);
index 3ded8aefbd535f3182d1f28b1bed78dd9bedd543..744971d09165a8269c38922c225ac3cdbc7e4c07 100644 (file)
@@ -2104,14 +2104,13 @@ void GridOut::write_svg(const Triangulation<2,2> &tria, std::ostream &out) const
 // draw the legend
   if (svg_flags.draw_legend) out << '\n' << " <!-- legend -->" << '\n';
 
-  unsigned int line_offset = 0;
-
   additional_width = 0;
   if (!svg_flags.margin) additional_width = static_cast<unsigned int>(.5 + (height/100.) * 2.5);
 
   // explanation of the cell labeling
   if (svg_flags.draw_legend && (svg_flags.label_level_number || svg_flags.label_cell_index || svg_flags.label_material_id || svg_flags.label_subdomain_id || svg_flags.label_level_subdomain_id ))
     {
+      unsigned int line_offset = 0;
       out << " <rect x=\"" << width + additional_width << "\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * margin_in_percent)
           << "\" width=\"" << static_cast<unsigned int>(.5 + (height/100.) * (40. - margin_in_percent)) << "\" height=\"" << static_cast<unsigned int>(.5 + height * .165) << "\"/>" << '\n';
 
index 86be8b5e310db322428991399d5bcc6542eb4084..010f9f1561093dfc34080b26c1821cb21f893c34 100644 (file)
@@ -3019,11 +3019,10 @@ next_cell:
     typename std::vector<typename Container::cell_iterator>::const_iterator uniform_cell;
     for (uniform_cell=uniform_cells.begin(); uniform_cell!=uniform_cells.end(); ++uniform_cell)
       {
-        bool repeat_vertex;
         for (unsigned int v=0; v<GeometryInfo<Container::dimension>::vertices_per_cell; ++v)
           {
             Point<Container::space_dimension> position=(*uniform_cell)->vertex (v);
-            repeat_vertex=false;
+            bool repeat_vertex=false;
 
             for (unsigned int m=0; m<i; ++m)
               {
index 9017181b30541cbd8baa3c8a4f7f10fa483704fe..d14f9f6d8d438869510e102bd24acff647eab755 100644 (file)
@@ -398,7 +398,6 @@ namespace TrilinosWrappers
         const std::pair<size_type, size_type>
         local_range = rhs.local_range();
 
-        int ierr;
         // Try to copy all the rows of the matrix one by one. In case of error
         // (i.e., the column indices are different), we need to abort and blow
         // away the matrix.
@@ -410,8 +409,8 @@ namespace TrilinosWrappers
             int n_entries, rhs_n_entries;
             TrilinosScalar *value_ptr, *rhs_value_ptr;
             int *index_ptr, *rhs_index_ptr;
-            ierr = rhs.matrix->ExtractMyRowView (row_local, rhs_n_entries,
-                                                 rhs_value_ptr, rhs_index_ptr);
+            int ierr = rhs.matrix->ExtractMyRowView (row_local, rhs_n_entries,
+                                                     rhs_value_ptr, rhs_index_ptr);
             (void)ierr;
             Assert (ierr == 0, ExcTrilinosError(ierr));
 
@@ -1774,7 +1773,6 @@ namespace TrilinosWrappers
     local_range = rhs.local_range();
     const bool same_col_map = matrix->ColMap().SameAs(rhs.matrix->ColMap());
 
-    int ierr;
     for (size_type row=local_range.first; row < local_range.second; ++row)
       {
         const int row_local =
@@ -1787,8 +1785,8 @@ namespace TrilinosWrappers
         int n_entries, rhs_n_entries;
         TrilinosScalar *value_ptr, *rhs_value_ptr;
         int *index_ptr, *rhs_index_ptr;
-        ierr = rhs.matrix->ExtractMyRowView (row_local, rhs_n_entries,
-                                             rhs_value_ptr, rhs_index_ptr);
+        int ierr = rhs.matrix->ExtractMyRowView (row_local, rhs_n_entries,
+                                                 rhs_value_ptr, rhs_index_ptr);
         (void)ierr;
         Assert (ierr == 0, ExcTrilinosError(ierr));
 
index 9ed611f7a88b7d6c55daef76c361891154d22e20..7aae438f4418712f2b7854e7c3bffad79d868171 100644 (file)
@@ -126,19 +126,18 @@ namespace TrilinosWrappers
       // otherwise first flush Trilinos caches
       sparsity_pattern->compress ();
 
-      // get a representation of the present row
-      int ncols;
-
       colnum_cache.reset (new std::vector<size_type> (sparsity_pattern->row_length(this->a_row)));
 
 
       if (colnum_cache->size() > 0)
         {
-          int ierr;
-          ierr = sparsity_pattern->graph->ExtractGlobalRowCopy((TrilinosWrappers::types::int_type)this->a_row,
-                                                               colnum_cache->size(),
-                                                               ncols,
-                                                               (TrilinosWrappers::types::int_type *)&(*colnum_cache)[0]);
+          // get a representation of the present row
+          int ncols;
+          const int ierr = sparsity_pattern->graph->ExtractGlobalRowCopy
+                           ((TrilinosWrappers::types::int_type)this->a_row,
+                            colnum_cache->size(),
+                            ncols,
+                            (TrilinosWrappers::types::int_type *)&(*colnum_cache)[0]);
           AssertThrow (ierr == 0, ExcTrilinosError(ierr));
           AssertThrow (static_cast<std::vector<size_type>::size_type>(ncols) == colnum_cache->size(),
                        ExcInternalError());
index 7034790113c6fd7d64ac2cf698f37864ab53fdfd..7565d2a21d926059aa80347b523718aa5ffa3325 100644 (file)
@@ -409,11 +409,10 @@ namespace OpenCASCADE
     Assert(Inters.IsDone(), ExcMessage("Could not project point."));
 
     double minDistance = 1e7;
-    double distance;
     Point<3> result;
     for (int i=0; i<Inters.NbPnt(); ++i)
       {
-        distance = point(origin).Distance(Inters.Pnt(i+1));
+        const double distance = point(origin).Distance(Inters.Pnt(i+1));
         //cout<<"Point "<<i<<": "<<point(Inters.Pnt(i+1))<<"  distance: "<<distance<<endl;
         if (distance < minDistance)
           {

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.