https://mooseframework.inl.gov
MooseUtils.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 // MOOSE includes
13 #include "MooseTypes.h"
14 #include "HashMap.h"
15 #include "InfixIterator.h"
16 #include "MooseEnumItem.h"
17 #include "MooseError.h"
18 #include "Moose.h"
19 #include "ExecutablePath.h"
20 #include "ConsoleUtils.h"
21 #include "MooseStringUtils.h"
22 
23 #include "libmesh/compare_types.h"
24 #include "libmesh/bounding_box.h"
25 #include "libmesh/int_range.h"
26 #include "libmesh/tensor_tools.h"
27 #include "metaphysicl/raw_type.h"
28 #include "metaphysicl/metaphysicl_version.h"
29 #include "metaphysicl/dualnumber_decl.h"
30 #include "metaphysicl/dynamic_std_array_wrapper.h"
31 #include "timpi/standard_type.h"
32 
33 // C++ includes
34 #include <string>
35 #include <vector>
36 #include <map>
37 #include <list>
38 #include <filesystem>
39 #include <deque>
40 #include <regex>
41 
42 // Forward Declarations
43 class InputParameters;
44 class ExecFlagEnum;
45 class MaterialProperties;
46 class MaterialBase;
47 
48 namespace libMesh
49 {
50 class Elem;
51 namespace Parallel
52 {
53 class Communicator;
54 }
55 }
56 class MultiMooseEnum;
57 
58 namespace MooseUtils
59 {
60 
61 std::filesystem::path pathjoin(const std::filesystem::path & p);
62 
63 template <typename... Args>
64 std::filesystem::path
65 pathjoin(const std::filesystem::path & p, Args... args)
66 {
67  return p / pathjoin(args...);
68 }
69 
73 bool parsesToReal(const std::string & input, Real * parsed_real = nullptr);
74 
77 std::string runTestsExecutable();
78 
82 std::string findTestRoot();
83 
85 std::string installedInputsDir(const std::string & app_name,
86  const std::string & dir_name,
87  const std::string & extra_error_msg = "");
88 
90 std::string docsDir(const std::string & app_name);
91 
99 std::string mooseDocsURL(const std::string & path);
100 
102 std::string replaceAll(std::string str, const std::string & from, const std::string & to);
103 
107 std::string convertLatestCheckpoint(std::string orig);
108 
110 int levenshteinDist(const std::string & s1, const std::string & s2);
111 
117 void escape(std::string & str);
118 
124 std::string removeExtraWhitespace(const std::string & str);
125 
132 std::vector<std::string> split(const std::string & str,
133  const std::string & delimiter,
134  std::size_t max_count = std::numeric_limits<std::size_t>::max());
135 std::vector<std::string> rsplit(const std::string & str,
136  const std::string & delimiter,
137  std::size_t max_count = std::numeric_limits<std::size_t>::max());
138 
142 template <typename Iterator>
143 std::string
144 join(Iterator begin, Iterator end, const std::string & delimiter)
145 {
146  std::ostringstream oss;
147  std::copy(begin, end, infix_ostream_iterator<std::string>(oss, delimiter.c_str()));
148  return oss.str();
149 }
150 
154 template <typename T>
155 std::string
156 join(const T & strings, const std::string & delimiter)
157 {
158  return join(strings.begin(), strings.end(), delimiter);
159 }
160 
164 std::size_t fileSize(const std::string & filename);
165 
169 bool pathContains(const std::string & expression,
170  const std::string & string_to_find,
171  const std::string & delims = "/");
172 
182 bool checkFileReadable(const std::string & filename,
183  bool check_line_endings = false,
184  bool throw_on_unreadable = true,
185  bool check_for_git_lfs_pointer = true);
186 
193 bool checkFileWriteable(const std::string & filename, bool throw_on_unwritable = true);
194 
204 bool checkForGitLFSPointer(std::ifstream & file);
205 
210 void parallelBarrierNotify(const libMesh::Parallel::Communicator & comm, bool messaging = true);
211 
220 void serialBegin(const libMesh::Parallel::Communicator & comm, bool warn = true);
221 
228 void serialEnd(const libMesh::Parallel::Communicator & comm, bool warn = true);
229 
237 bool hasExtension(const std::string & filename, std::string ext, bool strip_exodus_ext = false);
238 
246 std::string getExtension(const std::string & filename, const bool rfind = false);
247 
252 std::string stripExtension(const std::string & s, const bool rfind = false);
253 
261 template <typename T>
262 std::pair<std::filesystem::path, std::filesystem::path>
263 splitFileName(const T & full_file)
264 {
265  const auto p = std::filesystem::path(std::string(full_file));
266  // Error if path ends with /
267  if (!p.has_filename())
268  mooseError("Invalid full file name: ", p);
269 
270  const auto d = p.parent_path();
271  return {d.empty() ? "." : d, p.filename()};
272 }
273 
279 std::string getCurrentWorkingDir();
280 
289 void makedirs(const std::string & dir_name, bool throw_on_failure = false);
290 
299 void removedirs(const std::string & dir_name, bool throw_on_failure = false);
300 
306 std::string camelCaseToUnderscore(const std::string & camel_case_name);
307 
313 std::string underscoreToCamelCase(const std::string & underscore_name, bool leading_upper_case);
314 
318 std::string shortName(const std::string & name);
319 
323 std::string baseName(const std::string & name);
324 
328 std::string hostname();
329 
333 unsigned short getTermWidth(bool use_environment);
334 
338 std::string prettyCppType(const std::string & cpp_type);
339 
343 template <typename T>
344 std::string
345 prettyCppType(const T * obj = nullptr)
346 {
347  if (obj)
348  return prettyCppType(libMesh::demangle(typeid(*obj).name()));
349  else
350  return prettyCppType(libMesh::demangle(typeid(T).name()));
351 }
352 
356 template <typename T1, typename T2>
357 bool
358 doesMapContainValue(const std::map<T1, T2> & the_map, const T2 & value)
359 {
360  for (typename std::map<T1, T2>::const_iterator iter = the_map.begin(); iter != the_map.end();
361  ++iter)
362  if (iter->second == value)
363  return true;
364  return false;
365 }
366 
376 inline bool
377 absoluteFuzzyEqual(const Point & v1,
378  const Point & v2,
379  const Real tol = libMesh::TOLERANCE * libMesh::TOLERANCE)
380 {
381  for (const auto i : make_range(LIBMESH_DIM))
382  if (std::abs(v1(i) - v2(i)) > tol)
383  return false;
384  return true;
385 }
386 
394 template <
395  typename T,
396  typename T2,
397  typename T3 = T,
398  typename std::enable_if<libMesh::ScalarTraits<T>::value && libMesh::ScalarTraits<T2>::value &&
400  int>::type = 0>
401 bool
402 absoluteFuzzyEqual(const T & var1,
403  const T2 & var2,
404  const T3 & tol = libMesh::TOLERANCE * libMesh::TOLERANCE)
405 {
406  return (std::abs(MetaPhysicL::raw_value(var1) - MetaPhysicL::raw_value(var2)) <=
408 }
409 
418 template <
419  typename T,
420  typename T2,
421  typename T3 = T,
422  typename std::enable_if<libMesh::ScalarTraits<T>::value && libMesh::ScalarTraits<T2>::value &&
424  int>::type = 0>
425 bool
426 absoluteFuzzyGreaterEqual(const T & var1,
427  const T2 & var2,
428  const T3 & tol = libMesh::TOLERANCE * libMesh::TOLERANCE)
429 {
430  return (MetaPhysicL::raw_value(var1) >=
432 }
433 
442 template <
443  typename T,
444  typename T2,
445  typename T3 = T,
446  typename std::enable_if<libMesh::ScalarTraits<T>::value && libMesh::ScalarTraits<T2>::value &&
448  int>::type = 0>
449 bool
450 absoluteFuzzyGreaterThan(const T & var1,
451  const T2 & var2,
452  const T3 & tol = libMesh::TOLERANCE * libMesh::TOLERANCE)
453 {
454  return (MetaPhysicL::raw_value(var1) >
456 }
457 
466 template <
467  typename T,
468  typename T2,
469  typename T3 = T,
470  typename std::enable_if<libMesh::ScalarTraits<T>::value && libMesh::ScalarTraits<T2>::value &&
472  int>::type = 0>
473 bool
474 absoluteFuzzyLessEqual(const T & var1,
475  const T2 & var2,
476  const T3 & tol = libMesh::TOLERANCE * libMesh::TOLERANCE)
477 {
478  return (MetaPhysicL::raw_value(var1) <=
480 }
481 
489 template <
490  typename T,
491  typename T2,
492  typename T3 = T,
493  typename std::enable_if<libMesh::ScalarTraits<T>::value && libMesh::ScalarTraits<T2>::value &&
495  int>::type = 0>
496 bool
497 absoluteFuzzyLessThan(const T & var1,
498  const T2 & var2,
499  const T3 & tol = libMesh::TOLERANCE * libMesh::TOLERANCE)
500 {
501  return (MetaPhysicL::raw_value(var1) <
503 }
504 
512 template <typename T, typename T2, typename T3 = Real>
513 bool
514 relativeFuzzyEqual(const T & var1,
515  const T2 & var2,
516  const T3 & tol = libMesh::TOLERANCE * libMesh::TOLERANCE)
517 {
518  if constexpr (libMesh::ScalarTraits<T>::value ||
520  {
523  "Mathematical types must be same for arguments to relativelyFuzzEqual");
525  return absoluteFuzzyEqual(
526  var1,
527  var2,
528  tol * (std::abs(MetaPhysicL::raw_value(var1)) + std::abs(MetaPhysicL::raw_value(var2))));
529  else if constexpr (libMesh::TensorTools::TensorTraits<T>::rank == 1)
530  {
531  for (const auto i : make_range(Moose::dim))
532  if (!relativeFuzzyEqual(var1(i), var2(i), tol))
533  return false;
534 
535  return true;
536  }
537  else if constexpr (libMesh::TensorTools::TensorTraits<T>::rank == 2)
538  {
539  for (const auto i : make_range(Moose::dim))
540  for (const auto j : make_range(Moose::dim))
541  if (!relativeFuzzyEqual(var1(i, j), var2(i, j), tol))
542  return false;
543 
544  return true;
545  }
546  }
547  else
548  {
549  // We dare to dream
550  mooseAssert(var1.size() == var2.size(), "These must be the same size");
551  for (const auto i : index_range(var1))
552  if (!relativeFuzzyEqual(var1(i), var2(i), tol))
553  return false;
554 
555  return true;
556  }
557 }
558 
567 template <
568  typename T,
569  typename T2,
570  typename T3 = T,
571  typename std::enable_if<libMesh::ScalarTraits<T>::value && libMesh::ScalarTraits<T2>::value &&
573  int>::type = 0>
574 bool
575 relativeFuzzyGreaterEqual(const T & var1,
576  const T2 & var2,
577  const T3 & tol = libMesh::TOLERANCE * libMesh::TOLERANCE)
578 {
579  return (absoluteFuzzyGreaterEqual(
580  var1,
581  var2,
583 }
584 
592 template <
593  typename T,
594  typename T2,
595  typename T3 = T,
596  typename std::enable_if<libMesh::ScalarTraits<T>::value && libMesh::ScalarTraits<T2>::value &&
598  int>::type = 0>
599 bool
600 relativeFuzzyGreaterThan(const T & var1,
601  const T2 & var2,
602  const T3 & tol = libMesh::TOLERANCE * libMesh::TOLERANCE)
603 {
604  return (absoluteFuzzyGreaterThan(
605  var1,
606  var2,
608 }
609 
618 template <
619  typename T,
620  typename T2,
621  typename T3 = T,
622  typename std::enable_if<libMesh::ScalarTraits<T>::value && libMesh::ScalarTraits<T2>::value &&
624  int>::type = 0>
625 bool
626 relativeFuzzyLessEqual(const T & var1,
627  const T2 & var2,
628  const T3 & tol = libMesh::TOLERANCE * libMesh::TOLERANCE)
629 {
630  return (absoluteFuzzyLessEqual(
631  var1,
632  var2,
634 }
635 
643 template <
644  typename T,
645  typename T2,
646  typename T3 = T,
647  typename std::enable_if<libMesh::ScalarTraits<T>::value && libMesh::ScalarTraits<T2>::value &&
649  int>::type = 0>
650 bool
651 relativeFuzzyLessThan(const T & var1,
652  const T2 & var2,
653  const T3 & tol = libMesh::TOLERANCE * libMesh::TOLERANCE)
654 {
655  return (absoluteFuzzyLessThan(
656  var1,
657  var2,
659 }
660 
665 template <typename T>
666 void
667 getUnion(const std::vector<T> & vector1, const std::vector<T> & vector2, std::vector<T> & common)
668 {
669  std::unordered_set<T> unique_elements;
670  unique_elements.reserve(vector1.size() + vector2.size());
671  unique_elements.insert(vector1.begin(), vector1.end());
672  unique_elements.insert(vector2.begin(), vector2.end());
673 
674  // Now populate the common vector with the union
675  common.assign(unique_elements.begin(), unique_elements.end());
676 }
677 
683 template <typename T>
684 class Has_size
685 {
686  using Yes = char;
687  struct No
688  {
689  char x[2];
690  };
691 
692  template <typename C>
693  static Yes test(decltype(&C::size));
694  template <typename C>
695  static No test(...);
696 
697 public:
698  static constexpr bool value = sizeof(test<T>(0)) == sizeof(Yes);
699 };
700 
707 template <typename T>
708 bool
709 isZero(const T & value, const Real tolerance = TOLERANCE * TOLERANCE * TOLERANCE)
710 {
711  if constexpr (Has_size<T>::value)
712  {
713  for (const auto & element : value)
714  if (!isZero(element, tolerance))
715  return false;
716 
717  return true;
718  }
719  else if constexpr (libMesh::TensorTools::TensorTraits<T>::rank == 0)
720  return MooseUtils::absoluteFuzzyEqual(MetaPhysicL::raw_value(value), 0, tolerance);
721  else if constexpr (libMesh::TensorTools::TensorTraits<T>::rank == 1)
722  {
723  for (const auto i : make_range(Moose::dim))
724  if (!MooseUtils::absoluteFuzzyEqual(MetaPhysicL::raw_value(value(i)), 0, tolerance))
725  return false;
726 
727  return true;
728  }
729  else if constexpr (libMesh::TensorTools::TensorTraits<T>::rank == 2)
730  {
731  for (const auto i : make_range(Moose::dim))
732  for (const auto j : make_range(Moose::dim))
733  if (!MooseUtils::absoluteFuzzyEqual(MetaPhysicL::raw_value(value(i, j)), 0, tolerance))
734  return false;
735 
736  return true;
737  }
738 }
739 
751 
781 void indentMessage(const std::string & prefix,
782  std::string & message,
783  const char * color = COLOR_CYAN,
784  bool dont_indent_first_line = true,
785  const std::string & post_prefix = ": ");
786 
790 std::string & removeColor(std::string & msg);
791 
792 std::list<std::string> listDir(const std::string path, bool files_only = false);
793 
794 bool pathExists(const std::string & path);
795 
803 std::list<std::string> getFilesInDirs(const std::list<std::string> & directory_list,
804  const bool files_only = true);
805 
811 std::string getLatestCheckpointFilePrefix(const std::list<std::string> & checkpoint_files);
812 
813 /*
814  * Checks to see if a string matches a search string
815  * @param name The name to check
816  * @param search_string The search string to check name against
817  */
818 bool wildCardMatch(std::string name, std::string search_string);
819 
820 /*
821  * Checks to see if a candidate string matches a pattern string, permitting glob
822  * wildcards (* and ?) anywhere in the pattern.
823  * @param candidate The name to check
824  * @param pattern The search string to check name candidate
825  */
826 bool globCompare(const std::string & candidate,
827  const std::string & pattern,
828  std::size_t c = 0,
829  std::size_t p = 0);
830 
831 template <typename T>
832 void
833 expandAllMatches(const std::vector<T> & candidates, std::vector<T> & patterns)
834 {
835  std::set<T> expanded;
836  for (const auto & p : patterns)
837  {
838  unsigned int found = 0;
839  for (const auto & c : candidates)
840  if (globCompare(c, p))
841  {
842  expanded.insert(c);
843  found++;
844  }
845  if (!found)
846  throw std::invalid_argument(p);
847  }
848  patterns.assign(expanded.begin(), expanded.end());
849 }
850 
861 template <typename T>
862 T
863 convert(const std::string & str, bool throw_on_failure = false)
864 {
865  T val;
866  try
867  {
868  convert(str, val, true);
869  }
870  catch (std::exception const & e)
871  {
872  if (throw_on_failure)
873  throw;
874  mooseError(e.what());
875  }
876  return val;
877 }
878 
882 void createSymlink(const std::string & target, const std::string & link);
883 
887 void clearSymlink(const std::string & link);
888 
893 template <typename T>
894 T
895 concatenate(T c1, const T & c2)
896 {
897  c1.insert(c2.begin(), c2.end());
898  return c1;
899 }
900 
904 template <typename T>
905 std::vector<T>
906 concatenate(std::vector<T> c1, const std::vector<T> & c2)
907 {
908  c1.insert(c1.end(), c2.begin(), c2.end());
909  return c1;
910 }
911 
915 template <typename T>
916 std::vector<T>
917 concatenate(std::vector<T> c1, const T & item)
918 {
919  c1.push_back(item);
920  return c1;
921 }
922 
926 bool beginsWith(const std::string & value, const std::string & begin_value);
927 
936 template <typename T>
937 int
938 numDigits(const T & num)
939 {
940  return num > 9 ? static_cast<int>(std::log10(static_cast<double>(num))) + 1 : 1;
941 }
942 
947 
953 int stringToInteger(const std::string & input, bool throw_on_failure = false);
954 
966 void linearPartitionItems(dof_id_type num_items,
967  dof_id_type num_chunks,
968  dof_id_type chunk_id,
969  dof_id_type & num_local_items,
970  dof_id_type & local_items_begin,
971  dof_id_type & local_items_end);
972 
982 linearPartitionChunk(dof_id_type num_items, dof_id_type num_chunks, dof_id_type item_id);
983 
987 std::string realpath(const std::string & path);
988 
994 template <typename T>
995 struct IsLikeReal
996 {
997  static constexpr bool value = false;
998 };
999 template <>
1000 struct IsLikeReal<Real>
1001 {
1002  static constexpr bool value = true;
1003 };
1004 template <>
1005 struct IsLikeReal<ADReal>
1006 {
1007  static constexpr bool value = true;
1008 };
1009 
1013 template <typename T>
1014 struct canBroadcast
1015 {
1016  static constexpr bool value = std::is_base_of<TIMPI::DataType, TIMPI::StandardType<T>>::value ||
1017  TIMPI::Has_buffer_type<TIMPI::Packing<T>>::value;
1018 };
1019 
1021 const static struct AnyType
1022 {
1023 } Any;
1024 
1025 template <typename T1, typename T2>
1026 bool
1027 wildcardEqual(const T1 & a, const T2 & b)
1028 {
1029  return a == b;
1030 }
1031 
1032 template <typename T>
1033 bool
1034 wildcardEqual(const T &, AnyType)
1035 {
1036  return true;
1037 }
1038 template <typename T>
1039 bool
1040 wildcardEqual(AnyType, const T &)
1041 {
1042  return true;
1043 }
1045 
1049 template <typename C, typename It, typename M1, typename M2>
1050 auto
1051 findPair(C & container, It start_iterator, const M1 & first, const M2 & second)
1052 {
1053  return std::find_if(start_iterator,
1054  container.end(),
1055  [&](auto & item) {
1056  return wildcardEqual(first, item.first) &&
1057  wildcardEqual(second, item.second);
1058  });
1059 }
1060 
1076 libMesh::BoundingBox buildBoundingBox(const Point & p1, const Point & p2);
1077 
1085 template <typename T, std::size_t N, bool value_init = true>
1086 #if METAPHYSICL_MAJOR_VERSION < 2
1087 class SemidynamicVector : public MetaPhysicL::DynamicStdArrayWrapper<T, MetaPhysicL::NWrapper<N>>
1088 {
1089  typedef MetaPhysicL::DynamicStdArrayWrapper<T, MetaPhysicL::NWrapper<N>> Parent;
1090 #else
1091 class SemidynamicVector : public MetaPhysicL::DynamicStdArrayWrapper<T, N>
1092 {
1093  typedef MetaPhysicL::DynamicStdArrayWrapper<T, N> Parent;
1094 #endif
1095 
1096 public:
1097  SemidynamicVector(std::size_t size) : Parent()
1098  {
1099  Parent::resize(size);
1100  if constexpr (value_init)
1101  for (const auto i : make_range(size))
1102  _data[i] = T{};
1103  }
1104 
1105  void resize(std::size_t new_size)
1106  {
1107  [[maybe_unused]] const auto old_dynamic_n = Parent::size();
1108 
1109  Parent::resize(new_size);
1110 
1111  if constexpr (value_init)
1112  for (const auto i : make_range(old_dynamic_n, _dynamic_n))
1113  _data[i] = T{};
1114  }
1115 
1116  void push_back(const T & v)
1117  {
1118  const auto old_dynamic_n = Parent::size();
1119  Parent::resize(old_dynamic_n + 1);
1120  _data[old_dynamic_n] = v;
1121  }
1122 
1123  template <typename... Args>
1124  void emplace_back(Args &&... args)
1125  {
1126  const auto old_dynamic_n = Parent::size();
1127  Parent::resize(old_dynamic_n + 1);
1128  (::new (&_data[old_dynamic_n]) T(std::forward<Args>(args)...));
1129  }
1130 
1131  std::size_t max_size() const { return N; }
1132 
1133  using Parent::_data;
1134  using Parent::_dynamic_n;
1135 };
1136 
1149 template <typename T>
1150 T *
1151 get(const std::unique_ptr<T> & u)
1152 {
1153  return u.get();
1154 }
1155 
1156 template <typename T>
1157 T *
1158 get(T * p)
1159 {
1160  return p;
1161 }
1162 
1163 template <typename T>
1164 T *
1165 get(const std::shared_ptr<T> & s)
1166 {
1167  return s.get();
1168 }
1169 
1174 template <class InputIterator>
1175 bool
1176 setsIntersect(InputIterator first1, InputIterator last1, InputIterator first2, InputIterator last2)
1177 {
1178  while (first1 != last1 && first2 != last2)
1179  {
1180  if (*first1 == *first2)
1181  return true;
1182 
1183  if (*first1 < *first2)
1184  ++first1;
1185  else if (*first1 > *first2)
1186  ++first2;
1187  }
1188  return false;
1189 }
1190 
1191 template <class T>
1192 bool
1193 setsIntersect(const T & s1, const T & s2)
1194 {
1195  return setsIntersect(s1.begin(), s1.end(), s2.begin(), s2.end());
1196 }
1197 
1203 inline bool
1204 isDigits(const std::string & str)
1205 {
1206  return std::all_of(str.begin(), str.end(), [](unsigned char c) { return std::isdigit(c); });
1207 }
1208 
1214 inline bool
1215 isFloat(const std::string & str)
1216 {
1217  if (str.empty())
1218  return false;
1219  char * ptr;
1220  strtof(str.c_str(), &ptr);
1221  return (*ptr) == '\0';
1222 }
1223 
1227 std::string canonicalPath(const std::string & path);
1228 
1232 bool startsWith(const std::string & string1, const std::string & string2);
1233 
1238 void replaceStart(std::string & string1, const std::string & string2, const std::string & string3);
1239 
1243 bool isAllLowercase(const std::string & str);
1244 } // MooseUtils namespace
1245 
1246 namespace Moose
1247 {
1248 template <typename T>
1249 struct ADType;
1250 
1251 template <typename T, std::size_t N, bool value_init>
1252 struct ADType<MooseUtils::SemidynamicVector<T, N, value_init>>
1253 {
1254  typedef MooseUtils::SemidynamicVector<typename ADType<T>::type, N, value_init> type;
1255 };
1256 }
1257 
1261 void removeSubstring(std::string & main, const std::string & sub);
1262 
1266 std::string removeSubstring(const std::string & main, const std::string & sub);
void makedirs(const std::string &dir_name, bool throw_on_failure)
Definition: MooseUtils.C:449
std::string name(const ElemQuality q)
std::string docsDir(const std::string &app_name)
Definition: MooseUtils.C:125
MetaPhysicL::DualNumber< V, D, asd > abs(const MetaPhysicL::DualNumber< V, D, asd > &a)
Definition: EigenADReal.h:50
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:21
std::list< std::string > listDir(const std::string path, bool files_only)
Definition: MooseUtils.C:782
bool beginsWith(const std::string &value, const std::string &begin_value)
Definition: MooseUtils.C:955
void serialEnd(const libMesh::Parallel::Communicator &comm, bool warn)
Definition: MooseUtils.C:371
HashMap is an abstraction for dictionary data type, we make it thread-safe by locking inserts...
Definition: HashMap.h:18
bool pathContains(const std::string &expression, const std::string &string_to_find, const std::string &delims)
Definition: MooseUtils.C:231
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
void MaterialPropertyStorageDump(const HashMap< const libMesh::Elem *, HashMap< unsigned int, MaterialProperties >> &props)
Definition: MooseUtils.C:688
static constexpr Real TOLERANCE
bool isAllLowercase(const std::string &str)
Definition: MooseUtils.C:1195
bool startsWith(const std::string &string1, const std::string &string2)
Definition: MooseUtils.C:1179
auto raw_value(const Eigen::Map< T > &in)
Definition: EigenADReal.h:100
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:163
We need to instantiate the following CompareTypes to tell the compiler that ADReal is a subtype of Ch...
std::string installedInputsDir(const std::string &app_name, const std::string &dir_name, const std::string &extra_error_msg)
Definition: MooseUtils.C:103
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
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)
Definition: MooseUtils.C:973
bool checkForGitLFSPointer(std::ifstream &file)
Definition: MooseUtils.C:290
std::string realpath(const std::string &path)
Definition: MooseUtils.C:1125
DualNumber< Real, DNDerivativeType, true > ADReal
Definition: ADRealForward.h:42
std::string removeExtraWhitespace(const std::string &input)
Definition: MooseUtils.C:225
std::string convertLatestCheckpoint(std::string orig)
Definition: MooseUtils.C:157
std::string mooseDocsURL(const std::string &path)
Definition: MooseUtils.C:139
std::string hostname()
Definition: MooseUtils.C:624
auto max(const L &left, const R &right)
bool convert(const std::string &str, T &value, const bool throw_on_failure)
Takes the string representation of a value and converts it to the value.
std::string camelCaseToUnderscore(const std::string &camel_case_name)
Definition: MooseUtils.C:568
std::string shortName(const std::string &name)
Definition: MooseUtils.C:612
void removeSubstring(std::string &main, const std::string &sub)
Definition: MooseUtils.C:1203
ExecFlagEnum getDefaultExecFlagEnum()
Definition: MooseUtils.C:961
void replaceStart(std::string &string1, const std::string &string2, const std::string &string3)
Definition: MooseUtils.C:1187
void indentMessage(const std::string &prefix, std::string &message, const char *color, bool indent_first_line, const std::string &post_prefix)
Definition: MooseUtils.C:738
uint8_t processor_id_type
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
std::string getLatestCheckpointFilePrefix(const std::list< std::string > &checkpoint_files)
Definition: MooseUtils.C:819
std::string stripExtension(const std::string &s, const bool rfind)
Definition: MooseUtils.C:427
std::string canonicalPath(const std::string &path)
Definition: MooseUtils.C:1173
std::string runTestsExecutable()
Definition: MooseUtils.C:65
std::size_t fileSize(const std::string &filename)
Definition: MooseUtils.C:1095
std::string underscoreToCamelCase(const std::string &underscore_name, bool leading_upper_case)
Definition: MooseUtils.C:580
std::string & removeColor(std::string &msg)
Definition: MooseUtils.C:722
std::string demangle(const char *name)
int main(int argc, char *argv[])
Initialize, create and run a MooseApp.
Definition: MooseMain.h:31
charT const * delimiter
Definition: InfixIterator.h:35
void clearSymlink(const std::string &link)
Definition: MooseUtils.C:1073
std::vector< std::string > rsplit(const std::string &str, const std::string &delimiter, std::size_t max_count)
Definition: MooseUtils.C:1040
processor_id_type linearPartitionChunk(dof_id_type num_items, dof_id_type num_chunks, dof_id_type item_id)
Definition: MooseUtils.C:999
void createSymlink(const std::string &target, const std::string &link)
Definition: MooseUtils.C:1060
std::filesystem::path pathjoin(const std::filesystem::path &p)
Definition: MooseUtils.C:59
bool hasExtension(const std::string &filename, std::string ext, bool strip_exodus_ext)
Definition: MooseUtils.C:387
std::string baseName(const std::string &name)
Definition: MooseUtils.C:618
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void serialBegin(const libMesh::Parallel::Communicator &comm, bool warn)
Definition: MooseUtils.C:357
bool wildCardMatch(std::string name, std::string search_string)
Definition: MooseUtils.C:888
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
bool globCompare(const std::string &candidate, const std::string &pattern, std::size_t c, std::size_t p)
Definition: MooseUtils.C:932
IntRange< T > make_range(T beg, T end)
BoundingBox buildBoundingBox(const Point &p1, const Point &p2)
Definition: MooseUtils.C:1131
int levenshteinDist(const std::string &s1, const std::string &s2)
Definition: MooseUtils.C:176
std::string getCurrentWorkingDir()
Definition: MooseUtils.C:436
std::string getExtension(const std::string &filename, const bool rfind)
Definition: MooseUtils.C:411
std::list< std::string > getFilesInDirs(const std::list< std::string > &directory_list, const bool files_only)
Definition: MooseUtils.C:808
bool checkFileWriteable(const std::string &filename, bool throw_on_unwritable)
Definition: MooseUtils.C:307
void removedirs(const std::string &dir_name, bool throw_on_failure)
Definition: MooseUtils.C:505
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type...
std::vector< std::string > split(const std::string &str, const std::string &delimiter, std::size_t max_count)
Definition: MooseUtils.C:1020
bool parsesToReal(const std::string &input, Real *parsed_real)
Definition: MooseUtils.C:89
bool pathExists(const std::string &path)
Definition: MooseUtils.C:247
std::string replaceAll(std::string str, const std::string &from, const std::string &to)
Definition: MooseUtils.C:145
bool checkFileReadable(const std::string &filename, bool check_line_endings, bool throw_on_unreadable, bool check_for_git_lfs_pointer)
Definition: MooseUtils.C:254
MaterialBases compute MaterialProperties.
Definition: MaterialBase.h:62
auto index_range(const T &sizable)
int stringToInteger(const std::string &input, bool throw_on_failure)
Definition: MooseUtils.C:967
void escape(std::string &str)
Definition: MooseUtils.C:207
std::string prettyCppType(const std::string &cpp_type)
Definition: MooseUtils.C:1140
uint8_t dof_id_type
std::string findTestRoot()
Definition: MooseUtils.C:75
unsigned short getTermWidth(bool use_environment)
Definition: MooseUtils.C:640
void parallelBarrierNotify(const Parallel::Communicator &comm, bool messaging)
Definition: MooseUtils.C:327