13 #if !defined(KRATOS_FILE_NAME_DATA_COLLECTOR)
14 #define KRATOS_FILE_NAME_DATA_COLLECTOR
18 #include <unordered_map>
66 const std::string& rFileName,
70 : mFileName(rFileName),
80 void SetFileName(
const std::string& rFileName) { mFileName = rFileName; }
84 void SetRank(
const int Rank) { mRank = Rank; }
88 void SetStep(
const int Step) { mStep = Step; }
92 void SetTime(
const double Time) { mTime = Time; }
114 return (mFileName == rRHS.mFileName && mRank == rRHS.mRank &&
115 mStep == rRHS.mStep && mTime == rRHS.mTime);
124 std::string mFileName =
"";
129 friend class PatternFlag;
182 const std::string& rFileNamePattern,
183 const std::unordered_map<std::string, std::string>& rFlagFormatMap);
197 std::string GetFileName()
const;
207 std::string GetPath()
const;
223 std::vector<std::string> GetSortedFileNamesList(
224 const std::vector<std::string>& rFlagsSortingOrder)
const;
245 bool RetrieveFileNameData(
247 const std::string& rFileNameWithoutPath)
const;
257 std::vector<FileNameData> GetFileNameDataList()
const;
277 static void SortListOfFileNameData(
278 std::vector<FileNameData>& rFileNameDataList,
279 const std::vector<std::string>& rFlagsSortingOrder);
294 static std::pair<bool, std::string> ExtractFileNamePattern(
295 const std::string& rFileName,
296 const std::vector<std::string>& rFlagsList);
310 class KRATOS_API(KRATOS_CORE) PatternFlag
327 const std::string& rPatternFlag,
328 const std::string& rPatternValueFormat =
"");
346 bool UpdateFileNameData(
348 std::size_t& rCurrentPosition,
349 const std::string& rData)
const
351 return (this->*mUpdateData)(rFileNameData, rCurrentPosition, rData);
360 std::string GetValueString(
363 return (this->*mGetValueString)(rModelPart);
375 return (mPatternFlag.front() ==
'<' && mPatternFlag.back() ==
'>');
383 std::string GetPatternFlagString()
const
408 static bool RetrieveIntegerValue(
410 std::size_t& rCurrentPosition,
411 const std::string& rData);
434 static bool RetrieveFloatingPointValue(
436 std::size_t& rCurrentPosition,
437 const std::string& rData);
445 const std::string mPatternFlag;
446 const std::string mPatternValueFormat;
447 bool (PatternFlag::*mUpdateData)(FileNameData& rFileNameData, std::size_t& rCurrentPosition,
const std::string& rData)
const;
448 std::string (PatternFlag::*mGetValueString)(
const ModelPart& rModelPart)
const;
454 bool UpdateRank(FileNameData& rFileNameData, std::size_t& rCurrentPosition,
const std::string& rData)
const;
455 bool UpdateStep(FileNameData& rFileNameData, std::size_t& rCurrentPosition,
const std::string& rData)
const;
456 bool UpdateTime(FileNameData& rFileNameData, std::size_t& rCurrentPosition,
const std::string& rData)
const;
457 bool UpdateCustomString(FileNameData& rFileNameData, std::size_t& rCurrentPosition,
const std::string& rData)
const;
459 std::string GetRankString(
const ModelPart& rModelPart)
const;
460 std::string GetStepString(
const ModelPart& rModelPart)
const;
461 std::string GetTimeString(
const ModelPart& rModelPart)
const;
462 std::string GetCustomString(
const ModelPart& rModelPart)
const;
471 template <
class TDataType>
472 std::string GetFormattedValueString(
473 const TDataType& rData)
const
475 if (mPatternValueFormat ==
"") {
476 return std::to_string(rData);
478 int length = std::snprintf(
nullptr, 0, mPatternValueFormat.c_str(), rData);
481 char* buf =
new char[length + 1];
482 std::snprintf(buf, length + 1, mPatternValueFormat.c_str(), rData);
484 std::string data_str(buf);
499 std::string mFilePath;
500 std::vector<PatternFlag> mFileNamePatternFlags;
512 static std::vector<std::string> GetPatternFlagStrings(
513 const std::string& rPattern);
522 static void FindAndReplace(
523 std::string& rInputString,
524 const std::string& rSearchString,
525 const std::string& rReplaceString);
Definition: file_name_data_collector.h:49
double GetTime() const
Definition: file_name_data_collector.h:94
void SetFileName(const std::string &rFileName)
Definition: file_name_data_collector.h:80
void SetStep(const int Step)
Definition: file_name_data_collector.h:88
int GetStep() const
Definition: file_name_data_collector.h:90
FileNameData()
Definition: file_name_data_collector.h:62
int GetRank() const
Definition: file_name_data_collector.h:86
void Clear()
Definition: file_name_data_collector.h:100
bool operator==(const FileNameData &rRHS)
Definition: file_name_data_collector.h:112
std::string GetFileName() const
Definition: file_name_data_collector.h:82
void SetRank(const int Rank)
Definition: file_name_data_collector.h:84
KRATOS_CLASS_POINTER_DEFINITION(FileNameData)
Pointer definition of FileNameData.
void SetTime(const double Time)
Definition: file_name_data_collector.h:92
FileNameData(const std::string &rFileName, const int Rank, const int Step, const double Time)
Definition: file_name_data_collector.h:65
Definition: file_name_data_collector.h:33
KRATOS_CLASS_POINTER_DEFINITION(FileNameDataCollector)
Pointer definition of FileNameDataCollector.
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
Kratos::ModelPart ModelPart
Definition: kratos_wrapper.h:31
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
REACTION_CHECK_STIFFNESS_FACTOR INNER_LOOP_ITERATION DISTANCE_THRESHOLD ACTIVE_CHECK_FACTOR AUXILIAR_COORDINATES NORMAL_GAP WEIGHTED_GAP WEIGHTED_SCALAR_RESIDUAL bool
Definition: contact_structural_mechanics_application_variables.h:93