]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fuse two loops.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 14 Aug 2008 16:03:33 +0000 (16:03 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 14 Aug 2008 16:03:33 +0000 (16:03 +0000)
git-svn-id: https://svn.dealii.org/trunk@16547 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/examples/step-31/step-31.cc

index ec62724e9c83c15e5824e5749acfe273b65d3aae..e1a0cfb6b7c8992f04b9945e218c06022a8ac964 100644 (file)
@@ -1765,7 +1765,7 @@ void BoussinesqFlowProblem<dim>::assemble_rhs_T ()
 {
                                   // TODO: right now, always do explicit
                                   // Euler
-  const bool is_first_timestep = (timestep_number == 0 ? true : true);
+  const bool use_bdf2_scheme = (timestep_number == 0 ? false : false);
 
   system_matrix.block(2,2) = 0;
   
@@ -1853,41 +1853,40 @@ void BoussinesqFlowProblem<dim>::assemble_rhs_T ()
              grad_phi_T[k] = fe_values[temperature].gradient(k,q);
              phi_T[k]      = fe_values[temperature].value (k, q);
            }
+
+         const Point<dim> p = fe_values.quadrature_point(q);
+         const double gamma = RightHandSide<dim>().value (p, dim+1);
+         
          
          for (unsigned int i=0; i<dofs_per_cell; ++i)
            for (unsigned int j=0; j<dofs_per_cell; ++j)
              local_matrix(i,j) += (phi_T[i] * phi_T[j]
                                    + kappa * grad_phi_T[i] * grad_phi_T[j])
                                   * fe_values.JxW(q);
-       }
-      
       
                                       // build rhs contributions
-      for (unsigned int q=0; q<n_q_points; ++q)
-        for (unsigned int i=0; i<dofs_per_cell; ++i)
-          {
-            const double        old_T      = old_solution_values[q](dim+1);
-           const Tensor<1,dim> old_grad_T = old_solution_grads[q][dim+1];
+         for (unsigned int i=0; i<dofs_per_cell; ++i)
+           {
+             const double        old_T      = old_solution_values[q](dim+1);
+             const Tensor<1,dim> old_grad_T = old_solution_grads[q][dim+1];
            
-            Tensor<1,dim> present_u;
-            for (unsigned int d=0; d<dim; ++d)
-              present_u[d] = present_solution_values[q](d);
-
-            const double     phi_i_T      = fe_values[temperature].value (i, q);
-           const Point<dim> p = fe_values.quadrature_point(q);
-
-            local_rhs(i) += (old_T * phi_i_T
-                            -
-                            time_step *
-                             present_u * old_grad_T * phi_i_T
-                            +
-                            time_step *
-                            RightHandSide<dim>().value (p, dim+1)
-                            * phi_i_T)
-                            *
-                            fe_values.JxW(q);
-          }
-
+             Tensor<1,dim> present_u;
+             for (unsigned int d=0; d<dim; ++d)
+               present_u[d] = present_solution_values[q](d);
+
+
+             local_rhs(i) += (old_T * phi_T[i]
+                              -
+                              time_step *
+                              present_u * old_grad_T * phi_T[i]
+                              +
+                              time_step *
+                              gamma * phi_T[i])
+                             *
+                             fe_values.JxW(q);
+           }
+       }
+      
       cell->get_dof_indices (local_dof_indices);
 
       for (unsigned int i=0; i<dofs_per_cell; ++i)

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.