GEOS
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static 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  DiscretizationSetPath
 
struct  MeshLevelSet
 Allow to reference a set in a given MeshLevel structure. More...
 
struct  StatsState
 
struct  ViewKeys
 the associated view keys More...
 

Public Types

using SolverType = typename StatsAggregatorTraits< Impl >::SolverType
 
using StatsGroupType = typename StatsAggregatorTraits< Impl >::StatsGroupType
 
using SetType = SortedArray< localIndex >
 
using SetViewType = SortedArrayView< localIndex const >
 
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 &, string_view, bool) >
 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, explores the data structure to collect them. More...
 
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...
 
bool isComputed (real64 const timeRequest, StatsGroupType const &stats)
 
bool isRestrictedToSets ()
 
bool isTargetingMultipleSets ()
 
string const & getOwnerName () const
 
stdVector< string > const & getWarnings () const
 
Data Structure Traversal Strategy
void forRegionStatistics (RegionStatsFunc< MeshLevel & > const &functor) const
 Execute the given functor on each mesh-level (discretization) available for this instance. More...
 
void forRegionStatistics (MeshLevel &mesh, StatsGroupType &meshSetsStats, bool enableCompoundSet, RegionStatsFunc< MeshLevelSet > const &functor) const
 Execute the given functor on each set present in the given mesh-level (discretization). More...
 
void forRegionStatistics (MeshLevelSet meshSet, StatsGroupType &setStats, RegionStatsFunc< CellElementRegion & > const &functor) const
 Execute the given functor on each region available in the given mesh-level for the given set. More...
 
void forRegionStatistics (CellElementRegion &region, StatsGroupType &setRegionStats, RegionStatsFunc< CellElementSubRegion & > const &functor) const
 Execute the given functor on each sub-region available in the given region for the given set. More...
 
dataRepository::Group & getInstanceStatisticsGroup (MeshLevel &mesh) const
 Get the Instance Statistics Group for the given mesh-level. More...
 
StatsGroupType & getMeshLevelStatistics (MeshLevel &mesh) const
 
StatsGroupType & getSetStatistics (MeshLevel &mesh, string_view setName="") const
 
StatsGroupType & getRegionStatistics (MeshLevel &mesh, string_view regionName, string_view setName="") const
 

Protected Types

using SetsCompound = stdMap< string, stdMap< string, SetType > >
 

Protected Member Functions

void enableRegionStatisticsAggregation (RegionStatsRegisterFunc &&registerStatsFunc, string_array const &setNames)
 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...
 
MeshLevel & getMeshLevel (DiscretizationSetPath const &path) const
 
StatsGroupType & getCompoundSetStatistics (MeshLevel &mesh) const
 
bool isCompoundSetStatistics (StatsGroupType const &stats) const
 
void setTargetSets (string_array const &setNames)
 Set the statstics target sets to restrict the statistics to. More...
 
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, SetType const &targetSet) 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...
 

Static Protected Member Functions

static std::set< string > getMeshLevelPartialSetNames (MeshLevel const &mesh, string_array const &regionNames)
 TODO.
 

Protected Attributes

dataRepository::DataContext const & m_ownerDataContext
 
bool const m_dataOutputEnabled
 If true, the stats are to save in the output HDF5.
 
dataRepository::Group & m_meshBodies
 
stdVector< DiscretizationSetPath > m_discretizationsPaths
 
std::set< string > m_setNames
 
bool m_isAnySetsIntersecting
 if true, at least ont set intersects with another, threfore we must compute mesh-level statistics with a coupound.
 
stdVector< string > m_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 90 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 110 of file StatisticsAggregatorBase.hpp.

◆ RegionStatsRegisterFunc

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

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

  • dataRepository::Group & targetName: the parent Group,
  • string const & parent: name of the statistics target (i.e. region name).
  • string_view setName: name of the target element set. If none is specified (empty), "all" elements set is targeted.
  • bool dataOutputEnabled: enable Group output features

Definition at line 120 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 50 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 413 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 420 of file StatisticsAggregatorBaseHelpers.hpp.

◆ computeSubRegionRankStats()

template<typename Impl >
void geos::StatsAggregatorBase< Impl >::computeSubRegionRankStats ( CellElementSubRegion &  subRegion,
StatsGroupType &  subRegionStats,
SetType const &  targetSet 
) 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
targetSet
Note
Must be implemented for each type that implements this template (CRTP).

Definition at line 402 of file StatisticsAggregatorBase.hpp.

◆ enableRegionStatisticsAggregation()

template<typename Impl >
void geos::StatsAggregatorBase< Impl >::enableRegionStatisticsAggregation ( RegionStatsRegisterFunc &&  registerStatsFunc,
string_array const &  setNames 
)
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
setNamesThe list of mesh element sets to restrict the statistics to. If empty, the whole mesh-level is processed.

Definition at line 123 of file StatisticsAggregatorBaseHelpers.hpp.

◆ forRegionStatistics() [1/4]

template<typename Impl >
void geos::StatsAggregatorBase< Impl >::forRegionStatistics ( CellElementRegion &  region,
StatsGroupType &  setRegionStats,
RegionStatsFunc< CellElementSubRegion & > const &  functor 
) const

Execute the given functor on each sub-region available in the given region for the given set.

Parameters
meshSetthe target region set.
setRegionStatsthe region statistics data structure for the given set.
functorthe function to execute.

Definition at line 385 of file StatisticsAggregatorBaseHelpers.hpp.

◆ forRegionStatistics() [2/4]

template<typename Impl >
void geos::StatsAggregatorBase< Impl >::forRegionStatistics ( MeshLevel &  mesh,
StatsGroupType &  meshSetsStats,
bool  enableCompoundSet,
RegionStatsFunc< MeshLevelSet > const &  functor 
) const

Execute the given functor on each set present in the given mesh-level (discretization).

Parameters
meshthe target mesh-level.
meshSetsStatsthe instance mesh-level statistics data structure.
enableCompoundSetif true, the functor will also be applied on the compound set (which is an optional internal computation data structure).
functorthe function to execute.

Definition at line 346 of file StatisticsAggregatorBaseHelpers.hpp.

◆ forRegionStatistics() [3/4]

template<typename Impl >
void geos::StatsAggregatorBase< Impl >::forRegionStatistics ( MeshLevelSet  meshSet,
StatsGroupType &  setStats,
RegionStatsFunc< CellElementRegion & > const &  functor 
) const

Execute the given functor on each region available in the given mesh-level for the given set.

Parameters
meshSetthe target mesh-level set.
setStatsthe mesh-level statistics data structure for the given set.
functorthe function to execute.

Definition at line 367 of file StatisticsAggregatorBaseHelpers.hpp.

◆ forRegionStatistics() [4/4]

template<typename Impl >
void geos::StatsAggregatorBase< Impl >::forRegionStatistics ( RegionStatsFunc< MeshLevel & > const &  functor) const

Execute the given functor on each mesh-level (discretization) available for this instance.

Parameters
functorthe function to execute.

Definition at line 333 of file StatisticsAggregatorBaseHelpers.hpp.

◆ getCompoundSetStatistics()

template<typename Impl >
StatsAggregatorBase< Impl >::StatsGroupType & geos::StatsAggregatorBase< Impl >::getCompoundSetStatistics ( MeshLevel &  mesh) const
protected
Returns
An optional statistics data structure (see StatsGroupType), aggregated from all sets over all targeted regions, for the given set in the given mesh-level.
Parameters
meshthe mesh-level (discretization).
Exceptions
InputErrorif no compound set exists, for instance if isSetsCompoundEnabled == false.

Definition at line 295 of file StatisticsAggregatorBaseHelpers.hpp.

◆ getInstanceStatisticsGroup()

template<typename Impl >
dataRepository::Group & geos::StatsAggregatorBase< Impl >::getInstanceStatisticsGroup ( MeshLevel &  mesh) const

Get the Instance Statistics Group for the given mesh-level.

Parameters
meshthe mesh-level (discretization).
Returns
A Group instance hierarchically holding all statistics data structures.

Definition at line 259 of file StatisticsAggregatorBaseHelpers.hpp.

◆ getMeshLevel()

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

Definition at line 250 of file StatisticsAggregatorBaseHelpers.hpp.

◆ getMeshLevelStatistics()

template<typename Impl >
StatsAggregatorBase< Impl >::StatsGroupType & geos::StatsAggregatorBase< Impl >::getMeshLevelStatistics ( MeshLevel &  mesh) const
Returns
A statistics data structure (see StatsGroupType), aggregated from all targeted regions and sets in the given mesh-level.
Parameters
meshthe mesh-level (discretization).

Definition at line 269 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 284 of file StatisticsAggregatorBase.hpp.

◆ getRegionStatistics()

template<typename Impl >
StatsAggregatorBase< Impl >::StatsGroupType & geos::StatsAggregatorBase< Impl >::getRegionStatistics ( MeshLevel &  mesh,
string_view  regionName,
string_view  setName = "" 
) const
Returns
A statistics data structure (see StatsGroupType), for the given set, in the given region, in the given mesh-level.
Parameters
meshThe mesh-level (discretization)
setNamethe name of element set. If none is specified (empty), "all" elements set is targeted.
regionNameThe name of the desired region
Exceptions
InputError- if no statistics data is found for the given region name.
  • if "all" is targeted, but the instance does not target "all" element set.

Definition at line 317 of file StatisticsAggregatorBaseHelpers.hpp.

◆ getSetStatistics()

template<typename Impl >
StatsAggregatorBase< Impl >::StatsGroupType & geos::StatsAggregatorBase< Impl >::getSetStatistics ( MeshLevel &  mesh,
string_view  setName = "" 
) const
Returns
A statistics data structure (see StatsGroupType), aggregated from all targeted regions for the given set in the given mesh-level.
Parameters
meshthe mesh-level (discretization).
setNamethe name of element set. If none is specified (empty), "all" elements set is targeted.
Exceptions
InputErrorif "all" is targeted, but the instance does not target "all" element set.

Definition at line 279 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 290 of file StatisticsAggregatorBase.hpp.

◆ initStatisticsAggregation()

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

Enable the computation of any statistics, explores the data structure to collect them.

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

finding all sets in this mesh level

Definition at line 84 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 392 of file StatisticsAggregatorBase.hpp.

◆ isCompoundSetStatistics()

template<typename Impl >
bool geos::StatsAggregatorBase< Impl >::isCompoundSetStatistics ( StatsGroupType const &  stats) const
protected
Returns
true if the RegionStatistics is processed from a compound set of other instances.
Parameters
statsa statistics data structure

Definition at line 310 of file StatisticsAggregatorBaseHelpers.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 400 of file StatisticsAggregatorBaseHelpers.hpp.

◆ isRestrictedToSets()

template<typename Impl >
bool geos::StatsAggregatorBase< Impl >::isRestrictedToSets ( )
inline
Returns
true if the region statistics target given sets. false if the statistics are targeted on only one mesh-level-wide set

Definition at line 271 of file StatisticsAggregatorBase.hpp.

◆ isTargetingMultipleSets()

template<typename Impl >
bool geos::StatsAggregatorBase< Impl >::isTargetingMultipleSets ( )
inline
Returns
true if the region statistics target multiple sets. false if the statistics are targeted on only one set

Definition at line 278 of file StatisticsAggregatorBase.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 421 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 429 of file StatisticsAggregatorBase.hpp.

◆ setTargetSets()

template<typename Impl >
void geos::StatsAggregatorBase< Impl >::setTargetSets ( string_array const &  setNames)
protected

Set the statstics target sets to restrict the statistics to.

Parameters
setNamesthe list of target sets. If "all" is included, or none is present, all the discretisation is targeted.

Member Data Documentation

◆ m_discretizationsPaths

template<typename Impl >
stdVector< DiscretizationSetPath > geos::StatsAggregatorBase< Impl >::m_discretizationsPaths
protected

Data repository paths of the element sets per mesh levels TODO: can it be generalized with the "all" set

Definition at line 327 of file StatisticsAggregatorBase.hpp.

◆ m_ownerDataContext

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

Definition at line 318 of file StatisticsAggregatorBase.hpp.

◆ m_setNames

template<typename Impl >
std::set< string > geos::StatsAggregatorBase< Impl >::m_setNames
protected

The list of mesh element sets to restrict the region statistics to. Cannot be empty: if the whole mesh-level is to process, "all" must be targeted.

Definition at line 331 of file StatisticsAggregatorBase.hpp.

◆ m_warnings

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

Definition at line 337 of file StatisticsAggregatorBase.hpp.


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