FEDEM Solver
R8.0
Source code of the dynamics solver
|
Class holding the data of a Fedem results file. More...
#include <FFrResultContainer.H>
Public Types | |
enum | Status { FFR_CONTAINER_INVALID = 1 , FFR_NO_FILE_FOUND , FFR_TEXT_FILE , FFR_TEXT_PRESENT , FFR_NEW_TEXT , FFR_HEADER_INCOMPLETE , FFR_HEADER_COMPLETE , FFR_DATA_CLOSED , FFR_DATA_PRESENT , FFR_NEW_DATA } |
Enums defining the various container statuses that may occur. More... | |
enum | PositionStatus { FFR_NOT_SET , FFR_BEFORE_START , FFR_INSIDE , FFR_AFTER_END } |
Enums defining the file position statuses that may occur. More... | |
Public Member Functions | |
FFrResultContainer (FFrExtractor *extractor, const std::string &fileName) | |
The constructor initializes the data members. More... | |
~FFrResultContainer () | |
The destructor closes the file and releases heap-allocated data. More... | |
FFrResultContainer (const FFrResultContainer &)=delete | |
Disable default copy constructor. More... | |
FFrResultContainer & | operator= (const FFrResultContainer &)=delete |
Disable default assignment operator. More... | |
Status | close () |
Closes the results file of this container, if still open. More... | |
Status | updateContainerStatus () |
Updates the container to a new status (used from the system ticks). More... | |
Status | getContainerStatus () const |
Returns the current status of this results container. More... | |
bool | isHeaderComplete () const |
Returns true, if the file header has been successfully parsed. More... | |
const std::string & | getFileName () const |
Returns the file name of this results container. More... | |
unsigned int | getDate () const |
Returns the time stamp of this results container. More... | |
int | getStepsInFile () const |
Returns the number of time steps in this results container. More... | |
int | getStepSize () const |
Returns the size (in bytes) of the results data of each time step. More... | |
FT_int | getHeaderSize () const |
Returns the size (in bytes) of the results file header. More... | |
void | printInfo () const |
Prints out some size parameters for this results container. More... | |
const FFrEntrySet & | topLevel () const |
Returns a const reference to the top-level entries container. More... | |
const FFrTimeMap & | getPhysicalTime () const |
Returns a const reference to the time step mapping. More... | |
int | positionAtKey (double key, bool getNextHigher=false) |
Positions the file to the specified key (physical time). More... | |
bool | isPositioned () const |
Returns whether the file has been positioned. More... | |
void | resetPositioning () |
Resets the file position. More... | |
int | readPositionedTimestepData (const double *values, int nvals, int bitPos, int cellBits, int repeats) |
Reads a double variable from the specified position. More... | |
int | readPositionedTimestepData (const float *values, int nvals, int bitPos, int cellBits, int repeats) |
Reads a float variable from the specified position. More... | |
int | readPositionedTimestepData (const int *values, int nvals, int bitPos, int cellBits, int repeats) |
Reads an integer variable from the specified position. More... | |
PositionStatus | getPositioningStatus () const |
Returns current file position status flag. More... | |
double | getCurrentKey () const |
Returns current physical time of this container. More... | |
double | getFirstKey () const |
Returns first physical time of this container. More... | |
double | getLastKey () const |
Returns last physical time of this container. More... | |
double | getDistanceFromPosKey (bool usePositionedKey=false) const |
Returns the difference between current position and the wanted key. More... | |
bool | getDistanceToNextKey (double &dist) |
Calculates the distance to the next key for this results container. More... | |
void | collectGarbage (FFrEntryBase *entry) |
Collects temporary entries to be deleted when parsing finished. More... | |
void | enablePreRead (bool f) |
Enables time step pre-read cache. More... | |
bool | isPreReadEnabled () const |
Checks if the time step cache is enabled. More... | |
void | clearPreRead () |
Clears the time step cache. More... | |
Protected Member Functions | |
void | printSizeParameters (FT_int fileSize) const |
Prints out sime size parameters for the results file. More... | |
bool | readFileHeader () |
Reads the header of the file. More... | |
FFrStatus | readVariables (FILE *fp, FFrCreatorData &cd, bool dataBlocks=false) |
Reads variable definitions and references. More... | |
bool | buildAndResolveHierarchy () |
Builds and resolves the results hierarchy of the file. More... | |
bool | readTimeStepInformation () |
Reads time step information from the file. More... | |
bool | readText () |
Reads the file squentially from current file position. More... | |
bool | reopenForDataAccess () |
Reopens the results file for direct access of binary data. More... | |
void | fillPreRead () |
Reads all data associated with current time step into a cache. More... | |
double | getKey (int flag) const |
Returns current, first or last physical time of this container. More... | |
int | actualRead (void *var, int nvals, int bitPos, int cellBits, int repeats) |
Reads a certain number of bytes from the binary results file. More... | |
Private Attributes | |
FFrVariableReference * | myPhysTimeRef |
Pointer to physical time variable. More... | |
bool | swapBytes |
Endian mismatch? More... | |
int | timeStepSize |
Time step size in bytes (max 2GB) More... | |
FT_int | myHeaderSize |
Binary start position in bytes. More... | |
FILE * | myFile |
File descriptor used in header parsing. More... | |
FT_FILE | myDataFile |
File handle used for data access. More... | |
Status | myStatus |
Current status of the file reading. More... | |
std::string | myFileName |
File name associated with this result container. More... | |
std::string | myModule |
Program module that wrote the results file. More... | |
unsigned int | myDate |
Time stamp of the results file. More... | |
FFrExtractor * | myExtractor |
Result extractor that own this container. More... | |
FFrEntrySet | myTopLevelEntries |
List of all top-level entries. More... | |
FFrEntrySet | myGarbage |
Garbage collection container. More... | |
int | myPositionedTimeStep |
Current file position. More... | |
int | myLastReadEndPos |
Position after the last data read. More... | |
FFrTimeMap | myPhysicalTimeMap |
Physical time to results mapping. More... | |
FFrTimeMap::iterator | myCurrentIndexIt |
Pointer to what we should read. More... | |
double | myWantedKey |
The physical time to read results for. More... | |
PositionStatus | myWantedKeyStatus |
Is the key inside, exact, front or rear. More... | |
bool | iAmLazyPositioned |
Only move file pointer first time reading data. More... | |
bool | iAmPreReading |
Read all results for current time step into core. More... | |
char * | myPreRead |
Pre-read cache. More... | |
int | myPreReadTimeStep |
Current time step in pre-read cache. More... | |
Class holding the data of a Fedem results file.
Instances of this class represents one results file each of a Fedem model. The class also contains methods for parsing the file header and populating the datastructure for traversing the results hierarchy, as well as methods for reading the results themselves (binary data).
FFrResultContainer::FFrResultContainer | ( | FFrExtractor * | extractor, |
const std::string & | fileName | ||
) |
The constructor initializes the data members.
FFrResultContainer::~FFrResultContainer | ( | ) |
The destructor closes the file and releases heap-allocated data.
|
delete |
Disable default copy constructor.
|
protected |
Reads a certain number of bytes from the binary results file.
[out] | var | The memory segment to read into |
[in] | nvals | Number of values (cell) that we want to read |
[in] | bitPos | File position to start reading from |
[in] | cellBits | Number of bits in each cell |
[in] | repeats | Number of values present on file for the variable to read |
The data values associated with a variable is read from the physical file. Note: nvals < repeats is not an error condition (it used to be earlier). It should be allowed to read only a part of a variable, if the user wants to.
|
protected |
Builds and resolves the results hierarchy of the file.
Recursively builds and resolves the file's hierarchy. The return value is the length of one binary line (e.g., one time step) in the file.
Resolving:
void FFrResultContainer::clearPreRead | ( | ) |
Clears the time step cache.
FFrResultContainer::Status FFrResultContainer::close | ( | ) |
Closes the results file of this container, if still open.
void FFrResultContainer::collectGarbage | ( | FFrEntryBase * | entry | ) |
Collects temporary entries to be deleted when parsing finished.
|
inline |
Enables time step pre-read cache.
|
protected |
Reads all data associated with current time step into a cache.
|
inline |
Returns the current status of this results container.
|
inline |
Returns current physical time of this container.
|
inline |
Returns the time stamp of this results container.
double FFrResultContainer::getDistanceFromPosKey | ( | bool | usePositionedKey = false | ) | const |
Returns the difference between current position and the wanted key.
bool FFrResultContainer::getDistanceToNextKey | ( | double & | dist | ) |
Calculates the distance to the next key for this results container.
Calculates the distance to the next key for this container. Returns true if the wanted key (as set with positionAtKey()) is either within or in front of the container values.
Returns false if the wanted key is after the values in the container or if the container is empty.
|
inline |
Returns the file name of this results container.
|
inline |
Returns first physical time of this container.
|
inline |
Returns the size (in bytes) of the results file header.
|
protected |
Returns current, first or last physical time of this container.
|
inline |
Returns last physical time of this container.
|
inline |
Returns a const reference to the time step mapping.
|
inline |
Returns current file position status flag.
|
inline |
Returns the number of time steps in this results container.
|
inline |
Returns the size (in bytes) of the results data of each time step.
|
inline |
Returns true, if the file header has been successfully parsed.
|
inline |
Returns whether the file has been positioned.
|
inline |
Checks if the time step cache is enabled.
|
delete |
Disable default assignment operator.
int FFrResultContainer::positionAtKey | ( | double | key, |
bool | getNextHigher = false |
||
) |
Positions the file to the specified key (physical time).
void FFrResultContainer::printInfo | ( | ) | const |
Prints out some size parameters for this results container.
|
protected |
Prints out sime size parameters for the results file.
|
protected |
Reads the header of the file.
Reads the file header and stores the obtained binary position in the object.
|
inline |
Reads a double variable from the specified position.
|
inline |
Reads a float variable from the specified position.
|
inline |
Reads an integer variable from the specified position.
|
protected |
Reads the file squentially from current file position.
Reads the file from current file position to check if the size has increased. Should be called on initial read and for each new "beep" from other processes.
|
protected |
Reads time step information from the file.
Should be called on initial read and for each new "beep" from other processes.
|
protected |
Reads variable definitions and references.
|
protected |
Reopens the results file for direct access of binary data.
Reopens the results file using low-lewel IO-routines. To handle data files larger than 2GB on Windows.
void FFrResultContainer::resetPositioning | ( | ) |
Resets the file position.
|
inline |
Returns a const reference to the top-level entries container.
FFrResultContainer::Status FFrResultContainer::updateContainerStatus | ( | ) |
Updates the container to a new status (used from the system ticks).
Tries to open the results file, read the header and the time step information in the file. Returns an enum telling the new status of the container.
|
private |
Only move file pointer first time reading data.
|
private |
Read all results for current time step into core.
|
private |
Pointer to what we should read.
|
private |
File handle used for data access.
|
private |
Time stamp of the results file.
|
private |
Result extractor that own this container.
|
private |
File descriptor used in header parsing.
|
private |
File name associated with this result container.
|
private |
Garbage collection container.
|
private |
Binary start position in bytes.
|
private |
Position after the last data read.
|
private |
Program module that wrote the results file.
|
private |
Physical time to results mapping.
|
private |
Pointer to physical time variable.
|
private |
Current file position.
|
private |
Pre-read cache.
|
private |
Current time step in pre-read cache.
|
private |
Current status of the file reading.
|
private |
List of all top-level entries.
|
private |
The physical time to read results for.
|
private |
Is the key inside, exact, front or rear.
|
private |
Endian mismatch?
|
private |
Time step size in bytes (max 2GB)