From fcf62c12e9524878272585bf686c61edf17ed7d5 Mon Sep 17 00:00:00 2001 From: bangerth Date: Thu, 28 Oct 2010 15:32:51 +0000 Subject: [PATCH] Replace version with timers by a cleaned-up version. git-svn-id: https://svn.dealii.org/trunk@22537 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-40/step-40-commented.cc | 406 --------------- deal.II/examples/step-40/step-40.cc | 491 ++++-------------- 2 files changed, 91 insertions(+), 806 deletions(-) delete mode 100644 deal.II/examples/step-40/step-40-commented.cc diff --git a/deal.II/examples/step-40/step-40-commented.cc b/deal.II/examples/step-40/step-40-commented.cc deleted file mode 100644 index b94923467c..0000000000 --- a/deal.II/examples/step-40/step-40-commented.cc +++ /dev/null @@ -1,406 +0,0 @@ -/* $Id$ */ -/* Author: Wolfgang Bangerth, Texas A&M University, 2009, 2010 */ -/* Timo Heister, University of Goettingen, 2009, 2010 */ - -/* $Id$ */ -/* */ -/* Copyright (C) 2009, 2010 by Timo Heister and the deal.II authors */ -/* */ -/* This file is subject to QPL and may not be distributed */ -/* without copyright and license information. Please refer */ -/* to the file deal.II/doc/license.html for the text and */ -/* further information on this license. */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -using namespace dealii; - - -template -class LaplaceProblem -{ - public: - LaplaceProblem (); - ~LaplaceProblem (); - - void run (const unsigned int initial_global_refine); - - private: - void setup_system (); - void assemble_system (); - void solve (); - void refine_grid (); - void output_results (const unsigned int cycle) const; - - MPI_Comm mpi_communicator; - - parallel::distributed::Triangulation triangulation; - - DoFHandler dof_handler; - FE_Q fe; - - IndexSet locally_owned_dofs; - IndexSet locally_relevant_dofs; - - ConstraintMatrix constraints; - - PETScWrappers::MPI::SparseMatrix system_matrix; - PETScWrappers::MPI::Vector locally_relevant_solution; - PETScWrappers::MPI::Vector system_rhs; - - ConditionalOStream pcout; -}; - - - -template -LaplaceProblem::LaplaceProblem () - : - mpi_communicator (MPI_COMM_WORLD), - triangulation (mpi_communicator, - typename Triangulation::MeshSmoothing - (Triangulation::smoothing_on_refinement | - Triangulation::smoothing_on_coarsening)), - dof_handler (triangulation), - fe (2), - pcout (std::cout, - (Utilities::System:: - get_this_mpi_process(mpi_communicator) - == 0)) -{} - - - -template -LaplaceProblem::~LaplaceProblem () -{ - dof_handler.clear (); -} - - - -template -void LaplaceProblem::setup_system () -{ - locally_relevant_solution.reinit (mpi_communicator, - locally_owned_dofs, - locally_relevant_dofs); - system_rhs.reinit (mpi_communicator, - dof_handler.n_dofs(), - dof_handler.n_locally_owned_dofs()); - - locally_relevant_solution = 0; - system_rhs = 0; - - constraints.clear (); - constraints.reinit (locally_relevant_dofs); - - DoFTools::make_hanging_node_constraints (dof_handler, constraints); - VectorTools::interpolate_boundary_values (dof_handler, - 0, - ZeroFunction(), - constraints); - constraints.close (); - - - CompressedSimpleSparsityPattern csp (dof_handler.n_dofs(), - dof_handler.n_dofs(), - locally_relevant_dofs); - DoFTools::make_sparsity_pattern (dof_handler, - csp, - constraints, false); - SparsityTools::distribute_sparsity_pattern (csp, - dof_handler.n_locally_owned_dofs_per_processor(), - mpi_communicator, - locally_relevant_dofs); - system_matrix.reinit (mpi_communicator, - csp, - dof_handler.n_locally_owned_dofs_per_processor(), - dof_handler.n_locally_owned_dofs_per_processor(), - Utilities::System::get_this_mpi_process(mpi_communicator)); -} - - - -template -void LaplaceProblem::assemble_system () -{ - const QGauss quadrature_formula(3); - - FEValues fe_values (fe, quadrature_formula, - update_values | update_gradients | - update_quadrature_points | - update_JxW_values); - - const unsigned int dofs_per_cell = fe.dofs_per_cell; - const unsigned int n_q_points = quadrature_formula.size(); - - FullMatrix cell_matrix (dofs_per_cell, dofs_per_cell); - Vector cell_rhs (dofs_per_cell); - - std::vector local_dof_indices (dofs_per_cell); - - typename DoFHandler::active_cell_iterator - cell = dof_handler.begin_active(), - endc = dof_handler.end(); - for (; cell!=endc; ++cell) - if (cell->subdomain_id() == triangulation.locally_owned_subdomain()) - { - cell_matrix = 0; - cell_rhs = 0; - - fe_values.reinit (cell); - - for (unsigned int q_point=0; q_point - 0.5+0.25*sin(4.0*numbers::PI*fe_values.quadrature_point(q_point)[0]) - ? 1 : -1) * - fe_values.JxW(q_point)); - } - - cell->get_dof_indices (local_dof_indices); - constraints.distribute_local_to_global (cell_matrix, - cell_rhs, - local_dof_indices, - system_matrix, - system_rhs); - } - - system_matrix.compress (); - system_rhs.compress (); -} - - - - - -template -void LaplaceProblem::solve () -{ - PETScWrappers::MPI::Vector - completely_distributed_solution (mpi_communicator, - dof_handler.n_dofs(), - dof_handler.n_locally_owned_dofs()); - - SolverControl solver_control (dof_handler.n_dofs(), 1e-12); - - PETScWrappers::SolverCG solver(solver_control, mpi_communicator); - PETScWrappers::PreconditionBlockJacobi preconditioner(system_matrix); - - solver.solve (system_matrix, completely_distributed_solution, system_rhs, - preconditioner); - - pcout << " Solved in " << solver_control.last_step() - << " iterations." << std::endl; - - constraints.distribute (completely_distributed_solution); - - locally_relevant_solution = completely_distributed_solution; -} - - - -template -void LaplaceProblem::refine_grid () -{ - Vector estimated_error_per_cell (triangulation.n_active_cells()); - KellyErrorEstimator::estimate (dof_handler, - QGauss(3), - typename FunctionMap::type(), - locally_relevant_solution, - estimated_error_per_cell); - parallel::distributed::GridRefinement:: - refine_and_coarsen_fixed_number (triangulation, - estimated_error_per_cell, - 0.3, 0.03); - triangulation.execute_coarsening_and_refinement (); -} - - - - -template -void LaplaceProblem::output_results (const unsigned int cycle) const -{ - DataOut data_out; - data_out.attach_dof_handler (dof_handler); - data_out.add_data_vector (locally_relevant_solution, "u"); - - Vector subdomain (triangulation.n_active_cells()); - // could just fill entire vector with subdomain_id() - { - unsigned int index = 0; - for (typename Triangulation::active_cell_iterator - cell = triangulation.begin_active(); - cell != triangulation.end(); ++cell, ++index) - subdomain(index) = (cell->is_ghost() || cell->is_artificial() - ? - -1 - : - cell->subdomain_id()); - } - data_out.add_data_vector (subdomain, "subdomain"); - data_out.build_patches (); - - const std::string filename = ("solution-" + - Utilities::int_to_string (cycle, 2) + - "." + - Utilities::int_to_string - (triangulation.locally_owned_subdomain(), 4)); - - std::ofstream output ((filename + ".vtu").c_str()); - data_out.write_vtu (output); - - if (Utilities::System::get_this_mpi_process(mpi_communicator) == 0) - { - std::vector filenames; - for (unsigned int i=0; - i -void LaplaceProblem::run (const unsigned int initial_global_refine) -{ - const unsigned int n_cycles = 12; - for (unsigned int cycle=0; cycle1) - { - refine = (unsigned int)Utilities::string_to_int(argv[1]); - } - - { - LaplaceProblem<2> laplace_problem_2d; - laplace_problem_2d.run (refine); - } - - PetscFinalize(); - } - catch (std::exception &exc) - { - std::cerr << std::endl << std::endl - << "----------------------------------------------------" - << std::endl; - std::cerr << "Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" - << std::endl; - - return 1; - } - catch (...) - { - std::cerr << std::endl << std::endl - << "----------------------------------------------------" - << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" - << std::endl; - return 1; - } - - return 0; -} diff --git a/deal.II/examples/step-40/step-40.cc b/deal.II/examples/step-40/step-40.cc index b8683b8024..b94923467c 100644 --- a/deal.II/examples/step-40/step-40.cc +++ b/deal.II/examples/step-40/step-40.cc @@ -1,6 +1,6 @@ /* $Id$ */ -/* Author: Wolfgang Bangerth, Texas A&M University, 2009 */ -/* Timo Heister, University of Goettingen, 2009 */ +/* Author: Wolfgang Bangerth, Texas A&M University, 2009, 2010 */ +/* Timo Heister, University of Goettingen, 2009, 2010 */ /* $Id$ */ /* */ @@ -11,105 +11,43 @@ /* to the file deal.II/doc/license.html for the text and */ /* further information on this license. */ -// comment to use PETSc: -//#define USE_TRILINOS - - #include #include -#include #include #include #include #include #include #include -#include #include -#include #include #include #include -#ifdef USE_TRILINOS -#include -#include -#include -#include -#else #include #include #include #include -#endif #include #include #include -#include -#include -#include #include #include #include #include #include -#include #include #include #include #include -#include #include #include -#include "timeblock.h" - using namespace dealii; -void print_it(Utilities::System::MinMaxAvg & result) -{ - std::cout// << "sum: " << result.sum - << " avg: " << (long)result.avg/1024 - << " min: " << (long)result.min/1024 << " @" << result.min_index - << " max: " << (long)result.max/1024 << " @" << result.max_index - << std::endl; -} - -void print_memory_stats() -{ - int myid = Utilities::System::get_this_mpi_process(MPI_COMM_WORLD); - Utilities::System::MemoryStats stats; - Utilities::System::get_memory_stats(stats); - Utilities::System::MinMaxAvg r; - Utilities::System::calculate_collective_mpi_min_max_avg(MPI_COMM_WORLD, stats.VmPeak, r); - if (myid==0) - { - std::cout << "MEM: VmPeak: "; - print_it(r); - } - Utilities::System::calculate_collective_mpi_min_max_avg(MPI_COMM_WORLD, stats.VmSize, r); - if (myid==0) - { - std::cout << "MEM: VmSize: "; - print_it(r); - } - Utilities::System::calculate_collective_mpi_min_max_avg(MPI_COMM_WORLD, stats.VmHWM, r); - if (myid==0) - { - std::cout << "MEM: VmHWM: "; - print_it(r); - } - Utilities::System::calculate_collective_mpi_min_max_avg(MPI_COMM_WORLD, stats.VmRSS, r); - if (myid==0) - { - std::cout << "MEM: VmRSS: "; - print_it(r); - } -} - template class LaplaceProblem @@ -118,7 +56,7 @@ class LaplaceProblem LaplaceProblem (); ~LaplaceProblem (); - void run (unsigned int refine); + void run (const unsigned int initial_global_refine); private: void setup_system (); @@ -127,6 +65,8 @@ class LaplaceProblem void refine_grid (); void output_results (const unsigned int cycle) const; + MPI_Comm mpi_communicator; + parallel::distributed::Triangulation triangulation; DoFHandler dof_handler; @@ -137,21 +77,11 @@ class LaplaceProblem ConstraintMatrix constraints; -#ifdef USE_TRILINOS - TrilinosWrappers::SparseMatrix system_matrix; - TrilinosWrappers::MPI::Vector solution; - TrilinosWrappers::MPI::Vector system_rhs; - parallel::distributed::SolutionTransfer soltrans; -#else PETScWrappers::MPI::SparseMatrix system_matrix; - PETScWrappers::MPI::Vector solution; + PETScWrappers::MPI::Vector locally_relevant_solution; PETScWrappers::MPI::Vector system_rhs; - parallel::distributed::SolutionTransfer soltrans; -#endif ConditionalOStream pcout; - - }; @@ -159,15 +89,16 @@ class LaplaceProblem template LaplaceProblem::LaplaceProblem () : - triangulation (MPI_COMM_WORLD - ,typename Triangulation::MeshSmoothing (Triangulation::smoothing_on_refinement | Triangulation::smoothing_on_coarsening) - ), + mpi_communicator (MPI_COMM_WORLD), + triangulation (mpi_communicator, + typename Triangulation::MeshSmoothing + (Triangulation::smoothing_on_refinement | + Triangulation::smoothing_on_coarsening)), dof_handler (triangulation), fe (2), - soltrans(dof_handler), pcout (std::cout, (Utilities::System:: - get_this_mpi_process(MPI_COMM_WORLD) + get_this_mpi_process(mpi_communicator) == 0)) {} @@ -184,82 +115,42 @@ LaplaceProblem::~LaplaceProblem () template void LaplaceProblem::setup_system () { - TimeBlock t(pcout, "setup_system", false); - { - TimeBlock t(pcout, "_init_vectors"); -#ifdef USE_TRILINOS - solution.reinit (locally_relevant_dofs, MPI_COMM_WORLD); - system_rhs.reinit (locally_owned_dofs, MPI_COMM_WORLD); -#else - solution.reinit ( MPI_COMM_WORLD, locally_owned_dofs, locally_relevant_dofs); - system_rhs.reinit (MPI_COMM_WORLD, dof_handler.n_dofs(), - dof_handler.n_locally_owned_dofs()); - - solution = 0; - system_rhs = 0; -#endif - } + locally_relevant_solution.reinit (mpi_communicator, + locally_owned_dofs, + locally_relevant_dofs); + system_rhs.reinit (mpi_communicator, + dof_handler.n_dofs(), + dof_handler.n_locally_owned_dofs()); + + locally_relevant_solution = 0; + system_rhs = 0; constraints.clear (); constraints.reinit (locally_relevant_dofs); - { - - TimeBlock t(pcout, "_make_hn"); - - DoFTools::make_hanging_node_constraints (static_cast&>(dof_handler), - constraints); - } - - { - TimeBlock t(pcout, "_interpol_bv"); - VectorTools::interpolate_boundary_values (static_cast&>(dof_handler), - 0, - ZeroFunction(), - constraints); - constraints.close (); - } + DoFTools::make_hanging_node_constraints (dof_handler, constraints); + VectorTools::interpolate_boundary_values (dof_handler, + 0, + ZeroFunction(), + constraints); + constraints.close (); CompressedSimpleSparsityPattern csp (dof_handler.n_dofs(), dof_handler.n_dofs(), locally_relevant_dofs); - { - TimeBlock t(pcout, "_make_sp", false); - - DoFTools::make_sparsity_pattern (static_cast&>(dof_handler), - csp, - constraints, false); - } - - { - TimeBlock t(pcout, "_init_matrix", false); -#ifdef USE_TRILINOS - system_matrix.reinit (locally_owned_dofs, csp, MPI_COMM_WORLD, true); -#else - - { - TimeBlock t(pcout, "__prep_csp", false); - SparsityTools::distribute_sparsity_pattern<>(csp, - dof_handler.n_locally_owned_dofs_per_processor(), - MPI_COMM_WORLD, - locally_relevant_dofs); - } - - system_matrix.reinit (MPI_COMM_WORLD, - csp, - dof_handler.n_locally_owned_dofs_per_processor(), - dof_handler.n_locally_owned_dofs_per_processor(), - Utilities::System::get_this_mpi_process(MPI_COMM_WORLD)); -#if (PETSC_VERSION_MAJOR <= 2) -// MatSetOption (system_matrix, MAT_YES_NEW_NONZERO_LOCATIONS); -#else -// MatSetOption (system_matrix, MAT_NEW_NONZERO_LOCATION_ERR, PETSC_FALSE); -// MatSetOption (system_matrix, MAT_NEW_NONZERO_LOCATIONS, PETSC_TRUE); -#endif - -#endif - } + DoFTools::make_sparsity_pattern (dof_handler, + csp, + constraints, false); + SparsityTools::distribute_sparsity_pattern (csp, + dof_handler.n_locally_owned_dofs_per_processor(), + mpi_communicator, + locally_relevant_dofs); + system_matrix.reinit (mpi_communicator, + csp, + dof_handler.n_locally_owned_dofs_per_processor(), + dof_handler.n_locally_owned_dofs_per_processor(), + Utilities::System::get_this_mpi_process(mpi_communicator)); } @@ -267,8 +158,6 @@ void LaplaceProblem::setup_system () template void LaplaceProblem::assemble_system () { - TimeBlock t(pcout, "assemble"); - const QGauss quadrature_formula(3); FEValues fe_values (fe, quadrature_formula, @@ -303,17 +192,15 @@ void LaplaceProblem::assemble_system () fe_values.shape_grad(j,q_point) * fe_values.JxW(q_point)); - double v = fe_values.quadrature_point(q_point)[0]; - v = 0.5+0.25*sin(4.0*numbers::PI*v); - cell_rhs(i) += (fe_values.shape_value(i,q_point) * - (v < fe_values.quadrature_point(q_point)[1] + (fe_values.quadrature_point(q_point)[1] + > + 0.5+0.25*sin(4.0*numbers::PI*fe_values.quadrature_point(q_point)[0]) ? 1 : -1) * fe_values.JxW(q_point)); } cell->get_dof_indices (local_dof_indices); - constraints.distribute_local_to_global (cell_matrix, cell_rhs, local_dof_indices, @@ -321,12 +208,8 @@ void LaplaceProblem::assemble_system () system_rhs); } -#ifdef USE_TRILINOS - system_rhs.compress (Add); -#else - system_rhs.compress (); -#endif system_matrix.compress (); + system_rhs.compress (); } @@ -336,83 +219,25 @@ void LaplaceProblem::assemble_system () template void LaplaceProblem::solve () { - // we do not want to get spammed with solver info. - deallog.depth_console (0); - - TimeBlock t(pcout, "solve", false); - -#ifdef USE_TRILINOS - TrilinosWrappers::MPI::Vector distributed_solution (locally_owned_dofs, - MPI_COMM_WORLD); - - distributed_solution.reinit(solution, false, true); -#else + PETScWrappers::MPI::Vector + completely_distributed_solution (mpi_communicator, + dof_handler.n_dofs(), + dof_handler.n_locally_owned_dofs()); - PETScWrappers::MPI::Vector distributed_solution(MPI_COMM_WORLD, - dof_handler.n_dofs(), - dof_handler.n_locally_owned_dofs()); + SolverControl solver_control (dof_handler.n_dofs(), 1e-12); - distributed_solution = solution; -#endif - - print_memory_stats(); - - SolverControl solver_control (solution.size(), 1e-12); -#ifdef USE_TRILINOS - SolverCG solver (solver_control); - - TrilinosWrappers::PreconditionAMG preconditioner; - preconditioner.initialize(system_matrix); -#else - PETScWrappers::SolverCG solver(solver_control, MPI_COMM_WORLD); + PETScWrappers::SolverCG solver(solver_control, mpi_communicator); PETScWrappers::PreconditionBlockJacobi preconditioner(system_matrix); -#endif - - { // memory consumption - pcout << "Mem: Tria (p4est) DofH Constraints Mat X Rhs I_lo I_lr" - << std::endl; -// MPI_Barrier(MPI_COMM_WORLD); - - pcout << "MEM: " - << " " << triangulation.memory_consumption() - << " " << triangulation.memory_consumption_p4est() - << " " << dof_handler.memory_consumption() - << " " << constraints.memory_consumption() - << " " << system_matrix.memory_consumption() - << " " << solution.memory_consumption() - << " " << system_rhs.memory_consumption() - << " " << locally_owned_dofs.memory_consumption() - << " " << locally_relevant_dofs.memory_consumption() -// << " " << preconditioner.memory_consumption() - << " ~sum=" << (triangulation.memory_consumption() + dof_handler.memory_consumption() - + constraints.memory_consumption() + system_matrix.memory_consumption() - + solution.memory_consumption() + system_rhs.memory_consumption() - + locally_owned_dofs.memory_consumption() - + locally_relevant_dofs.memory_consumption() )/1024 - << " kB" - << std::endl; - -// MPI_Barrier(MPI_COMM_WORLD); - } - - - solver.solve (system_matrix, distributed_solution, system_rhs, - preconditioner); - - print_memory_stats(); + solver.solve (system_matrix, completely_distributed_solution, system_rhs, + preconditioner); pcout << " Solved in " << solver_control.last_step() << " iterations." << std::endl; - constraints.distribute (distributed_solution); - solution = distributed_solution; - -#ifndef USE_TRILINOS - solution.update_ghost_values(); -#endif + constraints.distribute (completely_distributed_solution); - deallog.depth_console (1); + locally_relevant_solution = completely_distributed_solution; } @@ -420,104 +245,17 @@ void LaplaceProblem::solve () template void LaplaceProblem::refine_grid () { - TimerOutput computing_timer(pcout, TimerOutput::summary, - TimerOutput::wall_times); - - computing_timer.enter_section ("Estimating"); - Vector estimated_error_per_cell (triangulation.n_active_cells()); - - { - - TimeBlock t(pcout, "kelly"); - - KellyErrorEstimator::estimate (static_cast&>(dof_handler), + KellyErrorEstimator::estimate (dof_handler, QGauss(3), typename FunctionMap::type(), - solution, + locally_relevant_solution, estimated_error_per_cell); - } - - computing_timer.exit_section(); - - computing_timer.enter_section ("Marking"); - { - TimeBlock t(pcout, "marking"); - parallel::distributed::GridRefinement:: refine_and_coarsen_fixed_number (triangulation, estimated_error_per_cell, 0.3, 0.03); - } - - computing_timer.exit_section(); - - computing_timer.enter_section ("Refining"); - - - { - TimeBlock t(pcout, "prep_c&r"); - - triangulation.prepare_coarsening_and_refinement(); - } - - if (0) - { - //output refinement information for - //debugging - - const std::string filename = ("ref." + - Utilities::int_to_string - (triangulation.locally_owned_subdomain(), 4) + - ".vtk"); - std::ofstream output (filename.c_str()); - - DataOut data_out; - data_out.attach_dof_handler (dof_handler); - - unsigned int n_coarse=0; - Vector subdomain (triangulation.n_active_cells()); - { - unsigned int index = 0; - - for (typename Triangulation::active_cell_iterator - cell = triangulation.begin_active(); - cell != triangulation.end(); ++cell, ++index) - { - subdomain(index)=0; - - if (cell->is_ghost() || cell->is_artificial()) - subdomain(index)=-4; - - if (cell->refine_flag_set()) - subdomain(index)+=1; - if (cell->coarsen_flag_set()) - { - subdomain(index)+=2; - ++n_coarse; - } - } - } - std::cout << "id=" << triangulation.locally_owned_subdomain() << " n_coarsen=" << n_coarse << std::endl; - - data_out.add_data_vector (subdomain, "info"); - data_out.build_patches (); - data_out.write_vtk (output); - } - - { - TimeBlock t(pcout, "soltrans.prep"); - - soltrans.prepare_for_coarsening_and_refinement(solution); - } - - { - TimeBlock t(pcout, "c&r", false); - triangulation.execute_coarsening_and_refinement (); - } - - computing_timer.exit_section(); } @@ -526,19 +264,12 @@ void LaplaceProblem::refine_grid () template void LaplaceProblem::output_results (const unsigned int cycle) const { - const std::string filename = ("solution-" + - Utilities::int_to_string (cycle, 2) + - "." + - Utilities::int_to_string - (triangulation.locally_owned_subdomain(), 4) + - ".d2"); - std::ofstream output (filename.c_str()); - DataOut data_out; data_out.attach_dof_handler (dof_handler); - data_out.add_data_vector (solution, "u"); + data_out.add_data_vector (locally_relevant_solution, "u"); Vector subdomain (triangulation.n_active_cells()); + // could just fill entire vector with subdomain_id() { unsigned int index = 0; for (typename Triangulation::active_cell_iterator @@ -551,67 +282,59 @@ void LaplaceProblem::output_results (const unsigned int cycle) const cell->subdomain_id()); } data_out.add_data_vector (subdomain, "subdomain"); - data_out.build_patches (); - data_out.write_deal_II_intermediate (output); + const std::string filename = ("solution-" + + Utilities::int_to_string (cycle, 2) + + "." + + Utilities::int_to_string + (triangulation.locally_owned_subdomain(), 4)); + + std::ofstream output ((filename + ".vtu").c_str()); + data_out.write_vtu (output); + + if (Utilities::System::get_this_mpi_process(mpi_communicator) == 0) + { + std::vector filenames; + for (unsigned int i=0; + i -void LaplaceProblem::run (unsigned int refine) +void LaplaceProblem::run (const unsigned int initial_global_refine) { - { - TimeBlock t(pcout, "empty"); - } - - unsigned int cycles = 12; - - pcout << "running " << cycles << " cycles with refine= " << refine << -#ifdef USE_TRILINOS - " with Trilinos" -#else - " with PETSc" -#endif - << std::endl; - - for (unsigned int cycle=0; cycle t(pcout, "dist_dofs"); - dof_handler.distribute_dofs (fe); - } + dof_handler.distribute_dofs (fe); + // eliminate locally_owned_dofs = dof_handler.locally_owned_dofs (); DoFTools::extract_locally_relevant_dofs (dof_handler, locally_relevant_dofs); @@ -619,35 +342,14 @@ void LaplaceProblem::run (unsigned int refine) pcout << " Number of degrees of freedom: " << dof_handler.n_dofs() << std::endl; -/* pcout << " ("; - for (unsigned int i=0; i0) - { - TimeBlock t(pcout, "soltrans.interp"); - soltrans.interpolate(solution); - } - - - computing_timer.exit_section(); + setup_system (); - computing_timer.enter_section ("Assembling system"); assemble_system (); - computing_timer.exit_section(); - - computing_timer.enter_section ("Solving system"); solve (); - computing_timer.exit_section(); -// output_results (cycle); + if (Utilities::System::get_n_mpi_processes(mpi_communicator) <= 100) + output_results (cycle); pcout << std::endl; } @@ -659,13 +361,8 @@ int main(int argc, char *argv[]) { try { -#ifdef USE_TRILINOS - Utilities::System::MPI_InitFinalize mpi_initialization(argc, argv); -#else PetscInitialize(&argc, &argv); -#endif - - deallog.depth_console (1); + deallog.depth_console (0); int refine=5; if (argc>1) @@ -678,13 +375,7 @@ int main(int argc, char *argv[]) laplace_problem_2d.run (refine); } - print_memory_stats(); - -#ifndef USE_TRILINOS - PetscLogPrintSummary(MPI_COMM_WORLD, "petsc.log" ); PetscFinalize(); -#endif - } catch (std::exception &exc) { -- 2.39.5