13 #ifndef FFR_RESULT_CONTAINER_H
14 #define FFR_RESULT_CONTAINER_H
48 std::set<std::string>*
dict;
138 int bitPos,
int cellBits,
int repeats)
140 return this->
actualRead((
void*)values,nvals,bitPos,cellBits,repeats);
145 int bitPos,
int cellBits,
int repeats)
147 return this->
actualRead((
void*)values,nvals,bitPos,cellBits,repeats);
152 int bitPos,
int cellBits,
int repeats)
154 return this->
actualRead((
void*)values,nvals,bitPos,cellBits,repeats);
198 bool dataBlocks =
false);
211 double getKey(
int flag)
const;
213 int actualRead(
void* var,
int nvals,
int bitPos,
int cellBits,
int repeats);
Functions and data type for direct access of large binary files.
#define FT_FILE
File pointer.
Definition: FFaIO.H:136
#define FT_int
64-bit integer type.
Definition: FFaIO.H:134
FFrStatus
Definition: FFrEnums.H:12
std::set< FFrItemGroup *, FFrItemGroup::Less > ItemGroupSet
Definition: FFrItemGroup.H:83
std::vector< FFrEntryBase * > FFrEntrySet
Results entry container.
Definition: FFrResultContainer.H:32
std::map< double, int > FFrTimeMap
Physical time to time step mapping.
Definition: FFrResultContainer.H:26
std::set< FFrVariable *, FFrVariable::Less > VariableSet
Definition: FFrVariable.H:79
Definition: FFrEntryBase.H:28
Class holding the data of a Fedem results file.
Definition: FFrResultContainer.H:71
bool swapBytes
Endian mismatch?
Definition: FFrResultContainer.H:219
int getStepSize() const
Returns the size (in bytes) of the results data of each time step.
Definition: FFrResultContainer.H:116
int readPositionedTimestepData(const double *values, int nvals, int bitPos, int cellBits, int repeats)
Reads a double variable from the specified position.
Definition: FFrResultContainer.H:137
int positionAtKey(double key, bool getNextHigher=false)
Positions the file to the specified key (physical time).
Definition: FFrResultContainer.C:953
bool iAmPreReading
Read all results for current time step into core.
Definition: FFrResultContainer.H:247
FFrResultContainer(FFrExtractor *extractor, const std::string &fileName)
The constructor initializes the data members.
Definition: FFrResultContainer.C:31
FFrExtractor * myExtractor
Result extractor that own this container.
Definition: FFrResultContainer.H:232
bool isPositioned() const
Returns whether the file has been positioned.
Definition: FFrResultContainer.H:131
int getStepsInFile() const
Returns the number of time steps in this results container.
Definition: FFrResultContainer.H:114
int myLastReadEndPos
Position after the last data read.
Definition: FFrResultContainer.H:238
bool buildAndResolveHierarchy()
Builds and resolves the results hierarchy of the file.
Definition: FFrResultContainer.C:534
Status getContainerStatus() const
Returns the current status of this results container.
Definition: FFrResultContainer.H:104
FFrResultContainer & operator=(const FFrResultContainer &)=delete
Disable default assignment operator.
bool readText()
Reads the file squentially from current file position.
Definition: FFrResultContainer.C:689
FFrVariableReference * myPhysTimeRef
Pointer to physical time variable.
Definition: FFrResultContainer.H:216
bool isPreReadEnabled() const
Checks if the time step cache is enabled.
Definition: FFrResultContainer.H:186
Status updateContainerStatus()
Updates the container to a new status (used from the system ticks).
Definition: FFrResultContainer.C:110
int readPositionedTimestepData(const int *values, int nvals, int bitPos, int cellBits, int repeats)
Reads an integer variable from the specified position.
Definition: FFrResultContainer.H:151
double myWantedKey
The physical time to read results for.
Definition: FFrResultContainer.H:243
void collectGarbage(FFrEntryBase *entry)
Collects temporary entries to be deleted when parsing finished.
Definition: FFrResultContainer.C:588
std::string myFileName
File name associated with this result container.
Definition: FFrResultContainer.H:227
FFrEntrySet myGarbage
Garbage collection container.
Definition: FFrResultContainer.H:234
bool readFileHeader()
Reads the header of the file.
Definition: FFrResultContainer.C:234
void printInfo() const
Prints out some size parameters for this results container.
Definition: FFrResultContainer.C:655
unsigned int getDate() const
Returns the time stamp of this results container.
Definition: FFrResultContainer.H:111
void clearPreRead()
Clears the time step cache.
Definition: FFrResultContainer.C:88
double getDistanceFromPosKey(bool usePositionedKey=false) const
Returns the difference between current position and the wanted key.
Definition: FFrResultContainer.C:880
bool reopenForDataAccess()
Reopens the results file for direct access of binary data.
Definition: FFrResultContainer.C:606
FFrEntrySet myTopLevelEntries
List of all top-level entries.
Definition: FFrResultContainer.H:233
void printSizeParameters(FT_int fileSize) const
Prints out sime size parameters for the results file.
Definition: FFrResultContainer.C:667
PositionStatus myWantedKeyStatus
Is the key inside, exact, front or rear.
Definition: FFrResultContainer.H:244
Status myStatus
Current status of the file reading.
Definition: FFrResultContainer.H:224
void fillPreRead()
Reads all data associated with current time step into a cache.
Definition: FFrResultContainer.C:1034
PositionStatus
Enums defining the file position statuses that may occur.
Definition: FFrResultContainer.H:159
@ FFR_INSIDE
Definition: FFrResultContainer.H:162
@ FFR_AFTER_END
Definition: FFrResultContainer.H:163
@ FFR_BEFORE_START
Definition: FFrResultContainer.H:161
@ FFR_NOT_SET
Definition: FFrResultContainer.H:160
double getCurrentKey() const
Returns current physical time of this container.
Definition: FFrResultContainer.H:169
Status
Enums defining the various container statuses that may occur.
Definition: FFrResultContainer.H:84
@ FFR_HEADER_INCOMPLETE
Definition: FFrResultContainer.H:90
@ FFR_DATA_PRESENT
Definition: FFrResultContainer.H:93
@ FFR_TEXT_PRESENT
Definition: FFrResultContainer.H:88
@ FFR_TEXT_FILE
Definition: FFrResultContainer.H:87
@ FFR_DATA_CLOSED
Definition: FFrResultContainer.H:92
@ FFR_NO_FILE_FOUND
Definition: FFrResultContainer.H:86
@ FFR_NEW_DATA
Definition: FFrResultContainer.H:94
@ FFR_CONTAINER_INVALID
Definition: FFrResultContainer.H:85
@ FFR_NEW_TEXT
Definition: FFrResultContainer.H:89
@ FFR_HEADER_COMPLETE
Definition: FFrResultContainer.H:91
FFrResultContainer(const FFrResultContainer &)=delete
Disable default copy constructor.
FT_int getHeaderSize() const
Returns the size (in bytes) of the results file header.
Definition: FFrResultContainer.H:118
const std::string & getFileName() const
Returns the file name of this results container.
Definition: FFrResultContainer.H:109
FFrStatus readVariables(FILE *fp, FFrCreatorData &cd, bool dataBlocks=false)
Reads variable definitions and references.
Definition: FFrResultContainer.C:451
void resetPositioning()
Resets the file position.
Definition: FFrResultContainer.C:1013
~FFrResultContainer()
The destructor closes the file and releases heap-allocated data.
Definition: FFrResultContainer.C:59
std::string myModule
Program module that wrote the results file.
Definition: FFrResultContainer.H:228
int myPreReadTimeStep
Current time step in pre-read cache.
Definition: FFrResultContainer.H:250
double getKey(int flag) const
Returns current, first or last physical time of this container.
Definition: FFrResultContainer.C:863
double getFirstKey() const
Returns first physical time of this container.
Definition: FFrResultContainer.H:171
char * myPreRead
Pre-read cache.
Definition: FFrResultContainer.H:249
bool readTimeStepInformation()
Reads time step information from the file.
Definition: FFrResultContainer.C:714
int timeStepSize
Time step size in bytes (max 2GB)
Definition: FFrResultContainer.H:220
PositionStatus getPositioningStatus() const
Returns current file position status flag.
Definition: FFrResultContainer.H:167
double getLastKey() const
Returns last physical time of this container.
Definition: FFrResultContainer.H:173
FILE * myFile
File descriptor used in header parsing.
Definition: FFrResultContainer.H:222
FT_FILE myDataFile
File handle used for data access.
Definition: FFrResultContainer.H:223
unsigned int myDate
Time stamp of the results file.
Definition: FFrResultContainer.H:229
const FFrEntrySet & topLevel() const
Returns a const reference to the top-level entries container.
Definition: FFrResultContainer.H:124
bool iAmLazyPositioned
Only move file pointer first time reading data.
Definition: FFrResultContainer.H:246
const FFrTimeMap & getPhysicalTime() const
Returns a const reference to the time step mapping.
Definition: FFrResultContainer.H:126
FT_int myHeaderSize
Binary start position in bytes.
Definition: FFrResultContainer.H:221
bool getDistanceToNextKey(double &dist)
Calculates the distance to the next key for this results container.
Definition: FFrResultContainer.C:913
FFrTimeMap myPhysicalTimeMap
Physical time to results mapping.
Definition: FFrResultContainer.H:240
int actualRead(void *var, int nvals, int bitPos, int cellBits, int repeats)
Reads a certain number of bytes from the binary results file.
Definition: FFrResultContainer.C:1091
void enablePreRead(bool f)
Enables time step pre-read cache.
Definition: FFrResultContainer.H:184
FFrTimeMap::iterator myCurrentIndexIt
Pointer to what we should read.
Definition: FFrResultContainer.H:241
Status close()
Closes the results file of this container, if still open.
Definition: FFrResultContainer.C:69
int myPositionedTimeStep
Current file position.
Definition: FFrResultContainer.H:237
int readPositionedTimestepData(const float *values, int nvals, int bitPos, int cellBits, int repeats)
Reads a float variable from the specified position.
Definition: FFrResultContainer.H:144
bool isHeaderComplete() const
Returns true, if the file header has been successfully parsed.
Definition: FFrResultContainer.H:106
Definition: FFrVariableReference.H:18
real(dp) function dist(a, b, g)
Calculates the distance between the angles a,b,g and euler.
Definition: rotationModule.f90:274
Incapsulation of temporary data used during results file parsing.
Definition: FFrResultContainer.H:36
VariableSet * extractorVariables
Pointer to the result variable container of the results extractor.
Definition: FFrResultContainer.H:44
ItemGroupSet * extractorIGs
Pointer to the item group container of the results extractor.
Definition: FFrResultContainer.H:46
FFrEntrySet & topLevelEntries
Reference to the top-level entries of the results container.
Definition: FFrResultContainer.H:42
std::map< int, FFrVariable * > variables
Temporary variable container.
Definition: FFrResultContainer.H:38
FFrCreatorData(FFrEntrySet &tl, VariableSet *vars, ItemGroupSet *itgs, std::set< std::string > *tdic)
The constructor initializes the data members.
Definition: FFrResultContainer.H:51
std::map< int, FFrItemGroup * > itemGroups
Temporary item group container.
Definition: FFrResultContainer.H:40
std::set< std::string > * dict
Pointer to the text dictionary of the results extractor.
Definition: FFrResultContainer.H:48