diff --git a/include/solvers/heat_transfer.h b/include/solvers/heat_transfer.h index 131b971116..39f8f02bd6 100644 --- a/include/solvers/heat_transfer.h +++ b/include/solvers/heat_transfer.h @@ -12,8 +12,8 @@ #include #include #include -#include #include +#include #include #include @@ -131,9 +131,11 @@ class HeatTransfer : public AuxiliaryPhysics if (simulation_parameters.timer.type == Parameters::Timer::Type::none) this->computing_timer.disable_output(); - if (simulation_parameters.post_processing.calculate_average_temp_and_hf){ - average_temperature = std::make_shared>(this->dof_handler); - } + if (simulation_parameters.post_processing.calculate_average_temp_and_hf) + { + average_temperature = + std::make_shared>(this->dof_handler); + } } /** @@ -801,7 +803,7 @@ class HeatTransfer : public AuxiliaryPhysics std::shared_ptr> average_temperature; /** - * @brief Locally owned average temperature calculated using the AverageScalarInTime object. + * @brief Locally owned average temperature calculated using the AverageScalarInTime object. */ GlobalVectorType average_temperature_to_output; diff --git a/include/solvers/navier_stokes_base.h b/include/solvers/navier_stokes_base.h index 7236ed19f4..6b1c6fd9bb 100644 --- a/include/solvers/navier_stokes_base.h +++ b/include/solvers/navier_stokes_base.h @@ -15,8 +15,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/include/solvers/postprocessing_scalar.h b/include/solvers/postprocessing_scalar.h index 21c98a1f3b..c99c44fb9e 100644 --- a/include/solvers/postprocessing_scalar.h +++ b/include/solvers/postprocessing_scalar.h @@ -31,170 +31,170 @@ using namespace dealii; template class AverageScalarInTime { - public: - /** - * @brief Constructor that initializes the solution transfer objects for the scalar field. - * - * @param[in] dof_handler Used to initialize the solution transfer objects. - */ - AverageScalarInTime(DoFHandler &dof_handler); - - - /** - * @brief Calculate time-averaged scalar field using vector with no ghost - * cells. - * - * @param[in] local_evaluation_point The solution vector with no ghost cells. - * - * @param[in] post_processing The postprocessing parameters to definie initial - * - * @param[in] current_time The current time. - * - * @param[in] time_step The time step. - */ - void - calculate_average_scalar(const GlobalVectorType &local_evaluation_point, - const Parameters::PostProcessing &post_processing, - const double current_time, - const double time_step); - - void - initialize_vectors(const IndexSet &locally_owned_dofs, - const IndexSet &locally_relevant_dofs, - const MPI_Comm &mpi_communicator); - - /** - * @brief Use the inverse of the time since the beginning of the time averaging to reevaluate the average scalar field. - * - */ - GlobalVectorType - get_average_scalar() - { - return average_scalar; - } - - /** - * @brief Prepare average velocity object for dynamic mesh adaptation. - */ - void - update_average_scalar(); - - /** - * @brief Prepare average velocity object for dynamic mesh adaptation. - */ - void - prepare_for_mesh_adaptation(); - - /** - * @brief Reestablish solution vectors after dynamic mesh adaptation. - */ - void - post_mesh_adaptation(); - - /** - * @brief Save checkpoints to continuing averaging after restart. - * - * @param[in] prefix Name for checkpointing files. - * - * @return Vector with average values. - */ - std::vector - save(const std::string &prefix); - - /** - * @brief Read checkpoints to continuing averaging after restart. - * - * @param[in] prefix Name for checkpoint files. - * - * @return Vector with average values. - */ - std::vector - read(const std::string &prefix); - - - /** - * @brief Sanitize the average scalar object after a checkpoint has been read by - * resetting all of the locally_owned vectors using the locally_relevant - * vectors. This is necessary because only the locally_relevant_vectors are - * saved, but the calculation routines expect that the content of the - * locally_owned vectors match that of the locally_relevant vectors. - */ - void - sanitize_after_restart() - { - sum_scalar_dt = sum_scalar_dt_with_ghost_cells; - } - - private: - /** - * @brief Vector to store the scalar field multiplied by time step. - * - */ - GlobalVectorType scalar_dt; - - /** - * @brief Ghosted vector to store the sum of all the scalar multiplied by time step. - * - */ - GlobalVectorType sum_scalar_dt_with_ghost_cells; - - /** - * @brief Vector to store the sum of all the scalar multiplied by time step. - * - */ - GlobalVectorType sum_scalar_dt; - - /** - * @brief Object to transfer the averaged scalar in case of mesh adaptation. - * - */ - parallel::distributed::SolutionTransfer solution_transfer_sum_scalar_dt; - - /** - * @brief Time averaged scalar. - */ - GlobalVectorType average_scalar; - - /** - * @brief Time averaged scalar containing the locally owned and locally relevant dofs for all processes. - */ - GlobalVectorType average_scalar_with_ghost_cells; - - /** - * @brief Difference between the simulation starting time and the initial averaging time. - */ - double real_initial_time; - - /** - * @brief Vector to store the sum of all the scalar field multiplied by time step. - * - */ - double total_time_for_average; - - /** - * @brief Time step. - * - */ - double dt; - - /** - * @brief First time step is stored in dt_0 and added to total_time_for_average to ensure the first average calculation does not result in a division by zero. - * - */ - double dt_0; - - /** - * @brief Inverse of the total time for averaging. - * - */ - double inv_range_time; - - /** - * @brief Track whether we are within the averaging time period. - * - */ - bool average_calculation; - +public: + /** + * @brief Constructor that initializes the solution transfer objects for the scalar field. + * + * @param[in] dof_handler Used to initialize the solution transfer objects. + */ + AverageScalarInTime(DoFHandler &dof_handler); + + + /** + * @brief Calculate time-averaged scalar field using vector with no ghost + * cells. + * + * @param[in] local_evaluation_point The solution vector with no ghost cells. + * + * @param[in] post_processing The postprocessing parameters to definie initial + * + * @param[in] current_time The current time. + * + * @param[in] time_step The time step. + */ + void + calculate_average_scalar(const GlobalVectorType &local_evaluation_point, + const Parameters::PostProcessing &post_processing, + const double current_time, + const double time_step); + + void + initialize_vectors(const IndexSet &locally_owned_dofs, + const IndexSet &locally_relevant_dofs, + const MPI_Comm &mpi_communicator); + + /** + * @brief Use the inverse of the time since the beginning of the time averaging to reevaluate the average scalar field. + * + */ + GlobalVectorType + get_average_scalar() + { + return average_scalar; + } + + /** + * @brief Prepare average velocity object for dynamic mesh adaptation. + */ + void + update_average_scalar(); + + /** + * @brief Prepare average velocity object for dynamic mesh adaptation. + */ + void + prepare_for_mesh_adaptation(); + + /** + * @brief Reestablish solution vectors after dynamic mesh adaptation. + */ + void + post_mesh_adaptation(); + + /** + * @brief Save checkpoints to continuing averaging after restart. + * + * @param[in] prefix Name for checkpointing files. + * + * @return Vector with average values. + */ + std::vector + save(const std::string &prefix); + + /** + * @brief Read checkpoints to continuing averaging after restart. + * + * @param[in] prefix Name for checkpoint files. + * + * @return Vector with average values. + */ + std::vector + read(const std::string &prefix); + + + /** + * @brief Sanitize the average scalar object after a checkpoint has been read by + * resetting all of the locally_owned vectors using the locally_relevant + * vectors. This is necessary because only the locally_relevant_vectors are + * saved, but the calculation routines expect that the content of the + * locally_owned vectors match that of the locally_relevant vectors. + */ + void + sanitize_after_restart() + { + sum_scalar_dt = sum_scalar_dt_with_ghost_cells; + } + +private: + /** + * @brief Vector to store the scalar field multiplied by time step. + * + */ + GlobalVectorType scalar_dt; + + /** + * @brief Ghosted vector to store the sum of all the scalar multiplied by time step. + * + */ + GlobalVectorType sum_scalar_dt_with_ghost_cells; + + /** + * @brief Vector to store the sum of all the scalar multiplied by time step. + * + */ + GlobalVectorType sum_scalar_dt; + + /** + * @brief Object to transfer the averaged scalar in case of mesh adaptation. + * + */ + parallel::distributed::SolutionTransfer + solution_transfer_sum_scalar_dt; + + /** + * @brief Time averaged scalar. + */ + GlobalVectorType average_scalar; + + /** + * @brief Time averaged scalar containing the locally owned and locally relevant dofs for all processes. + */ + GlobalVectorType average_scalar_with_ghost_cells; + + /** + * @brief Difference between the simulation starting time and the initial averaging time. + */ + double real_initial_time; + + /** + * @brief Vector to store the sum of all the scalar field multiplied by time step. + * + */ + double total_time_for_average; + + /** + * @brief Time step. + * + */ + double dt; + + /** + * @brief First time step is stored in dt_0 and added to total_time_for_average to ensure the first average calculation does not result in a division by zero. + * + */ + double dt_0; + + /** + * @brief Inverse of the total time for averaging. + * + */ + double inv_range_time; + + /** + * @brief Track whether we are within the averaging time period. + * + */ + bool average_calculation; }; -#endif \ No newline at end of file +#endif diff --git a/include/solvers/tracer.h b/include/solvers/tracer.h index 7ead7c7654..022b16e050 100644 --- a/include/solvers/tracer.h +++ b/include/solvers/tracer.h @@ -484,7 +484,8 @@ class Tracer : public AuxiliaryPhysics Parameters::InitialConditionType::average_velocity_profile && !this->simulation_parameters.multiphysics.fluid_dynamics && simulation_control->get_current_time() > - this->simulation_parameters.post_processing.initial_time_for_average_velocities) + this->simulation_parameters.post_processing + .initial_time_for_average_velocities) { scratch_data.reinit_face_velocity( velocity_cell, @@ -512,7 +513,8 @@ class Tracer : public AuxiliaryPhysics Parameters::InitialConditionType::average_velocity_profile && !this->simulation_parameters.multiphysics.fluid_dynamics && simulation_control->get_current_time() > - this->simulation_parameters.post_processing.initial_time_for_average_velocities) + this->simulation_parameters.post_processing + .initial_time_for_average_velocities) { scratch_data.reinit_face_velocity( velocity_cell, diff --git a/source/core/parameters.cc b/source/core/parameters.cc index 0d69d2f272..5e6de8aa26 100644 --- a/source/core/parameters.cc +++ b/source/core/parameters.cc @@ -1843,10 +1843,11 @@ namespace Parameters Patterns::Bool(), "Enable calculation of average velocities."); - prm.declare_entry("calculate average temperature and average heat flux", - "false", - Patterns::Bool(), - "Enable calculation of time average temperature and time average heat flux"); + prm.declare_entry( + "calculate average temperature and average heat flux", + "false", + Patterns::Bool(), + "Enable calculation of time average temperature and time average heat flux"); prm.declare_entry( "calculate pressure drop", @@ -2077,20 +2078,23 @@ namespace Parameters prm.get_bool("calculate apparent viscosity"); calculate_average_velocities = prm.get_bool("calculate average velocities"); - calculate_average_temp_and_hf = prm.get_bool("calculate average temperature and average heat flux"); - calculate_pressure_drop = prm.get_bool("calculate pressure drop"); - inlet_boundary_id = prm.get_integer("inlet boundary id"); - outlet_boundary_id = prm.get_integer("outlet boundary id"); - calculate_flow_rate = prm.get_bool("calculate flow rate"); - calculate_tracer_flow_rate = prm.get_bool("calculate tracer flow rate"); - initial_time_for_average_velocities = prm.get_double("initial time for average velocity"); - initial_time_for_average_temp_and_hf = prm.get_double("initial time for average temperature and average heat flux"); - kinetic_energy_output_name = prm.get("kinetic energy name"); - pressure_drop_output_name = prm.get("pressure drop name"); - flow_rate_output_name = prm.get("flow rate name"); - tracer_flow_rate_output_name = prm.get("tracer flow rate name"); - enstrophy_output_name = prm.get("enstrophy name"); - pressure_power_output_name = prm.get("pressure power name"); + calculate_average_temp_and_hf = + prm.get_bool("calculate average temperature and average heat flux"); + calculate_pressure_drop = prm.get_bool("calculate pressure drop"); + inlet_boundary_id = prm.get_integer("inlet boundary id"); + outlet_boundary_id = prm.get_integer("outlet boundary id"); + calculate_flow_rate = prm.get_bool("calculate flow rate"); + calculate_tracer_flow_rate = prm.get_bool("calculate tracer flow rate"); + initial_time_for_average_velocities = + prm.get_double("initial time for average velocity"); + initial_time_for_average_temp_and_hf = prm.get_double( + "initial time for average temperature and average heat flux"); + kinetic_energy_output_name = prm.get("kinetic energy name"); + pressure_drop_output_name = prm.get("pressure drop name"); + flow_rate_output_name = prm.get("flow rate name"); + tracer_flow_rate_output_name = prm.get("tracer flow rate name"); + enstrophy_output_name = prm.get("enstrophy name"); + pressure_power_output_name = prm.get("pressure power name"); viscous_dissipation_output_name = prm.get("viscous dissipation name"); apparent_viscosity_output_name = prm.get("apparent viscosity name"); output_frequency = prm.get_integer("output frequency"); diff --git a/source/solvers/cahn_hilliard.cc b/source/solvers/cahn_hilliard.cc index f56844263e..16a8eead7c 100644 --- a/source/solvers/cahn_hilliard.cc +++ b/source/solvers/cahn_hilliard.cc @@ -732,7 +732,8 @@ CahnHilliard::postprocess(bool first_iteration) Parameters::InitialConditionType::average_velocity_profile && !this->simulation_parameters.multiphysics.fluid_dynamics && simulation_control->get_current_time() > - this->simulation_parameters.post_processing.initial_time_for_average_velocities) + this->simulation_parameters.post_processing + .initial_time_for_average_velocities) { position_and_velocity = calculate_barycenter( this->present_solution, @@ -755,7 +756,8 @@ CahnHilliard::postprocess(bool first_iteration) Parameters::InitialConditionType::average_velocity_profile && !this->simulation_parameters.multiphysics.fluid_dynamics && simulation_control->get_current_time() > - this->simulation_parameters.post_processing.initial_time_for_average_velocities) + this->simulation_parameters.post_processing + .initial_time_for_average_velocities) { position_and_velocity = calculate_barycenter(this->present_solution, diff --git a/source/solvers/heat_transfer.cc b/source/solvers/heat_transfer.cc index c5ea1d6d01..02b12059e5 100644 --- a/source/solvers/heat_transfer.cc +++ b/source/solvers/heat_transfer.cc @@ -482,7 +482,8 @@ HeatTransfer::assemble_local_system_matrix( Parameters::InitialConditionType::average_velocity_profile && !this->simulation_parameters.multiphysics.fluid_dynamics && simulation_control->get_current_time() > - this->simulation_parameters.post_processing.initial_time_for_average_velocities) + this->simulation_parameters.post_processing + .initial_time_for_average_velocities) { scratch_data.reinit_fluid_dynamics( fd_cell, @@ -507,7 +508,8 @@ HeatTransfer::assemble_local_system_matrix( Parameters::InitialConditionType::average_velocity_profile && !this->simulation_parameters.multiphysics.fluid_dynamics && simulation_control->get_current_time() > - this->simulation_parameters.post_processing.initial_time_for_average_velocities) + this->simulation_parameters.post_processing + .initial_time_for_average_velocities) { scratch_data.reinit_fluid_dynamics( fd_cell, @@ -649,7 +651,8 @@ HeatTransfer::assemble_local_system_rhs( Parameters::InitialConditionType::average_velocity_profile && !this->simulation_parameters.multiphysics.fluid_dynamics && simulation_control->get_current_time() > - this->simulation_parameters.post_processing.initial_time_for_average_velocities) + this->simulation_parameters.post_processing + .initial_time_for_average_velocities) { scratch_data.reinit_fluid_dynamics( fd_cell, @@ -675,7 +678,8 @@ HeatTransfer::assemble_local_system_rhs( Parameters::InitialConditionType::average_velocity_profile && !this->simulation_parameters.multiphysics.fluid_dynamics && simulation_control->get_current_time() > - this->simulation_parameters.post_processing.initial_time_for_average_velocities) + this->simulation_parameters.post_processing + .initial_time_for_average_velocities) { scratch_data.reinit_fluid_dynamics( fd_cell, @@ -786,55 +790,59 @@ HeatTransfer::attach_solution_to_output(DataOut &data_out) // Add the average heat flux // Ouput the time average temperature - if (simulation_parameters.post_processing.calculate_average_temp_and_hf && this->simulation_control->get_current_time() > simulation_parameters.post_processing.initial_time_for_average_temp_and_hf + 1e-12) - { - this->average_temperature->calculate_average_scalar( - this->present_solution, - this->simulation_parameters.post_processing, - simulation_control->get_current_time(), - simulation_control->get_time_step()); - this->average_temperature_to_output = this -> average_temperature -> get_average_scalar(); - data_out.add_data_vector(dof_handler, this->average_temperature_to_output, "temperature_average"); - - // Output the time average heat flux - average_heat_flux_postprocessors.clear(); - average_heat_flux_postprocessors.reserve(n_fluids + n_solids); - - // Heat fluxes in fluids - for (unsigned int f_id = 0; f_id < n_fluids; ++f_id) - { - average_heat_flux_postprocessors.emplace_back( - HeatFluxPostprocessor(thermal_conductivity_models[f_id], - "average_f", - f_id, - mesh_m_id, - solid_phase_present)); - - // Also add the time average heat flux - data_out.add_data_vector(this->dof_handler, - this->average_temperature_to_output, - average_heat_flux_postprocessors[f_id]); - } - // Heat fluxes in solids - for (unsigned int m_id = n_fluids; m_id < n_fluids + n_solids; ++m_id) - { - mesh_m_id += 1; - average_heat_flux_postprocessors.emplace_back( - HeatFluxPostprocessor(thermal_conductivity_models[m_id], - "average_s", - m_id - n_fluids, - mesh_m_id, - solid_phase_present)); - - // Also add the time average heat flux - data_out.add_data_vector(this->dof_handler, - this->average_temperature_to_output, - average_heat_flux_postprocessors[m_id]); - } - } - - - + if (simulation_parameters.post_processing.calculate_average_temp_and_hf && + this->simulation_control->get_current_time() > + simulation_parameters.post_processing + .initial_time_for_average_temp_and_hf + + 1e-12) + { + this->average_temperature->calculate_average_scalar( + this->present_solution, + this->simulation_parameters.post_processing, + simulation_control->get_current_time(), + simulation_control->get_time_step()); + this->average_temperature_to_output = + this->average_temperature->get_average_scalar(); + data_out.add_data_vector(dof_handler, + this->average_temperature_to_output, + "temperature_average"); + + // Output the time average heat flux + average_heat_flux_postprocessors.clear(); + average_heat_flux_postprocessors.reserve(n_fluids + n_solids); + + // Heat fluxes in fluids + for (unsigned int f_id = 0; f_id < n_fluids; ++f_id) + { + average_heat_flux_postprocessors.emplace_back( + HeatFluxPostprocessor(thermal_conductivity_models[f_id], + "average_f", + f_id, + mesh_m_id, + solid_phase_present)); + + // Also add the time average heat flux + data_out.add_data_vector(this->dof_handler, + this->average_temperature_to_output, + average_heat_flux_postprocessors[f_id]); + } + // Heat fluxes in solids + for (unsigned int m_id = n_fluids; m_id < n_fluids + n_solids; ++m_id) + { + mesh_m_id += 1; + average_heat_flux_postprocessors.emplace_back( + HeatFluxPostprocessor(thermal_conductivity_models[m_id], + "average_s", + m_id - n_fluids, + mesh_m_id, + solid_phase_present)); + + // Also add the time average heat flux + data_out.add_data_vector(this->dof_handler, + this->average_temperature_to_output, + average_heat_flux_postprocessors[m_id]); + } + } } template @@ -1086,7 +1094,7 @@ HeatTransfer::pre_mesh_adaptation() } if (simulation_parameters.post_processing.calculate_average_temp_and_hf) - this -> average_temperature->prepare_for_mesh_adaptation(); + this->average_temperature->prepare_for_mesh_adaptation(); } template @@ -1117,9 +1125,9 @@ HeatTransfer::post_mesh_adaptation() nonzero_constraints.distribute(tmp_previous_solution); previous_solutions[i] = tmp_previous_solution; } - + if (simulation_parameters.post_processing.calculate_average_temp_and_hf) - this -> average_temperature -> post_mesh_adaptation(); + this->average_temperature->post_mesh_adaptation(); } template @@ -1160,7 +1168,7 @@ HeatTransfer::write_checkpoint() sol_set_transfer.emplace_back(&previous_solution); } - std::string checkpoint_file_prefix = + std::string checkpoint_file_prefix = this->simulation_parameters.simulation_control.output_folder + this->simulation_parameters.restart_parameters.filename; @@ -1171,7 +1179,7 @@ HeatTransfer::write_checkpoint() sol_set_transfer.insert(sol_set_transfer.end(), avg_scalar_set_transfer.begin(), - avg_scalar_set_transfer.end()); + avg_scalar_set_transfer.end()); } solution_transfer->prepare_for_serialization(sol_set_transfer); @@ -1228,9 +1236,10 @@ HeatTransfer::read_checkpoint() input_vectors[i + 1] = &distributed_previous_solutions[i]; } - parallel::distributed::SolutionTransfer system_trans_vectors(this->dof_handler); + parallel::distributed::SolutionTransfer + system_trans_vectors(this->dof_handler); - std::string checkpoint_file_prefix = + std::string checkpoint_file_prefix = this->simulation_parameters.simulation_control.output_folder + this->simulation_parameters.restart_parameters.filename; @@ -1240,13 +1249,15 @@ HeatTransfer::read_checkpoint() std::vector sum_vectors = this->average_temperature->read(checkpoint_file_prefix); - input_vectors.insert(input_vectors.end(), sum_vectors.begin(), sum_vectors.end()); + input_vectors.insert(input_vectors.end(), + sum_vectors.begin(), + sum_vectors.end()); } solution_transfer->deserialize(input_vectors); if (simulation_parameters.post_processing.calculate_average_temp_and_hf) - this->average_temperature->sanitize_after_restart(); + this->average_temperature->sanitize_after_restart(); present_solution = distributed_system; for (unsigned int i = 0; i < previous_solutions.size(); ++i) @@ -1340,9 +1351,10 @@ HeatTransfer::setup_dofs() } } // Initialize the vectors used in the time average temperature calculation - if (this->simulation_parameters.post_processing.calculate_average_temp_and_hf) + if (this->simulation_parameters.post_processing + .calculate_average_temp_and_hf) { - this -> average_temperature -> initialize_vectors( + this->average_temperature->initialize_vectors( this->locally_owned_dofs, this->locally_relevant_dofs, mpi_communicator); diff --git a/source/solvers/navier_stokes_base.cc b/source/solvers/navier_stokes_base.cc index 11a7a7a3e5..26c8a7a750 100644 --- a/source/solvers/navier_stokes_base.cc +++ b/source/solvers/navier_stokes_base.cc @@ -12,8 +12,8 @@ #include #include #include -#include #include +#include #include #include @@ -905,7 +905,6 @@ NavierStokesBase::box_refine_mesh(const bool restart) if (this->simulation_parameters.post_processing .calculate_average_velocities) average_velocities->post_mesh_adaptation(); - } } @@ -1382,7 +1381,9 @@ NavierStokesBase::postprocess_fd(bool firstIter) // time >= initial time with the epsilon as tolerance. const double dt = simulation_control->get_time_step(); if (simulation_control->get_current_time() > - (simulation_parameters.post_processing.initial_time_for_average_velocities - 1e-6 * dt)) + (simulation_parameters.post_processing + .initial_time_for_average_velocities - + 1e-6 * dt)) { this->average_velocities->calculate_average_velocities( this->local_evaluation_point, diff --git a/source/solvers/postprocessing_scalar.cc b/source/solvers/postprocessing_scalar.cc index e402bc3b01..31dc2b2ec6 100644 --- a/source/solvers/postprocessing_scalar.cc +++ b/source/solvers/postprocessing_scalar.cc @@ -8,8 +8,7 @@ #include template -AverageScalarInTime::AverageScalarInTime( - DoFHandler &dof_handler) +AverageScalarInTime::AverageScalarInTime(DoFHandler &dof_handler) : solution_transfer_sum_scalar_dt(dof_handler) , total_time_for_average(0.0) , average_calculation(false) @@ -23,9 +22,10 @@ AverageScalarInTime::calculate_average_scalar( const double current_time, const double time_step) { - const double epsilon = 1e-6; - const double initial_time = post_processing.initial_time_for_average_temp_and_hf; - dt = time_step; + const double epsilon = 1e-6; + const double initial_time = + post_processing.initial_time_for_average_temp_and_hf; + dt = time_step; // When averaging velocities begins if (current_time >= (initial_time - epsilon) && !average_calculation) @@ -48,15 +48,14 @@ AverageScalarInTime::calculate_average_scalar( // Calculate the average velocities. average_scalar.equ(inv_range_time, sum_scalar_dt); - } template void AverageScalarInTime::initialize_vectors( - const IndexSet &locally_owned_dofs, - const IndexSet &locally_relevant_dofs, - const MPI_Comm &mpi_communicator) + const IndexSet &locally_owned_dofs, + const IndexSet &locally_relevant_dofs, + const MPI_Comm &mpi_communicator) { // Reinitialisation of the average velocity and reynolds stress vectors // to get the right length. @@ -93,7 +92,8 @@ void AverageScalarInTime::prepare_for_mesh_adaptation() { sum_scalar_dt_with_ghost_cells = sum_scalar_dt; - solution_transfer_sum_scalar_dt.prepare_for_coarsening_and_refinement(sum_scalar_dt_with_ghost_cells); + solution_transfer_sum_scalar_dt.prepare_for_coarsening_and_refinement( + sum_scalar_dt_with_ghost_cells); } template @@ -147,4 +147,4 @@ AverageScalarInTime::read(const std::string &prefix) } template class AverageScalarInTime<2>; -template class AverageScalarInTime<3>; \ No newline at end of file +template class AverageScalarInTime<3>; diff --git a/source/solvers/postprocessing_velocities.cc b/source/solvers/postprocessing_velocities.cc index 4d4682fed7..a44b1e480a 100644 --- a/source/solvers/postprocessing_velocities.cc +++ b/source/solvers/postprocessing_velocities.cc @@ -25,9 +25,10 @@ AverageVelocities::calculate_average_velocities( const double ¤t_time, const double &time_step) { - const double epsilon = 1e-6; - const double initial_time = post_processing.initial_time_for_average_velocities; - dt = time_step; + const double epsilon = 1e-6; + const double initial_time = + post_processing.initial_time_for_average_velocities; + dt = time_step; // When averaging velocities begins if (current_time >= (initial_time - epsilon) && !average_calculation) diff --git a/source/solvers/tracer.cc b/source/solvers/tracer.cc index e70be5e4e9..2ec04b8f4a 100644 --- a/source/solvers/tracer.cc +++ b/source/solvers/tracer.cc @@ -277,7 +277,8 @@ Tracer::assemble_local_system_matrix( Parameters::InitialConditionType::average_velocity_profile && !this->simulation_parameters.multiphysics.fluid_dynamics && simulation_control->get_current_time() > - this->simulation_parameters.post_processing.initial_time_for_average_velocities) + this->simulation_parameters.post_processing + .initial_time_for_average_velocities) { scratch_data.reinit_velocity( velocity_cell, @@ -303,7 +304,8 @@ Tracer::assemble_local_system_matrix( Parameters::InitialConditionType::average_velocity_profile && !this->simulation_parameters.multiphysics.fluid_dynamics && simulation_control->get_current_time() > - this->simulation_parameters.post_processing.initial_time_for_average_velocities) + this->simulation_parameters.post_processing + .initial_time_for_average_velocities) { scratch_data.reinit_velocity( velocity_cell, @@ -562,7 +564,8 @@ Tracer::assemble_local_system_rhs( Parameters::InitialConditionType::average_velocity_profile && !this->simulation_parameters.multiphysics.fluid_dynamics && simulation_control->get_current_time() > - this->simulation_parameters.post_processing.initial_time_for_average_velocities) + this->simulation_parameters.post_processing + .initial_time_for_average_velocities) { scratch_data.reinit_velocity( velocity_cell, @@ -588,7 +591,8 @@ Tracer::assemble_local_system_rhs( Parameters::InitialConditionType::average_velocity_profile && !this->simulation_parameters.multiphysics.fluid_dynamics && simulation_control->get_current_time() > - this->simulation_parameters.post_processing.initial_time_for_average_velocities) + this->simulation_parameters.post_processing + .initial_time_for_average_velocities) { scratch_data.reinit_velocity( velocity_cell, diff --git a/source/solvers/vof.cc b/source/solvers/vof.cc index 9cacfd365c..c607942545 100644 --- a/source/solvers/vof.cc +++ b/source/solvers/vof.cc @@ -114,7 +114,8 @@ VolumeOfFluid::assemble_local_system_matrix( Parameters::InitialConditionType::average_velocity_profile && !this->simulation_parameters.multiphysics.fluid_dynamics && simulation_control->get_current_time() > - this->simulation_parameters.post_processing.initial_time_for_average_velocities) + this->simulation_parameters.post_processing + .initial_time_for_average_velocities) { scratch_data.reinit_velocity( velocity_cell, @@ -142,7 +143,8 @@ VolumeOfFluid::assemble_local_system_matrix( Parameters::InitialConditionType::average_velocity_profile && !this->simulation_parameters.multiphysics.fluid_dynamics && simulation_control->get_current_time() > - this->simulation_parameters.post_processing.initial_time_for_average_velocities) + this->simulation_parameters.post_processing + .initial_time_for_average_velocities) { scratch_data.reinit_velocity( velocity_cell, @@ -244,7 +246,8 @@ VolumeOfFluid::assemble_local_system_rhs( Parameters::InitialConditionType::average_velocity_profile && !this->simulation_parameters.multiphysics.fluid_dynamics && simulation_control->get_current_time() > - this->simulation_parameters.post_processing.initial_time_for_average_velocities) + this->simulation_parameters.post_processing + .initial_time_for_average_velocities) { scratch_data.reinit_velocity( velocity_cell, @@ -272,7 +275,8 @@ VolumeOfFluid::assemble_local_system_rhs( Parameters::InitialConditionType::average_velocity_profile && !this->simulation_parameters.multiphysics.fluid_dynamics && simulation_control->get_current_time() > - this->simulation_parameters.post_processing.initial_time_for_average_velocities) + this->simulation_parameters.post_processing + .initial_time_for_average_velocities) { scratch_data.reinit_velocity( velocity_cell, @@ -978,7 +982,8 @@ VolumeOfFluid::postprocess(bool first_iteration) Parameters::InitialConditionType::average_velocity_profile && !this->simulation_parameters.multiphysics.fluid_dynamics && simulation_control->get_current_time() > - this->simulation_parameters.post_processing.initial_time_for_average_velocities) + this->simulation_parameters.post_processing + .initial_time_for_average_velocities) { position_and_velocity = calculate_barycenter( this->present_solution, @@ -1001,7 +1006,8 @@ VolumeOfFluid::postprocess(bool first_iteration) Parameters::InitialConditionType::average_velocity_profile && !this->simulation_parameters.multiphysics.fluid_dynamics && simulation_control->get_current_time() > - this->simulation_parameters.post_processing.initial_time_for_average_velocities) + this->simulation_parameters.post_processing + .initial_time_for_average_velocities) { position_and_velocity = calculate_barycenter(this->present_solution, diff --git a/tests/solvers/average_scalar_01.cc b/tests/solvers/average_scalar_01.cc index c17123d55e..c39fcd4235 100644 --- a/tests/solvers/average_scalar_01.cc +++ b/tests/solvers/average_scalar_01.cc @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later /** - * @brief This test checks the AverageScalarInTime class in postprocessing_scalar.cc. It does so by averaging a solution in time. + * @brief This test checks the AverageScalarInTime class in postprocessing_scalar.cc. It does so by averaging a solution in time. */ // Deal.II includes @@ -30,7 +30,6 @@ void test() { - MPI_Comm mpi_communicator(MPI_COMM_WORLD); // Parameters @@ -75,10 +74,11 @@ test() GlobalVectorType average_solution; // Time info - const double time_end = simulation_control_parameters.time_end; - const double initial_time = postprocessing_parameters.initial_time_for_average_temp_and_hf; - double time = simulation_control->get_current_time(); - double epsilon = 1e-6; + const double time_end = simulation_control_parameters.time_end; + const double initial_time = + postprocessing_parameters.initial_time_for_average_temp_and_hf; + double time = simulation_control->get_current_time(); + double epsilon = 1e-6; // Initialize averaged vectors average.initialize_vectors(locally_owned_dofs, @@ -157,4 +157,4 @@ main(int argc, char **argv) } return 0; -} \ No newline at end of file +} diff --git a/tests/solvers/average_velocities_01.cc b/tests/solvers/average_velocities_01.cc index f215985627..1107da61fa 100644 --- a/tests/solvers/average_velocities_01.cc +++ b/tests/solvers/average_velocities_01.cc @@ -74,10 +74,11 @@ test() GlobalVectorType average_solution; // Time info - const double time_end = simulation_control_parameters.time_end; - const double initial_time = postprocessing_parameters.initial_time_for_average_velocities; - double time = simulation_control->get_current_time(); - double epsilon = 1e-6; + const double time_end = simulation_control_parameters.time_end; + const double initial_time = + postprocessing_parameters.initial_time_for_average_velocities; + double time = simulation_control->get_current_time(); + double epsilon = 1e-6; // Initialize averaged vectors average.initialize_vectors(locally_owned_dofs, diff --git a/tests/solvers/average_velocities_02.cc b/tests/solvers/average_velocities_02.cc index 29c31a6a0e..fe930db494 100644 --- a/tests/solvers/average_velocities_02.cc +++ b/tests/solvers/average_velocities_02.cc @@ -84,11 +84,12 @@ test() GlobalBlockVectorType average_solution(locally_owned_dofs, mpi_communicator); // Time and output info - const double time_end = simulation_control_parameters.time_end; - const double initial_time = postprocessing_parameters.initial_time_for_average_velocities; - double time = simulation_control->get_current_time(); - double dt = 0.0; - const double epsilon = 1e-6; + const double time_end = simulation_control_parameters.time_end; + const double initial_time = + postprocessing_parameters.initial_time_for_average_velocities; + double time = simulation_control->get_current_time(); + double dt = 0.0; + const double epsilon = 1e-6; // Initialize averaged vectors average.initialize_vectors(locally_owned_dofs, diff --git a/tests/solvers/average_velocities_03.cc b/tests/solvers/average_velocities_03.cc index f773bf3871..51146d13a1 100644 --- a/tests/solvers/average_velocities_03.cc +++ b/tests/solvers/average_velocities_03.cc @@ -79,10 +79,11 @@ test() // average_solution.update_ghost_values(); // Time and output info - const double time_end = simulation_control_parameters.time_end; - const double initial_time = postprocessing_parameters.initial_time_for_average_velocities; - double time = simulation_control->get_current_time(); - const double epsilon = 1e-6; + const double time_end = simulation_control_parameters.time_end; + const double initial_time = + postprocessing_parameters.initial_time_for_average_velocities; + double time = simulation_control->get_current_time(); + const double epsilon = 1e-6; // Initialize averaged vectors average.initialize_vectors(locally_owned_dofs, diff --git a/tests/solvers/reynolds_stress_01.cc b/tests/solvers/reynolds_stress_01.cc index 6cb2b2c1eb..af99436a1a 100644 --- a/tests/solvers/reynolds_stress_01.cc +++ b/tests/solvers/reynolds_stress_01.cc @@ -83,10 +83,11 @@ test() GlobalVectorType reynolds_shear_stresses; // Time info - const double time_end = simulation_control_parameters.time_end; - const double initial_time = postprocessing_parameters.initial_time_for_average_velocities; - double time = simulation_control->get_current_time(); - double epsilon = 1e-6; + const double time_end = simulation_control_parameters.time_end; + const double initial_time = + postprocessing_parameters.initial_time_for_average_velocities; + double time = simulation_control->get_current_time(); + double epsilon = 1e-6; // Initialize averaged vectors postprocessing_velocities.initialize_vectors(locally_owned_dofs, diff --git a/tests/solvers/reynolds_stress_02.cc b/tests/solvers/reynolds_stress_02.cc index 84c1c1346c..d0a1c930b7 100644 --- a/tests/solvers/reynolds_stress_02.cc +++ b/tests/solvers/reynolds_stress_02.cc @@ -92,11 +92,12 @@ test() GlobalBlockVectorType reynolds_shear_stresses; // Time info - const double time_end = simulation_control_parameters.time_end; - const double initial_time = postprocessing_parameters.initial_time_for_average_velocities; - double time = simulation_control->get_current_time(); - double dt = 0.0; - double epsilon = 1e-6; + const double time_end = simulation_control_parameters.time_end; + const double initial_time = + postprocessing_parameters.initial_time_for_average_velocities; + double time = simulation_control->get_current_time(); + double dt = 0.0; + double epsilon = 1e-6; // Initialize averaged vectors postprocessing_velocities.initialize_vectors(locally_owned_dofs, diff --git a/tests/solvers/reynolds_stress_03.cc b/tests/solvers/reynolds_stress_03.cc index f3945210ed..5855d45cc4 100644 --- a/tests/solvers/reynolds_stress_03.cc +++ b/tests/solvers/reynolds_stress_03.cc @@ -81,10 +81,11 @@ test() LinearAlgebra::distributed::Vector reynolds_shear_stresses; // Time info - const double time_end = simulation_control_parameters.time_end; - const double initial_time = postprocessing_parameters.initial_time_for_average_velocities; - double time = simulation_control->get_current_time(); - double epsilon = 1e-6; + const double time_end = simulation_control_parameters.time_end; + const double initial_time = + postprocessing_parameters.initial_time_for_average_velocities; + double time = simulation_control->get_current_time(); + double epsilon = 1e-6; // Initialize averaged vectors postprocessing_velocities.initialize_vectors(locally_owned_dofs,