GEOSX
HistoryCollectionBase.hpp
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2020 TotalEnergies
8  * Copyright (c) 2020- GEOSX Contributors
9  * All rights reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
15 #ifndef GEOS_HISTORYCOLLECTIONBASE_HPP
16 #define GEOS_HISTORYCOLLECTIONBASE_HPP
17 
18 #include "HistoryCollection.hpp"
19 
20 #if defined(GEOSX_USE_PYGEOSX)
21 #include "fileIO/python/PyHistoryCollectionType.hpp"
22 #endif
23 
24 namespace geos
25 {
26 
33 {
34 public:
36  HistoryCollectionBase( string const & name, Group * parent ):
37  HistoryCollection( name, parent ),
38  m_targetIsMeshObject( false ),
39  m_collectionCount( 1 ),
42  { }
43 
44  void initializePostSubGroups() override;
45 
46  localIndex numCollectors() const override;
47 
48  virtual bool execute( real64 const time_n,
49  real64 const dt,
50  integer const cycleNumber,
51  integer const eventCounter,
52  real64 const eventProgress,
53  DomainPartition & domain ) override;
54 
55  void registerBufferProvider( localIndex collectionIdx, BufferProvider bufferProvider ) override;
56 
57  HistoryMetadata getTimeMetaData() const override;
58 
59  void registerTimeBufferProvider( TimeBufferProvider timeBufferProvider ) override;
60 
62 
63 #if defined(GEOSX_USE_PYGEOSX)
68  virtual PyTypeObject * getPythonType() const override
69  { return python::getPyHistoryCollectionType(); }
70 #endif
71 
72 protected:
73 
75  // Doxygen fails with error message `warning: documented empty return type of...`
80  virtual void updateSetsIndices( DomainPartition const & domain ) = 0;
82 
92  dataRepository::Group const * getTargetObject( DomainPartition const & domain, string const & objectPath ) const;
93 
100  virtual void collect( DomainPartition const & domain,
101  localIndex const collectionIdx,
102  buffer_unit_type * & buffer ) = 0;
103 
106 
109 
112 
114  std::vector< BufferProvider > m_bufferProviders;
115 
120  std::vector< std::unique_ptr< HistoryCollection > > m_metaDataCollectors;
121 };
122 
123 }
124 
125 #endif // include guard
Partition of the decomposed physical domain. It also manages the connexion information to its neighbo...
Intermediate class for code factorisation. It mainly deals with collector and buffer management....
HistoryCollectionBase(string const &name, Group *parent)
Constructor.
TimeBufferProvider m_timeBufferProvider
Callbacks to get the current time buffer head to write time data into.
dataRepository::Group const * getTargetObject(DomainPartition const &domain, string const &objectPath) const
Retrieve the target object from the data repository.
HistoryCollection & getMetaDataCollector(localIndex metaIdx) override
Get a collector of meta-information for this collector.
virtual void collect(DomainPartition const &domain, localIndex const collectionIdx, buffer_unit_type *&buffer)=0
Collect history information into the provided buffer. Typically called from HistoryCollection::execut...
bool m_targetIsMeshObject
whether the target object is associated with mesh entities (fields, etc)
localIndex m_collectionCount
The number of discrete collection operations described by metadata this collection collects.
std::vector< std::unique_ptr< HistoryCollection > > m_metaDataCollectors
The set of metadata collectors for this collector.
void registerBufferProvider(localIndex collectionIdx, BufferProvider bufferProvider) override
Register a callback that provides the current head of the time history data buffer.
localIndex numCollectors() const override
Get the number of discrete collection operations this collector conducts.
std::vector< BufferProvider > m_bufferProviders
Callbacks to get the current buffer head to write history data into.
HistoryMetadata getTimeMetaData() const override
Get a metadata object relating the the Time variable itself.
void registerTimeBufferProvider(TimeBufferProvider timeBufferProvider) override
Register a callback that gives the current head of the time data buffer.
std::function< buffer_unit_type *() > TimeBufferProvider
Type of time buffer provider.
std::function< buffer_unit_type *(localIndex) > BufferProvider
Type of buffer provider.
A minimal class to specify information about time history information being collected and output.
double real64
64-bit floating point type.
Definition: DataTypes.hpp:139
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:122
signed char buffer_unit_type
Type stored in communication buffers.
Definition: DataTypes.hpp:149
GEOSX_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125