FEDEM Solver  R8.0
Source code of the dynamics solver
FFrExtractor.H
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2023 SAP SE
2 //
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 // This file is part of FEDEM - https://openfedem.org
7 
14 #ifndef FFR_EXTRACTOR_H
15 #define FFR_EXTRACTOR_H
16 
17 #include "FFrLib/FFrVariable.H"
18 #include "FFrLib/FFrItemGroup.H"
19 #include <string>
20 #include <vector>
21 #include <set>
22 #include <map>
23 
24 class FFrEntryBase;
25 class FFrObjectGroup;
27 class FFrResultContainer;
29 
30 
44 {
45 public:
48  FFrExtractor(const char* xname = NULL);
50  virtual ~FFrExtractor();
51 
53  static void releaseMemoryBlocks(bool readOps = false);
54 
56  const std::string& getName() const { return myName; }
57 
59  bool addFiles(const std::set<std::string>& fileNames,
60  bool showProgress = false);
62  virtual bool addFiles(const std::vector<std::string>& fileNames,
63  bool showProgress = false, bool mustExist = false);
65  bool addFile(const std::string& fileName, bool mustExist = false);
66 
68  void closeFiles();
69 
71  std::set<std::string> getAllResultContainerFiles() const;
72 
74  FFrResultContainer* getResultContainer(const std::string& fileName) const;
75 
77  virtual bool removeFiles(const std::set<std::string>& fileNames);
78 
80  virtual void doResultFilesUpdate();
81 
86 
88  bool empty() const { return myTopLevelOGs.empty(); }
89 
91  FFrEntryBase* getTopLevelVar(const std::string& key) const;
93  FFrObjectGroup* getObjectGroup(int id) const;
95  FFrSuperObjectGroup* getSuperGroup(const std::string& key) const;
96 
98  void printContainerInfo() const;
100  void printHierarchy() const;
101 
105  void search(std::vector<FFrEntryBase*>& entries,
106  const FFaResultDescription& descr);
111  FFrEntryBase* findVar(const std::string& oType, int baseId,
112  const std::string& vName);
113 
114 
115  // RDB Positioning:
116 
118  bool resetRDBPositioning();
119 
125  bool positionRDB(double wantedTime, double& foundTime,
126  bool getNextHigher = false);
127 
130  bool incrementRDB();
131 
132 
133  // RDB Time info access:
134 
136  void getValidKeys(std::set<double>& resKeys,
137  const std::set<std::string>& files) const;
138 
140  void enableTimeStepPreRead(const std::set<std::string>& files);
142  void disableTimeStepPreRead();
144  void clearPreReadTimeStep();
145 
147  double getLastTimeStep() const;
149  double getFirstTimeStep() const;
151  double getLastWrittenTime() const;
152 
154  double getCurrentRDBPhysTime() const { return myCurrentPhysTime; }
155 
157  int getSingleTimeStepData(const FFrEntryBase* entryRef,
158  const double* values, int nval);
160  int getSingleTimeStepData(const FFrEntryBase* entryRef,
161  const int* values, int nval);
162 
164  std::set<std::string>* getDictionary() { return &myDict; }
165 
166 protected:
168  virtual int doSingleResultFileUpdate(FFrResultContainer* container);
170  bool updateExtractorHeader(FFrResultContainer* container);
171 
172 private:
173  std::string myName;
175 
177  std::set<std::string> myDict;
178 
180  typedef std::map<std::string,FFrResultContainer*> ContainerMap;
181 
185 
186 protected:
188  std::map<std::string,FFrSuperObjectGroup*> myTopLevelSOGs;
190  std::map<int,FFrObjectGroup*> myTopLevelOGs;
192  std::map<std::string,FFrEntryBase*> myTopLevelVars;
193 };
194 
195 #endif
std::set< FFrItemGroup *, FFrItemGroup::Less > ItemGroupSet
Definition: FFrItemGroup.H:83
std::set< FFrVariable *, FFrVariable::Less > VariableSet
Definition: FFrVariable.H:79
Class representing a result variable description.
Definition: FFaResultDescription.H:31
Definition: FFrEntryBase.H:28
Front-end for the result extraction module.
Definition: FFrExtractor.H:44
void enableTimeStepPreRead(const std::set< std::string > &files)
Enables file-based pre-read of time steps.
Definition: FFrExtractor.C:920
bool incrementRDB()
Increments the RDB to the closest time step defined.
Definition: FFrExtractor.C:815
FFrEntryBase * getTopLevelVar(const std::string &key) const
Returns a specified top level variable or item group.
Definition: FFrExtractor.C:480
std::map< std::string, FFrEntryBase * > myTopLevelVars
Top level variable mapping.
Definition: FFrExtractor.H:192
ItemGroupSet myItemGroups
All item groups in this extractor.
Definition: FFrExtractor.H:184
void printHierarchy() const
Prints out the RDB hierarchy of this extractor to std::cout.
Definition: FFrExtractor.C:569
void getValidKeys(std::set< double > &resKeys, const std::set< std::string > &files) const
Get a set of keys for which valid data exist in the provided files.
Definition: FFrExtractor.C:848
double getCurrentRDBPhysTime() const
Returns RDB position information.
Definition: FFrExtractor.H:154
std::map< std::string, FFrResultContainer * > ContainerMap
File name to result container mapping.
Definition: FFrExtractor.H:180
FFrSuperObjectGroup * getSuperGroup(const std::string &key) const
Returns a specified super object group.
Definition: FFrExtractor.C:494
double myCurrentPhysTime
Physical time of last time step read.
Definition: FFrExtractor.H:174
void printContainerInfo() const
Prints out some information for the result containers to std::cout.
Definition: FFrExtractor.C:551
bool addFile(const std::string &fileName, bool mustExist=false)
Adds a single file to the RDB.
Definition: FFrExtractor.C:168
FFrEntryBase * search(const FFaResultDescription &descr)
Finds the first entry that matches a search criterion.
Definition: FFrExtractor.C:346
FFrEntryBase * findVar(const std::string &oType, int baseId, const std::string &vName)
Finds a variable reference of an object group.
Definition: FFrExtractor.C:501
VariableSet myVariables
All variables in this extractor.
Definition: FFrExtractor.H:183
double getLastWrittenTime() const
Returns the physical time of the last changed time step in RDB.
Definition: FFrExtractor.C:899
std::set< std::string > myDict
Text dictionary used to minimize multiple string storage.
Definition: FFrExtractor.H:177
bool empty() const
Returns whether the extractor contains any results or not.
Definition: FFrExtractor.H:88
void disableTimeStepPreRead()
Disables file-based pre-read of time steps.
Definition: FFrExtractor.C:929
FFrExtractor(const char *xname=NULL)
Default constructor.
Definition: FFrExtractor.C:31
virtual int doSingleResultFileUpdate(FFrResultContainer *container)
Checks if there is new data on disk for the given container.
Definition: FFrExtractor.C:532
ItemGroupSet * getItemGroups()
Returns a pointer to the item group container of this extractor.
Definition: FFrExtractor.H:85
virtual ~FFrExtractor()
The destructor frees the dynamically allocated members.
Definition: FFrExtractor.C:48
double getLastTimeStep() const
Returns the physical time of the last time step in RDB.
Definition: FFrExtractor.C:862
ContainerMap myContainers
All result containers in this extractor.
Definition: FFrExtractor.H:182
FFrObjectGroup * getObjectGroup(int id) const
Returns a specified object group.
Definition: FFrExtractor.C:487
const std::string & getName() const
Returns the name of this extractor.
Definition: FFrExtractor.H:56
double getFirstTimeStep() const
Returns the physical time of the first time step in RDB.
Definition: FFrExtractor.C:878
void closeFiles()
Closes all result container files.
Definition: FFrExtractor.C:144
std::map< int, FFrObjectGroup * > myTopLevelOGs
Top level object group mapping.
Definition: FFrExtractor.H:190
VariableSet * getVariables()
Returns a pointer to the variables container of this extractor.
Definition: FFrExtractor.H:83
std::string myName
Name of this extractor.
Definition: FFrExtractor.H:173
bool updateExtractorHeader(FFrResultContainer *container)
Updates the top-level containers with items from container.
Definition: FFrExtractor.C:203
int getSingleTimeStepData(const FFrEntryBase *entryRef, const double *values, int nval)
Special single time step interface.
Definition: FFrExtractor.C:755
bool addFiles(const std::set< std::string > &fileNames, bool showProgress=false)
Adds a set of files to the RDB.
Definition: FFrExtractor.C:91
std::set< std::string > * getDictionary()
Returns the text dictionary of this extractor.
Definition: FFrExtractor.H:164
virtual void doResultFilesUpdate()
Checks if there is new data on disk.
Definition: FFrExtractor.C:525
std::set< std::string > getAllResultContainerFiles() const
Returns all result container files currently in this extractor.
Definition: FFrExtractor.C:151
bool resetRDBPositioning()
Resets the RDB to point to the first of all time steps recorded.
Definition: FFrExtractor.C:782
std::map< std::string, FFrSuperObjectGroup * > myTopLevelSOGs
Top level super object group mapping.
Definition: FFrExtractor.H:188
virtual bool removeFiles(const std::set< std::string > &fileNames)
Removes the specified files from the RDB.
Definition: FFrExtractor.C:293
void clearPreReadTimeStep()
Clears the pre-read time step cache.
Definition: FFrExtractor.C:936
FFrResultContainer * getResultContainer(const std::string &fileName) const
Returns the result container associated with fileName.
Definition: FFrExtractor.C:161
static void releaseMemoryBlocks(bool readOps=false)
Releases the dynamically allocated memory blocks in global scope.
Definition: FFrExtractor.C:76
bool positionRDB(double wantedTime, double &foundTime, bool getNextHigher=false)
Positions the result containers in the RDB.
Definition: FFrExtractor.C:687
Definition: FFrObjectGroup.H:19
Class holding the data of a Fedem results file.
Definition: FFrResultContainer.H:71
Definition: FFrSuperObjectGroup.H:15