From 73f6156878f7e1ab26f0e9a5dd12a7691ee8206c Mon Sep 17 00:00:00 2001 From: kronbichler Date: Mon, 29 Dec 2008 15:14:33 +0000 Subject: [PATCH] Updated step-32 to use parallel Trilinos sparsity pattern. git-svn-id: https://svn.dealii.org/trunk@18041 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-32/step-32.cc | 130 +++++++++--------- .../include/lac/trilinos_sparsity_pattern.h | 2 +- deal.II/lac/source/block_sparsity_pattern.cc | 2 +- .../lac/source/trilinos_sparsity_pattern.cc | 10 +- 4 files changed, 73 insertions(+), 71 deletions(-) diff --git a/deal.II/examples/step-32/step-32.cc b/deal.II/examples/step-32/step-32.cc index 73ee39434f..76191ab78c 100644 --- a/deal.II/examples/step-32/step-32.cc +++ b/deal.II/examples/step-32/step-32.cc @@ -396,7 +396,8 @@ double BoussinesqFlowProblem::get_maximal_velocity () const cell = stokes_dof_handler.begin_active(), endc = stokes_dof_handler.end(); for (; cell!=endc; ++cell) - if (cell->subdomain_id() == Utilities::Trilinos::get_this_mpi_process(trilinos_communicator)) + if (cell->subdomain_id() == + Utilities::Trilinos::get_this_mpi_process(trilinos_communicator)) { fe_values.reinit (cell); fe_values[velocities].get_function_values (localized_stokes_solution, @@ -442,25 +443,27 @@ BoussinesqFlowProblem::get_extrapolated_temperature_range () const cell = temperature_dof_handler.begin_active(), endc = temperature_dof_handler.end(); for (; cell!=endc; ++cell) - { - fe_values.reinit (cell); - fe_values.get_function_values (old_temperature_solution, - old_temperature_values); - fe_values.get_function_values (old_old_temperature_solution, - old_old_temperature_values); + if (cell->subdomain_id() == + Utilities::Trilinos::get_this_mpi_process(trilinos_communicator)) + { + fe_values.reinit (cell); + fe_values.get_function_values (old_temperature_solution, + old_temperature_values); + fe_values.get_function_values (old_old_temperature_solution, + old_old_temperature_values); - for (unsigned int q=0; q::get_extrapolated_temperature_range () const cell = temperature_dof_handler.begin_active(), endc = temperature_dof_handler.end(); for (; cell!=endc; ++cell) - { - fe_values.reinit (cell); - fe_values.get_function_values (old_temperature_solution, - old_temperature_values); + if (cell->subdomain_id() == + Utilities::Trilinos::get_this_mpi_process(trilinos_communicator)) + { + fe_values.reinit (cell); + fe_values.get_function_values (old_temperature_solution, + old_temperature_values); - for (unsigned int q=0; q &old_temperature, const std::vector > &old_temperature_grads, const std::vector > &old_old_temperature_grads, const std::vector &old_temperature_laplacians, - const std::vector &old_old_temperature_laplaceians, + const std::vector &old_old_temperature_laplacians, const std::vector > &present_velocity_values, const std::vector &gamma_values, const double global_u_infty, @@ -643,14 +648,7 @@ void BoussinesqFlowProblem::setup_dofs () { stokes_matrix.clear (); - BlockCompressedSimpleSparsityPattern csp (2,2); - - csp.block(0,0).reinit (n_u, n_u); - csp.block(0,1).reinit (n_u, n_p); - csp.block(1,0).reinit (n_p, n_u); - csp.block(1,1).reinit (n_p, n_p); - - csp.collect_sizes (); + TrilinosWrappers::BlockSparsityPattern sp (stokes_partitioner); Table<2,DoFTools::Coupling> coupling (dim+1, dim+1); @@ -661,10 +659,11 @@ void BoussinesqFlowProblem::setup_dofs () else coupling[c][d] = DoFTools::none; - DoFTools::make_sparsity_pattern (stokes_dof_handler, coupling, csp, + DoFTools::make_sparsity_pattern (stokes_dof_handler, coupling, sp, stokes_constraints, false); + sp.compress(); - stokes_matrix.reinit (stokes_partitioner, csp); + stokes_matrix.reinit (sp); } { @@ -672,14 +671,7 @@ void BoussinesqFlowProblem::setup_dofs () Mp_preconditioner.reset (); stokes_preconditioner_matrix.clear (); - BlockCompressedSimpleSparsityPattern csp (2,2); - - csp.block(0,0).reinit (n_u, n_u); - csp.block(0,1).reinit (n_u, n_p); - csp.block(1,0).reinit (n_p, n_u); - csp.block(1,1).reinit (n_p, n_p); - - csp.collect_sizes (); + TrilinosWrappers::BlockSparsityPattern sp (stokes_partitioner); Table<2,DoFTools::Coupling> coupling (dim+1, dim+1); for (unsigned int c=0; c::setup_dofs () else coupling[c][d] = DoFTools::none; - DoFTools::make_sparsity_pattern (stokes_dof_handler, coupling, csp, + DoFTools::make_sparsity_pattern (stokes_dof_handler, coupling, sp, stokes_constraints, false); + sp.compress(); - stokes_preconditioner_matrix.reinit (stokes_partitioner, csp); + stokes_preconditioner_matrix.reinit (sp); } temperature_partitioner @@ -707,13 +700,14 @@ void BoussinesqFlowProblem::setup_dofs () temperature_stiffness_matrix.clear (); temperature_matrix.clear (); - CompressedSimpleSparsityPattern csp (n_T, n_T); - DoFTools::make_sparsity_pattern (temperature_dof_handler, csp, + TrilinosWrappers::SparsityPattern sp (temperature_partitioner); + DoFTools::make_sparsity_pattern (temperature_dof_handler, sp, temperature_constraints, false); + sp.compress(); - temperature_matrix.reinit (temperature_partitioner, csp); - temperature_mass_matrix.reinit (temperature_partitioner, csp); - temperature_stiffness_matrix.reinit (temperature_partitioner, csp); + temperature_matrix.reinit (sp); + temperature_mass_matrix.reinit (sp); + temperature_stiffness_matrix.reinit (sp); } stokes_solution.reinit (stokes_partitioner); @@ -755,7 +749,8 @@ BoussinesqFlowProblem::assemble_stokes_preconditioner () cell = stokes_dof_handler.begin_active(), endc = stokes_dof_handler.end(); for (; cell!=endc; ++cell) - if (cell->subdomain_id() == Utilities::Trilinos::get_this_mpi_process(trilinos_communicator)) + if (cell->subdomain_id() == + Utilities::Trilinos::get_this_mpi_process(trilinos_communicator)) { stokes_fe_values.reinit (cell); local_matrix = 0; @@ -876,7 +871,8 @@ void BoussinesqFlowProblem::assemble_stokes_system () temperature_cell = temperature_dof_handler.begin_active(); for (; cell!=endc; ++cell, ++temperature_cell) - if (cell->subdomain_id() == Utilities::Trilinos::get_this_mpi_process(trilinos_communicator)) + if (cell->subdomain_id() == + Utilities::Trilinos::get_this_mpi_process(trilinos_communicator)) { stokes_fe_values.reinit (cell); temperature_fe_values.reinit (temperature_cell); @@ -975,7 +971,8 @@ void BoussinesqFlowProblem::assemble_temperature_matrix () cell = temperature_dof_handler.begin_active(), endc = temperature_dof_handler.end(); for (; cell!=endc; ++cell) - if (cell->subdomain_id() == Utilities::Trilinos::get_this_mpi_process(trilinos_communicator)) + if (cell->subdomain_id() == + Utilities::Trilinos::get_this_mpi_process(trilinos_communicator) ) { local_mass_matrix = 0; local_stiffness_matrix = 0; @@ -1095,7 +1092,8 @@ void BoussinesqFlowProblem::assemble_temperature_system () stokes_cell = stokes_dof_handler.begin_active(); for (; cell!=endc; ++cell, ++stokes_cell) - if (cell->subdomain_id() == Utilities::Trilinos::get_this_mpi_process(trilinos_communicator) ) + if (cell->subdomain_id() == + Utilities::Trilinos::get_this_mpi_process(trilinos_communicator) ) { local_rhs = 0; @@ -1112,10 +1110,10 @@ void BoussinesqFlowProblem::assemble_temperature_system () temperature_fe_values.get_function_gradients (old_old_temperature_solution, old_old_temperature_grads); - temperature_fe_values.get_function_hessians (old_temperature_solution, - old_temperature_laplacians); - temperature_fe_values.get_function_hessians (old_old_temperature_solution, - old_old_temperature_laplacians); + temperature_fe_values.get_function_laplacians (old_temperature_solution, + old_temperature_laplacians); + temperature_fe_values.get_function_laplacians (old_old_temperature_solution, + old_old_temperature_laplacians); temperature_right_hand_side.value_list (temperature_fe_values.get_quadrature_points(), gamma_values); diff --git a/deal.II/lac/include/lac/trilinos_sparsity_pattern.h b/deal.II/lac/include/lac/trilinos_sparsity_pattern.h index 71a9508bf1..364a60f4f0 100755 --- a/deal.II/lac/include/lac/trilinos_sparsity_pattern.h +++ b/deal.II/lac/include/lac/trilinos_sparsity_pattern.h @@ -1237,7 +1237,7 @@ namespace TrilinosWrappers { // if the size is too small, extend the // cache by 10 elements - if (n_cached_elements > cached_row_indices.size()) + if (n_cached_elements >= cached_row_indices.size()) cached_row_indices.resize(cached_row_indices.size() + 10); cached_row_indices[n_cached_elements] = j; diff --git a/deal.II/lac/source/block_sparsity_pattern.cc b/deal.II/lac/source/block_sparsity_pattern.cc index 37481370fc..67e84d312c 100644 --- a/deal.II/lac/source/block_sparsity_pattern.cc +++ b/deal.II/lac/source/block_sparsity_pattern.cc @@ -605,7 +605,7 @@ namespace TrilinosWrappers { for (unsigned int i=0;iblock(i,j).reinit(input_maps[i],input_maps[j]); + this->block(i,j).reinit(input_maps[i], input_maps[j]); this->collect_sizes(); } diff --git a/deal.II/lac/source/trilinos_sparsity_pattern.cc b/deal.II/lac/source/trilinos_sparsity_pattern.cc index 49bdefb7be..3a1379ea0b 100755 --- a/deal.II/lac/source/trilinos_sparsity_pattern.cc +++ b/deal.II/lac/source/trilinos_sparsity_pattern.cc @@ -619,8 +619,7 @@ namespace TrilinosWrappers unsigned int SparsityPattern::n_rows () const { - int n_rows = graph -> NumGlobalRows(); - + const int n_rows = graph -> NumGlobalRows(); return n_rows; } @@ -629,7 +628,12 @@ namespace TrilinosWrappers unsigned int SparsityPattern::n_cols () const { - int n_cols = graph -> NumGlobalCols(); + int n_cols; + if (graph->Filled() == true) + n_cols = graph -> NumGlobalCols(); + else + n_cols = col_map.NumGlobalElements(); + return n_cols; } -- 2.39.5