KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
|
#include <file_name_data_collector.h>
Classes | |
class | FileNameData |
Public Member Functions | |
Type Definitions | |
KRATOS_CLASS_POINTER_DEFINITION (FileNameDataCollector) | |
Pointer definition of FileNameDataCollector. More... | |
Life Cycle | |
FileNameDataCollector (const ModelPart &rModelPart, const std::string &rFileNamePattern, const std::unordered_map< std::string, std::string > &rFlagFormatMap) | |
Construct a new File Name Information Collector object. More... | |
Public member operations | |
std::string | GetFileName () const |
Get the File Name string. More... | |
std::string | GetPath () const |
Get the Path. More... | |
std::vector< std::string > | GetSortedFileNamesList (const std::vector< std::string > &rFlagsSortingOrder) const |
Gets sorted list of files. More... | |
bool | RetrieveFileNameData (FileNameData &rFileNameData, const std::string &rFileNameWithoutPath) const |
Get filename data. More... | |
std::vector< FileNameData > | GetFileNameDataList () const |
Retrieves list of file name data objects. More... | |
Static Public Member Functions | |
Public static operations | |
static void | SortListOfFileNameData (std::vector< FileNameData > &rFileNameDataList, const std::vector< std::string > &rFlagsSortingOrder) |
Sorts given list of file name data vector. More... | |
static std::pair< bool, std::string > | ExtractFileNamePattern (const std::string &rFileName, const std::vector< std::string > &rFlagsList) |
Extracts file name pattern from a given file name. More... | |
Kratos::FileNameDataCollector::FileNameDataCollector | ( | const ModelPart & | rModelPart, |
const std::string & | rFileNamePattern, | ||
const std::unordered_map< std::string, std::string > & | rFlagFormatMap | ||
) |
Construct a new File Name Information Collector object.
Construct an object which will handle given filename pattern. This rFileNamePattern can incldue folders, subfolders. It must include the file name. Followings are the list of flags supported.
Accepted flags are: "<rank>" : ranks of the model part "<step>" : STEP value in model parts's process info "<time>" : TIME value in model part's process info "<model_part_name>" : name of the model part "<model_part_full_name>": full name of the model part.
Flags "<rank>", "<step>" and "<time>" is only allowed be in the file name only. (Those flags are not allowed to be present in file path)
Example rFileNamePattern:
rFileNamePattern should always have a seperation character/string in between two flags. This seperation character/string can not start with a digit.
rFlagFormatMap holds format for each flag. If no format is specified, then value for that flag will be written without any formatting. Example map: { "<time>": "0.4f", "<step>": "%4d" }
Example formats:
rModelPart | Model part on which this file name data collection is based on |
rFileNamePattern | File name pattern (can have file name with or without file path) |
rFlagFormatMap | Map of formats (key : flag, value: format [both as strings]) |
|
static |
Extracts file name pattern from a given file name.
This method returns the file name pattern matching given order of flags from left to right. If all the given flags are found, this returns true, otherwise false.
Example patterns: Check test_file_name_data_collector.py::test_ExtractFileNamePattern
rFileName | Filename with or without file path |
rFlagsList | List of flags exists in the file name |
std::string Kratos::FileNameDataCollector::GetFileName | ( | ) | const |
Get the File Name string.
This method returns the file name string according to file name pattern and time step format provided in the constructor.
std::vector< FileNameDataCollector::FileNameData > Kratos::FileNameDataCollector::GetFileNameDataList | ( | ) | const |
Retrieves list of file name data objects.
This iterates through the constructor given file name pattern path files, and returns file name data vector containing file name data for matching file names.
std::string Kratos::FileNameDataCollector::GetPath | ( | ) | const |
Get the Path.
This method returns path obtained from the constructor specified pattern
std::vector< std::string > Kratos::FileNameDataCollector::GetSortedFileNamesList | ( | const std::vector< std::string > & | rFlagsSortingOrder | ) | const |
Gets sorted list of files.
This method returns list of file names matching the pattern given in the constructor The list of file names are sorted in the flags order given in rFlagsSortingOrder.
Accepted flags are: "<rank>" : ranks of the model part "<step>" : STEP value in model parts's process info "<time>" : TIME value in model part's process info
rFlagsSortingOrder | Sorting order list of strings |
Kratos::FileNameDataCollector::KRATOS_CLASS_POINTER_DEFINITION | ( | FileNameDataCollector | ) |
Pointer definition of FileNameDataCollector.
bool Kratos::FileNameDataCollector::RetrieveFileNameData | ( | FileNameData & | rFileNameData, |
const std::string & | rFileNameWithoutPath | ||
) | const |
Get filename data.
This will return FileNameData object containing rank, step, time if they are available in the given file name pattern. rFileNameWithoutPath should be only filename without the path.
If the corrensponding rFileNameWithoutPath does not math the pattern given in the constructor then this returns false; otherwise true.
If retrieval is successfully, FileNameData::mFileName will be filled with full file name including the path (specified by the constructor pattern). It will not check for existence of the file in the same path.
rFileNameData | Data retrieved from rFileNameWithoutPath |
rFileNameWithoutPath | File name without file path |
|
static |
Sorts given list of file name data vector.
This method sorts given list of file name data vector according to sorting flags order given in rFlagsSortingOrder.
Accepted flags are: "<rank>" : ranks of the model part "<step>" : STEP value in model parts's process info "<time>" : TIME value in model part's process info
rFileNameDataList | |
rFlagsSortingOrder |