Classes | |
struct | AnyType |
Comparison helpers that support the MooseUtils::Any wildcard which will match any value. More... | |
class | Buffer |
Base class for a buffer. More... | |
struct | canBroadcast |
Custom type trait that has a value of true for types that can be broadcasted. More... | |
class | CircularBuffer |
An optimized circular buffer. More... | |
class | DelimitedFileReader |
Utility class for reading delimited data (e.g., CSV data). More... | |
class | Has_size |
Taken from https://stackoverflow.com/a/257382 Evaluating constexpr (Has_size<T>::value) in a templated method over class T will return whether T is a standard container or a singleton. More... | |
struct | IsLikeReal |
Custom type trait that has a value of true for types that cam be use interchangably with Real. More... | |
struct | IsLikeReal< DualReal > |
struct | IsLikeReal< Real > |
class | LIFOBuffer |
An optimized LIFO (Last In First Out) buffer. More... | |
class | SemidynamicVector |
Utility class template for a semidynamic vector with a maximum size N and a chosen dynamic size. More... | |
class | SharedPool |
Originally From https://stackoverflow.com/a/27837534/2042320. More... | |
class | StaticallyAllocatedSet |
Optimized set with static allocation. More... | |
Functions | |
std::filesystem::path | pathjoin (const std::filesystem::path &p) |
template<typename... Args> | |
std::filesystem::path | pathjoin (const std::filesystem::path &p, Args... args) |
bool | parsesToReal (const std::string &input) |
Check if the input string can be parsed into a Real. More... | |
std::string | runTestsExecutable () |
Returns the location of either a local repo run_tests script - or an installed test executor script if run_tests isn't found. More... | |
std::string | findTestRoot () |
Searches in the current working directory and then recursively up in each parent directory looking for a "testroot" file. More... | |
std::string | installedInputsDir (const std::string &app_name, const std::string &dir_name, const std::string &extra_error_msg="") |
Returns the directory of any installed inputs or the empty string if none are found. More... | |
std::string | docsDir (const std::string &app_name) |
Returns the directory of any installed docs/site. More... | |
std::string | replaceAll (std::string str, const std::string &from, const std::string &to) |
Replaces all occurences of from in str with to and returns the result. More... | |
std::string | convertLatestCheckpoint (std::string orig) |
Replaces "LATEST" placeholders with the latest checkpoint file name. More... | |
int | levenshteinDist (const std::string &s1, const std::string &s2) |
Computes and returns the Levenshtein distance between strings s1 and s2. More... | |
void | escape (std::string &str) |
This function will escape all of the standard C++ escape characters so that they can be printed. More... | |
std::string | trim (const std::string &str, const std::string &white_space=" \\\) |
Standard scripting language trim function. More... | |
std::vector< std::string > | split (const std::string &str, const std::string &delimiter, std::size_t max_count=std::numeric_limits< std::size_t >::max()) |
Python like split functions for strings. More... | |
std::vector< std::string > | rsplit (const std::string &str, const std::string &delimiter, std::size_t max_count=std::numeric_limits< std::size_t >::max()) |
template<typename T > | |
std::string | join (const T &strings, const std::string &delimiter) |
Python like join function for strings. More... | |
std::size_t | fileSize (const std::string &filename) |
Check the file size. More... | |
bool | pathContains (const std::string &expression, const std::string &string_to_find, const std::string &delims="/") |
This function tokenizes a path and checks to see if it contains the string to look for. More... | |
bool | checkFileReadable (const std::string &filename, bool check_line_endings=false, bool throw_on_unreadable=true, bool check_for_git_lfs_pointer=true) |
Checks to see if a file is readable (exists and permissions) More... | |
bool | checkFileWriteable (const std::string &filename, bool throw_on_unwritable=true) |
Check if the file is writable (path exists and permissions) More... | |
bool | checkForGitLFSPointer (std::ifstream &file) |
Check if the file is a Git-LFS pointer. More... | |
void | parallelBarrierNotify (const libMesh::Parallel::Communicator &comm, bool messaging=true) |
This function implements a parallel barrier function but writes progress to stdout. More... | |
void | serialBegin (const libMesh::Parallel::Communicator &comm, bool warn=true) |
This function marks the begin of a section of code that is executed in serial rank by rank. More... | |
void | serialEnd (const libMesh::Parallel::Communicator &comm, bool warn=true) |
Closes a section of code that is executed in serial rank by rank, and that was opened with a call to serialBegin. More... | |
bool | hasExtension (const std::string &filename, std::string ext, bool strip_exodus_ext=false) |
Function tests if the supplied filename as the desired extension. More... | |
std::string | stripExtension (const std::string &s) |
Removes any file extension from the given string s (i.e. More... | |
template<typename T > | |
std::pair< std::filesystem::path, std::filesystem::path > | splitFileName (const T &full_file) |
Function for splitting path and filename. More... | |
std::string | getCurrentWorkingDir () |
Returns the current working directory as a string. More... | |
void | makedirs (const std::string &dir_name, bool throw_on_failure=false) |
Recursively make directories. More... | |
void | removedirs (const std::string &dir_name, bool throw_on_failure=false) |
Recursively remove directories from inner-most when the directories are empty. More... | |
std::string | camelCaseToUnderscore (const std::string &camel_case_name) |
Function for converting a camel case name to a name containing underscores. More... | |
std::string | underscoreToCamelCase (const std::string &underscore_name, bool leading_upper_case) |
Function for converting an underscore name to a camel case name. More... | |
std::string | shortName (const std::string &name) |
Function for stripping name after the file / in parser block. More... | |
std::string | baseName (const std::string &name) |
Function for string the information before the final / in a parser block. More... | |
std::string | hostname () |
Get the hostname the current process is running on. More... | |
unsigned short | getTermWidth (bool use_environment) |
Returns the width of the terminal using sys/ioctl. More... | |
std::string | prettyCppType (const std::string &cpp_type) |
template<typename T > | |
std::string | prettyCppType (const T *=nullptr) |
template<typename T1 , typename T2 > | |
bool | doesMapContainValue (const std::map< T1, T2 > &the_map, const T2 &value) |
This routine is a simple helper function for searching a map by values instead of keys. More... | |
template<typename T , typename T2 , typename T3 = T, typename std::enable_if< ScalarTraits< T >::value &&ScalarTraits< T2 >::value &&ScalarTraits< T3 >::value, int >::type = 0> | |
bool | absoluteFuzzyEqual (const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE) |
Function to check whether two variables are equal within an absolute tolerance. More... | |
template<typename T , typename T2 , typename T3 = T, typename std::enable_if< ScalarTraits< T >::value &&ScalarTraits< T2 >::value &&ScalarTraits< T3 >::value, int >::type = 0> | |
bool | absoluteFuzzyGreaterEqual (const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE) |
Function to check whether a variable is greater than or equal to another variable within an absolute tolerance. More... | |
template<typename T , typename T2 , typename T3 = T, typename std::enable_if< ScalarTraits< T >::value &&ScalarTraits< T2 >::value &&ScalarTraits< T3 >::value, int >::type = 0> | |
bool | absoluteFuzzyGreaterThan (const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE) |
Function to check whether a variable is greater than another variable within an absolute tolerance. More... | |
template<typename T , typename T2 , typename T3 = T, typename std::enable_if< ScalarTraits< T >::value &&ScalarTraits< T2 >::value &&ScalarTraits< T3 >::value, int >::type = 0> | |
bool | absoluteFuzzyLessEqual (const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE) |
Function to check whether a variable is less than or equal to another variable within an absolute tolerance. More... | |
template<typename T , typename T2 , typename T3 = T, typename std::enable_if< ScalarTraits< T >::value &&ScalarTraits< T2 >::value &&ScalarTraits< T3 >::value, int >::type = 0> | |
bool | absoluteFuzzyLessThan (const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE) |
Function to check whether a variable is less than another variable within an absolute tolerance. More... | |
template<typename T , typename T2 , typename T3 = Real> | |
bool | relativeFuzzyEqual (const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE) |
Function to check whether two variables are equal within a relative tolerance. More... | |
template<typename T , typename T2 , typename T3 = T, typename std::enable_if< ScalarTraits< T >::value &&ScalarTraits< T2 >::value &&ScalarTraits< T3 >::value, int >::type = 0> | |
bool | relativeFuzzyGreaterEqual (const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE) |
Function to check whether a variable is greater than or equal to another variable within a relative tolerance. More... | |
template<typename T , typename T2 , typename T3 = T, typename std::enable_if< ScalarTraits< T >::value &&ScalarTraits< T2 >::value &&ScalarTraits< T3 >::value, int >::type = 0> | |
bool | relativeFuzzyGreaterThan (const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE) |
Function to check whether a variable is greater than another variable within a relative tolerance. More... | |
template<typename T , typename T2 , typename T3 = T, typename std::enable_if< ScalarTraits< T >::value &&ScalarTraits< T2 >::value &&ScalarTraits< T3 >::value, int >::type = 0> | |
bool | relativeFuzzyLessEqual (const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE) |
Function to check whether a variable is less than or equal to another variable within a relative tolerance. More... | |
template<typename T , typename T2 , typename T3 = T, typename std::enable_if< ScalarTraits< T >::value &&ScalarTraits< T2 >::value &&ScalarTraits< T3 >::value, int >::type = 0> | |
bool | relativeFuzzyLessThan (const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE) |
Function to check whether a variable is less than another variable within a relative tolerance. More... | |
template<typename T > | |
bool | isZero (const T &value, const Real tolerance=TOLERANCE *TOLERANCE *TOLERANCE) |
void | MaterialPropertyStorageDump (const HashMap< const libMesh::Elem *, HashMap< unsigned int, MaterialProperties >> &props) |
Function to dump the contents of MaterialPropertyStorage for debugging purposes. More... | |
void | indentMessage (const std::string &prefix, std::string &message, const char *color=COLOR_CYAN, bool dont_indent_first_line=true, const std::string &post_prefix=": ") |
Indents the supplied message given the prefix and color. More... | |
std::string & | removeColor (std::string &msg) |
remove ANSI escape sequences for terminal color from msg More... | |
std::list< std::string > | listDir (const std::string path, bool files_only=false) |
bool | pathExists (const std::string &path) |
bool | pathIsDirectory (const std::string &path) |
std::list< std::string > | getFilesInDirs (const std::list< std::string > &directory_list, const bool files_only=true) |
Retrieves the names of all of the files contained within the list of directories passed into the routine. More... | |
std::string | getLatestCheckpointFilePrefix (const std::list< std::string > &checkpoint_files) |
Returns the most recent checkpoint prefix (the four numbers at the begining) If a suitable file isn't found the empty string is returned. More... | |
bool | wildCardMatch (std::string name, std::string search_string) |
bool | globCompare (const std::string &candidate, const std::string &pattern, std::size_t c=0, std::size_t p=0) |
template<typename T > | |
void | expandAllMatches (const std::vector< T > &candidates, std::vector< T > &patterns) |
template<typename T > | |
void | tokenize (const std::string &str, std::vector< T > &elements, unsigned int min_len=1, const std::string &delims="/") |
This function will split the passed in string on a set of delimiters appending the substrings to the passed in vector. More... | |
template<typename T > | |
bool | tokenizeAndConvert (const std::string &str, std::vector< T > &tokenized_vector, const std::string &delimiter=" \\\) |
tokenizeAndConvert splits a string using delimiter and then converts to type T. More... | |
template<typename T > | |
T | convert (const std::string &str, bool throw_on_failure=false) |
convert takes a string representation of a number type and converts it to the number. More... | |
template<> | |
short int | convert< short int > (const std::string &str, bool throw_on_failure) |
template<> | |
unsigned short int | convert< unsigned short int > (const std::string &str, bool throw_on_failure) |
template<> | |
int | convert< int > (const std::string &str, bool throw_on_failure) |
template<> | |
unsigned int | convert< unsigned int > (const std::string &str, bool throw_on_failure) |
template<> | |
long int | convert< long int > (const std::string &str, bool throw_on_failure) |
template<> | |
unsigned long int | convert< unsigned long int > (const std::string &str, bool throw_on_failure) |
template<> | |
long long int | convert< long long int > (const std::string &str, bool throw_on_failure) |
template<> | |
unsigned long long int | convert< unsigned long long int > (const std::string &str, bool throw_on_failure) |
void | createSymlink (const std::string &target, const std::string &link) |
Create a symbolic link, if the link already exists it is replaced. More... | |
void | clearSymlink (const std::string &link) |
Remove a symbolic link, if the given filename is a link. More... | |
std::string | toUpper (const std::string &name) |
Convert supplied string to upper case. More... | |
std::string | toLower (const std::string &name) |
Convert supplied string to lower case. More... | |
template<typename T > | |
T | concatenate (T c1, const T &c2) |
Returns a container that contains the content of second passed in container inserted into the first passed in container (set or map union). More... | |
template<typename T > | |
std::vector< T > | concatenate (std::vector< T > c1, const std::vector< T > &c2) |
Returns a vector that contains is the concatenation of the two passed in vectors. More... | |
template<typename T > | |
std::vector< T > | concatenate (std::vector< T > c1, const T &item) |
Returns the passed in vector with the item appended to it. More... | |
template<typename T > | |
int | numDigits (const T &num) |
Return the number of digits for a number. More... | |
ExecFlagEnum | getDefaultExecFlagEnum () |
Return the default ExecFlagEnum for MOOSE. More... | |
int | stringToInteger (const std::string &input, bool throw_on_failure=false) |
Robust string to integer conversion that fails for cases such at "1foo". More... | |
void | linearPartitionItems (dof_id_type num_items, dof_id_type num_chunks, dof_id_type chunk_id, dof_id_type &num_local_items, dof_id_type &local_items_begin, dof_id_type &local_items_end) |
Linearly partition a number of items. More... | |
processor_id_type | linearPartitionChunk (dof_id_type num_items, dof_id_type num_chunks, dof_id_type item_id) |
Return the chunk_id that is assigned to handle item_id. More... | |
std::string | realpath (const std::string &path) |
Wrapper around PetscGetRealPath, which is a cross-platform replacement for realpath. More... | |
template<typename C , typename M1 , typename M2 > | |
C::iterator | findPair (C &container, const M1 &first, const M2 &second) |
Find a specific pair in a container matching on first, second or both pair components. More... | |
BoundingBox | buildBoundingBox (const Point &p1, const Point &p2) |
Construct a valid bounding box from 2 arbitrary points. More... | |
template<typename T > | |
T * | get (const std::unique_ptr< T > &u) |
The MooseUtils::get() specializations are used to support making forwards-compatible code changes from dumb pointers to smart pointers. More... | |
template<typename T > | |
T * | get (T *p) |
template<typename T > | |
T * | get (const std::shared_ptr< T > &s) |
template<class InputIterator > | |
bool | setsIntersect (InputIterator first1, InputIterator last1, InputIterator first2, InputIterator last2) |
This method detects whether two sets intersect without building a result set. More... | |
template<class T > | |
bool | setsIntersect (const T &s1, const T &s2) |
bool | isDigits (const std::string &str) |
Courtesy https://stackoverflow.com/a/8889045 and https://en.cppreference.com/w/cpp/string/byte/isdigit. More... | |
template<class T , typename... Args> | |
auto | reset (int, T &obj, Args... args) -> decltype(obj.reset(args...), void()) |
template<class T , typename... Args> | |
void | reset (double, T &, Args...) |
void | parallelBarrierNotify (const Parallel::Communicator &comm, bool messaging) |
void | addLineBreaks (std::string &message, unsigned int line_width) |
template<typename T > | |
T | convertStringToInt (const std::string &str, bool throw_on_failure) |
template<typename T > | |
void | swap (std::vector< T > &data, const std::size_t idx0, const std::size_t idx1, const libMesh::Parallel::Communicator &comm) |
Swap function for serial or distributed vector of data. More... | |
template<typename T > | |
void | swap (std::vector< T > &data, const std::size_t idx0, const std::size_t idx1, const libMesh::Parallel::Communicator *comm_ptr=nullptr) |
template<typename T > | |
void | shuffle (std::vector< T > &data, MooseRandom &generator, const std::size_t seed_index=0) |
Shuffle function for serial or distributed vector of data that shuffles in place. More... | |
template<typename T > | |
void | shuffle (std::vector< T > &data, MooseRandom &generator, const libMesh::Parallel::Communicator &comm) |
template<typename T > | |
void | shuffle (std::vector< T > &data, MooseRandom &generator, const std::size_t seed_index, const libMesh::Parallel::Communicator &comm) |
template<typename T > | |
void | shuffle (std::vector< T > &data, MooseRandom &generator, const std::size_t seed_index, const libMesh::Parallel::Communicator *comm_ptr) |
template<typename T > | |
std::vector< T > | resample (const std::vector< T > &data, MooseRandom &generator, const std::size_t seed_index=0) |
Randomly resample a vector of data, allowing a value to be repeated. More... | |
template<typename T > | |
std::vector< T > | resample (const std::vector< T > &data, MooseRandom &generator, const libMesh::Parallel::Communicator &comm) |
template<typename T > | |
std::vector< T > | resample (const std::vector< T > &data, MooseRandom &generator, const std::size_t seed_index, const libMesh::Parallel::Communicator &comm) |
template<typename T > | |
std::vector< T > | resample (const std::vector< T > &data, MooseRandom &generator, const std::size_t seed_index, const libMesh::Parallel::Communicator *comm_ptr) |
template<typename T , typename ActionFunctor > | |
void | resampleWithFunctor (const std::vector< T > &data, const ActionFunctor &functor, MooseRandom &generator, const std::size_t seed_index=0) |
Randomly resample a vector of data and apply a functor, allowing a value to be repeated. More... | |
template<typename T , typename ActionFunctor > | |
void | resampleWithFunctor (const std::vector< T > &data, const ActionFunctor &functor, MooseRandom &generator, const libMesh::Parallel::Communicator &comm) |
template<typename T , typename ActionFunctor > | |
void | resampleWithFunctor (const std::vector< T > &data, const ActionFunctor &functor, MooseRandom &generator, const std::size_t seed_index, const libMesh::Parallel::Communicator &comm) |
template<typename T , typename ActionFunctor > | |
void | resampleWithFunctor (const std::vector< T > &data, const ActionFunctor &functor, MooseRandom &generator, const std::size_t seed_index, const libMesh::Parallel::Communicator *comm_ptr) |
static const struct MooseUtils::AnyType | Any |
template<typename T1 , typename T2 > | |
bool | wildcardEqual (const T1 &a, const T2 &b) |
template<typename T > | |
bool | wildcardEqual (const T &, AnyType) |
template<typename T > | |
bool | wildcardEqual (AnyType, const T &) |
bool MooseUtils::absoluteFuzzyEqual | ( | const T & | var1, |
const T2 & | var2, | ||
const T3 & | tol = libMesh::TOLERANCE * libMesh::TOLERANCE |
||
) |
Function to check whether two variables are equal within an absolute tolerance.
var1 | The first variable to be checked |
var2 | The second variable to be checked |
tol | The tolerance to be used |
Definition at line 346 of file MooseUtils.h.
Referenced by FormattedTable::addData(), MultiAppVariableValueSamplePostprocessorTransfer::cacheElemToPostprocessorData(), MultiAppGeneralFieldTransfer::cacheIncomingInterpVals(), CartesianGridDivision::CartesianGridDivision(), MeshDiagnosticsGenerator::checkNonConformalMeshFromAdaptivity(), MeshDiagnosticsGenerator::checkNonPlanarSides(), CircularBoundaryCorrectionGenerator::circularCenterCalculator(), ComparisonPostprocessor::comparisonIsTrue(), VariableCondensationPreconditioner::computeDInverseDiag(), ThresholdElementSubdomainModifier::computeSubdomainID(), CylindricalGridDivision::CylindricalGridDivision(), MultiAppGeneralFieldTransfer::detectConflict(), CartesianGridDivision::divisionIndex(), CylindricalGridDivision::divisionIndex(), SphericalGridDivision::divisionIndex(), MultiAppGeneralFieldNearestLocationTransfer::evaluateInterpValuesNearestNode(), MultiAppGeneralFieldTransfer::examineLocalValueConflicts(), MultiAppGeneralFieldTransfer::examineReceivedValueConflicts(), PointValue::execute(), FindValueOnLine::execute(), FillBetweenPointVectorsTools::fillBetweenPointVectorsGenerator(), RankFourTensorTempl< T >::fillGeneralOrthotropicFromInputVector(), MeshDivisionFunctorReductionVectorPostprocessor::finalize(), BicubicInterpolation::findInterval(), MeshRepairGenerator::fixOverlappingNodes(), ParsedCurveGenerator::generate(), AdvancedExtruderGenerator::generate(), CircularBoundaryCorrectionGenerator::generate(), CircularBoundaryCorrectionGenerator::generateRadialCorrectionFactor(), FunctorBinnedValuesDivision::getBinIndex(), TransfiniteMeshGenerator::getEdge(), Positions::getNearestPositionIndex(), MultiAppGeneralFieldTransfer::getRestrictedFromBoundingBoxes(), SideAverageValue::getValue(), RelativeDifferencePostprocessor::getValue(), LineValueSampler::getValue(), Moose::FV::greenGaussGradient(), MooseAppCoordTransform::hasScalingOrRotationTransformation(), AutomaticMortarGeneration::householderOrthogolization(), ElementGroupCentroidPositions::initialize(), MooseVariableBase::initialSetup(), MooseMeshUtils::isCoPlanar(), ActivateElementsCoupled::isElementActivated(), MultiAppCoordTransform::isIdentity(), RankTwoTensorTempl< Real >::isSymmetric(), isZero(), MooseMeshXYCuttingUtils::lineRemoverCutElemTri(), MooseMeshXYCuttingUtils::lineRemoverMoveNode(), LineValueSampler::LineValueSampler(), FillBetweenPointVectorsTools::needFlip(), CutMeshByPlaneGenerator::nonDuplicateNodeCreator(), EigenExecutionerBase::normalizeSolution(), MultiAppCoordTransform::operator()(), RankTwoTensorTempl< Real >::operator==(), TableOutput::outputPostprocessors(), TableOutput::outputReporter(), PointIndexedMap::PointIndexedMap(), CutMeshByPlaneGenerator::pointPairPlaneInterception(), RankTwoTensorTempl< Real >::positiveProjectionEigenDecomposition(), EigenExecutionerBase::postExecute(), EigenProblem::preScaleEigenVector(), MooseMeshXYCuttingUtils::quasiTriElementsFixer(), CoarsenBlockGenerator::recursiveCoarsen(), relativeFuzzyEqual(), BicubicInterpolation::sample2ndDerivative(), BicubicInterpolation::sampleDerivative(), BicubicInterpolation::sampleValueAndDerivativesInternal(), TimeSequenceStepperBase::setupSequence(), Predictor::shouldApply(), SphericalGridDivision::SphericalGridDivision(), SymmetryTransformGenerator::SymmetryTransformGenerator(), CutMeshByPlaneGenerator::tet4ElemCutter(), TimeIntervalTimes::TimeIntervalTimes(), SecantSolve::transformPostprocessors(), SteffensenSolve::transformPostprocessors(), SteffensenSolve::transformVariables(), SecantSolve::transformVariables(), MooseMeshXYCuttingUtils::triElemSplitter(), ParsedCurveGenerator::tSectionSpaceDefiner(), Axisymmetric2D3DSolutionFunction::value(), and XYMeshLineCutter::XYMeshLineCutter().
bool MooseUtils::absoluteFuzzyGreaterEqual | ( | const T & | var1, |
const T2 & | var2, | ||
const T3 & | tol = libMesh::TOLERANCE * libMesh::TOLERANCE |
||
) |
Function to check whether a variable is greater than or equal to another variable within an absolute tolerance.
var1 | The first variable to be checked |
var2 | The second variable to be checked |
tol | The tolerance to be used |
Definition at line 369 of file MooseUtils.h.
Referenced by ComparisonPostprocessor::comparisonIsTrue(), TimePeriod::conditionMet(), CylindricalGridDivision::divisionIndex(), SphericalGridDivision::divisionIndex(), CartesianGridDivision::divisionIndex(), PlaneIDMeshGenerator::PlaneIDMeshGenerator(), and relativeFuzzyGreaterEqual().
bool MooseUtils::absoluteFuzzyGreaterThan | ( | const T & | var1, |
const T2 & | var2, | ||
const T3 & | tol = libMesh::TOLERANCE * libMesh::TOLERANCE |
||
) |
Function to check whether a variable is greater than another variable within an absolute tolerance.
var1 | The first variable to be checked |
var2 | The second variable to be checked |
tol | The tolerance to be used |
Definition at line 392 of file MooseUtils.h.
Referenced by MultiAppGeneralFieldTransfer::cacheIncomingInterpVals(), ComparisonPostprocessor::comparisonIsTrue(), SphericalGridDivision::divisionIndex(), CartesianGridDivision::divisionIndex(), CylindricalGridDivision::divisionIndex(), FillBetweenPointVectorsTools::elementsCreationFromNodesVectors(), CircularBoundaryCorrectionGenerator::generate(), Times::getNextTime(), Times::getPreviousTime(), CartesianGridDivision::initialize(), CylindricalGridDivision::initialize(), SphericalGridDivision::initialize(), PointReduction::perpendicularDistance(), CutMeshByPlaneGenerator::pointPairPlaneInterception(), CutMeshByPlaneGenerator::pointPlaneRelation(), CoarsenBlockGenerator::recursiveCoarsen(), relativeFuzzyGreaterThan(), TimeIntervalTimes::TimeIntervalTimes(), and Axisymmetric2D3DSolutionFunction::value().
bool MooseUtils::absoluteFuzzyLessEqual | ( | const T & | var1, |
const T2 & | var2, | ||
const T3 & | tol = libMesh::TOLERANCE * libMesh::TOLERANCE |
||
) |
Function to check whether a variable is less than or equal to another variable within an absolute tolerance.
var1 | The first variable to be checked |
var2 | The second variable to be checked |
tol | The tolerance to be used |
Definition at line 415 of file MooseUtils.h.
Referenced by MultiAppConservativeTransfer::adjustTransferredSolution(), MultiAppConservativeTransfer::adjustTransferredSolutionNearestPoint(), ComparisonPostprocessor::comparisonIsTrue(), FunctorBinnedValuesDivision::FunctorBinnedValuesDivision(), relativeFuzzyLessEqual(), and TimeIntervalTimes::TimeIntervalTimes().
bool MooseUtils::absoluteFuzzyLessThan | ( | const T & | var1, |
const T2 & | var2, | ||
const T3 & | tol = libMesh::TOLERANCE * libMesh::TOLERANCE |
||
) |
Function to check whether a variable is less than another variable within an absolute tolerance.
var1 | The first variable to be checked |
var2 | The second variable to be checked |
tol | The tolerance to be used |
Definition at line 437 of file MooseUtils.h.
Referenced by FormattedTable::addData(), MultiAppVariableValueSamplePostprocessorTransfer::cacheElemToPostprocessorData(), ComparisonPostprocessor::comparisonIsTrue(), TimePeriod::conditionMet(), CartesianGridDivision::divisionIndex(), CylindricalGridDivision::divisionIndex(), SphericalGridDivision::divisionIndex(), Positions::getNearestPositionIndex(), CutMeshByPlaneGenerator::pointPlaneRelation(), and relativeFuzzyLessThan().
Definition at line 713 of file MooseUtils.C.
std::string MooseUtils::baseName | ( | const std::string & | name | ) |
Function for string the information before the final / in a parser block.
Definition at line 601 of file MooseUtils.C.
Referenced by Moose::Builder::walkRaw().
BoundingBox MooseUtils::buildBoundingBox | ( | const Point & | p1, |
const Point & | p2 | ||
) |
Construct a valid bounding box from 2 arbitrary points.
If you have 2 points in space and you wish to construct a bounding box, you should use this method to avoid unexpected behavior of the underlying BoundingBox class in libMesh. BoundingBox class expect 2 points whose coordinates are "sorted" (i.e., x-, y- and -z coordinates of the first point are smaller then the corresponding coordinates of the second point). If this "sorting" is not present, the BoundingBox class will build an empty box and any further testing of points inside the box will fail. This method will allow you to obtain the correct bounding box for any valid combination of 2 corner points of a box.
p1 | First corner of the constructed bounding box |
p2 | Second corner of the constructed bounding box |
Definition at line 1223 of file MooseUtils.C.
Referenced by PropertyReadFile::PropertyReadFile().
std::string MooseUtils::camelCaseToUnderscore | ( | const std::string & | camel_case_name | ) |
Function for converting a camel case name to a name containing underscores.
camel_case_name | A string containing camel casing |
Definition at line 551 of file MooseUtils.C.
Referenced by MooseApp::appNameToLibName().
bool MooseUtils::checkFileReadable | ( | const std::string & | filename, |
bool | check_line_endings = false , |
||
bool | throw_on_unreadable = true , |
||
bool | check_for_git_lfs_pointer = true |
||
) |
Checks to see if a file is readable (exists and permissions)
filename | The filename to check |
check_line_endings | Whether or not to see if the file contains DOS line endings. |
throw_on_unreadable | Whether or not to throw a MOOSE error if the file doesn't exist |
check_for_git_lfs_pointer | Whether or not to call a subroutine utility to make sure that the file in question is not actually a git-lfs pointer. |
Definition at line 253 of file MooseUtils.C.
Referenced by FileMesh::buildMesh(), docsDir(), MooseApp::dynamicRegistration(), ExodusFileTimes::ExodusFileTimes(), ExodusTimeSequenceStepper::ExodusTimeSequenceStepper(), findTestRoot(), MooseServer::gatherDocumentDefinitionLocations(), FileMeshGenerator::generate(), DataFileInterface< Action >::getDataFileName(), DataFileInterface< Action >::getDataFileNameByName(), installedInputsDir(), RestartableDataReader::isAvailable(), ADFParser::JITCompile(), MooseApp::loadLibraryAndDependencies(), Exodus::output(), Parser::parse(), MooseUtils::DelimitedFileReader::read(), JSONFileReader::read(), MultiApp::readCommandLineArguments(), SolutionUserObject::readXda(), MooseApp::run(), runTestsExecutable(), and ValueCache< T >::ValueCache().
bool MooseUtils::checkFileWriteable | ( | const std::string & | filename, |
bool | throw_on_unwritable = true |
||
) |
Check if the file is writable (path exists and permissions)
filename | The filename you want to see if you can write to. |
throw_on_unwritable | Whether or not to throw a MOOSE error if the file is not writable return a Boolean indicating whether the file exists and is writable |
Definition at line 306 of file MooseUtils.C.
Referenced by PNGOutput::makePNG().
bool MooseUtils::checkForGitLFSPointer | ( | std::ifstream & | file | ) |
Check if the file is a Git-LFS pointer.
When using a repository that utilizes Git-LFS, it's possible that the client may not have the right packages installed in which case the clone will contain plain-text files with key information for retrieving the actual (large) files. This can cause odd errors since the file technically exists, is readable, and even has the right name/extension. However, the content of the file will not match the expected content.
file | A pointer to the open filestream. |
Definition at line 289 of file MooseUtils.C.
Referenced by checkFileReadable().
void MooseUtils::clearSymlink | ( | const std::string & | link | ) |
Remove a symbolic link, if the given filename is a link.
Definition at line 1165 of file MooseUtils.C.
Referenced by createSymlink(), and CSV::initialSetup().
T MooseUtils::concatenate | ( | T | c1, |
const T & | c2 | ||
) |
Returns a container that contains the content of second passed in container inserted into the first passed in container (set or map union).
Definition at line 902 of file MooseUtils.h.
Referenced by MaterialDerivativeTestKernelBase< Real >::MaterialDerivativeTestKernelBase().
std::vector<T> MooseUtils::concatenate | ( | std::vector< T > | c1, |
const std::vector< T > & | c2 | ||
) |
Returns a vector that contains is the concatenation of the two passed in vectors.
Definition at line 913 of file MooseUtils.h.
std::vector<T> MooseUtils::concatenate | ( | std::vector< T > | c1, |
const T & | item | ||
) |
Returns the passed in vector with the item appended to it.
Definition at line 924 of file MooseUtils.h.
T MooseUtils::convert | ( | const std::string & | str, |
bool | throw_on_failure = false |
||
) |
convert takes a string representation of a number type and converts it to the number.
This method is here to get around deficiencies in the STL stoi and stod methods where they might successfully convert part of a string to a number when we'd like to throw an error.
Definition at line 831 of file MooseUtils.h.
Referenced by MooseServer::getDocumentSymbolKind().
int MooseUtils::convert< int > | ( | const std::string & | str, |
bool | throw_on_failure | ||
) |
Definition at line 996 of file MooseUtils.C.
Referenced by SystemBase::copyVars(), and stringToInteger().
long int MooseUtils::convert< long int > | ( | const std::string & | str, |
bool | throw_on_failure | ||
) |
Definition at line 1010 of file MooseUtils.C.
long long int MooseUtils::convert< long long int > | ( | const std::string & | str, |
bool | throw_on_failure | ||
) |
Definition at line 1024 of file MooseUtils.C.
short int MooseUtils::convert< short int > | ( | const std::string & | str, |
bool | throw_on_failure | ||
) |
Definition at line 982 of file MooseUtils.C.
unsigned int MooseUtils::convert< unsigned int > | ( | const std::string & | str, |
bool | throw_on_failure | ||
) |
Definition at line 1003 of file MooseUtils.C.
unsigned long int MooseUtils::convert< unsigned long int > | ( | const std::string & | str, |
bool | throw_on_failure | ||
) |
Definition at line 1017 of file MooseUtils.C.
unsigned long long int MooseUtils::convert< unsigned long long int > | ( | const std::string & | str, |
bool | throw_on_failure | ||
) |
Definition at line 1031 of file MooseUtils.C.
unsigned short int MooseUtils::convert< unsigned short int > | ( | const std::string & | str, |
bool | throw_on_failure | ||
) |
Definition at line 989 of file MooseUtils.C.
std::string MooseUtils::convertLatestCheckpoint | ( | std::string | orig | ) |
Replaces "LATEST" placeholders with the latest checkpoint file name.
Definition at line 146 of file MooseUtils.C.
Referenced by SetupRecoverFileBaseAction::act(), FileMeshGenerator::deduceCheckpointPath(), and FEProblemBase::FEProblemBase().
T MooseUtils::convertStringToInt | ( | const std::string & | str, |
bool | throw_on_failure | ||
) |
Definition at line 939 of file MooseUtils.C.
void MooseUtils::createSymlink | ( | const std::string & | target, |
const std::string & | link | ||
) |
Create a symbolic link, if the link already exists it is replaced.
Definition at line 1152 of file MooseUtils.C.
Referenced by CSV::output().
std::string MooseUtils::docsDir | ( | const std::string & | app_name | ) |
Returns the directory of any installed docs/site.
Definition at line 120 of file MooseUtils.C.
Referenced by MooseApp::run().
bool MooseUtils::doesMapContainValue | ( | const std::map< T1, T2 > & | the_map, |
const T2 & | value | ||
) |
This routine is a simple helper function for searching a map by values instead of keys.
Definition at line 323 of file MooseUtils.h.
Referenced by MooseMeshUtils::getBoundaryIDs().
void MooseUtils::escape | ( | std::string & | str | ) |
This function will escape all of the standard C++ escape characters so that they can be printed.
The passed in parameter is modified in place
Definition at line 196 of file MooseUtils.C.
Referenced by MooseServer::addParametersToList(), MooseServer::addValuesToList(), MooseServer::getHoverDisplayText(), YAMLFormatter::printBlockOpen(), InputFileFormatter::printParams(), YAMLFormatter::printParams(), and JsonSyntaxTree::setParams().
void MooseUtils::expandAllMatches | ( | const std::vector< T > & | candidates, |
std::vector< T > & | patterns | ||
) |
Definition at line 753 of file MooseUtils.h.
Referenced by SingleMatrixPreconditioner::SingleMatrixPreconditioner().
std::size_t MooseUtils::fileSize | ( | const std::string & | filename | ) |
C::iterator MooseUtils::findPair | ( | C & | container, |
const M1 & | first, | ||
const M2 & | second | ||
) |
Find a specific pair in a container matching on first, second or both pair components.
Definition at line 1053 of file MooseUtils.h.
Referenced by Moose::PetscSupport::disableLinearConvergedReason(), Moose::PetscSupport::disableNonlinearConvergedReason(), Moose::PetscSupport::isSNESVI(), and Moose::PetscSupport::processPetscPairs().
std::string MooseUtils::findTestRoot | ( | ) |
Searches in the current working directory and then recursively up in each parent directory looking for a "testroot" file.
Returns the full path to the first testroot file found.
Definition at line 74 of file MooseUtils.C.
Referenced by MooseApp::runInputs().
T* MooseUtils::get | ( | const std::unique_ptr< T > & | u | ) |
The MooseUtils::get() specializations are used to support making forwards-compatible code changes from dumb pointers to smart pointers.
The same line of code, e.g.
libMesh::Parameters::Value * value = MooseUtils::get(map_iter->second);
will then work regardless of whether map_iter->second is a dumb pointer or a smart pointer. Note that the smart pointer get() functions are const so they can be (ab)used to get a non-const pointer to the underlying resource. We are simply following this convention here.
Definition at line 1147 of file MooseUtils.h.
Referenced by InputParameterWarehouse::addInputParameters(), JsonSyntaxTree::buildOptions(), YAMLFormatter::buildOutputString(), JsonSyntaxTree::buildOutputString(), RestartableDataIO::currentData(), RestartableDataIO::dataSize(), and Moose::Builder::extractParams().
T* MooseUtils::get | ( | T * | p | ) |
Definition at line 1154 of file MooseUtils.h.
T* MooseUtils::get | ( | const std::shared_ptr< T > & | s | ) |
Definition at line 1161 of file MooseUtils.h.
std::string MooseUtils::getCurrentWorkingDir | ( | ) |
Returns the current working directory as a string.
If there's a problem obtaining the current working directory, this function just returns an empty string. It doesn't not throw.
Definition at line 419 of file MooseUtils.C.
Referenced by MooseApp::runInputs().
ExecFlagEnum MooseUtils::getDefaultExecFlagEnum | ( | ) |
Return the default ExecFlagEnum for MOOSE.
Definition at line 1053 of file MooseUtils.C.
Referenced by AddNodalNormalsAction::act(), AdvancedOutput::addValidParams(), Output::getDefaultExecFlagEnum(), Control::getExecuteOptions(), OutputOnWarehouse::OutputOnWarehouse(), SetupDebugAction::validParams(), and SetupInterface::validParams().
std::list< std::string > MooseUtils::getFilesInDirs | ( | const std::list< std::string > & | directory_list, |
const bool | files_only = true |
||
) |
Retrieves the names of all of the files contained within the list of directories passed into the routine.
The names returned will be the paths to the files relative to the current directory.
directory_list | The list of directories to retrieve files from. |
file_only | Whether or not to list only files |
Definition at line 791 of file MooseUtils.C.
Referenced by MooseApp::getCheckpointFiles().
std::string MooseUtils::getLatestCheckpointFilePrefix | ( | const std::list< std::string > & | checkpoint_files | ) |
Returns the most recent checkpoint prefix (the four numbers at the begining) If a suitable file isn't found the empty string is returned.
checkpoint_files | the list of files to analyze |
Definition at line 802 of file MooseUtils.C.
Referenced by convertLatestCheckpoint(), and MooseApp::setRestartRecoverFileBase().
unsigned short MooseUtils::getTermWidth | ( | bool | use_environment | ) |
Returns the width of the terminal using sys/ioctl.
Initialize the value we intend to populate just in case the system call fails
Initialize the value we intend to populate just in case the system call fails
Definition at line 623 of file MooseUtils.C.
Referenced by FormattedTable::printTable().
bool MooseUtils::globCompare | ( | const std::string & | candidate, |
const std::string & | pattern, | ||
std::size_t | c = 0 , |
||
std::size_t | p = 0 |
||
) |
Definition at line 915 of file MooseUtils.C.
Referenced by RestartableDataReporter::execute(), expandAllMatches(), and ReferenceResidualProblem::initialSetup().
bool MooseUtils::hasExtension | ( | const std::string & | filename, |
std::string | ext, | ||
bool | strip_exodus_ext = false |
||
) |
Function tests if the supplied filename as the desired extension.
filename | The filename to test the extension |
ext | The extension to test for (do not include the .) |
strip_exodus_ext | When true, this function ignores -s* from the end of the extension |
Definition at line 386 of file MooseUtils.C.
Referenced by FileRangeBuilder::FileRangeBuilder(), getLatestCheckpointFilePrefix(), and SolutionUserObject::initialSetup().
std::string MooseUtils::hostname | ( | ) |
Get the hostname the current process is running on.
Definition at line 607 of file MooseUtils.C.
Referenced by MooseApp::MooseApp().
void MooseUtils::indentMessage | ( | const std::string & | prefix, |
std::string & | message, | ||
const char * | color = COLOR_CYAN , |
||
bool | dont_indent_first_line = true , |
||
const std::string & | post_prefix = ": " |
||
) |
Indents the supplied message given the prefix and color.
prefix | The prefix to use for indenting |
message | The message that will be indented |
color | The color to apply to the prefix (default CYAN) |
indent_first_line | If true this will indent the first line too (default) |
post_prefix | A string to append right after the prefix, defaults to a column and a space |
Takes a message like the following and indents it with another color code (see below)
Input message: COLOR_YELLOW *** Warning *** Something bad has happened and we want to draw attention to it with color COLOR_DEFAULT
Output message: COLOR_CYAN sub_app: COLOR_YELLOW COLOR_CYAN sub_app: COLOR_YELLOW *** Warning *** COLOR_CYAN sub_app: COLOR_YELLOW Something bad has happened and we want to draw attention to it with color COLOR_DEFAULT
Also handles single line color codes COLOR_CYAN sub_app: 0 Nonlinear |R| = COLOR_GREEN 1.0e-10 COLOR_DEFAULT
Not indenting the first line is useful in the case where the first line is actually finishing the line before it.
Definition at line 721 of file MooseUtils.C.
Referenced by FEProblemBase::checkNonlinearConvergence(), ConsoleUtils::formatString(), OutputWarehouse::mooseConsole(), moose::internal::mooseErrorRaw(), MooseApp::setupOptions(), and Console::write().
std::string MooseUtils::installedInputsDir | ( | const std::string & | app_name, |
const std::string & | dir_name, | ||
const std::string & | extra_error_msg = "" |
||
) |
Returns the directory of any installed inputs or the empty string if none are found.
Definition at line 98 of file MooseUtils.C.
Referenced by MooseApp::copyInputs().
|
inline |
Courtesy https://stackoverflow.com/a/8889045 and https://en.cppreference.com/w/cpp/string/byte/isdigit.
Definition at line 1200 of file MooseUtils.h.
Referenced by RenameBlockGenerator::generate(), RenameBoundaryGenerator::generate(), MooseMeshUtils::getBoundaryID(), MooseMeshUtils::getBoundaryIDs(), and MooseMeshUtils::getSubdomainID().
bool MooseUtils::isZero | ( | const T & | value, |
const Real | tolerance = TOLERANCE * TOLERANCE * TOLERANCE |
||
) |
value | The quantity to test for zero-ness |
tolerance | The tolerance for testing zero-ness. The default is 1e-18 for double precision configurations of libMesh/MOOSE |
Definition at line 628 of file MooseUtils.h.
Referenced by MathUtils::barycentricToCartesian2D(), MathUtils::barycentricToCartesian3D(), MathUtils::circumcenter2D(), and MathUtils::circumcenter3D().
std::string MooseUtils::join | ( | const T & | strings, |
const std::string & | delimiter | ||
) |
Python like join function for strings.
Definition at line 130 of file MooseUtils.h.
Referenced by MooseObjectWarehouseBase< Indicator >::activeObjectsToFormattedString(), boundaryIntegrityCheckError(), ControllableParameter::checkExecuteOnType(), ComputeFVFluxThread< RangeType, AttribMatrixTags >::checkPropDeps(), MeshGeneratorSystem::createAddedMeshGenerators(), MeshGeneratorSystem::createMeshGeneratorOrder(), DependencyResolverInterface::cyclicDependencyError(), MaterialBase::declareGenericPropertyByName(), MaterialPropertyInterface::getBlockMaterialProperty(), Material::getGenericMaterialPropertyByName(), MaterialPropertyInterface::getGenericMaterialPropertyByName(), Syntax::getSortedTask(), MaterialPropertyInterface::hasADMaterialPropertyByName(), MaterialPropertyInterface::hasMaterialPropertyByName(), SubProblem::initialSetup(), ConsoleUtils::mooseObjectVectorToString(), MaterialPropertyDebugOutput::output(), and SubProblem::showFunctorRequestors().
int MooseUtils::levenshteinDist | ( | const std::string & | s1, |
const std::string & | s2 | ||
) |
Computes and returns the Levenshtein distance between strings s1 and s2.
Definition at line 165 of file MooseUtils.C.
Referenced by Moose::findSimilar().
processor_id_type MooseUtils::linearPartitionChunk | ( | dof_id_type | num_items, |
dof_id_type | num_chunks, | ||
dof_id_type | item_id | ||
) |
Return the chunk_id that is assigned to handle item_id.
num_items | Global number of items to partition |
num_chunks | Total number of chunks to split into |
item_id | The item to find the chunk_id for |
Definition at line 1091 of file MooseUtils.C.
Referenced by DistributedRectilinearMeshGenerator::buildCube().
void MooseUtils::linearPartitionItems | ( | dof_id_type | num_items, |
dof_id_type | num_chunks, | ||
dof_id_type | chunk_id, | ||
dof_id_type & | num_local_items, | ||
dof_id_type & | local_items_begin, | ||
dof_id_type & | local_items_end | ||
) |
Linearly partition a number of items.
num_items | The number of items to partition |
num_chunks | The number of chunks to partition into |
chunk_id | The ID of the chunk you are trying to get information about (typically the current MPI rank) |
num_local_items | Output: The number of items for this chunk_id |
local_items_begin | Output: The first item for this chunk_id |
local_items_end | Output: One past the final item for this chunk_id |
Definition at line 1065 of file MooseUtils.C.
Referenced by DistributedRectilinearMeshGenerator::buildCube().
std::list< std::string > MooseUtils::listDir | ( | const std::string | path, |
bool | files_only = false |
||
) |
Definition at line 765 of file MooseUtils.C.
Referenced by convertLatestCheckpoint(), DataFileInterface< Action >::getDataFileNameByName(), getFilesInDirs(), and removedirs().
void MooseUtils::makedirs | ( | const std::string & | dir_name, |
bool | throw_on_failure = false |
||
) |
Recursively make directories.
dir_name | A complete path |
throw_on_failure | True to throw instead of error out when creating a directory is failed. |
The path can be relative like 'a/b/c' or absolute like '/a/b/c'. The path is allowed to contain '.' or '..'.
Definition at line 432 of file MooseUtils.C.
Referenced by MooseApp::MooseApp().
void MooseUtils::MaterialPropertyStorageDump | ( | const HashMap< const libMesh::Elem *, HashMap< unsigned int, MaterialProperties >> & | props | ) |
Function to dump the contents of MaterialPropertyStorage for debugging purposes.
props | The storage item to dump, this should be MaterialPropertyStorage.props(state) |
Currently this only words for scalar material properties. Something to do as needed would be to create a method in MaterialProperty that may be overloaded to dump the type using template specialization.
Definition at line 671 of file MooseUtils.C.
int MooseUtils::numDigits | ( | const T & | num | ) |
Return the number of digits for a number.
This can foster quite a large discussion: https://stackoverflow.com/questions/1489830/efficient-way-to-determine-number-of-digits-in-an-integer
For our purposes I like the following algorithm.
Definition at line 940 of file MooseUtils.h.
Referenced by XMLOutput::filename(), JSONOutput::filename(), CSV::getVectorPostprocessorFileName(), CSV::output(), MooseUtils::DelimitedFileReader::readColumnData(), and MooseUtils::DelimitedFileReader::readRowData().
void MooseUtils::parallelBarrierNotify | ( | const libMesh::Parallel::Communicator & | comm, |
bool | messaging = true |
||
) |
This function implements a parallel barrier function but writes progress to stdout.
Referenced by FEProblemBase::backupMultiApps(), FEProblemBase::execMultiApps(), FEProblemBase::execMultiAppTransfers(), FEProblemBase::finishMultiAppStep(), and FEProblemBase::restoreMultiApps().
void MooseUtils::parallelBarrierNotify | ( | const Parallel::Communicator & | comm, |
bool | messaging | ||
) |
Definition at line 326 of file MooseUtils.C.
bool MooseUtils::parsesToReal | ( | const std::string & | input | ) |
Check if the input string can be parsed into a Real.
Definition at line 88 of file MooseUtils.C.
Referenced by DiffusionCG::addFEBCs(), DiffusionCG::addFEKernels(), DiffusionFV::addFVBCs(), and DiffusionFV::addFVKernels().
bool MooseUtils::pathContains | ( | const std::string & | expression, |
const std::string & | string_to_find, | ||
const std::string & | delims = "/" |
||
) |
This function tokenizes a path and checks to see if it contains the string to look for.
Definition at line 224 of file MooseUtils.C.
bool MooseUtils::pathExists | ( | const std::string & | path | ) |
Definition at line 240 of file MooseUtils.C.
Referenced by MooseApp::copyInputs(), FileMeshGenerator::deduceCheckpointPath(), docsDir(), findTestRoot(), installedInputsDir(), RestartableDataReader::isAvailable(), makedirs(), removedirs(), MooseApp::run(), and runTestsExecutable().
bool MooseUtils::pathIsDirectory | ( | const std::string & | path | ) |
Definition at line 247 of file MooseUtils.C.
Referenced by Registry::addDataFilePath(), and DataFileInterface< Action >::getDataFileNameByName().
std::filesystem::path MooseUtils::pathjoin | ( | const std::filesystem::path & | p | ) |
Definition at line 58 of file MooseUtils.C.
Referenced by Registry::addDataFilePath(), docsDir(), findTestRoot(), DataFileInterface< Action >::getDataFileNameByName(), installedInputsDir(), ADFParser::JITCompile(), MooseApp::loadLibraryAndDependencies(), pathjoin(), MooseApp::run(), and runTestsExecutable().
std::filesystem::path MooseUtils::pathjoin | ( | const std::filesystem::path & | p, |
Args... | args | ||
) |
Definition at line 64 of file MooseUtils.h.
std::string MooseUtils::prettyCppType | ( | const std::string & | cpp_type | ) |
cpp_type
. Definition at line 1232 of file MooseUtils.C.
Referenced by MooseServer::addParametersToList(), MooseServer::addValuesToList(), PhysicsBase::assertParamDefined(), ReporterGeneralContext< T >::contextType(), ReporterBroadcastContext< T >::contextType(), ReporterScatterContext< T >::contextType(), ReporterGatherContext< T >::contextType(), ReporterVectorContext< T >::contextType(), FunctorSmootherTempl< T >::FunctorSmootherTempl(), MooseServer::gatherDocumentDefinitionLocations(), prettyCppType(), ThreadedElementLoop< ConstElemPointerRange >::printExecutionOrdering(), and JsonSyntaxTree::setParams().
std::string MooseUtils::prettyCppType | ( | const T * | = nullptr | ) |
Definition at line 313 of file MooseUtils.h.
std::string MooseUtils::realpath | ( | const std::string & | path | ) |
Wrapper around PetscGetRealPath, which is a cross-platform replacement for realpath.
Definition at line 1217 of file MooseUtils.C.
Referenced by Parser::parse(), and MooseApp::run().
bool MooseUtils::relativeFuzzyEqual | ( | const T & | var1, |
const T2 & | var2, | ||
const T3 & | tol = libMesh::TOLERANCE * libMesh::TOLERANCE |
||
) |
Function to check whether two variables are equal within a relative tolerance.
var1 | The first variable to be checked |
var2 | The second variable to be checked |
tol | The relative tolerance to be used |
Definition at line 454 of file MooseUtils.h.
Referenced by MortarNodalAuxKernelTempl< ComputeValueType >::compute(), SymmetricRankFourTensorTempl< T >::fillGeneralOrthotropicFromInputVector(), SymmetricRankFourTensorTempl< T >::isIsotropic(), RankFourTensorTempl< T >::isIsotropic(), SymmetricRankTwoTensorTempl< T >::positiveProjectionEigenDecomposition(), and EigenProblem::postScaleEigenVector().
bool MooseUtils::relativeFuzzyGreaterEqual | ( | const T & | var1, |
const T2 & | var2, | ||
const T3 & | tol = libMesh::TOLERANCE * libMesh::TOLERANCE |
||
) |
Function to check whether a variable is greater than or equal to another variable within a relative tolerance.
var1 | The first variable to be checked |
var2 | The second variable to be checked |
tol | The tolerance to be used |
Definition at line 514 of file MooseUtils.h.
Referenced by FunctionDT::computeDT().
bool MooseUtils::relativeFuzzyGreaterThan | ( | const T & | var1, |
const T2 & | var2, | ||
const T3 & | tol = libMesh::TOLERANCE * libMesh::TOLERANCE |
||
) |
Function to check whether a variable is greater than another variable within a relative tolerance.
var1 | The first variable to be checked |
var2 | The second variable to be checked |
tol | The tolerance to be used |
Definition at line 538 of file MooseUtils.h.
bool MooseUtils::relativeFuzzyLessEqual | ( | const T & | var1, |
const T2 & | var2, | ||
const T3 & | tol = libMesh::TOLERANCE * libMesh::TOLERANCE |
||
) |
Function to check whether a variable is less than or equal to another variable within a relative tolerance.
var1 | The first variable to be checked |
var2 | The second variable to be checked |
tol | The tolerance to be used |
Definition at line 563 of file MooseUtils.h.
bool MooseUtils::relativeFuzzyLessThan | ( | const T & | var1, |
const T2 & | var2, | ||
const T3 & | tol = libMesh::TOLERANCE * libMesh::TOLERANCE |
||
) |
Function to check whether a variable is less than another variable within a relative tolerance.
var1 | The first variable to be checked |
var2 | The second variable to be checked |
tol | The tolerance to be used |
Definition at line 587 of file MooseUtils.h.
Referenced by PenetrationThread::competeInteractionsBothOnFace(), and FunctionDT::computeDT().
std::string & MooseUtils::removeColor | ( | std::string & | msg | ) |
remove ANSI escape sequences for terminal color from msg
Definition at line 705 of file MooseUtils.C.
Referenced by Console::writeStreamToFile().
void MooseUtils::removedirs | ( | const std::string & | dir_name, |
bool | throw_on_failure = false |
||
) |
Recursively remove directories from inner-most when the directories are empty.
dir_name | A complete path |
throw_on_failure | True to throw instead of error out when deleting a directory is failed. |
The path can be relative like 'a/b/c' or absolute like '/a/b/c'. The path is allowed to contain '.' or '..'.
Definition at line 488 of file MooseUtils.C.
std::string MooseUtils::replaceAll | ( | std::string | str, |
const std::string & | from, | ||
const std::string & | to | ||
) |
Replaces all occurences of from in str with to and returns the result.
Definition at line 134 of file MooseUtils.C.
Referenced by ReporterDebugOutput::output(), and MooseBaseParameterInterface::paramErrorMsg().
std::vector< T > MooseUtils::resample | ( | const std::vector< T > & | data, |
MooseRandom & | generator, | ||
const std::size_t | seed_index = 0 |
||
) |
Randomly resample a vector of data, allowing a value to be repeated.
data | The vector on which the values are to be swapped |
generator | Random number generator to use for shuffle |
seed_index | (default: 0) The seed index to use for calls to randl |
comm_ptr | Optional Communicator, if provided and running with multiple processors the vector is assumed to be distributed |
Definition at line 530 of file Shuffle.h.
Referenced by resample().
std::vector< T > MooseUtils::resample | ( | const std::vector< T > & | data, |
MooseRandom & | generator, | ||
const libMesh::Parallel::Communicator & | comm | ||
) |
Definition at line 539 of file Shuffle.h.
std::vector< T > MooseUtils::resample | ( | const std::vector< T > & | data, |
MooseRandom & | generator, | ||
const std::size_t | seed_index, | ||
const libMesh::Parallel::Communicator & | comm | ||
) |
Definition at line 548 of file Shuffle.h.
std::vector< T > MooseUtils::resample | ( | const std::vector< T > & | data, |
MooseRandom & | generator, | ||
const std::size_t | seed_index, | ||
const libMesh::Parallel::Communicator * | comm_ptr | ||
) |
Definition at line 334 of file Shuffle.h.
void MooseUtils::resampleWithFunctor | ( | const std::vector< T > & | data, |
const ActionFunctor & | functor, | ||
MooseRandom & | generator, | ||
const std::size_t | seed_index = 0 |
||
) |
Randomly resample a vector of data and apply a functor, allowing a value to be repeated.
data | The vector on which the values are to be swapped |
functor | Functor to apply to each entry of the resampled vector |
generator | Random number generator to use for shuffle |
seed_index | (default: 0) The seed index to use for calls to randl |
comm_ptr | Optional Communicator, if provided and running with multiple processors the vector is assumed to be distributed |
Definition at line 558 of file Shuffle.h.
Referenced by resampleWithFunctor().
void MooseUtils::resampleWithFunctor | ( | const std::vector< T > & | data, |
const ActionFunctor & | functor, | ||
MooseRandom & | generator, | ||
const libMesh::Parallel::Communicator & | comm | ||
) |
Definition at line 568 of file Shuffle.h.
void MooseUtils::resampleWithFunctor | ( | const std::vector< T > & | data, |
const ActionFunctor & | functor, | ||
MooseRandom & | generator, | ||
const std::size_t | seed_index, | ||
const libMesh::Parallel::Communicator & | comm | ||
) |
Definition at line 578 of file Shuffle.h.
void MooseUtils::resampleWithFunctor | ( | const std::vector< T > & | data, |
const ActionFunctor & | functor, | ||
MooseRandom & | generator, | ||
const std::size_t | seed_index, | ||
const libMesh::Parallel::Communicator * | comm_ptr | ||
) |
Definition at line 426 of file Shuffle.h.
auto MooseUtils::reset | ( | int | , |
T & | obj, | ||
Args... | args | ||
) | -> decltype(obj.reset(args...), void()) |
Definition at line 21 of file SharedPool.h.
Referenced by MooseUtils::SharedPool< T >::acquire().
void MooseUtils::reset | ( | double | , |
T & | , | ||
Args... | |||
) |
Definition at line 28 of file SharedPool.h.
std::vector< std::string > MooseUtils::rsplit | ( | const std::string & | str, |
const std::string & | delimiter, | ||
std::size_t | max_count = std::numeric_limits<std::size_t>::max() |
||
) |
Definition at line 1132 of file MooseUtils.C.
Referenced by Moose::Builder::setScalarParameter< ReporterName, std::string >(), Moose::Builder::setVectorParameter< CLIArgString, std::string >(), and Moose::Builder::setVectorParameter< ReporterName, std::string >().
std::string MooseUtils::runTestsExecutable | ( | ) |
Returns the location of either a local repo run_tests script - or an installed test executor script if run_tests isn't found.
Definition at line 64 of file MooseUtils.C.
Referenced by MooseApp::runInputs().
void MooseUtils::serialBegin | ( | const libMesh::Parallel::Communicator & | comm, |
bool | warn = true |
||
) |
This function marks the begin of a section of code that is executed in serial rank by rank.
The section must be closed with a call to serialEnd. These functions are intended for debugging use to obtain clean terminal output from multiple ranks (use –keep-cout).
comm | The communicator to use |
warn | Whether or not to warn that something is being serialized |
Definition at line 356 of file MooseUtils.C.
Referenced by SerializerGuard::SerializerGuard().
void MooseUtils::serialEnd | ( | const libMesh::Parallel::Communicator & | comm, |
bool | warn = true |
||
) |
Closes a section of code that is executed in serial rank by rank, and that was opened with a call to serialBegin.
No MPI communication can happen in this block.
comm | The communicator to use |
warn | Whether or not to warn that something is being serialized |
Definition at line 370 of file MooseUtils.C.
Referenced by SerializerGuard::~SerializerGuard().
bool MooseUtils::setsIntersect | ( | InputIterator | first1, |
InputIterator | last1, | ||
InputIterator | first2, | ||
InputIterator | last2 | ||
) |
This method detects whether two sets intersect without building a result set.
It exits as soon as any intersection is detected.
Definition at line 1172 of file MooseUtils.h.
Referenced by Coupleable::checkWritableVar(), and setsIntersect().
bool MooseUtils::setsIntersect | ( | const T & | s1, |
const T & | s2 | ||
) |
Definition at line 1189 of file MooseUtils.h.
std::string MooseUtils::shortName | ( | const std::string & | name | ) |
Function for stripping name after the file / in parser block.
Definition at line 595 of file MooseUtils.C.
Referenced by InputParameterWarehouse::addInputParameters(), ActionFactory::create(), CSV::getVectorPostprocessorFileName(), CSV::getVectorPostprocessorFilePrefix(), and CSV::initialSetup().
void MooseUtils::shuffle | ( | std::vector< T > & | data, |
MooseRandom & | generator, | ||
const std::size_t | seed_index = 0 |
||
) |
Shuffle function for serial or distributed vector of data that shuffles in place.
data | The vector on which the values are to be swapped |
generator | Random number generator to use for shuffle |
seed_index | (default: 0) The seed index to use for calls to randl |
comm_ptr | Optional Communicator, if provided and running with multiple processors the vector is assumed to be distributed |
Both the serial and distributed version implement a Fisher-Yates shuffle https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
NOTE: This distributed shuffle I have here does a parallel communication with each swap pair generated. I am certain that there are more efficient ways to shuffle a distributed vector, but there doesn't seem to be an algorithm in the literature (my search was not extensive).
The reason I came to this conclusion was because of a 2019 paper, which states the following (https://iopscience.iop.org/article/10.1088/1742-6596/1196/1/012035):
The study also says that the Fisher-Yates Shuffle can be developed in two ways, namely the algorithm's initial assumptions that allow for discrete uniform variables, and also with the avent of large core clusters and GPUs, there is an interest in making parallel versions of this algorithm.
This paper discusses the MergeShuffle (https://arxiv.org/abs/1508.03167), but that is a shared memory parallel algorithm.
Hence, if you want to become famous create a parallel Fisher-Yates algorithm for MPI.
Definition at line 504 of file Shuffle.h.
Referenced by shuffle().
void MooseUtils::shuffle | ( | std::vector< T > & | data, |
MooseRandom & | generator, | ||
const libMesh::Parallel::Communicator & | comm | ||
) |
Definition at line 511 of file Shuffle.h.
void MooseUtils::shuffle | ( | std::vector< T > & | data, |
MooseRandom & | generator, | ||
const std::size_t | seed_index, | ||
const libMesh::Parallel::Communicator & | comm | ||
) |
Definition at line 520 of file Shuffle.h.
void MooseUtils::shuffle | ( | std::vector< T > & | data, |
MooseRandom & | generator, | ||
const std::size_t | seed_index, | ||
const libMesh::Parallel::Communicator * | comm_ptr | ||
) |
Definition at line 243 of file Shuffle.h.
std::vector< std::string > MooseUtils::split | ( | const std::string & | str, |
const std::string & | delimiter, | ||
std::size_t | max_count = std::numeric_limits<std::size_t>::max() |
||
) |
Python like split functions for strings.
NOTE: This is similar to the tokenize function, but it maintains empty items, which tokenize does not. For example, "foo;bar;;" becomes {"foo", "bar", "", ""}.
Definition at line 1112 of file MooseUtils.C.
Referenced by SONDefinitionFormatter::addParameters(), MultiApp::createApp(), and MeshGenerator::generateInternal().
std::pair<std::filesystem::path, std::filesystem::path> MooseUtils::splitFileName | ( | const T & | full_file | ) |
Function for splitting path and filename.
full_file | A complete filename and path |
If the supplied filename does not contain a path, it returns "." as the path
Definition at line 231 of file MooseUtils.h.
Referenced by Registry::addDataFilePath(), FileRangeBuilder::FileRangeBuilder(), MooseApp::loadLibraryAndDependencies(), and MooseApp::MooseApp().
int MooseUtils::stringToInteger | ( | const std::string & | input, |
bool | throw_on_failure = false |
||
) |
Robust string to integer conversion that fails for cases such at "1foo".
input | The string to convert. |
throw_on_failure | Throw an invalid_argument exception instead of mooseError. |
Definition at line 1059 of file MooseUtils.C.
Referenced by FormattedTable::printTable().
std::string MooseUtils::stripExtension | ( | const std::string & | s | ) |
Removes any file extension from the given string s (i.e.
any ".[extension]" suffix of s) and returns the result.
Definition at line 410 of file MooseUtils.C.
Referenced by SplitMeshAction::act(), and SetupMeshAction::modifyParamsForUseSplit().
void MooseUtils::swap | ( | std::vector< T > & | data, |
const std::size_t | idx0, | ||
const std::size_t | idx1, | ||
const libMesh::Parallel::Communicator & | comm | ||
) |
Swap function for serial or distributed vector of data.
data | The vector on which the values are to be swapped |
idx0,idx1 | The global indices to be swapped |
comm_ptr | Optional Communicator, if provided and running with multiple processors the vector is assumed to be distributed |
Definition at line 494 of file Shuffle.h.
Referenced by Syntax::addDependencySets(), AllNodesSendListThread::AllNodesSendListThread(), Moose::applyIndices(), AutomaticMortarGeneration::buildMortarSegmentMesh(), RestartableDataReader::clear(), DistributedRectilinearMeshGenerator::paritionSquarely(), MaterialPropertyStorage::shift(), shuffle(), swap(), MooseUtils::StaticallyAllocatedSet< T, N >::swap(), MooseArray< libMesh::VectorValue >::swap(), and MooseUtils::Buffer< T >::swap().
void MooseUtils::swap | ( | std::vector< T > & | data, |
const std::size_t | idx0, | ||
const std::size_t | idx1, | ||
const libMesh::Parallel::Communicator * | comm_ptr = nullptr |
||
) |
Definition at line 155 of file Shuffle.h.
void MooseUtils::tokenize | ( | const std::string & | str, |
std::vector< T > & | elements, | ||
unsigned int | min_len = 1 , |
||
const std::string & | delims = "/" |
||
) |
This function will split the passed in string on a set of delimiters appending the substrings to the passed in vector.
The delimiters default to "/" but may be supplied as well. In addition if min_len is supplied, the minimum token length will be greater than the supplied value. T should be std::string or a MOOSE derived string class.
Definition at line 779 of file MooseUtils.h.
Referenced by CommandLine::addArgument(), InputParameters::addCommandLineParamHelper(), Syntax::addDependencySets(), MooseEnumBase::addEnumerationName(), MooseEnumBase::addEnumerationNames(), JsonInputFileFormatter::addLine(), InputParameters::addParamNamesToGroup(), MultiMooseEnum::erase(), TransfiniteMeshGenerator::getDiscreteEdge(), MooseApp::getLibrarySearchPaths(), TransfiniteMeshGenerator::getParsedEdge(), Syntax::isAssociated(), makedirs(), MultiMooseEnum::operator=(), FunctionMaterialPropertyDescriptor< is_ad >::parseDependentSymbols(), FunctionMaterialPropertyDescriptor< is_ad >::parseDerivative(), pathContains(), InputFileFormatter::printParams(), MultiMooseEnum::push_back(), MooseUtils::DelimitedFileReader::readColumnData(), InputParameters::registerBuildableTypes(), removedirs(), Moose::Builder::setDoubleIndexParameter(), Moose::Builder::setScalarParameter(), Moose::Builder::setTripleIndexParameter(), Moose::Builder::setVectorVectorComponentParameter(), MooseApp::showInputs(), SingleMatrixPreconditioner::SingleMatrixPreconditioner(), tokenizeAndConvert(), and wildCardMatch().
bool MooseUtils::tokenizeAndConvert | ( | const std::string & | str, |
std::vector< T > & | tokenized_vector, | ||
const std::string & | delimiter = " \t\n\v\f\r" |
||
) |
tokenizeAndConvert splits a string using delimiter and then converts to type T.
If the conversion fails tokenizeAndConvert returns false, otherwise true.
Definition at line 806 of file MooseUtils.h.
Referenced by SplitMeshAction::act(), TransfiniteMeshGenerator::getCircarcEdge(), TransfiniteMeshGenerator::getDiscreteEdge(), and MooseApp::MooseApp().
std::string MooseUtils::toLower | ( | const std::string & | name | ) |
Convert supplied string to lower case.
name The string to convert upper case.
Definition at line 1045 of file MooseUtils.C.
Referenced by MooseServer::getDocumentSymbolKind(), SubProblem::getVariableHelper(), ConsoleUtils::outputRelationshipManagerInformation(), and WorkBalance::WorkBalance().
std::string MooseUtils::toUpper | ( | const std::string & | name | ) |
Convert supplied string to upper case.
name The string to convert upper case.
Definition at line 1037 of file MooseUtils.C.
Referenced by SubProblem::addMatrixTag(), SubProblem::addVectorTag(), MooseEnumBase::find(), SubProblem::getMatrixTagID(), SubProblem::getVectorTagID(), SubProblem::matrixTagExists(), MooseEnumItem::operator!=(), MooseEnumItem::operator==(), MooseEnum::operator==(), moose::internal::ExecFlagRegistry::registerFlag(), Coupleable::vectorTagDofValueHelper(), SubProblem::vectorTagExists(), and Coupleable::vectorTagValueHelper().
std::string MooseUtils::trim | ( | const std::string & | str, |
const std::string & | white_space = " \t\n\v\f\r" |
||
) |
Standard scripting language trim function.
Definition at line 214 of file MooseUtils.C.
Referenced by CommandLine::addArgument(), MooseEnumBase::addEnumerationName(), JsonInputFileFormatter::addLine(), JsonInputFileFormatter::addParameters(), SONDefinitionFormatter::addParameters(), MooseServer::addParametersToList(), InputParameters::appendFunctorDescription(), MooseServer::formatDocument(), MooseUtils::DelimitedFileReader::preprocessLine(), InputFileFormatter::printParams(), MooseUtils::DelimitedFileReader::readColumnData(), and tokenizeAndConvert().
std::string MooseUtils::underscoreToCamelCase | ( | const std::string & | underscore_name, |
bool | leading_upper_case | ||
) |
Function for converting an underscore name to a camel case name.
underscore_name | A string containing underscores |
Definition at line 563 of file MooseUtils.C.
Referenced by MooseApp::libNameToAppName(), and ConsoleUtils::outputRelationshipManagerInformation().
bool MooseUtils::wildcardEqual | ( | const T1 & | a, |
const T2 & | b | ||
) |
Definition at line 1029 of file MooseUtils.h.
Referenced by findPair().
bool MooseUtils::wildcardEqual | ( | const T & | , |
AnyType | |||
) |
Definition at line 1036 of file MooseUtils.h.
bool MooseUtils::wildcardEqual | ( | AnyType | , |
const T & | |||
) |
Definition at line 1042 of file MooseUtils.h.
bool MooseUtils::wildCardMatch | ( | std::string | name, |
std::string | search_string | ||
) |
Definition at line 871 of file MooseUtils.C.
Referenced by JsonSyntaxTree::addParameters(), JsonSyntaxTree::addSyntaxType(), SyntaxTree::TreeNode::print(), InputFileFormatter::printParams(), and JsonSyntaxTree::setParams().
|
static |