From: David Wells Date: Thu, 16 Mar 2017 22:21:14 +0000 (-0400) Subject: Initialize variables in step constructors. X-Git-Tag: v8.5.0-rc1~25^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=527a9a1145a4e696f8b07c88d3f96f5ba3e7a4d0;p=dealii.git Initialize variables in step constructors. --- diff --git a/examples/step-14/step-14.cc b/examples/step-14/step-14.cc index 6bcf068688..d7da265483 100644 --- a/examples/step-14/step-14.cc +++ b/examples/step-14/step-14.cc @@ -397,7 +397,8 @@ namespace Step14 template Base::Base (Triangulation &coarse_grid) : - triangulation (&coarse_grid) + triangulation (&coarse_grid), + refinement_cycle (numbers::invalid_unsigned_int) {} diff --git a/examples/step-18/step-18.cc b/examples/step-18/step-18.cc index 7f4ef9950b..8097a8a6d6 100644 --- a/examples/step-18/step-18.cc +++ b/examples/step-18/step-18.cc @@ -740,10 +740,15 @@ namespace Step18 fe (FE_Q(1), dim), dof_handler (triangulation), quadrature_formula (2), + present_time (0.0), + present_timestep (1.0), + end_time (10.0), + timestep_no (0), mpi_communicator (MPI_COMM_WORLD), n_mpi_processes (Utilities::MPI::n_mpi_processes(mpi_communicator)), this_mpi_process (Utilities::MPI::this_mpi_process(mpi_communicator)), - pcout (std::cout, this_mpi_process == 0) + pcout (std::cout, this_mpi_process == 0), + n_local_cells (numbers::invalid_unsigned_int) {} @@ -765,11 +770,6 @@ namespace Step18 template void TopLevel::run () { - present_time = 0; - present_timestep = 1; - end_time = 10; - timestep_no = 0; - do_initial_timestep (); while (present_time < end_time) diff --git a/examples/step-21/step-21.cc b/examples/step-21/step-21.cc index 034d657ad7..7d932e0d99 100644 --- a/examples/step-21/step-21.cc +++ b/examples/step-21/step-21.cc @@ -596,6 +596,7 @@ namespace Step21 dof_handler (triangulation), n_refinement_steps (5), time_step (0), + timestep_number (1), viscosity (0.2) {} @@ -1244,7 +1245,6 @@ namespace Step21 old_solution); } - timestep_number = 1; double time = 0; do diff --git a/examples/step-23/step-23.cc b/examples/step-23/step-23.cc index 03089ec69c..5f62bb1361 100644 --- a/examples/step-23/step-23.cc +++ b/examples/step-23/step-23.cc @@ -140,7 +140,7 @@ namespace Step23 Vector old_solution_u, old_solution_v; Vector system_rhs; - double time, time_step; + double time_step, time; unsigned int timestep_number; const double theta; }; @@ -311,6 +311,8 @@ namespace Step23 fe (1), dof_handler (triangulation), time_step (1./64), + time (time_step), + timestep_number (1), theta (0.5) {} @@ -511,9 +513,7 @@ namespace Step23 Vector tmp (solution_u.size()); Vector forcing_terms (solution_u.size()); - for (timestep_number=1, time=time_step; - time<=5; - time+=time_step, ++timestep_number) + for (; time<=5; time+=time_step, ++timestep_number) { std::cout << "Time step " << timestep_number << " at t=" << time diff --git a/examples/step-24/step-24.cc b/examples/step-24/step-24.cc index 0e4294a821..7c473acbb6 100644 --- a/examples/step-24/step-24.cc +++ b/examples/step-24/step-24.cc @@ -95,7 +95,7 @@ namespace Step24 Vector old_solution_p, old_solution_v; Vector system_rhs_p, system_rhs_v; - double time, time_step; + double time_step, time; unsigned int timestep_number; const double theta; @@ -192,12 +192,15 @@ namespace Step24 // imaging) since this is where many of the experiments we want to compare // the output with are made in. The Crank-Nicolson scheme is used again, // i.e. theta is set to 0.5. The time step is later selected to satisfy $k = - // \frac hc$ + // \frac hc$: here we initialize it to an invalid number. template TATForwardProblem::TATForwardProblem () : fe (1), dof_handler (triangulation), + time_step (std::numeric_limits::quiet_NaN()), + time (time_step), + timestep_number (1), theta (0.5), wave_speed (1.437) { @@ -498,9 +501,7 @@ namespace Step24 Vector G2 (solution_v.size()); const double end_time = 0.7; - for (timestep_number=1, time=time_step; - time<=end_time; - time+=time_step, ++timestep_number) + for (time=time_step; time<=end_time; time+=time_step, ++timestep_number) { std::cout << std::endl; std::cout<< "time_step " << timestep_number << " @ t=" << time << std::endl; diff --git a/examples/step-26/step-26.cc b/examples/step-26/step-26.cc index 50ffdde15f..fc9eb3bcf5 100644 --- a/examples/step-26/step-26.cc +++ b/examples/step-26/step-26.cc @@ -206,7 +206,9 @@ namespace Step26 : fe(1), dof_handler(triangulation), + time (0.0), time_step(1. / 500), + timestep_number (0), theta(0.5) {} @@ -465,9 +467,6 @@ start_time_iteration: old_solution); solution = old_solution; - timestep_number = 0; - time = 0; - output_results(); // Then we start the main loop until the computed time exceeds our diff --git a/examples/step-28/step-28.cc b/examples/step-28/step-28.cc index ce1cef8978..6fde76097d 100644 --- a/examples/step-28/step-28.cc +++ b/examples/step-28/step-28.cc @@ -1308,7 +1308,8 @@ namespace Step28 : parameters (parameters), material_data (parameters.n_groups), - fe (parameters.fe_degree) + fe (parameters.fe_degree), + k_eff (std::numeric_limits::quiet_NaN()) {} diff --git a/examples/step-31/step-31.cc b/examples/step-31/step-31.cc index eedc929966..a4da66e1f3 100644 --- a/examples/step-31/step-31.cc +++ b/examples/step-31/step-31.cc @@ -568,7 +568,7 @@ namespace Step31 BoussinesqFlowProblem::BoussinesqFlowProblem () : triangulation (Triangulation::maximum_smoothing), - + global_Omega_diameter (std::numeric_limits::quiet_NaN()), stokes_degree (1), stokes_fe (FE_Q(stokes_degree+1), dim, FE_Q(stokes_degree), 1), diff --git a/examples/step-35/step-35.cc b/examples/step-35/step-35.cc index b1f83006d4..935ddd7940 100644 --- a/examples/step-35/step-35.cc +++ b/examples/step-35/step-35.cc @@ -122,7 +122,22 @@ namespace Step35 // In the constructor of this class we declare all the parameters. The // details of how this works have been discussed elsewhere, for example in // step-19 and step-29. - Data_Storage::Data_Storage() + Data_Storage::Data_Storage() : + form (METHOD_ROTATIONAL), + initial_time (0.), + final_time (1.), + Reynolds (1.), + dt (5e-4), + n_global_refines (0), + pressure_degree (1), + vel_max_iterations (1000), + vel_Krylov_size (30), + vel_off_diagonals (60), + vel_update_prec (15), + vel_eps (1e-12), + vel_diag_strength (0.01), + verbose (true), + output_interval (15) { prm.declare_entry ("Method_Form", "rotational", Patterns::Selection ("rotational|standard"), diff --git a/examples/step-42/step-42.cc b/examples/step-42/step-42.cc index 440a580260..a238022859 100644 --- a/examples/step-42/step-42.cc +++ b/examples/step-42/step-42.cc @@ -861,7 +861,9 @@ namespace Step42 (new EquationData::SphereObstacle(base_mesh == "box" ? 1.0 : 0.5))), transfer_solution (prm.get_bool("transfer solution")), - n_refinement_cycles (prm.get_integer("number of cycles")) + n_refinement_cycles (prm.get_integer("number of cycles")), + current_refinement_cycle (0) + { std::string strat = prm.get("refinement strategy"); if (strat == "global") @@ -2151,8 +2153,7 @@ namespace Step42 PlasticityContactProblem::run () { computing_timer.reset(); - for (current_refinement_cycle = 0; - current_refinement_cycle < n_refinement_cycles; + for (; current_refinement_cycle < n_refinement_cycles; ++current_refinement_cycle) { { diff --git a/examples/step-43/step-43.cc b/examples/step-43/step-43.cc index d97f6404e4..5bf087e247 100644 --- a/examples/step-43/step-43.cc +++ b/examples/step-43/step-43.cc @@ -624,7 +624,7 @@ namespace Step43 TwoPhaseFlowProblem::TwoPhaseFlowProblem (const unsigned int degree) : triangulation (Triangulation::maximum_smoothing), - + global_Omega_diameter (std::numeric_limits::quiet_NaN()), degree (degree), darcy_degree (degree), darcy_fe (FE_Q(darcy_degree+1), dim, @@ -645,6 +645,7 @@ namespace Step43 time_step (0), old_time_step (0), + timestep_number (0), viscosity (0.2), porosity (1.0), AOS_threshold (3.0), @@ -2197,7 +2198,6 @@ start_time_iteration: SaturationInitialValues(), old_saturation_solution); - timestep_number = 0; time_step = old_time_step = 0; current_macro_time_step = old_macro_time_step = 0;