GEOS
HistoryCollectionBase.hpp
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 Total, S.A
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
16 #ifndef GEOS_HISTORYCOLLECTIONBASE_HPP
17 #define GEOS_HISTORYCOLLECTIONBASE_HPP
18 
19 #include "HistoryCollection.hpp"
20 
21 #if defined(GEOS_USE_PYGEOSX)
22 #include "fileIO/python/PyHistoryCollectionType.hpp"
23 #endif
24 
25 namespace geos
26 {
27 
34 {
35 public:
37  HistoryCollectionBase( string const & name, Group * parent ):
38  HistoryCollection( name, parent ),
39  m_targetIsMeshObject( false ),
40  m_collectionCount( 1 ),
43  { }
44 
45  void initializePostSubGroups() override;
46 
47  localIndex numCollectors() const override;
48 
49  virtual bool execute( real64 const time_n,
50  real64 const dt,
51  integer const cycleNumber,
52  integer const eventCounter,
53  real64 const eventProgress,
54  DomainPartition & domain ) override;
55 
56  void registerBufferProvider( localIndex collectionIdx, BufferProvider bufferProvider ) override;
57 
58  HistoryMetadata getTimeMetaData() const override;
59 
60  void registerTimeBufferProvider( TimeBufferProvider timeBufferProvider ) override;
61 
63 
64 #if defined(GEOS_USE_PYGEOSX)
69  virtual PyTypeObject * getPythonType() const override
70  { return python::getPyHistoryCollectionType(); }
71 #endif
72 
73 protected:
74 
76  // Doxygen fails with error message `warning: documented empty return type of...`
81  virtual void updateSetsIndices( DomainPartition const & domain ) = 0;
83 
93  dataRepository::Group const * getTargetObject( DomainPartition const & domain, string const & objectPath ) const;
94 
101  virtual void collect( DomainPartition const & domain,
102  localIndex const collectionIdx,
103  buffer_unit_type * & buffer ) = 0;
104 
107 
110 
113 
115  std::vector< BufferProvider > m_bufferProviders;
116 
121  std::vector< std::unique_ptr< HistoryCollection > > m_metaDataCollectors;
122 };
123 
124 }
125 
126 #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)
void initializePostSubGroups() override
Forwarding public initializing function...
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.
virtual bool execute(real64 const time_n, real64 const dt, integer const cycleNumber, integer const eventCounter, real64 const eventProgress, DomainPartition &domain) override
Main extension point of executable targets.
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:99
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82
signed char buffer_unit_type
Type stored in communication buffers.
Definition: DataTypes.hpp:109