![]() |
OGS
|
Basic algorithms and helper functions provided for all other libraries.
Namespaces | |
namespace | IO |
namespace | TMP |
Classes | |
class | ConfigTree |
class | CPUTime |
Count CPU time. More... | |
struct | DynamicSpan |
class | GradualSubdivision |
class | GradualSubdivisionFixedNum |
class | Histogram |
class | ISubdivision |
class | MemWatch |
class | Range |
Wraps a pair of iterators for use as a range in range-based for-loops. More... | |
class | RunTime |
Count the running time. More... | |
class | TCLAPCustomOutput |
struct | TimeInterval |
class | UniformSubdivision |
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. | |
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 T > | |
void | cleanupVectorElements (std::vector< T * > &items) |
template<typename T1 , typename... Args> | |
void | cleanupVectorElements (std::vector< T1 * > &dependent_items, Args &&... args) |
template<typename List > | |
constexpr bool | any_of (List const &values) |
Checks if any of the elements in the given list is true. | |
template<typename List > | |
constexpr bool | all_of (List const &values) |
Checks if all of the elements in the given list are true. | |
template<typename List > | |
constexpr bool | none_of (List const &values) |
Checks if none of the elements in the given list are true. | |
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. | |
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. | |
ConfigTree | makeConfigTree (const std::string &filepath, const bool be_ruthless, const std::string &toplevel_tag, std::stringstream &prj_stream) |
ConfigTree | makeConfigTreeFromFile (const std::string &filepath, const bool be_ruthless, const std::string &toplevel_tag) |
template<typename E > | |
constexpr auto | to_underlying (E e) noexcept |
Converts an enumeration to its underlying type. | |
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) |
template<typename T > | |
DynamicSpan (T *, std::size_t) -> DynamicSpan< T > | |
bool | isProjectDirectorySet () |
Returns true if the project directory is set. | |
bool | IsFileExisting (const std::string &strFilename) |
Returns true if given file exists. | |
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. | |
void | setProjectDirectory (std::string const &dir) |
Sets the project directory. | |
void | unsetProjectDirectory () |
Unsets the project directory. | |
void | removeFile (std::string const &filename) |
void | removeFiles (std::vector< std::string > const &files) |
template<typename T > | |
T | readBinaryValue (std::istream &in) |
template float | readBinaryValue< float > (std::istream &) |
template double | readBinaryValue< double > (std::istream &) |
template<typename T > | |
std::vector< T > | readBinaryArray (std::string const &filename, std::size_t const n) |
template std::vector< float > | readBinaryArray< float > (std::string const &, std::size_t const) |
template<typename T > | |
void | writeValueBinary (std::ostream &out, T const &val) |
write value as binary into the given output stream | |
template void | writeValueBinary< std::size_t > (std::ostream &, std::size_t const &) |
template<typename T > | |
T | swapEndianness (T const &v) |
template<typename T > | |
std::ostream & | operator<< (std::ostream &os, const Histogram< T > &h) |
template std::ostream & | operator<< (std::ostream &os, const Histogram< double > &h) |
void | setConsoleLogLevel (std::string const &level_string) |
void | initOGSLogger (std::string const &log_level) |
void | traverseIncludes (xmlDoc *doc, xmlNode *node, std::filesystem::path const &prj_dir) |
void | replaceIncludes (std::stringstream &prj_stream, std::filesystem::path const &prj_dir) |
void | patchStream (std::string const &patch_file, std::stringstream &prj_stream, bool after_includes=false) |
void | readAndPatchPrj (std::stringstream &prj_stream, std::string &prj_file, std::vector< std::string > &patch_files) |
void | prepareProjectFile (std::stringstream &prj_stream, const std::string &filepath, const std::vector< std::string > &patch_files, bool write_prj, const std::string &out_directory) |
Applies includes and patch files to project file. | |
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. | |
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. | |
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") |
|
constexpr |
Checks if all of the elements in the given list are true.
Definition at line 341 of file Algorithm.h.
|
constexpr |
Checks if any of the elements in the given list is true.
Definition at line 325 of file Algorithm.h.
Referenced by BaseLib::TMP::contains(), and none_of().
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 475 of file ConfigTree.cpp.
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 480 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 488 of file ConfigTree.cpp.
void BaseLib::cleanupVectorElements | ( | std::vector< T * > & | items | ) |
Function to destruct objects stored in a container as pointers.
Definition at line 300 of file Algorithm.h.
Referenced by GeoLib::GEOObjects::~GEOObjects(), FileIO::GMSH::GMSHInterface::~GMSHInterface(), FileIO::GMSH::GMSHPolygonTree::~GMSHPolygonTree(), cleanupVectorElements(), FileIO::SwmmInterface::convertSwmmInputToGeometry(), FileIO::Gocad::GocadAsciiReader::createMesh(), GeoLib::IO::XmlGmlInterface::readFile(), FileIO::GMSInterface::readMesh(), FileIO::TetGenInterface::readTetGenGeometry(), FileIO::TetGenInterface::readTetGenMesh(), and MeshLib::MeshRevision::simplifyMesh().
void BaseLib::cleanupVectorElements | ( | std::vector< T1 * > & | dependent_items, |
Args &&... | args | ||
) |
Util function to cleanup the memory of multiple containers containing pointers to objects. Sometimes, there are dependencies between the pointer items in the containers. For instance, a GeoLib::Polyline or a GeoLib::Surface depends on the GeoLib::Point pointers stored in a std::vector<GeoLib::Point*>. Then, the dependent items have to cleaned up before the GeoLib::Point objects are deleted. A similar relation exists between MeshLib::Element objects and MeshLib::Node objects.
Definition at line 317 of file Algorithm.h.
References cleanupVectorElements().
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 120 of file FileTools.cpp.
References getParenthesizedString(), and substituteKeyword().
Referenced by ProcessLib::OutputVTKFormat::constructFilename(), ProcessLib::OutputXDMFHDF5Format::constructFilename(), and ProcessLib::OutputVTKFormat::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 ProcessLib::DeactivatedSubdomain::isDeactivated().
bool BaseLib::containsIf | ( | Container const & | container, |
Predicate && | predicate | ||
) |
Definition at line 264 of file Algorithm.h.
Referenced by ProjectData::parseProcesses().
std::string BaseLib::containsKeyword | ( | std::string const & | str, |
std::string const & | keyword | ||
) |
Definition at line 75 of file FileTools.cpp.
Referenced by substituteKeyword().
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 200 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 23 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 173 of file FileTools.cpp.
Referenced by convert(), extractBaseNameWithoutExtension(), VtkRaster::findWorldFile(), identifyAndWriteBoundaryMeshes(), main(), FileIO::Gocad::GocadAsciiReader::readFile(), MeshLib::IO::readMeshFromFile(), writeCsvOutput(), and writeMeshOutput().
BaseLib::DynamicSpan | ( | T * | , |
std::size_t | |||
) | -> DynamicSpan< T > |
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.
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 179 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 184 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::GMSH::readGMSHMesh(), FileIO::GMSInterface::readMesh(), 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 211 of file FileTools.cpp.
Referenced by MeshLib::IO::getVtuFileNameForPetscOutputWithoutExtension(), Simulation::initializeDataStructures(), main(), parseCommandLineArguments(), anonymous_namespace{postLIE.cpp}::postPVD(), readAndPatchPrj(), FileIO::Legacy::readGLIFileV4(), readVtuFileNames(), 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(), anonymous_namespace{ProcessVariable.cpp}::findMeshInConfig(), ProjectData::parseProcessVariables(), MaterialPropertyLib::Medium::phase(), and ProcessLib::Output::prepareSubmesh().
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 84 of file StringTools.cpp.
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 executeSimulation(), initOGS(), and main().
std::string BaseLib::getFileExtension | ( | std::string const & | path | ) |
Extract extension from filename
Definition at line 190 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(), MaterialPropertyLib::createSaturationWeightedThermalConductivity(), anonymous_namespace{SubmeshResiduumOutputConfig.cpp}::filterMeshesForResiduumOutput(), 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 53 of file FileTools.cpp.
Referenced by constructFormattedFileName().
std::string const & BaseLib::getProjectDirectory | ( | ) |
Returns the directory where the prj file resides.
Definition at line 222 of file FileTools.cpp.
References OGS_FATAL.
Referenced by ChemistryLib::createChemicalSolverInterface< ChemicalSolver::Phreeqc >(), ProcessLib::ComponentTransport::createLookupTable(), MaterialLib::Solids::MFront::createMFrontConfig(), Simulation::initializeDataStructures(), and parseCommandLineArguments().
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 119 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 195 of file FileTools.cpp.
References getFileExtension().
Referenced by main(), and anonymous_namespace{readMeshFromFile.cpp}::readMeshFromFileSerial().
void BaseLib::initOGSLogger | ( | std::string const & | log_level | ) |
Definition at line 54 of file Logging.cpp.
References OGS_FATAL, and setConsoleLogLevel().
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 47 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 39 of file FileTools.cpp.
std::string BaseLib::joinPaths | ( | std::string const & | pathA, |
std::string const & | pathB | ||
) |
Concat two paths. Does not check for validity.
Definition at line 216 of file FileTools.cpp.
Referenced by ApplicationsLib::TestDefinition::TestDefinition(), ProcessLib::OutputVTKFormat::constructPVDName(), ChemistryLib::createChemicalSolverInterface< ChemicalSolver::Phreeqc >(), ProcessLib::ComponentTransport::createLookupTable(), MaterialLib::Solids::MFront::createMFrontConfig(), ProcessLib::Output::doOutputNonlinearIteration(), anonymous_namespace{TestDefinition.cpp}::findVtkdiff(), MeshLib::IO::getVtuFileNameForPetscOutputWithoutExtension(), main(), ProcessLib::outputMeshVtk(), ProcessLib::OutputXDMFHDF5Format::outputMeshXdmf(), anonymous_namespace{postLIE.cpp}::postPVD(), readAndPatchPrj(), FileIO::Legacy::readPolyline(), FileIO::Legacy::readPolylinePointVector(), FileIO::Legacy::readSurface(), readVtuFileNames(), and FileIO::Legacy::writeTINSurfaces().
ConfigTree BaseLib::makeConfigTree | ( | std::string const & | filepath, |
bool const | be_ruthless, | ||
std::string const & | toplevel_tag, | ||
std::stringstream & | prj_stream | ||
) |
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. |
prj_stream | content of the (pre-processed) prj file. |
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 24 of file ConfigTreeUtil.cpp.
References DBUG(), OGS_FATAL, BaseLib::ConfigTree::onerror(), and BaseLib::ConfigTree::onwarning().
Referenced by Simulation::initializeDataStructures(), and makeConfigTreeFromFile().
ConfigTree BaseLib::makeConfigTreeFromFile | ( | const std::string & | filepath, |
const bool | be_ruthless, | ||
const std::string & | toplevel_tag | ||
) |
Definition at line 57 of file ConfigTreeUtil.cpp.
References makeConfigTree(), and OGS_FATAL.
Referenced by 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::createOutputConfig(), 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.
|
constexpr |
Checks if none of the elements in the given list are true.
Definition at line 357 of file Algorithm.h.
References any_of().
template std::ostream & BaseLib::operator<< | ( | std::ostream & | os, |
const Histogram< double > & | 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 77 of file Histogram.cpp.
References BaseLib::Histogram< T >::getBinCounts(), BaseLib::Histogram< T >::getMaximum(), BaseLib::Histogram< T >::getMinimum(), and BaseLib::Histogram< T >::getNumberOfBins().
void BaseLib::patchStream | ( | std::string const & | patch_file, |
std::stringstream & | prj_stream, | ||
bool | after_includes = false |
||
) |
Definition at line 141 of file PrjProcessing.cpp.
References OGS_FATAL.
Referenced by prepareProjectFile(), and readAndPatchPrj().
void BaseLib::prepareProjectFile | ( | std::stringstream & | prj_stream, |
const std::string & | filepath, | ||
const std::vector< std::string > & | patch_files, | ||
bool | write_prj, | ||
const std::string & | out_directory | ||
) |
Applies includes and patch files to project file.
prj_stream | The processed prj as a stringstream. |
filepath | The prj file. |
patch_files | Optional patch files. |
write_prj | Write the processed project file to disk? |
out_directory | The directory to write the processed file to. |
Definition at line 283 of file PrjProcessing.cpp.
References INFO(), patchStream(), readAndPatchPrj(), and replaceIncludes().
Referenced by Simulation::initializeDataStructures().
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 | ||
) |
Definition at line 72 of file quicksort.h.
References quicksort().
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 101 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 230 of file PrjProcessing.cpp.
References DBUG(), ERR(), extractPath(), getFileExtension(), IsFileExisting(), joinPaths(), OGS_FATAL, and patchStream().
Referenced by prepareProjectFile().
std::vector< T > BaseLib::readBinaryArray | ( | std::string const & | filename, |
std::size_t const | n | ||
) |
Definition at line 280 of file FileTools.cpp.
References ERR().
template std::vector< float > BaseLib::readBinaryArray< float > | ( | std::string const & | , |
std::size_t const | |||
) |
T BaseLib::readBinaryValue | ( | std::istream & | in | ) |
Definition at line 268 of file FileTools.cpp.
template double BaseLib::readBinaryValue< double > | ( | std::istream & | ) |
Referenced by FileIO::Gocad::GocadSGridReader::readNodesBinary().
template float BaseLib::readBinaryValue< float > | ( | std::istream & | ) |
Referenced by FileIO::Gocad::GocadSGridReader::readNodesBinary().
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 249 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 259 of file FileTools.cpp.
References removeFile().
Referenced by Simulation::initializeDataStructures().
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(), and ProcessLib::TwoPhaseFlowWithPrho::createTwoPhaseFlowPrhoMaterialProperties().
void BaseLib::replaceIncludes | ( | std::stringstream & | prj_stream, |
std::filesystem::path const & | prj_dir | ||
) |
Definition at line 111 of file PrjProcessing.cpp.
References OGS_FATAL, and traverseIncludes().
Referenced by prepareProjectFile().
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 49 of file StringTools.cpp.
References replaceString().
Referenced by GeoLib::Station::createStation(), FileIO::FEFLOWMeshInterface::getIndexList(), FileIO::readDoubleFromStream(), DiagramList::readList(), and replaceString().
void BaseLib::setConsoleLogLevel | ( | std::string const & | level_string | ) |
Definition at line 37 of file Logging.cpp.
References console, ERR(), and OGS_FATAL.
Referenced by initOGSLogger(), and main().
void BaseLib::setProjectDirectory | ( | std::string const & | dir | ) |
Sets the project directory.
Definition at line 231 of file FileTools.cpp.
References OGS_FATAL.
Referenced by parseCommandLineArguments().
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 75 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 37 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 27 of file StringTools.cpp.
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 60 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 86 of file FileTools.cpp.
References containsKeyword().
Referenced by constructFormattedFileName().
double BaseLib::swapEndianness | ( | double const & | v | ) |
Definition at line 151 of file FileTools.cpp.
Referenced by FileIO::Gocad::GocadSGridReader::readNodesBinary().
T BaseLib::swapEndianness | ( | T const & | v | ) |
Definition at line 66 of file FileTools.h.
|
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 29 of file cpp23.h.
Referenced by MeshLib::IO::cellTypeOGS2XDMF(), ProcessLib::createOutputFormat(), MeshLib::IO::elemOGSTypeToXDMFType(), MeshLib::IO::getPropertyDataTypeSize(), MeshLib::IO::getPropertyDataTypeString(), MaterialLib::Solids::Ehlers::SolidEhlers< DisplacementDim >::integrateStress(), MeshLib::IO::meshPropertyDatatypeSize(), MeshLib::IO::meshPropertyDatatypeString(), OGSToVtkCellType(), MaterialLib::Solids::MFront::OGSMFrontTangentOperatorBlocksView< DisplacementDim, Gradients, TDynForces, ExtStateVars >::size(), and anonymous_namespace{CreateMFrontGeneric.cpp}::toString().
void BaseLib::traverseIncludes | ( | xmlDoc * | doc, |
xmlNode * | node, | ||
std::filesystem::path const & | prj_dir | ||
) |
Definition at line 29 of file PrjProcessing.cpp.
References INFO(), OGS_FATAL, and traverseIncludes().
Referenced by replaceIncludes(), and traverseIncludes().
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 57 of file StringTools.cpp.
Referenced by FileIO::FEFLOWMeshInterface::getIndexList(), getValue(), getVariables(), MeshLib::IO::Legacy::MeshIO::loadMeshFromFile(), FileIO::Gocad::parseGocadPropertyMetaData(), FileIO::Gocad::GocadAsciiReader::parseHeader(), 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::unsetProjectDirectory | ( | ) |
Unsets the project directory.
Definition at line 243 of file FileTools.cpp.
Referenced by finalize().
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 323 of file FileTools.cpp.
Referenced by ApplicationUtils::writeProperties().
template void BaseLib::writeValueBinary< std::size_t > | ( | std::ostream & | , |
std::size_t const & | |||
) |
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().
BASELIB_EXPORT std::shared_ptr< spdlog::logger > BaseLib::console = spdlog::stdout_color_mt("ogs") |
Definition at line 32 of file Logging.cpp.
Referenced by CRITICAL(), DBUG(), ERR(), INFO(), setConsoleLogLevel(), and WARN().