From 172b3689b627fc7e4d84423e89cb312edfbe6c2a Mon Sep 17 00:00:00 2001 From: frohne Date: Thu, 21 Feb 2013 00:38:41 +0000 Subject: [PATCH] changing the functions for computation time git-svn-id: https://svn.dealii.org/trunk@28502 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-42/step-42.cc | 113 +++++++++------------------- 1 file changed, 34 insertions(+), 79 deletions(-) diff --git a/deal.II/examples/step-42/step-42.cc b/deal.II/examples/step-42/step-42.cc index a24556b2c2..065acfebeb 100644 --- a/deal.II/examples/step-42/step-42.cc +++ b/deal.II/examples/step-42/step-42.cc @@ -137,7 +137,6 @@ namespace Step42 IndexSet locally_relevant_dofs; unsigned int number_iterations; - std::vector run_time; ConstraintMatrix constraints; ConstraintMatrix constraints_hanging_nodes; @@ -157,7 +156,6 @@ namespace Step42 TrilinosWrappers::PreconditionAMG::AdditionalData additional_data; TrilinosWrappers::PreconditionAMG preconditioner_u; - TrilinosWrappers::PreconditionAMG preconditioner_t; std::unique_ptr > input_obstacle; std::unique_ptr > plast_lin_hard; @@ -166,6 +164,8 @@ namespace Step42 double gamma; // Parameter for the linear isotropic hardening double e_modul; // E-Modul double nu; // Poisson ratio + + TimerOutput computing_timer; }; // As explained above this class @@ -414,10 +414,8 @@ namespace Step42 yield = 0; stress_strain_tensor = stress_strain_tensor_mu; double beta = 1.0; - if (deviator_stress_tensor_norm > - sigma_0) + if (deviator_stress_tensor_norm > sigma_0) { -// beta = (sigma_0 + gamma/(2*mu + gamma)*(deviator_stress_tensor_norm - sigma_0))/deviator_stress_tensor_norm; beta = sigma_0/deviator_stress_tensor_norm; stress_strain_tensor *= (gamma + (1 - gamma)*beta); yield = 1; @@ -447,19 +445,13 @@ namespace Step42 stress_strain_tensor = stress_strain_tensor_mu; stress_strain_tensor_linearized = stress_strain_tensor_mu; double beta = 1.0; - if (deviator_stress_tensor_norm > - sigma_0) + if (deviator_stress_tensor_norm > sigma_0) { -// beta = (sigma_0 + gamma/(2*mu + gamma)*(deviator_stress_tensor_norm - sigma_0))/deviator_stress_tensor_norm; beta = sigma_0/deviator_stress_tensor_norm; stress_strain_tensor *= (gamma + (1 - gamma)*beta); stress_strain_tensor_linearized *= (gamma + (1 - gamma)*beta); deviator_stress_tensor /= deviator_stress_tensor_norm; stress_strain_tensor_linearized -= (1 - gamma)*beta*2*mu*outer_product(deviator_stress_tensor, deviator_stress_tensor); - -// std::cout << "Plastisch mit beta = " << beta -// << ", sigma_0 = " << sigma_0 -// << std::endl; } stress_strain_tensor += stress_strain_tensor_kappa; @@ -615,7 +607,10 @@ namespace Step42 sigma_0 (400), gamma (0.01), e_modul (2.0e+5), - nu (0.3) + nu (0.3), + computing_timer (pcout, + TimerOutput::summary, + TimerOutput::wall_times) { // double _E, double _nu, double _sigma_0, double _gamma plast_lin_hard.reset (new ConstitutiveLaw (e_modul, nu, sigma_0, gamma, mpi_communicator, pcout)); @@ -739,6 +734,8 @@ namespace Step42 template void PlasticityContactProblem::assemble_nl_system (TrilinosWrappers::MPI::Vector &u) { + computing_timer.enter_section("Assembling"); + QGauss quadrature_formula(2); QGauss face_quadrature_formula(2); @@ -856,6 +853,8 @@ namespace Step42 system_matrix_newton.compress (); system_rhs_newton.compress (VectorOperation::add); + + computing_timer.exit_section("Assembling"); } template @@ -1034,7 +1033,7 @@ namespace Step42 template void PlasticityContactProblem::update_solution_and_constraints () { - clock_t start_proj, end_proj; + computing_timer.enter_section("Update solution and constraints"); const EquationData::Obstacle obstacle (input_obstacle); std::vector vertex_touched (dof_handler.n_dofs (), false); @@ -1115,6 +1114,8 @@ namespace Step42 constraints.close (); constraints.merge (constraints_dirichlet_hanging_nodes); + + computing_timer.exit_section("Update solution and constraints"); } // @sect4{PlasticityContactProblem::dirichlet_constraints} @@ -1190,7 +1191,7 @@ namespace Step42 template void PlasticityContactProblem::solve () { - Timer t; + computing_timer.enter_section ("Solving and Preconditioning"); TrilinosWrappers::MPI::Vector distributed_solution (system_rhs_newton); distributed_solution = solution; @@ -1200,18 +1201,13 @@ namespace Step42 distributed_solution.compress(VectorOperation::insert); system_rhs_newton.compress(VectorOperation::insert); - MPI_Barrier (mpi_communicator); - t.restart(); + computing_timer.enter_section("Preconditioning"); preconditioner_u.initialize (system_matrix_newton, additional_data); - MPI_Barrier (mpi_communicator); - t.stop(); - if (Utilities::MPI::this_mpi_process(mpi_communicator) == 0) - run_time[6] += t.wall_time(); + computing_timer.exit_section("Preconditioning"); - MPI_Barrier (mpi_communicator); - t.restart(); + computing_timer.enter_section("Solving"); PrimitiveVectorMemory mem; TrilinosWrappers::MPI::Vector tmp (system_rhs_newton); @@ -1231,16 +1227,15 @@ namespace Step42 << " FGMRES iterations." << std::endl; - MPI_Barrier (mpi_communicator); - t.stop(); - if (Utilities::MPI::this_mpi_process(mpi_communicator) == 0) - run_time[7] += t.wall_time(); + computing_timer.exit_section("Solving"); number_iterations += solver_control.last_step(); constraints.distribute (distributed_solution); solution = distributed_solution; + + computing_timer.exit_section("Solving and Preconditioning"); } @@ -1252,7 +1247,6 @@ namespace Step42 double resid_old=100000; TrilinosWrappers::MPI::Vector res (system_rhs_newton); TrilinosWrappers::MPI::Vector tmp_vector (system_rhs_newton); - Timer t; std::vector > constant_modes; DoFTools::extract_constant_modes (dof_handler, @@ -1283,37 +1277,17 @@ namespace Step42 pcout<< " Newton iteration " << j <("obstacle_file.pbm")); pcout << "Ostacle is available now." << std::endl; - Timer t; - run_time.resize (8); - const unsigned int n_cycles = 6; for (unsigned int cycle=0; cycle