OGS
|
Basic algorithms and helper functions provided for all other libraries.
Namespaces | |
IO | |
Classes | |
class | Range |
Wraps a pair of iterators for use as a range in range-based for-loops. More... | |
class | ConfigTree |
class | ConfigTreeTopLevel |
class | CPUTime |
Count CPU time. More... | |
struct | DynamicSpan |
class | Histogram |
class | MemWatch |
class | RunTime |
Count the running time. More... | |
class | ISubdivision |
class | UniformSubdivision |
class | GradualSubdivision |
class | GradualSubdivisionFixedNum |
class | TCLAPCustomOutput |
struct | TimeInterval |
Functions | |
template<typename T > | |
std::vector< T > | excludeObjectCopy (std::vector< T > const &src_vec, std::vector< std::size_t > const &exclude_positions) |
template<typename T > | |
void | excludeObjectCopy (std::vector< T > const &src_vec, std::vector< std::size_t > const &exclude_positions, std::vector< T > &dest_vec) |
template<typename InputIt , typename Predicate > | |
std::iterator_traits< InputIt >::reference | findElementOrError (InputIt begin, InputIt end, Predicate predicate, std::string const &error="") |
template<typename Map , typename Key , typename Value > | |
void | insertIfTypeIndexKeyUniqueElseError (Map &map, Key const &key, Value &&value, std::string const &error_message) |
template<typename Map , typename Key , typename Value > | |
void | insertIfKeyUniqueElseError (Map &map, Key const &key, Value &&value, std::string const &error_message) |
template<typename Map , typename Key , typename Value > | |
void | insertIfKeyValueUniqueElseError (Map &map, Key const &key, Value &&value, std::string const &error_message) |
template<typename Map , typename Key > | |
Map::mapped_type & | getOrError (Map &map, Key const &key, std::string const &error_message) |
template<typename Map , typename Key > | |
Map::mapped_type const & | getOrError (Map const &map, Key const &key, std::string const &error_message) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
template<typename Container , typename Predicate > | |
Container::value_type const & | getIfOrError (Container const &container, Predicate &&predicate, std::string const &error_message) |
template<typename T > | |
void | makeVectorUnique (std::vector< T > &v) |
template<typename T , class Compare > | |
void | makeVectorUnique (std::vector< T > &v, Compare comp) |
template<typename ValueType , typename IndexType > | |
void | reorderVector (std::vector< ValueType > &v, std::vector< IndexType > const &order) |
template<typename Container > | |
void | uniquePushBack (Container &container, typename Container::value_type const &element) |
template<typename Container > | |
bool | contains (Container const &container, typename Container::value_type const &element) |
template<typename Container , typename Predicate > | |
bool | containsIf (Container const &container, Predicate &&predicate) |
template<typename Container > | |
std::optional< typename Container::value_type > | findFirstNotEqualElement (Container const &container, typename Container::value_type const &element) |
template<typename Container > | |
std::size_t | findIndex (Container const &container, typename Container::value_type const &element) |
template<typename T1 , typename T2 > | |
void | cleanupVectorElements (std::vector< T1 * > const &items, std::vector< T2 * > const &dependent_items) |
void | checkAndInvalidate (ConfigTree &conf) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
void | checkAndInvalidate (ConfigTree *const conf) |
void | checkAndInvalidate (std::unique_ptr< ConfigTree > const &conf) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
template<typename T > | |
void | traverse_recursive (boost::property_tree::ptree &parent, boost::property_tree::ptree::path_type const &child_path, boost::property_tree::ptree &child, fs::path const &bench_dir, T &method) |
template<typename T > | |
void | traverse (boost::property_tree::ptree &parent, const fs::path bench_dir, T &method) |
void | replaceIncludes ([[maybe_unused]] boost::property_tree::ptree const &parent, [[maybe_unused]] boost::property_tree::ptree::path_type const &child_path, boost::property_tree::ptree &child, fs::path const &bench_dir) |
void | patchStream (std::string patch_file, std::stringstream &prj_stream) |
void | readAndPatchPrj (std::stringstream &prj_stream, std::string &prj_file, std::vector< std::string > patch_files) |
ConfigTreeTopLevel | makeConfigTree (const std::string &filepath, const bool be_ruthless, const std::string &toplevel_tag, const std::vector< std::string > &patch_files) |
template<typename E > | |
constexpr auto | to_underlying (E e) noexcept |
Converts an enumeration to its underlying type. More... | |
int | date2int (int y, int m, int d) |
std::string | int2date (int date) |
std::string | date2string (double ddate) |
int | strDate2int (const std::string &s) |
int | xmlDate2int (const std::string &s) |
std::string | formatDate (std::chrono::time_point< std::chrono::system_clock > const &time) |
bool | isProjectDirectorySet () |
Returns true if the project directory is set. More... | |
bool | IsFileExisting (const std::string &strFilename) |
Returns true if given file exists. More... | |
std::tuple< std::string, std::string::size_type, std::string::size_type > | getParenthesizedString (std::string const &in, char const open_char, char const close_char, std::string::size_type pos) |
std::string | containsKeyword (std::string const &str, std::string const &keyword) |
template<typename T > | |
bool | substituteKeyword (std::string &result, std::string &parenthesized_string, std::string::size_type begin, std::string::size_type end, std::string const &keyword, T &data) |
std::string | constructFormattedFileName (std::string const &format_specification, std::string const &mesh_name, int const timestep, double const t, int const iteration) |
double | swapEndianness (double const &v) |
std::string | dropFileExtension (std::string const &filename) |
std::string | extractBaseName (std::string const &pathname) |
std::string | extractBaseNameWithoutExtension (std::string const &pathname) |
std::string | getFileExtension (const std::string &path) |
bool | hasFileExtension (std::string const &extension, std::string const &filename) |
std::string | copyPathToFileName (const std::string &file_name, const std::string &source) |
std::string | extractPath (std::string const &pathname) |
std::string | joinPaths (std::string const &pathA, std::string const &pathB) |
std::string const & | getProjectDirectory () |
Returns the directory where the prj file resides. More... | |
void | setProjectDirectory (std::string const &dir) |
Sets the project directory. More... | |
void | removeFile (std::string const &filename) |
void | removeFiles (std::vector< std::string > const &files) |
template<typename T > | |
void | writeValueBinary (std::ostream &out, T const &val) |
write value as binary into the given output stream More... | |
template<typename T > | |
T | swapEndianness (T const &v) |
template<typename T > | |
T | readBinaryValue (std::istream &in) |
template<typename T > | |
std::vector< T > | readBinaryArray (std::string const &filename, std::size_t const n) |
template<typename T > | |
std::ostream & | operator<< (std::ostream &os, const Histogram< T > &h) |
void | setConsoleLogLevel (std::string const &level_string) |
template<typename It1 , typename It2 , typename Comparator > | |
void | quicksort (It1 first1, It1 last1, It2 first2, Comparator compare) |
template<typename It1 , typename It2 > | |
void | quicksort (It1 first1, It1 last1, It2 first2) |
template<typename T1 , typename T2 = std::size_t> | |
void | quicksort (T1 *array, std::size_t beg, std::size_t end, T2 *perm) |
template<typename T1 , typename T2 = std::size_t> | |
void | quicksort (std::vector< T1 > &array, std::size_t beg, std::size_t end, std::vector< T2 > &perm) |
template<typename T1 , typename T2 = std::size_t> | |
void | quicksort (std::vector< T1 * > &array, std::size_t beg, std::size_t end, std::vector< T2 > &perm) |
std::vector< std::string > | splitString (std::string const &str) |
std::list< std::string > | splitString (const std::string &str, char delim) |
std::string | replaceString (const std::string &searchString, const std::string &replaceString, std::string stringToReplace) |
void | trim (std::string &str, char ch) |
void | simplify (std::string &str) |
std::string | format (const char *format_str,...) |
std::string | randomString (std::size_t length) |
Returns a random string of the given length containing just a-z,A-Z,0-9. More... | |
std::string | getUniqueName (std::vector< std::string > const &existing_names, std::string const &input_name) |
Append '-' and a number such that the name is unique. More... | |
template<typename T > | |
T | str2number (const std::string &str) |
TimeInterval | createTimeInterval (ConfigTree const &config) |
Variables | |
std::shared_ptr< spdlog::logger > | console = spdlog::stdout_color_mt("ogs") |
void BaseLib::checkAndInvalidate | ( | ConfigTree & | conf | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 470 of file ConfigTree.cpp.
Referenced by BaseLib::ConfigTreeTopLevel::checkAndInvalidate().
void BaseLib::checkAndInvalidate | ( | ConfigTree *const | conf | ) |
Check if conf
has been read entirely and invalidate it.
This method can safely be called on nullptr's
.
Definition at line 475 of file ConfigTree.cpp.
void BaseLib::checkAndInvalidate | ( | std::unique_ptr< ConfigTree > const & | conf | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 483 of file ConfigTree.cpp.
void BaseLib::cleanupVectorElements | ( | std::vector< T1 * > const & | items, |
std::vector< T2 * > const & | dependent_items | ||
) |
Util function to cleanup vectors
Definition at line 300 of file Algorithm.h.
Referenced by FileIO::SwmmInterface::convertSwmmInputToGeometry(), FileIO::Gocad::GocadAsciiReader::createMesh(), FileIO::GMSInterface::readGMS3DMMesh(), FileIO::TetGenInterface::readTetGenMesh(), and MeshLib::MeshRevision::simplifyMesh().
std::string BaseLib::constructFormattedFileName | ( | std::string const & | format_specification, |
std::string const & | mesh_name, | ||
int const | timestep, | ||
double const | t, | ||
int const | iteration | ||
) |
Definition at line 116 of file FileTools.cpp.
References getParenthesizedString(), and substituteKeyword().
Referenced by ProcessLib::Output::OutputFile::constructFilename(), and anonymous_namespace{Output.cpp}::constructPVDName().
bool BaseLib::contains | ( | Container const & | container, |
typename Container::value_type const & | element | ||
) |
Definition at line 256 of file Algorithm.h.
Referenced by ProcessLib::LIE::duGlobalEnrichments(), and MaterialLib::Solids::MFront::getEquivalentPlasticStrainOffset().
bool BaseLib::containsIf | ( | Container const & | container, |
Predicate && | predicate | ||
) |
std::string BaseLib::containsKeyword | ( | std::string const & | str, |
std::string const & | keyword | ||
) |
std::string BaseLib::copyPathToFileName | ( | const std::string & | file_name, |
const std::string & | source | ||
) |
Checks if file_name already contains a qualified path and if not copies the path from source.
Definition at line 196 of file FileTools.cpp.
Referenced by ProjectData::ProjectData(), anonymous_namespace{ProjectData.cpp}::readMeshes(), anonymous_namespace{ProjectData.cpp}::readSingleMesh(), and GeoLib::IO::XmlStnInterface::readStations().
TimeInterval BaseLib::createTimeInterval | ( | ConfigTree const & | config | ) |
Definition at line 21 of file TimeInterval.cpp.
References BaseLib::ConfigTree::getConfigParameter(), and BaseLib::ConfigTree::getConfigSubtree().
Referenced by ProcessLib::createDirichletBoundaryConditionWithinTimeInterval().
int BaseLib::date2int | ( | int | y, |
int | m, | ||
int | d | ||
) |
Converts three integers representing a date into a double. Note: It is not really checked if the date actually makes sense.
Definition at line 26 of file DateTools.cpp.
References WARN().
Referenced by strDate2int(), and xmlDate2int().
std::string BaseLib::date2string | ( | double | ddate | ) |
Converts a double representing a date into a string. Note: It is not really checked if the date actually makes sense.
ddate | Number containing date in double format yyyymmdd |
Definition at line 65 of file DateTools.cpp.
References WARN().
Referenced by GeoLib::IO::XmlStnInterface::writeBoreholeData().
std::string BaseLib::dropFileExtension | ( | std::string const & | filename | ) |
Returns a string with file extension as found by getFileExtension() dropped.
Definition at line 169 of file FileTools.cpp.
Referenced by convert(), extractBaseNameWithoutExtension(), VtkRaster::findWorldFile(), identifyAndWriteBoundaryMeshes(), main(), FileIO::Gocad::GocadAsciiReader::readFile(), MeshLib::IO::readMeshFromFile(), writeCsvOutput(), and writeMeshOutput().
std::vector<T> BaseLib::excludeObjectCopy | ( | std::vector< T > const & | src_vec, |
std::vector< std::size_t > const & | exclude_positions | ||
) |
excludeObjectCopy copies only those objects that position within the source vector is not in the exclude_positions vector. The implementation of the algorithm requires that the given positions in exclude_positions are sorted in ascending order.
src_vec | the vector of source objects |
exclude_positions | the positions of objects in the source vector that do not have to be copied |
Definition at line 33 of file Algorithm.h.
References MathLib::LinAlg::copy().
Referenced by MeshLib::PropertyVector< PROP_VAL_TYPE >::clone(), MeshLib::PropertyVector< T * >::clone(), and excludeObjectCopy().
void BaseLib::excludeObjectCopy | ( | std::vector< T > const & | src_vec, |
std::vector< std::size_t > const & | exclude_positions, | ||
std::vector< T > & | dest_vec | ||
) |
Definition at line 61 of file Algorithm.h.
References excludeObjectCopy().
std::string BaseLib::extractBaseName | ( | std::string const & | pathname | ) |
Extracts basename from given pathname with extension.
Returns a string containing everything after the last path separator. If the the pathname does not contain a path separator original pathname is returned.
Definition at line 175 of file FileTools.cpp.
Referenced by OGSFileConverter::convertGLI2GML(), extractBaseNameWithoutExtension(), OGSFileConverter::fileExists(), MeshLib::IO::getVtuFileNameForPetscOutputWithoutExtension(), anonymous_namespace{postLIE.cpp}::postPVD(), FileIO::Legacy::readGLIFileV4(), and MeshLib::IO::NodePartitionedMeshReader::readMesh().
std::string BaseLib::extractBaseNameWithoutExtension | ( | std::string const & | pathname | ) |
Extracts basename from given pathname without its extension.
Same as extractBaseName(), but drops the file extension too.
Definition at line 180 of file FileTools.cpp.
References dropFileExtension(), and extractBaseName().
Referenced by FileIO::SwmmInterface::convertSwmmInputToGeometry(), anonymous_namespace{TestDefinition.cpp}::findVtkdiff(), FileIO::Gocad::GocadSGridReader::getMesh(), MeshLib::IO::Legacy::MeshIO::loadMeshFromFile(), main(), FileIO::FEFLOWMeshInterface::readFEFLOWFile(), FileIO::FEFLOWGeoInterface::readFEFLOWFile(), FileIO::GMSInterface::readGMS3DMMesh(), FileIO::GMSH::readGMSHMesh(), FileIO::TetGenInterface::readTetGenGeometry(), FileIO::TetGenInterface::readTetGenMesh(), MeshLib::IO::VtuInterface::readVTKFile(), MeshLib::IO::VtuInterface::readVTUFile(), and writeGeoOutput().
std::string BaseLib::extractPath | ( | std::string const & | pathname | ) |
Extracts the path of a pathname.
Returns a string up to the last path separator not including it.
Definition at line 207 of file FileTools.cpp.
Referenced by MeshLib::IO::getVtuFileNameForPetscOutputWithoutExtension(), main(), anonymous_namespace{postLIE.cpp}::postPVD(), readAndPatchPrj(), FileIO::Legacy::readGLIFileV4(), FileIO::Legacy::writeAllDataToGLIFileV4(), and FileIO::Legacy::writeGLIFileV4().
std::iterator_traits<InputIt>::reference BaseLib::findElementOrError | ( | InputIt | begin, |
InputIt | end, | ||
Predicate | predicate, | ||
std::string const & | error = "" |
||
) |
Definition at line 69 of file Algorithm.h.
References OGS_FATAL.
Referenced by MaterialPropertyLib::Phase::component(), ParameterLib::createParameter(), ProcessLib::SurfaceFluxData::createSurfaceFluxData(), ProcessLib::Output::doOutputAlways(), anonymous_namespace{ProcessVariable.cpp}::findMeshInConfig(), ProjectData::parseProcessVariables(), and MaterialPropertyLib::Medium::phase().
std::optional<typename Container::value_type> BaseLib::findFirstNotEqualElement | ( | Container const & | container, |
typename Container::value_type const & | element | ||
) |
Definition at line 271 of file Algorithm.h.
Referenced by ProcessLib::LIE::PostProcessTool::PostProcessTool().
std::size_t BaseLib::findIndex | ( | Container const & | container, |
typename Container::value_type const & | element | ||
) |
Returns the index of first element in container or, if the element is not found a std::size_t maximum value.
The maximum value of std::size_t is chosen, because such an index cannot exist in a container; the maximum index is std::size_t::max-1.
Definition at line 287 of file Algorithm.h.
Referenced by ProcessLib::LIE::PostProcessTool::PostProcessTool(), and ProcessLib::ComponentTransport::LookupTable::getTableEntryID().
std::string BaseLib::format | ( | const char * | format_str, |
... | |||
) |
Definition at line 85 of file StringTools.cpp.
Referenced by MeshLib::IO::getPropertyDataTypeSize(), main(), substituteKeyword(), and MeshLib::IO::write_xdmf().
std::string BaseLib::formatDate | ( | std::chrono::time_point< std::chrono::system_clock > const & | time | ) |
Formats the given time point according to RFC 3339 (cf. man-page of the unix date utility).
Example: 2006-08-14 02:34:56-06:00
Definition at line 137 of file DateTools.cpp.
Referenced by main().
std::string BaseLib::getFileExtension | ( | std::string const & | path | ) |
Extract extension from filename
Definition at line 186 of file FileTools.cpp.
Referenced by VtkVisImageItem::callVTKWriter(), VtkVisPointSetItem::callVTKWriter(), convert(), MeshLib::IO::getVtuFileNameForPetscOutputWithoutExtension(), hasFileExtension(), identifyAndWriteBoundaryMeshes(), FileIO::SwmmInterface::isSwmmInputFile(), main(), readAndPatchPrj(), FileIO::readGeometryFromFile(), FileIO::AsciiRasterInterface::readRaster(), FileIO::TetGenInterface::readTetGenGeometry(), writeCsvOutput(), FileIO::writeGeometryToFile(), and writeMeshOutput().
Container::value_type const& BaseLib::getIfOrError | ( | Container const & | container, |
Predicate && | predicate, | ||
std::string const & | error_message | ||
) |
Returns the value of from the given container
if such an entry fulfilling the predicate
exists; otherwise an error_message
is printed and the program is aborted.
Definition at line 192 of file Algorithm.h.
References OGS_FATAL.
Referenced by ProcessLib::createPerProcessData().
Map::mapped_type& BaseLib::getOrError | ( | Map & | map, |
Key const & | key, | ||
std::string const & | error_message | ||
) |
Returns the value of key
from the given map
if such an entry exists; otherwise an error_message
is printed and the program is aborted. Cf. also the const overload below.
Definition at line 147 of file Algorithm.h.
References OGS_FATAL.
Referenced by MaterialPropertyLib::createCurve(), ProcessLib::HeatTransportBHE::BHE::createFlowAndTemperatureControl(), ProcessLib::createPerProcessData(), ProjectData::parseNonlinearSolvers(), and ProcessLib::parseTimeIntervalOrCurve().
Map::mapped_type const& BaseLib::getOrError | ( | Map const & | map, |
Key const & | key, | ||
std::string const & | error_message | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 168 of file Algorithm.h.
References OGS_FATAL.
std::tuple< std::string, std::string::size_type, std::string::size_type > BaseLib::getParenthesizedString | ( | std::string const & | in, |
char const | open_char, | ||
char const | close_char, | ||
std::string::size_type | pos | ||
) |
Returns the begin and end position of the string enclosed in open_char and close_char and the enclosed string itself. Search starts at position pos within the string str. Nested open_char and close_char are not handled correctly.
Definition at line 49 of file FileTools.cpp.
Referenced by constructFormattedFileName().
std::string const & BaseLib::getProjectDirectory | ( | ) |
Returns the directory where the prj file resides.
Definition at line 217 of file FileTools.cpp.
References OGS_FATAL, anonymous_namespace{FileTools.cpp}::project_directory, and anonymous_namespace{FileTools.cpp}::project_directory_is_set.
Referenced by ChemistryLib::createChemicalSolverInterface< ChemicalSolver::Phreeqc >(), ProcessLib::ComponentTransport::createLookupTable(), MaterialLib::Solids::MFront::createMFront(), and main().
std::string BaseLib::getUniqueName | ( | std::vector< std::string > const & | existing_names, |
std::string const & | input_name | ||
) |
Append '-' and a number such that the name is unique.
Definition at line 120 of file StringTools.cpp.
Referenced by GeoLib::GEOObjects::isUniquePointVecName(), MeshLib::RasterDataToMesh::projectToElements(), and MeshLib::RasterDataToMesh::projectToNodes().
bool BaseLib::hasFileExtension | ( | std::string const & | extension, |
std::string const & | filename | ||
) |
Compares filename's extension with query extension. The comparison is case insensitive.
Definition at line 191 of file FileTools.cpp.
References getFileExtension().
Referenced by main(), and anonymous_namespace{readMeshFromFile.cpp}::readMeshFromFileSerial().
void BaseLib::insertIfKeyUniqueElseError | ( | Map & | map, |
Key const & | key, | ||
Value && | value, | ||
std::string const & | error_message | ||
) |
Inserts the given key
with the given value
into the map
if an entry with the given key
does not yet exist; otherwise an error_message
is printed and the program is aborted.
Definition at line 106 of file Algorithm.h.
References OGS_FATAL.
Referenced by ProcessLib::SecondaryVariableCollection::addNameMapping(), ProjectData::parseCurves(), ProjectData::parseLinearSolvers(), ProjectData::parseNonlinearSolvers(), GeoLib::IO::BoostXmlGmlInterface::readPoints(), GeoLib::IO::BoostXmlGmlInterface::readPolylines(), and GeoLib::IO::BoostXmlGmlInterface::readSurfaces().
void BaseLib::insertIfKeyValueUniqueElseError | ( | Map & | map, |
Key const & | key, | ||
Value && | value, | ||
std::string const & | error_message | ||
) |
Inserts the given key
with the given value
into the map
if neither an entry with the given key
nor an entry with the given value
already exists; otherwise an error_message
is printed and the program is aborted.
Definition at line 121 of file Algorithm.h.
References OGS_FATAL.
void BaseLib::insertIfTypeIndexKeyUniqueElseError | ( | Map & | map, |
Key const & | key, | ||
Value && | value, | ||
std::string const & | error_message | ||
) |
Inserts the given key
with the given value
into the map
if an entry with the given key
does not yet exist; otherwise an error_message
is printed and the program is aborted. Note: The type of key
must be std::type_index.
Definition at line 88 of file Algorithm.h.
References OGS_FATAL.
std::string BaseLib::int2date | ( | int | date | ) |
Converts an integer to a string date "dd.mm.yyyy" Note: (Almost) no checks are performed if the int makes sense as a date.
Definition at line 42 of file DateTools.cpp.
Referenced by DiagramList::readList().
bool BaseLib::IsFileExisting | ( | const std::string & | strFilename | ) |
Returns true if given file exists.
Returns true if given file exists.
strFilename | the file name |
Definition at line 43 of file FileTools.cpp.
Referenced by ChemistryLib::createChemicalSolverInterface< ChemicalSolver::Phreeqc >(), ProcessLib::ComponentTransport::createLookupTable(), anonymous_namespace{TestDefinition.cpp}::findVtkdiff(), anonymous_namespace{postLIE.cpp}::postPVD(), MeshLib::IO::NodePartitionedMeshReader::read(), readAndPatchPrj(), MeshLib::IO::VtuInterface::readVTKFile(), and MeshLib::IO::VtuInterface::readVTUFile().
bool BaseLib::isProjectDirectorySet | ( | ) |
Returns true if the project directory is set.
Definition at line 35 of file FileTools.cpp.
References anonymous_namespace{FileTools.cpp}::project_directory_is_set.
std::string BaseLib::joinPaths | ( | std::string const & | pathA, |
std::string const & | pathB | ||
) |
Concat two paths. Does not check for validity.
Definition at line 212 of file FileTools.cpp.
Referenced by ApplicationsLib::TestDefinition::TestDefinition(), anonymous_namespace{Output.cpp}::constructPVDName(), ChemistryLib::createChemicalSolverInterface< ChemicalSolver::Phreeqc >(), ProcessLib::ComponentTransport::createLookupTable(), MaterialLib::Solids::MFront::createMFront(), ProcessLib::Output::doOutputNonlinearIteration(), anonymous_namespace{TestDefinition.cpp}::findVtkdiff(), MeshLib::IO::getVtuFileNameForPetscOutputWithoutExtension(), main(), anonymous_namespace{postLIE.cpp}::postPVD(), readAndPatchPrj(), FileIO::Legacy::readPolyline(), FileIO::Legacy::readPolylinePointVector(), FileIO::Legacy::readSurface(), and FileIO::Legacy::writeTINSurfaces().
ConfigTreeTopLevel BaseLib::makeConfigTree | ( | std::string const & | filepath, |
bool const | be_ruthless, | ||
std::string const & | toplevel_tag, | ||
const std::vector< std::string > & | patch_files = {} |
||
) |
Create a ConfigTree from an XML file.
filepath | see ConfigTreeTopLevel::ConfigTreeTopLevel() |
be_ruthless | see ConfigTreeTopLevel::ConfigTreeTopLevel() |
toplevel_tag | name of the outermost tag in the XML file. The returned ConfigTree is rooted one level below that tag. |
patch_files | optional vector of strings with patch file paths. |
The parameter toplevel_tag
is provided for compatibility with our existing configuration files whose toplevel tags are written in camel case, which conflicts with the naming rules of ConfigTree. Via that parameter the naming rules do not apply to the toplevel tag.
Unfortunately the XML parser shipped with boost::property_tree
does not fully support the XML standard. Additionally there might be encoding issues. From their docs:
Please note that RapidXML does not understand the encoding specification.
If you pass it a > character buffer, it assumes the data is already correctly encoded; if you pass it a filename, > it will read the file using the character conversion of the locale you give it (or the global > locale if you give it none). This means that, in order to parse a UTF-8-encoded XML file into > a wptree, you have to supply an alternate locale, either directly or by replacing the global one.
Definition at line 242 of file ConfigTreeUtil.cpp.
References DBUG(), OGS_FATAL, readAndPatchPrj(), replaceIncludes(), and traverse().
Referenced by main(), and GeoLib::IO::BoostXmlGmlInterface::readFile().
void BaseLib::makeVectorUnique | ( | std::vector< T > & | v | ) |
Make the entries of the std::vector v
unique. The remaining entries will be sorted.
Definition at line 209 of file Algorithm.h.
Referenced by MaterialPropertyLib::collectVariables(), ProcessLib::ComponentTransport::createLookupTable(), ProcessLib::createOutput(), ProcessLib::LIE::anonymous_namespace{MeshUtils.cpp}::findFracutreIntersections(), ProcessLib::findProcessVariables(), MeshLib::getBaseNodes(), ProcessLib::HeatTransportBHE::getBHEDataInMesh(), MeshGeoToolsLib::getCandidateElementsForLineSegmentIntersection(), ProcessLib::LIE::getFractureMatrixDataInMesh(), MeshGeoToolsLib::mapLineSegment(), reorderNonlinearNodes(), and MeshLib::ElementSearch::searchByNodeIDs().
void BaseLib::makeVectorUnique | ( | std::vector< T > & | v, |
Compare | comp | ||
) |
Make the entries of the std::vector v
unique using the given binary function. The remaining entries will be sorted.
Definition at line 219 of file Algorithm.h.
std::ostream& BaseLib::operator<< | ( | std::ostream & | os, |
const Histogram< T > & | h | ||
) |
Writes histogram to output stream.
Writes histogram properties in this order: number of bins, minimum, maximum, bin0 count, ..., binN-1 count.
Definition at line 203 of file Histogram.h.
References MathLib::LinAlg::copy(), BaseLib::Histogram< T >::getBinCounts(), BaseLib::Histogram< T >::getMaximum(), BaseLib::Histogram< T >::getMinimum(), and BaseLib::Histogram< T >::getNumberOfBins().
void BaseLib::patchStream | ( | std::string | patch_file, |
std::stringstream & | prj_stream | ||
) |
Definition at line 119 of file ConfigTreeUtil.cpp.
References OGS_FATAL.
Referenced by readAndPatchPrj().
void BaseLib::quicksort | ( | It1 | first1, |
It1 | last1, | ||
It2 | first2 | ||
) |
Definition at line 52 of file quicksort.h.
References quicksort().
void BaseLib::quicksort | ( | It1 | first1, |
It1 | last1, | ||
It2 | first2, | ||
Comparator | compare | ||
) |
Definition at line 26 of file quicksort.h.
Referenced by quicksort(), and GeoLib::Polygon::splitPolygonAtPoint().
void BaseLib::quicksort | ( | std::vector< T1 * > & | array, |
std::size_t | beg, | ||
std::size_t | end, | ||
std::vector< T2 > & | perm | ||
) |
Definition at line 83 of file quicksort.h.
void BaseLib::quicksort | ( | std::vector< T1 > & | array, |
std::size_t | beg, | ||
std::size_t | end, | ||
std::vector< T2 > & | perm | ||
) |
void BaseLib::quicksort | ( | T1 * | array, |
std::size_t | beg, | ||
std::size_t | end, | ||
T2 * | perm | ||
) |
Definition at line 64 of file quicksort.h.
References quicksort().
std::string BaseLib::randomString | ( | std::size_t const | length | ) |
Returns a random string of the given length containing just a-z,A-Z,0-9.
Definition at line 102 of file StringTools.cpp.
Referenced by FileIO::createSurface().
void BaseLib::readAndPatchPrj | ( | std::stringstream & | prj_stream, |
std::string & | prj_file, | ||
std::vector< std::string > | patch_files | ||
) |
Definition at line 186 of file ConfigTreeUtil.cpp.
References DBUG(), ERR(), extractPath(), getFileExtension(), IsFileExisting(), joinPaths(), OGS_FATAL, and patchStream().
Referenced by makeConfigTree().
std::vector<T> BaseLib::readBinaryArray | ( | std::string const & | filename, |
std::size_t const | n | ||
) |
T BaseLib::readBinaryValue | ( | std::istream & | in | ) |
Definition at line 89 of file FileTools.h.
void BaseLib::removeFile | ( | std::string const & | filename | ) |
Removes a file. If a file does not exist nothing will happen, other errors lead to OGS_FATAL call.
Definition at line 236 of file FileTools.cpp.
References DBUG().
Referenced by MainWindow::callGMSH(), consolidateGeometry(), main(), and removeFiles().
void BaseLib::removeFiles | ( | std::vector< std::string > const & | files | ) |
Remove files. If a file does not exist nothing will happen, other errors lead to OGS_FATAL call.
Definition at line 245 of file FileTools.cpp.
References removeFile().
Referenced by main().
void BaseLib::reorderVector | ( | std::vector< ValueType > & | v, |
std::vector< IndexType > const & | order | ||
) |
Reorder a vector by a given index vector.
Note: It is good enough in performance for medium size vectors.
Definition at line 232 of file Algorithm.h.
Referenced by MaterialLib::PorousMedium::createPorousMediaProperties(), MaterialLib::TwoPhaseFlowWithPP::createTwoPhaseFlowMaterialProperties(), and ProcessLib::TwoPhaseFlowWithPrho::createTwoPhaseFlowPrhoMaterialProperties().
void BaseLib::replaceIncludes | ( | [[maybe_unused] ] boost::property_tree::ptree const & | parent, |
[[maybe_unused] ] boost::property_tree::ptree::path_type const & | child_path, | ||
boost::property_tree::ptree & | child, | ||
fs::path const & | bench_dir | ||
) |
Definition at line 79 of file ConfigTreeUtil.cpp.
References INFO().
Referenced by makeConfigTree().
std::string BaseLib::replaceString | ( | const std::string & | searchString, |
const std::string & | replaceString, | ||
std::string | stringToReplace | ||
) |
Replaces a substring with another in a string
searchString | Search for this string |
replaceString | Replace with this string |
stringToReplace | Search and replace in this string |
Definition at line 50 of file StringTools.cpp.
Referenced by GeoLib::Station::createStation(), FileIO::FEFLOWMeshInterface::getIndexList(), FileIO::readDoubleFromStream(), and DiagramList::readList().
void BaseLib::setConsoleLogLevel | ( | std::string const & | level_string | ) |
void BaseLib::setProjectDirectory | ( | std::string const & | dir | ) |
Sets the project directory.
Definition at line 226 of file FileTools.cpp.
References OGS_FATAL, anonymous_namespace{FileTools.cpp}::project_directory, and anonymous_namespace{FileTools.cpp}::project_directory_is_set.
Referenced by main().
void BaseLib::simplify | ( | std::string & | str | ) |
Removes multiple whitespaces (or other characters) from within a string. Equivalent functionality to Qt::QString::simplify().
Definition at line 76 of file StringTools.cpp.
References trim().
Referenced by FileIO::TetGenInterface::getNFacets(), FileIO::TetGenInterface::parseSmeshFacets(), FileIO::TetGenInterface::readElementsFromStream(), and FileIO::TetGenInterface::readNodesFromStream().
std::list< std::string > BaseLib::splitString | ( | const std::string & | str, |
char | delim | ||
) |
Splits a string into a list of strings.
str | String to be split |
delim | Character indicating that the string should be split |
Definition at line 38 of file StringTools.cpp.
std::vector< std::string > BaseLib::splitString | ( | std::string const & | str | ) |
Splits a string into a vector of strings. This method only works for string separation recognised by the std::stringstream iterator such as ' ' or '\t'.
str | String to be split |
Definition at line 28 of file StringTools.cpp.
References MathLib::LinAlg::copy().
Referenced by FileIO::SwmmInterface::addPointElevation(), FileIO::SwmmInterface::addRainGaugeTimeSeriesLocations(), GeoLib::Station::createStation(), FileIO::CsvInterface::findColumn(), FileIO::CsvInterface::getColumnNames(), FileIO::FEFLOWMeshInterface::getIndexList(), FileIO::TetGenInterface::getNFacets(), FileIO::Gocad::GocadAsciiReader::parseLine(), FileIO::Gocad::GocadAsciiReader::parseNodes(), FileIO::TetGenInterface::parseNodesFileHeader(), FileIO::Gocad::GocadAsciiReader::parseProperties(), FileIO::TetGenInterface::parseSmeshFacets(), FileIO::Gocad::GocadAsciiReader::parseSurface(), FileIO::Gocad::GocadAsciiReader::propertyCheck(), FileIO::GMSInterface::readBoreholesFromGMS(), FileIO::CsvInterface::readColumn(), FileIO::SwmmInterface::readCoordinates(), FileIO::Gocad::GocadAsciiReader::readData(), SensorData::readDataFromFile(), FileIO::FEFLOWMeshInterface::readElevation(), FileIO::SwmmInterface::readLineElements(), FileIO::SwmmInterface::readLinksAsPolylines(), FileIO::SwmmInterface::readNodeData(), FileIO::PetrelInterface::readPetrelWellTrace(), FileIO::PetrelInterface::readPetrelWellTraceData(), FileIO::CsvInterface::readPoints(), FileIO::SwmmInterface::readPollutants(), FileIO::SwmmInterface::readPolygons(), FileIO::SwmmInterface::readSubcatchments(), and splitMaterialIdString().
T BaseLib::str2number | ( | const std::string & | str | ) |
Converts a string into a number (double, float, int, ...) Example: std::size_t number (str2number<std::size_t> (str));
str | string to be converted |
Definition at line 59 of file StringTools.h.
int BaseLib::strDate2int | ( | const std::string & | s | ) |
Converts a string containing a date into a double. Note: It is not really checked if the date actually makes sense.
s | String containing the date, the expected format is "dd.mm.yyyy". |
Definition at line 102 of file DateTools.cpp.
References date2int().
Referenced by SensorData::readDataFromFile().
bool BaseLib::substituteKeyword | ( | std::string & | result, |
std::string & | parenthesized_string, | ||
std::string::size_type | begin, | ||
std::string::size_type | end, | ||
std::string const & | keyword, | ||
T & | data | ||
) |
Definition at line 82 of file FileTools.cpp.
References containsKeyword(), and format().
Referenced by constructFormattedFileName().
double BaseLib::swapEndianness | ( | double const & | v | ) |
Definition at line 147 of file FileTools.cpp.
References MaterialPropertyLib::c.
Referenced by FileIO::Gocad::GocadSGridReader::readNodesBinary().
T BaseLib::swapEndianness | ( | T const & | v | ) |
|
constexprnoexcept |
Converts an enumeration to its underlying type.
e | Enumeration value to convert |
https://en.cppreference.com/w/cpp/utility/to_underlying Implementation from Scott Meyers : Modern effective c++ , Item 10 Scoped enums
Definition at line 30 of file cpp23.h.
Referenced by MeshLib::IO::cellTypeOGS2XDMF(), MeshLib::IO::elemOGSTypeToXDMFType(), MeshLib::IO::getPropertyDataTypeSize(), MeshLib::IO::getPropertyDataTypeString(), MeshLib::IO::meshPropertyDatatypeSize(), and MeshLib::IO::meshPropertyDatatypeString().
void BaseLib::traverse | ( | boost::property_tree::ptree & | parent, |
const fs::path | bench_dir, | ||
T & | method | ||
) |
Definition at line 73 of file ConfigTreeUtil.cpp.
References traverse_recursive().
Referenced by makeConfigTree().
void BaseLib::traverse_recursive | ( | boost::property_tree::ptree & | parent, |
boost::property_tree::ptree::path_type const & | child_path, | ||
boost::property_tree::ptree & | child, | ||
fs::path const & | bench_dir, | ||
T & | method | ||
) |
void BaseLib::trim | ( | std::string & | str, |
char | ch = ' ' |
||
) |
Strip whitespace (or other characters) from the beginning and end of a string. Equivalent functionality to Qt::QString::trim().
Definition at line 58 of file StringTools.cpp.
Referenced by FileIO::FEFLOWMeshInterface::getIndexList(), getValue(), getVariables(), MeshLib::IO::Legacy::MeshIO::loadMeshFromFile(), FileIO::Gocad::parseGocadPropertyMetaData(), FileIO::Gocad::GocadAsciiReader::parseHeader(), FileIO::Gocad::parseName(), FileIO::FEFLOWMeshInterface::readELEMENTALSETS(), FileIO::FEFLOWMeshInterface::readElevation(), BaseLib::IO::readStringListFromFile(), FileIO::FEFLOWGeoInterface::readSuperMesh(), and simplify().
void BaseLib::uniquePushBack | ( | Container & | container, |
typename Container::value_type const & | element | ||
) |
Definition at line 245 of file Algorithm.h.
Referenced by GeoLib::EarClippingTriangulation::clipEars().
void BaseLib::writeValueBinary | ( | std::ostream & | out, |
T const & | val | ||
) |
write value as binary into the given output stream
T | data type of the value |
out | output stream, have to be opened in binary mode |
val | value |
Definition at line 63 of file FileTools.h.
Referenced by ApplicationUtils::writeProperties().
int BaseLib::xmlDate2int | ( | const std::string & | s | ) |
Converts a string containing a date into a double. Note: It is not really checked if the date actually makes sense.
s | String containing the date, the expected format is conform to the xml date type, i.e. "yyyy-mm-dd". |
Definition at line 117 of file DateTools.cpp.
References date2int(), and WARN().
Referenced by GeoLib::StationBorehole::createStation().
std::shared_ptr< spdlog::logger > BaseLib::console = spdlog::stdout_color_mt("ogs") |
Definition at line 29 of file Logging.cpp.
Referenced by CRITICAL(), DBUG(), ERR(), INFO(), setConsoleLogLevel(), and WARN().