GEOS
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
geos::StatsAggregatorBase< Impl > Class Template Reference

Reponsible of computing physical statistics over the grid, registering the result in the data repository, but not storing / outputing it by itself. It does not have mutable state except the encountered issues. More...

#include <StatisticsAggregatorBase.hpp>

Classes

struct  DiscretizationGroupPath
 
struct  StatsState
 
struct  ViewKeys
 the associated view keys More...
 

Public Types

using SolverType = typename StatsAggregatorTraits< Impl >::SolverType
 
using StatsGroupType = typename StatsAggregatorTraits< Impl >::StatsGroupType
 
template<typename OwnerType >
using RegionStatsFunc = std::function< void(OwnerType &, StatsGroupType &) >
 Standard function signature for any functor that applies on statistics group instances (StatsGroupType) More...
 
using RegionStatsRegisterFunc = std::function< StatsGroupType &(dataRepository::Group &, string const &) >
 A functor that can be used to register a statistics Group instance. Parameters: More...
 

Public Member Functions

 StatsAggregatorBase (dataRepository::DataContext const &ownerDataContext, dataRepository::Group &meshBodies, bool statsOutputEnabled)
 Construct a new Stats Aggregator object. More...
 
void initStatisticsAggregation (SolverType &solver)
 Enable the computation of any statistics, initialize data structure to collect them. Register the resulting data wrappers so they will be targeted by TimeHistory output. More...
 
void forRegionStatistics (RegionStatsFunc< MeshLevel > const &functor) const
 
void forRegionStatistics (MeshLevel &mesh, StatsGroupType &meshRegionsStatistics, RegionStatsFunc< CellElementRegion > const &functor) const
 
void forRegionStatistics (CellElementRegion &region, StatsGroupType &regionStatistics, RegionStatsFunc< CellElementSubRegion > const &functor) const
 
bool isComputed (real64 const timeRequest, StatsGroupType const &stats)
 
void setDirty ()
 set the statistics as dirty, ensuring isComputed() will be false until the next computation.
 
bool computeRegionsStatistics (real64 const timeRequest)
 Compute statistics on the mesh discretizations (average field pressure, etc) Results are reduced on rank 0, and broadcasted over all ranks. More...
 
string const & getOwnerName () const
 
stdVector< string > const & getWarnings () const
 
dataRepository::GroupgetInstanceStatisticsGroup (MeshLevel &mesh) const
 
StatsGroupType & getRegionsStatistics (MeshLevel &mesh) const
 
StatsGroupType & getRegionStatistics (MeshLevel &mesh, string_view regionName) const
 

Protected Member Functions

void enableRegionStatisticsAggregation (RegionStatsRegisterFunc &&registerStatsFunc)
 Enable the computation of region statistics, initialize data structure to collect them. Register the resulting data wrappers so they will be targeted by TimeHistory output. More...
 
MeshLevelgetMeshLevel (DiscretizationGroupPath const &path) const
 
void initStats (StatsGroupType &stats, real64 time) const
 Initialize all statistics values to aggregable default values, before any computation / reduction for the current timestep. More...
 
void computeSubRegionRankStats (CellElementSubRegion &subRegion, StatsGroupType &subRegionStats) const
 Compute the rank-local stats for the given sub-region and store the results in the given stats group. More...
 
void aggregateStats (StatsGroupType &stats, StatsGroupType const &other) const
 Aggregate all instance statistics with those of another instance on the current rank. More...
 
void mpiAggregateStats (StatsGroupType &stats) const
 Aggregate all instance statistics with those of other ranks. More...
 
void postAggregateStats (StatsGroupType &stats)
 Do the final computations for the statistics. Must be called after computations & aggregations. More...
 

Protected Attributes

dataRepository::DataContext const & m_ownerDataContext
 
bool const m_statsOutputEnabled
 If true, the stats are to save in the output HDF5.
 
dataRepository::Groupm_meshBodies
 
stdVector< DiscretizationGroupPathm_discretizationsPaths
 
stdVector< stringm_warnings
 
StatsState m_regionStatsState
 The current state of the region statistics.
 

Detailed Description

template<typename Impl>
class geos::StatsAggregatorBase< Impl >

Reponsible of computing physical statistics over the grid, registering the result in the data repository, but not storing / outputing it by itself. It does not have mutable state except the encountered issues.

Todo:
repair 1D HDF5 outputs to enable stats HDF5 outputs
Template Parameters
Implthe derived type of the statistics aggregator which contains all necessary implementations (CRTP)

Definition at line 77 of file StatisticsAggregatorBase.hpp.

Member Typedef Documentation

◆ RegionStatsFunc

template<typename Impl >
template<typename OwnerType >
using geos::StatsAggregatorBase< Impl >::RegionStatsFunc = std::function< void ( OwnerType &, StatsGroupType & ) >

Standard function signature for any functor that applies on statistics group instances (StatsGroupType)

  • param 0: OwnerType &, the group instance containing the data for which we want to aggregate the statistics (MeshLevel, CellElementRegion...)
  • param 1: StatsAggregateGroupType &, the statistics aggregate Group where to store the data
    Template Parameters
    OwnerTypethe concrete type of the OwnerType param

Definition at line 93 of file StatisticsAggregatorBase.hpp.

◆ RegionStatsRegisterFunc

template<typename Impl >
using geos::StatsAggregatorBase< Impl >::RegionStatsRegisterFunc = std::function< StatsGroupType & ( dataRepository::Group &, string const & ) >

A functor that can be used to register a statistics Group instance. Parameters:

  • dataRepository::Group &, the parent Group,
  • string const &, name of the statistics target (i.e. region name).

Definition at line 101 of file StatisticsAggregatorBase.hpp.

Constructor & Destructor Documentation

◆ StatsAggregatorBase()

template<typename Impl >
geos::StatsAggregatorBase< Impl >::StatsAggregatorBase ( dataRepository::DataContext const &  ownerDataContext,
dataRepository::Group meshBodies,
bool  statsOutputEnabled 
)

Construct a new Stats Aggregator object.

Parameters
ownerNamethe unique name of the entity requesting the statistics. An error is thrown if not unique in this context.
meshBodiesThe Group containing the MeshBody objects
statsOutputEnabledIf true, the stats are saved in the output HDF5 (through dataRepository::RestartFlags, but not functional for this output for now).

Definition at line 48 of file StatisticsAggregatorBaseHelpers.hpp.

Member Function Documentation

◆ aggregateStats()

template<typename Impl >
void geos::StatsAggregatorBase< Impl >::aggregateStats ( StatsGroupType &  stats,
StatsGroupType const &  other 
) const
inlineprotected

Aggregate all instance statistics with those of another instance on the current rank.

Parameters
statsthe statistics instance
otherthe other instance to aggregate with.
Note
Must be implemented for each type that implements this template (CRTP).

Definition at line 260 of file StatisticsAggregatorBase.hpp.

◆ computeRegionsStatistics()

template<typename Impl >
bool geos::StatsAggregatorBase< Impl >::computeRegionsStatistics ( real64 const  timeRequest)

Compute statistics on the mesh discretizations (average field pressure, etc) Results are reduced on rank 0, and broadcasted over all ranks.

Parameters
[in]timeRequestThe time for which we want to compute the statistics.
Returns
false if there was a problem that prevented the statistics to be computed correctly.

Definition at line 193 of file StatisticsAggregatorBaseHelpers.hpp.

◆ computeSubRegionRankStats()

template<typename Impl >
void geos::StatsAggregatorBase< Impl >::computeSubRegionRankStats ( CellElementSubRegion subRegion,
StatsGroupType &  subRegionStats 
) const
inlineprotected

Compute the rank-local stats for the given sub-region and store the results in the given stats group.

Parameters
subRegion
subRegionStatsthe stats group instance for the subregion
Note
Must be implemented for each type that implements this template (CRTP).

Definition at line 251 of file StatisticsAggregatorBase.hpp.

◆ enableRegionStatisticsAggregation()

template<typename Impl >
void geos::StatsAggregatorBase< Impl >::enableRegionStatisticsAggregation ( RegionStatsRegisterFunc &&  registerStatsFunc)
protected

Enable the computation of region statistics, initialize data structure to collect them. Register the resulting data wrappers so they will be targeted by TimeHistory output.

Note
Must be called in or after the "registerDataOnMesh" initialization phase
Parameters
registerStatsFuncThe functor which register each statistics group whithin the regions hierarchy

Definition at line 90 of file StatisticsAggregatorBaseHelpers.hpp.

◆ getMeshLevel()

template<typename Impl >
MeshLevel & geos::StatsAggregatorBase< Impl >::getMeshLevel ( DiscretizationGroupPath const &  path) const
protected
Parameters
paththe path of the discretization group in the data-repository.
Returns
MeshLevel& the MeshLevel Group for the given discretisation

Definition at line 254 of file StatisticsAggregatorBaseHelpers.hpp.

◆ getOwnerName()

template<typename Impl >
string const& geos::StatsAggregatorBase< Impl >::getOwnerName ( ) const
inline
Returns
the name of the entity that needs the statistics.

Definition at line 169 of file StatisticsAggregatorBase.hpp.

◆ getRegionStatistics()

template<typename Impl >
StatsAggregatorBase< Impl >::StatsGroupType & geos::StatsAggregatorBase< Impl >::getRegionStatistics ( MeshLevel mesh,
string_view  regionName 
) const
Returns
a specific statistics Group instance.
Parameters
meshThe desired mesh-level
regionNameThe name of the desired region
Exceptions
InputErrorif no statistics data is found for the given region name.

Definition at line 283 of file StatisticsAggregatorBaseHelpers.hpp.

◆ getWarnings()

template<typename Impl >
stdVector< string > const& geos::StatsAggregatorBase< Impl >::getWarnings ( ) const
inline
Returns
The encountered issues during the last computing method call.

Definition at line 175 of file StatisticsAggregatorBase.hpp.

◆ initStatisticsAggregation()

template<typename Impl >
void geos::StatsAggregatorBase< Impl >::initStatisticsAggregation ( SolverType &  solver)

Enable the computation of any statistics, initialize data structure to collect them. Register the resulting data wrappers so they will be targeted by TimeHistory output.

Parameters
solverflow solver object to retrieve:
  • the simulated regions,
  • fields for statistics computation.

Definition at line 58 of file StatisticsAggregatorBaseHelpers.hpp.

◆ initStats()

template<typename Impl >
void geos::StatsAggregatorBase< Impl >::initStats ( StatsGroupType &  stats,
real64  time 
) const
inlineprotected

Initialize all statistics values to aggregable default values, before any computation / reduction for the current timestep.

Parameters
statsthe statistics instance
timestart time of the current timestep (s)
Note
Must be implemented for each type that implements this template (CRTP).

Definition at line 242 of file StatisticsAggregatorBase.hpp.

◆ isComputed()

template<typename Impl >
bool geos::StatsAggregatorBase< Impl >::isComputed ( real64 const  timeRequest,
StatsGroupType const &  stats 
)
Parameters
[in]timeRequestThe time for which we want to know if the statistics are computed.
[in]statsthe statistics data structure we want to know if it has been computed
Returns
true if the statistics have been computed.

Definition at line 173 of file StatisticsAggregatorBaseHelpers.hpp.

◆ mpiAggregateStats()

template<typename Impl >
void geos::StatsAggregatorBase< Impl >::mpiAggregateStats ( StatsGroupType &  stats) const
inlineprotected

Aggregate all instance statistics with those of other ranks.

Parameters
statsthe statistics instance
Note
Must be implemented for each type that implements this template (CRTP).

Definition at line 268 of file StatisticsAggregatorBase.hpp.

◆ postAggregateStats()

template<typename Impl >
void geos::StatsAggregatorBase< Impl >::postAggregateStats ( StatsGroupType &  stats)
inlineprotected

Do the final computations for the statistics. Must be called after computations & aggregations.

Parameters
statsthe statistics instance
Note
Must be implemented for each type that implements this template (CRTP).

Definition at line 276 of file StatisticsAggregatorBase.hpp.

Member Data Documentation

◆ m_ownerDataContext

template<typename Impl >
dataRepository::DataContext const& geos::StatsAggregatorBase< Impl >::m_ownerDataContext
protected
See also
getOwnerName()

Definition at line 206 of file StatisticsAggregatorBase.hpp.

◆ m_warnings

template<typename Impl >
stdVector< string > geos::StatsAggregatorBase< Impl >::m_warnings
protected
See also
getWarnings()

Definition at line 216 of file StatisticsAggregatorBase.hpp.


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