Skip to content

Commit

Permalink
Refactor calculations and output
Browse files Browse the repository at this point in the history
  • Loading branch information
oguevremont committed Aug 5, 2024
1 parent aefae8f commit 9d076f6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
11 changes: 9 additions & 2 deletions include/solvers/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,20 @@ class Tracer : public AuxiliaryPhysics<dim, GlobalVectorType>
* @param current_solution_fd current solution for the fluid dynamics, parsed
* by postprocess
*
* @return values of the tracer flow rate at each boundary
*
* @tparam GlobalVectorType The type of the global vector used for the tracer physic
*/

template <typename GlobalVectorType>
void
std::vector<double>
postprocess_tracer_flow_rate(const GlobalVectorType &current_solution_fd);

/**
* @brief Writes the tracer flow rates to an output file
*/
void
write_tracer_flow_rates(const std::vector<double> tracer_flow_rate_vector);

/**
* @brief Writes the tracer statistics to an output file
*/
Expand Down
33 changes: 23 additions & 10 deletions source/solvers/tracer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -429,13 +429,6 @@ Tracer<dim>::postprocess(bool first_iteration)
0)
this->write_tracer_statistics();
}
if (this->simulation_parameters.timer.type ==
Parameters::Timer::Type::iteration)
{
announce_string(this->pcout, "Tracer");
this->computing_timer.print_summary();
this->computing_timer.reset();
}

// Calculate tracer flow rate at every boundary
if (this->simulation_parameters.post_processing.calculate_tracer_flow_rate)
Expand All @@ -448,16 +441,27 @@ Tracer<dim>::postprocess(bool first_iteration)
announce_string(this->pcout, "Tracer flow rates");
}

std::vector<double> tracer_flow_rates(
this->simulation_parameters.boundary_conditions.size);
if (multiphysics->fluid_dynamics_is_block())
{
postprocess_tracer_flow_rate(
tracer_flow_rates = postprocess_tracer_flow_rate(
*multiphysics->get_block_solution(PhysicsID::fluid_dynamics));
}
else
{
postprocess_tracer_flow_rate(
tracer_flow_rates = postprocess_tracer_flow_rate(
*multiphysics->get_solution(PhysicsID::fluid_dynamics));
}
this->write_tracer_flow_rates(tracer_flow_rates);
}

if (this->simulation_parameters.timer.type ==
Parameters::Timer::Type::iteration)
{
announce_string(this->pcout, "Tracer");
this->computing_timer.print_summary();
this->computing_timer.reset();
}
}

Expand Down Expand Up @@ -556,7 +560,7 @@ Tracer<dim>::calculate_tracer_statistics()

template <int dim>
template <typename VectorType>
void
std::vector<double>
Tracer<dim>::postprocess_tracer_flow_rate(const VectorType &current_solution_fd)
{
const unsigned int n_q_points_face = this->face_quadrature->size();
Expand Down Expand Up @@ -684,6 +688,14 @@ Tracer<dim>::postprocess_tracer_flow_rate(const VectorType &current_solution_fd)
tracer_flow_rate_vector[i_bc] =
Utilities::MPI::sum(tracer_flow_rate_vector[i_bc], mpi_communicator);

return tracer_flow_rate_vector;
}

template <int dim>
void
Tracer<dim>::write_tracer_flow_rates(
const std::vector<double> tracer_flow_rate_vector)
{
// Fill table
this->tracer_flow_rate_table.add_value(
"time", this->simulation_control->get_current_time());
Expand Down Expand Up @@ -712,6 +724,7 @@ Tracer<dim>::postprocess_tracer_flow_rate(const VectorType &current_solution_fd)
<< tracer_flow_rate_vector[i_bc] << std::endl;
}

auto mpi_communicator = triangulation->get_communicator();
if ((simulation_control->get_step_number() %
this->simulation_parameters.post_processing.output_frequency ==
0) &&
Expand Down

0 comments on commit 9d076f6

Please sign in to comment.