From: Martin Kronbichler Date: Mon, 18 May 2009 07:31:02 +0000 (+0000) Subject: Undo the changes from r18849 (merge from TBB branch). step-31 should not have been... X-Git-Tag: v8.0.0~7672 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=903fcea0e460615cd84dc7a0c29f2a4e5d4d05f0;p=dealii.git Undo the changes from r18849 (merge from TBB branch). step-31 should not have been touched. git-svn-id: https://svn.dealii.org/trunk@18865 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/examples/step-31/step-31.cc b/deal.II/examples/step-31/step-31.cc index 495b6ad68c..593bf5953e 100644 --- a/deal.II/examples/step-31/step-31.cc +++ b/deal.II/examples/step-31/step-31.cc @@ -20,7 +20,6 @@ #include #include #include -#include #include #include @@ -535,116 +534,6 @@ namespace LinearSolvers -namespace AssemblerData -{ - template - struct StokesPreconditioner - { - StokesPreconditioner (const FiniteElement &stokes_fe, - const Quadrature &stokes_quadrature, - const UpdateFlags update_flags); - StokesPreconditioner (const StokesPreconditioner &data); - - FEValues stokes_fe_values; - - FullMatrix local_matrix; - std::vector local_dof_indices; - - std::vector > grad_phi_u; - std::vector phi_p; - }; - - template - StokesPreconditioner:: - StokesPreconditioner (const FiniteElement &stokes_fe, - const Quadrature &stokes_quadrature, - const UpdateFlags update_flags) - : - stokes_fe_values (stokes_fe, stokes_quadrature, update_flags), - local_matrix (stokes_fe.dofs_per_cell, stokes_fe.dofs_per_cell), - local_dof_indices (stokes_fe.dofs_per_cell), - grad_phi_u (stokes_fe.dofs_per_cell), - phi_p (stokes_fe.dofs_per_cell) - {} - - - - template - StokesPreconditioner:: - StokesPreconditioner (const StokesPreconditioner &data) - : - stokes_fe_values (data.stokes_fe_values.get_fe(), - data.stokes_fe_values.get_quadrature(), - data.stokes_fe_values.get_update_flags()), - local_matrix (data.local_matrix), - local_dof_indices (data.local_dof_indices), - grad_phi_u (data.grad_phi_u), - phi_p (data.phi_p) - {} - - - - template - struct StokesSystem : public StokesPreconditioner - { - StokesSystem (const FiniteElement &stokes_fe, - const Quadrature &stokes_quadrature, - const UpdateFlags stokes_update_flags, - const FiniteElement &temperature_fe, - const UpdateFlags temperature_update_flags); - - StokesSystem (const StokesSystem &data); - - FEValues temperature_fe_values; - Vector local_rhs; - - std::vector > phi_u; - std::vector > grads_phi_u; - std::vector div_phi_u; - - std::vector old_temperature_values; - }; - - - template - StokesSystem:: - StokesSystem (const FiniteElement &stokes_fe, - const Quadrature &stokes_quadrature, - const UpdateFlags stokes_update_flags, - const FiniteElement &temperature_fe, - const UpdateFlags temperature_update_flags) - : - StokesPreconditioner (stokes_fe, stokes_quadrature, - stokes_update_flags), - temperature_fe_values (temperature_fe, stokes_quadrature, - temperature_update_flags), - local_rhs (stokes_fe.dofs_per_cell), - phi_u (stokes_fe.dofs_per_cell), - grads_phi_u (stokes_fe.dofs_per_cell), - div_phi_u (stokes_fe.dofs_per_cell), - old_temperature_values (stokes_quadrature.n_quadrature_points) - {} - - - template - StokesSystem:: - StokesSystem (const StokesSystem &data) - : - StokesPreconditioner (data), - temperature_fe_values (data.temperature_fe_values.get_fe(), - data.temperature_fe_values.get_quadrature(), - data.temperature_fe_values.get_update_flags()), - local_rhs (data.local_rhs), - phi_u (data.phi_u), - grads_phi_u (data.grads_phi_u), - div_phi_u (data.div_phi_u), - old_temperature_values (data.old_temperature_values) - {} -} - - - - // @sect3{The BoussinesqFlowProblem class template} // The definition of the class that defines @@ -718,6 +607,7 @@ class BoussinesqFlowProblem const double global_T_variation, const double cell_diameter) const; + Triangulation triangulation; double global_Omega_diameter; @@ -760,19 +650,6 @@ class BoussinesqFlowProblem bool rebuild_stokes_matrix; bool rebuild_temperature_matrices; bool rebuild_stokes_preconditioner; - - void - local_assemble_stokes_preconditioner (const typename DoFHandler::active_cell_iterator &cell, - AssemblerData::StokesPreconditioner &data); - - void copy_local_to_global_stokes_preconditioner (const AssemblerData::StokesPreconditioner &data); - - - void - local_assemble_stokes_system (const typename DoFHandler::active_cell_iterator &cell, - AssemblerData::StokesSystem &data); - - void copy_local_to_global_stokes_system (const AssemblerData::StokesSystem &data); }; @@ -1444,79 +1321,6 @@ void BoussinesqFlowProblem::setup_dofs () - - - -template -void -BoussinesqFlowProblem:: -local_assemble_stokes_preconditioner (const typename DoFHandler::active_cell_iterator &cell, - AssemblerData::StokesPreconditioner &data) -{ - const unsigned int dofs_per_cell = stokes_fe.dofs_per_cell; - const unsigned int n_q_points = data.stokes_fe_values.n_quadrature_points; - - const FEValuesExtractors::Vector velocities (0); - const FEValuesExtractors::Scalar pressure (dim); - - data.stokes_fe_values.reinit (cell); - data.local_matrix = 0; - - // The creation of the local matrix is - // rather simple. There are only a - // Laplace term (on the velocity) and a - // mass matrix weighted by $\eta^{-1}$ - // to be generated, so the creation of - // the local matrix is done in two - // lines. Once the local matrix is - // ready (loop over rows and columns in - // the local matrix on each quadrature - // point), we get the local DoF indices - // and write the local information into - // the global matrix. We do this as in - // step-27, i.e. we directly apply the - // constraints from hanging nodes - // locally. By doing so, we don't have - // to do that afterwards, and we don't - // also write into entries of the - // matrix that will actually be set to - // zero again later when eliminating - // constraints. - for (unsigned int q=0; qget_dof_indices (data.local_dof_indices); -} - - -template -void -BoussinesqFlowProblem:: -copy_local_to_global_stokes_preconditioner (const AssemblerData::StokesPreconditioner &data) -{ - stokes_constraints.distribute_local_to_global (data.local_matrix, - data.local_dof_indices, - stokes_preconditioner_matrix); -} - - - - // @sect4{BoussinesqFlowProblem::assemble_stokes_preconditioner} // // This function assembles the matrix we use @@ -1532,7 +1336,7 @@ copy_local_to_global_stokes_preconditioner (const AssemblerData::StokesPrecondit // we create data structures for the cell // matrix and the relation between local and // global DoFs. The vectors - // grad_phi_u and + // phi_grad_u and // phi_p are going to hold the // values of the basis functions in order to // faster build up the local matrices, as was @@ -1547,25 +1351,74 @@ BoussinesqFlowProblem::assemble_stokes_preconditioner () stokes_preconditioner_matrix = 0; const QGauss quadrature_formula(stokes_degree+2); + FEValues stokes_fe_values (stokes_fe, quadrature_formula, + update_JxW_values | + update_values | + update_gradients); + + const unsigned int dofs_per_cell = stokes_fe.dofs_per_cell; + const unsigned int n_q_points = quadrature_formula.size(); + + FullMatrix local_matrix (dofs_per_cell, dofs_per_cell); + std::vector local_dof_indices (dofs_per_cell); + + std::vector > phi_grad_u (dofs_per_cell); + std::vector phi_p (dofs_per_cell); + + const FEValuesExtractors::Vector velocities (0); + const FEValuesExtractors::Scalar pressure (dim); - AssemblerData::StokesPreconditioner - data_template (stokes_fe, quadrature_formula, - update_JxW_values | - update_values | - update_gradients); - - WorkStream().run (stokes_dof_handler.begin_active(), - stokes_dof_handler.end(), - std_cxx0x::bind (&BoussinesqFlowProblem:: - local_assemble_stokes_preconditioner, - this, - _1, - _2), - std_cxx0x::bind (&BoussinesqFlowProblem:: - copy_local_to_global_stokes_preconditioner, - this, - _1), - data_template); + typename DoFHandler::active_cell_iterator + cell = stokes_dof_handler.begin_active(), + endc = stokes_dof_handler.end(); + for (; cell!=endc; ++cell) + { + stokes_fe_values.reinit (cell); + local_matrix = 0; + + // The creation of the local matrix is + // rather simple. There are only a + // Laplace term (on the velocity) and a + // mass matrix weighted by $\eta^{-1}$ + // to be generated, so the creation of + // the local matrix is done in two + // lines. Once the local matrix is + // ready (loop over rows and columns in + // the local matrix on each quadrature + // point), we get the local DoF indices + // and write the local information into + // the global matrix. We do this as in + // step-27, i.e. we directly apply the + // constraints from hanging nodes + // locally. By doing so, we don't have + // to do that afterwards, and we don't + // also write into entries of the + // matrix that will actually be set to + // zero again later when eliminating + // constraints. + for (unsigned int q=0; qget_dof_indices (local_dof_indices); + stokes_constraints.distribute_local_to_global (local_matrix, + local_dof_indices, + stokes_preconditioner_matrix); + } } @@ -1770,14 +1623,37 @@ BoussinesqFlowProblem::build_stokes_preconditioner () // the local dofs compared to the global // system. template -void -BoussinesqFlowProblem:: -local_assemble_stokes_system (const typename DoFHandler::active_cell_iterator &cell, - AssemblerData::StokesSystem &data) +void BoussinesqFlowProblem::assemble_stokes_system () { - const unsigned int dofs_per_cell = data.stokes_fe_values.get_fe().dofs_per_cell; - const unsigned int n_q_points = data.stokes_fe_values.n_quadrature_points; + std::cout << " Assembling..." << std::flush; + + if (rebuild_stokes_matrix == true) + stokes_matrix=0; + + stokes_rhs=0; + + const QGauss quadrature_formula (stokes_degree+2); + FEValues stokes_fe_values (stokes_fe, quadrature_formula, + update_values | + update_quadrature_points | + update_JxW_values | + (rebuild_stokes_matrix == true + ? + update_gradients + : + UpdateFlags(0))); + FEValues temperature_fe_values (temperature_fe, quadrature_formula, + update_values); + + const unsigned int dofs_per_cell = stokes_fe.dofs_per_cell; + const unsigned int n_q_points = quadrature_formula.size(); + + FullMatrix local_matrix (dofs_per_cell, dofs_per_cell); + Vector local_rhs (dofs_per_cell); + + std::vector local_dof_indices (dofs_per_cell); + // Next we need a vector that will contain // the values of the temperature solution // at the previous time level at the @@ -1801,6 +1677,12 @@ local_assemble_stokes_system (const typename DoFHandler::active_cell_iterat // extract the individual blocks // (velocity, pressure, temperature) from // the total FE system. + std::vector old_temperature_values(n_q_points); + + std::vector > phi_u (dofs_per_cell); + std::vector > grads_phi_u (dofs_per_cell); + std::vector div_phi_u (dofs_per_cell); + std::vector phi_p (dofs_per_cell); const FEValuesExtractors::Vector velocities (0); const FEValuesExtractors::Scalar pressure (dim); @@ -1824,146 +1706,102 @@ local_assemble_stokes_system (const typename DoFHandler::active_cell_iterat // quadrature points. Then we are ready to // loop over the quadrature points on the // cell. - data.stokes_fe_values.reinit (cell); - typename DoFHandler::active_cell_iterator - temperature_cell (&triangulation, - cell->level(), - cell->index(), - &temperature_dof_handler); - data.temperature_fe_values.reinit (temperature_cell); + cell = stokes_dof_handler.begin_active(), + endc = stokes_dof_handler.end(); + typename DoFHandler::active_cell_iterator + temperature_cell = temperature_dof_handler.begin_active(); + + for (; cell!=endc; ++cell, ++temperature_cell) + { + stokes_fe_values.reinit (cell); + temperature_fe_values.reinit (temperature_cell); - data.local_matrix = 0; - data.local_rhs = 0; + local_matrix = 0; + local_rhs = 0; - data.temperature_fe_values.get_function_values (old_temperature_solution, - data.old_temperature_values); + temperature_fe_values.get_function_values (old_temperature_solution, + old_temperature_values); - for (unsigned int q=0; qrebuild_matrices - // flag. - for (unsigned int k=0; krebuild_matrices + // flag. + for (unsigned int k=0; k gravity = ( (dim == 2) ? (Point (0,1)) : - (Point (0,0,1)) ); - for (unsigned int i=0; ilocal_dof_indices. - // Again, we let the ConstraintMatrix - // class do the insertion of the cell - // matrix elements to the global - // matrix, which already condenses the - // hanging node constraints. - cell->get_dof_indices (data.local_dof_indices); -} - -template -void -BoussinesqFlowProblem:: -copy_local_to_global_stokes_system (const AssemblerData::StokesSystem &data) -{ - if (rebuild_stokes_matrix == true) - stokes_constraints.distribute_local_to_global (local_matrix, - local_rhs, - local_dof_indices, - stokes_matrix, - stokes_rhs); - else - stokes_constraints.distribute_local_to_global (local_rhs, - local_dof_indices, - stokes_rhs); -} - - - -template -void BoussinesqFlowProblem::assemble_stokes_system () -{ - std::cout << " Assembling..." << std::flush; - - if (rebuild_stokes_matrix == true) - stokes_matrix=0; - - stokes_rhs=0; + if (rebuild_stokes_matrix) + for (unsigned int i=0; i gravity = ( (dim == 2) ? (Point (0,1)) : + (Point (0,0,1)) ); + for (unsigned int i=0; i quadrature_formula (stokes_degree+2); + // The last step in the loop over all + // cells is to enter the local + // contributions into the global matrix + // and vector structures to the + // positions specified in + // local_dof_indices. + // Again, we let the ConstraintMatrix + // class do the insertion of the cell + // matrix elements to the global + // matrix, which already condenses the + // hanging node constraints. + cell->get_dof_indices (local_dof_indices); - AssemblerData::StokesSystem - data_template (stokes_fe, quadrature_formula, - (update_values | - update_quadrature_points | - update_JxW_values | - (rebuild_stokes_matrix == true - ? - update_gradients - : - UpdateFlags(0))), - temperature_fe, - update_values); - - WorkStream().run (stokes_dof_handler.begin_active(), - stokes_dof_handler.end(), - std_cxx0x::bind (&BoussinesqFlowProblem:: - local_assemble_stokes_system, - this, - _1, - _2), - std_cxx0x::bind (&BoussinesqFlowProblem:: - copy_local_to_global_stokes_system, - this, - _1), - data_template); + if (rebuild_stokes_matrix == true) + stokes_constraints.distribute_local_to_global (local_matrix, + local_rhs, + local_dof_indices, + stokes_matrix, + stokes_rhs); + else + stokes_constraints.distribute_local_to_global (local_rhs, + local_dof_indices, + stokes_rhs); + } rebuild_stokes_matrix = false; @@ -2156,6 +1994,7 @@ void BoussinesqFlowProblem:: const unsigned int n_q_points = quadrature_formula.size(); Vector local_rhs (dofs_per_cell); + FullMatrix local_matrix (dofs_per_cell, dofs_per_cell); std::vector local_dof_indices (dofs_per_cell);