Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
AverageScalar< dim > Class Template Reference

#include <postprocessing_scalar.h>

Public Member Functions

 AverageScalar (const DoFHandler< dim > &dof_handler)
void calculate_average_scalar (const GlobalVectorType &local_evaluation_point, const Parameters::PostProcessing< dim > &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)
GlobalVectorType get_average_scalar ()
void update_average_scalar ()
void prepare_for_mesh_adaptation ()
void post_mesh_adaptation ()
std::vector< const GlobalVectorType * > save (const std::string &prefix)
std::vector< GlobalVectorType * > read (const std::string &prefix)
void sanitize_after_restart ()
void zero_average_after_restart ()

Private Attributes

GlobalVectorType scalar_dt
GlobalVectorType sum_scalar_dt
GlobalVectorType sum_scalar_dt_with_ghost_cells
SolutionTransfer< dim, GlobalVectorType > solution_transfer_sum_scalar_dt
GlobalVectorType average_scalar
GlobalVectorType average_scalar_with_ghost_cells
double real_initial_time
double total_time_for_average
double dt
double dt_0
double inv_range_time
bool has_started_averaging

Detailed Description

template<int dim>
class AverageScalar< dim >

Calculates the time-averaged scalar field.

Template Parameters
dimAn integer that denotes the dimension of the space in which the flow is solved.
VectorTypeThe vector type used for the solvers (Trilinos (normal or block) or deal.II vectors).
DofsTypeThe type of storage of indices which differs according to vector.

Definition at line 27 of file postprocessing_scalar.h.

Constructor & Destructor Documentation

◆ AverageScalar()

template<int dim>
AverageScalar< dim >::AverageScalar ( const DoFHandler< dim > & dof_handler)

Constructor that initializes the solution transfer objects for the scalar field.

Parameters
[in]dof_handlerUsed to initialize the solution transfer objects. The solution transfer object is later used for mesh adaptation.

Definition at line 12 of file postprocessing_scalar.cc.

References has_started_averaging, solution_transfer_sum_scalar_dt, and total_time_for_average.

Member Function Documentation

◆ calculate_average_scalar()

template<int dim>
void AverageScalar< dim >::calculate_average_scalar ( const GlobalVectorType & local_evaluation_point,
const Parameters::PostProcessing< dim > & post_processing,
const double current_time,
const double time_step )

Calculate time-averaged scalar field using vector with no ghost cells.

Parameters
[in]local_evaluation_pointThe solution vector with no ghost cells.
[in]post_processingThe postprocessing parameters to get the initial time used for averaging.
[in]current_timeThe current time.
[in]time_stepThe time step.

Definition at line 20 of file postprocessing_scalar.cc.

References average_scalar, dt, dt_0, has_started_averaging, Parameters::PostProcessing< dim >::initial_time_for_average_temp_and_hf, inv_range_time, real_initial_time, scalar_dt, sum_scalar_dt, and total_time_for_average.

◆ get_average_scalar()

template<int dim>
GlobalVectorType AverageScalar< dim >::get_average_scalar ( )
inline

Getter for the average scalar.

Definition at line 81 of file postprocessing_scalar.h.

References average_scalar.

◆ initialize_vectors()

template<int dim>
void AverageScalar< dim >::initialize_vectors ( const IndexSet & locally_owned_dofs,
const IndexSet & locally_relevant_dofs,
const MPI_Comm & mpi_communicator )

Calculate time-averaged scalar field using vector with no ghost cells.

Parameters
[in]locally_owned_dofsDegrees of freedom owned by a single processor.
[in]locally_relevant_dofsDegrees of freedom that live on locally owned or ghost cells of a single processor.
[in]mpi_communicatorThe communicator information.

Definition at line 60 of file postprocessing_scalar.cc.

References average_scalar, average_scalar_with_ghost_cells, scalar_dt, sum_scalar_dt, and sum_scalar_dt_with_ghost_cells.

◆ post_mesh_adaptation()

template<int dim>
void AverageScalar< dim >::post_mesh_adaptation ( )

Reestablish solution vectors after dynamic mesh adaptation.

Definition at line 101 of file postprocessing_scalar.cc.

References solution_transfer_sum_scalar_dt, sum_scalar_dt, sum_scalar_dt_with_ghost_cells, and update_average_scalar().

◆ prepare_for_mesh_adaptation()

template<int dim>
void AverageScalar< dim >::prepare_for_mesh_adaptation ( )

Prepare average scalar object for dynamic mesh adaptation.

Definition at line 92 of file postprocessing_scalar.cc.

References solution_transfer_sum_scalar_dt, sum_scalar_dt, and sum_scalar_dt_with_ghost_cells.

◆ read()

template<int dim>
std::vector< GlobalVectorType * > AverageScalar< dim >::read ( const std::string & prefix)

Read checkpoints to continuing averaging after restart.

Parameters
[in]prefixName for checkpoint files.
Returns
Vector containing the average values.

Definition at line 132 of file postprocessing_scalar.cc.

References check_file_exists(), dt_0, has_started_averaging, real_initial_time, and sum_scalar_dt_with_ghost_cells.

◆ sanitize_after_restart()

template<int dim>
void AverageScalar< dim >::sanitize_after_restart ( )
inline

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.

Definition at line 133 of file postprocessing_scalar.h.

References sum_scalar_dt, and sum_scalar_dt_with_ghost_cells.

◆ save()

template<int dim>
std::vector< const GlobalVectorType * > AverageScalar< dim >::save ( const std::string & prefix)

Save checkpoints to continue the averaging after the restart.

Parameters
[in]prefixName for checkpointing files.
Returns
Vector containing the average values.

Definition at line 112 of file postprocessing_scalar.cc.

References dt_0, has_started_averaging, real_initial_time, sum_scalar_dt, and sum_scalar_dt_with_ghost_cells.

◆ update_average_scalar()

template<int dim>
void AverageScalar< dim >::update_average_scalar ( )

Prepare average scalar object for dynamic mesh adaptation.

Definition at line 80 of file postprocessing_scalar.cc.

References average_scalar, inv_range_time, sum_scalar_dt, and total_time_for_average.

◆ zero_average_after_restart()

template<int dim>
void AverageScalar< dim >::zero_average_after_restart ( )

Reinitialize the values of sum_scalar_dt_with_ghost_cells vector to 0 and the has_started_averaging flag to false. If the initial time for average temperature and heat flux parameter is greater than the simulation time, the checkpointed time-averaged heat flux is ignored after a restart. This allows users to restart a simulation with a different averaging start time.

Definition at line 154 of file postprocessing_scalar.cc.

References has_started_averaging, sum_scalar_dt, and sum_scalar_dt_with_ghost_cells.

Member Data Documentation

◆ average_scalar

template<int dim>
GlobalVectorType AverageScalar< dim >::average_scalar
private

Time averaged scalar.

Definition at line 172 of file postprocessing_scalar.h.

◆ average_scalar_with_ghost_cells

template<int dim>
GlobalVectorType AverageScalar< dim >::average_scalar_with_ghost_cells
private

Time averaged scalar containing the locally owned and locally relevant dofs for all processes.

Definition at line 177 of file postprocessing_scalar.h.

◆ dt

template<int dim>
double AverageScalar< dim >::dt
private

Time step.

Definition at line 194 of file postprocessing_scalar.h.

◆ dt_0

template<int dim>
double AverageScalar< dim >::dt_0
private

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.

Definition at line 200 of file postprocessing_scalar.h.

◆ has_started_averaging

template<int dim>
bool AverageScalar< dim >::has_started_averaging
private

Track whether we are within the averaging time period.

Definition at line 212 of file postprocessing_scalar.h.

◆ inv_range_time

template<int dim>
double AverageScalar< dim >::inv_range_time
private

Inverse of the total time for averaging.

Definition at line 206 of file postprocessing_scalar.h.

◆ real_initial_time

template<int dim>
double AverageScalar< dim >::real_initial_time
private

Difference between the simulation starting time and the initial averaging time.

Definition at line 182 of file postprocessing_scalar.h.

◆ scalar_dt

template<int dim>
GlobalVectorType AverageScalar< dim >::scalar_dt
private

Vector to store the scalar field multiplied by time step.

Definition at line 149 of file postprocessing_scalar.h.

◆ solution_transfer_sum_scalar_dt

template<int dim>
SolutionTransfer<dim, GlobalVectorType> AverageScalar< dim >::solution_transfer_sum_scalar_dt
private

Object to transfer the averaged scalar in case of mesh adaptation.

Definition at line 167 of file postprocessing_scalar.h.

◆ sum_scalar_dt

template<int dim>
GlobalVectorType AverageScalar< dim >::sum_scalar_dt
private

Vector to store the sum of all the scalar multiplied by time step.

Definition at line 155 of file postprocessing_scalar.h.

◆ sum_scalar_dt_with_ghost_cells

template<int dim>
GlobalVectorType AverageScalar< dim >::sum_scalar_dt_with_ghost_cells
private

Ghosted vector to store the sum of all the scalar multiplied by time step.

Definition at line 161 of file postprocessing_scalar.h.

◆ total_time_for_average

template<int dim>
double AverageScalar< dim >::total_time_for_average
private

Vector to store the sum of all the scalar field multiplied by time step.

Definition at line 188 of file postprocessing_scalar.h.


The documentation for this class was generated from the following files: