www.mooseframework.org
MooseUtils.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 // MOOSE includes
16 #include "MooseUtils.h"
17 #include "MooseError.h"
18 #include "MaterialProperty.h"
19 
20 #include "libmesh/elem.h"
21 
22 // External includes
23 #include "pcrecpp.h"
24 #include "tinydir.h"
25 
26 // C++ includes
27 #include <iostream>
28 #include <fstream>
29 #include <istream>
30 #include <iterator>
31 
32 // System includes
33 #include <sys/stat.h>
34 #include <numeric>
35 
36 std::string getLatestCheckpointFileHelper(const std::list<std::string> & checkpoint_files,
37  const std::vector<std::string> extensions,
38  bool keep_extension);
39 
40 namespace MooseUtils
41 {
42 
43 // this implementation is copied from
44 // https://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance#C.2B.2B
45 int
46 levenshteinDist(const std::string & s1, const std::string & s2)
47 {
48  // To change the type this function manipulates and returns, change
49  // the return type and the types of the two variables below.
50  auto s1len = s1.size();
51  auto s2len = s2.size();
52 
53  auto column_start = (decltype(s1len))1;
54 
55  auto column = new decltype(s1len)[s1len + 1];
56  std::iota(column + column_start, column + s1len + 1, column_start);
57 
58  for (auto x = column_start; x <= s2len; x++)
59  {
60  column[0] = x;
61  auto last_diagonal = x - column_start;
62  for (auto y = column_start; y <= s1len; y++)
63  {
64  auto old_diagonal = column[y];
65  auto possibilities = {
66  column[y] + 1, column[y - 1] + 1, last_diagonal + (s1[y - 1] == s2[x - 1] ? 0 : 1)};
67  column[y] = std::min(possibilities);
68  last_diagonal = old_diagonal;
69  }
70  }
71  auto result = column[s1len];
72  delete[] column;
73  return result;
74 }
75 
76 void
77 escape(std::string & str)
78 {
79  std::map<char, std::string> escapes;
80  escapes['\a'] = "\\a";
81  escapes['\b'] = "\\b";
82  escapes['\f'] = "\\f";
83  escapes['\n'] = "\\n";
84  escapes['\t'] = "\\t";
85  escapes['\v'] = "\\v";
86  escapes['\r'] = "\\r";
87 
88  for (const auto & it : escapes)
89  for (size_t pos = 0; (pos = str.find(it.first, pos)) != std::string::npos;
90  pos += it.second.size())
91  str.replace(pos, 1, it.second);
92 }
93 
94 std::string
95 trim(const std::string & str, const std::string & white_space)
96 {
97  const auto begin = str.find_first_not_of(white_space);
98  if (begin == std::string::npos)
99  return ""; // no content
100  const auto end = str.find_last_not_of(white_space);
101  return str.substr(begin, end - begin + 1);
102 }
103 
104 bool
105 pathContains(const std::string & expression,
106  const std::string & string_to_find,
107  const std::string & delims)
108 {
109  std::vector<std::string> elements;
110  tokenize(expression, elements, 0, delims);
111 
112  std::vector<std::string>::iterator found_it =
113  std::find(elements.begin(), elements.end(), string_to_find);
114  if (found_it != elements.end())
115  return true;
116  else
117  return false;
118 }
119 
120 bool
121 checkFileReadable(const std::string & filename, bool check_line_endings, bool throw_on_unreadable)
122 {
123  std::ifstream in(filename.c_str(), std::ifstream::in);
124  if (in.fail())
125  {
126  if (throw_on_unreadable)
127  mooseError(
128  (std::string("Unable to open file \"") + filename +
129  std::string("\". Check to make sure that it exists and that you have read permission."))
130  .c_str());
131  else
132  return false;
133  }
134 
135  if (check_line_endings)
136  {
137  std::istream_iterator<char> iter(in);
138  std::istream_iterator<char> eos;
139  in >> std::noskipws;
140  while (iter != eos)
141  if (*iter++ == '\r')
142  mooseError(filename + " contains Windows(DOS) line endings which are not supported.");
143  }
144 
145  in.close();
146 
147  return true;
148 }
149 
150 bool
151 checkFileWriteable(const std::string & filename, bool throw_on_unwritable)
152 {
153  std::ofstream out(filename.c_str(), std::ofstream::out);
154  if (out.fail())
155  {
156  if (throw_on_unwritable)
157  mooseError(
158  (std::string("Unable to open file \"") + filename +
159  std::string("\". Check to make sure that it exists and that you have write permission."))
160  .c_str());
161  else
162  return false;
163  }
164 
165  out.close();
166 
167  return true;
168 }
169 
170 void
171 parallelBarrierNotify(const Parallel::Communicator & comm)
172 {
173  processor_id_type slave_processor_id;
174 
175  if (comm.rank() == 0)
176  {
177  // The master process is already through, so report it
178  Moose::out << "Jobs complete: 1/" << comm.size() << (1 == comm.size() ? "\n" : "\r")
179  << std::flush;
180  for (unsigned int i = 2; i <= comm.size(); ++i)
181  {
182  comm.receive(MPI_ANY_SOURCE, slave_processor_id);
183  Moose::out << "Jobs complete: " << i << "/" << comm.size() << (i == comm.size() ? "\n" : "\r")
184  << std::flush;
185  }
186  }
187  else
188  {
189  slave_processor_id = comm.rank();
190  comm.send(0, slave_processor_id);
191  }
192 
193  comm.barrier();
194 }
195 
196 void
197 serialBegin(const libMesh::Parallel::Communicator & comm)
198 {
199  // unless we are the first processor...
200  if (comm.rank() > 0)
201  {
202  // ...wait for the previous processor to finish
203  int dummy = 0;
204  comm.receive(comm.rank() - 1, dummy);
205  }
206  else
207  mooseWarning("Entering serial execution block (use only for debugging)");
208 }
209 
210 void
211 serialEnd(const libMesh::Parallel::Communicator & comm)
212 {
213  // unless we are the last processor...
214  if (comm.rank() + 1 < comm.size())
215  {
216  // ...notify the next processor of its turn
217  int dummy = 0;
218  comm.send(comm.rank() + 1, dummy);
219  }
220 
221  comm.barrier();
222  if (comm.rank() == 0)
223  mooseWarning("Leaving serial execution block (use only for debugging)");
224 }
225 
226 bool
227 hasExtension(const std::string & filename, std::string ext, bool strip_exodus_ext)
228 {
229  // Extract the extension, w/o the '.'
230  std::string file_ext;
231  if (strip_exodus_ext)
232  {
233  pcrecpp::RE re(
234  ".*\\.([^\\.]*?)(?:-s\\d+)?\\s*$"); // capture the complete extension, ignoring -s*
235  re.FullMatch(filename, &file_ext);
236  }
237  else
238  {
239  pcrecpp::RE re(".*\\.([^\\.]*?)\\s*$"); // capture the complete extension
240  re.FullMatch(filename, &file_ext);
241  }
242 
243  // Perform the comparision
244  if (file_ext == ext)
245  return true;
246  else
247  return false;
248 }
249 
250 std::pair<std::string, std::string>
251 splitFileName(std::string full_file)
252 {
253  // Error if path ends with /
254  if (full_file.empty() || *full_file.rbegin() == '/')
255  mooseError("Invalid full file name: ", full_file);
256 
257  // Define the variables to output
258  std::string path;
259  std::string file;
260 
261  // Locate the / sepearting the file from path
262  std::size_t found = full_file.find_last_of("/");
263 
264  // If no / is found used "." for the path, otherwise seperate the two
265  if (found == std::string::npos)
266  {
267  path = ".";
268  file = full_file;
269  }
270  else
271  {
272  path = full_file.substr(0, found);
273  file = full_file.substr(found + 1);
274  }
275 
276  // Return the path and file as a pair
277  return std::pair<std::string, std::string>(path, file);
278 }
279 
280 std::string
281 camelCaseToUnderscore(const std::string & camel_case_name)
282 {
283  string replaced = camel_case_name;
284  // Put underscores in front of each contiguous set of capital letters
285  pcrecpp::RE("(?!^)(?<![A-Z])([A-Z]+)").GlobalReplace("_\\1", &replaced);
286 
287  // Convert all capital letters to lower case
288  std::transform(replaced.begin(), replaced.end(), replaced.begin(), ::tolower);
289  return replaced;
290 }
291 
292 std::string
293 underscoreToCamelCase(const std::string & underscore_name, bool leading_upper_case)
294 {
295  pcrecpp::StringPiece input(underscore_name);
296  pcrecpp::RE re("([^_]*)(_|$)");
297 
298  std::string result;
299  std::string us, not_us;
300  bool make_upper = leading_upper_case;
301  while (re.Consume(&input, &not_us, &us))
302  {
303  if (not_us.length() > 0)
304  {
305  if (make_upper)
306  {
307  result += std::toupper(not_us[0]);
308  if (not_us.length() > 1)
309  result += not_us.substr(1);
310  }
311  else
312  result += not_us;
313  }
314  if (us == "")
315  break;
316 
317  // Toggle flag so next match is upper cased
318  make_upper = true;
319  }
320 
321  return result;
322 }
323 
324 std::string
325 shortName(const std::string & name)
326 {
327  return name.substr(name.find_last_of('/') != std::string::npos ? name.find_last_of('/') + 1 : 0);
328 }
329 
330 std::string
331 baseName(const std::string & name)
332 {
333  return name.substr(0, name.find_last_of('/') != std::string::npos ? name.find_last_of('/') : 0);
334 }
335 
336 bool
337 absoluteFuzzyEqual(const Real & var1, const Real & var2, const Real & tol)
338 {
339  return (std::abs(var1 - var2) <= tol);
340 }
341 
342 bool
343 absoluteFuzzyGreaterEqual(const Real & var1, const Real & var2, const Real & tol)
344 {
345  return (var1 >= (var2 - tol));
346 }
347 
348 bool
349 absoluteFuzzyGreaterThan(const Real & var1, const Real & var2, const Real & tol)
350 {
351  return (var1 > (var2 + tol));
352 }
353 
354 bool
355 absoluteFuzzyLessEqual(const Real & var1, const Real & var2, const Real & tol)
356 {
357  return (var1 <= (var2 + tol));
358 }
359 
360 bool
361 absoluteFuzzyLessThan(const Real & var1, const Real & var2, const Real & tol)
362 {
363  return (var1 < (var2 - tol));
364 }
365 
366 bool
367 relativeFuzzyEqual(const Real & var1, const Real & var2, const Real & tol)
368 {
369  return (absoluteFuzzyEqual(var1, var2, tol * (std::abs(var1) + std::abs(var2))));
370 }
371 
372 bool
373 relativeFuzzyGreaterEqual(const Real & var1, const Real & var2, const Real & tol)
374 {
375  return (absoluteFuzzyGreaterEqual(var1, var2, tol * (std::abs(var1) + std::abs(var2))));
376 }
377 
378 bool
379 relativeFuzzyGreaterThan(const Real & var1, const Real & var2, const Real & tol)
380 {
381  return (absoluteFuzzyGreaterThan(var1, var2, tol * (std::abs(var1) + std::abs(var2))));
382 }
383 
384 bool
385 relativeFuzzyLessEqual(const Real & var1, const Real & var2, const Real & tol)
386 {
387  return (absoluteFuzzyLessEqual(var1, var2, tol * (std::abs(var1) + std::abs(var2))));
388 }
389 
390 bool
391 relativeFuzzyLessThan(const Real & var1, const Real & var2, const Real & tol)
392 {
393  return (absoluteFuzzyLessThan(var1, var2, tol * (std::abs(var1) + std::abs(var2))));
394 }
395 
396 void
398  const HashMap<const libMesh::Elem *, HashMap<unsigned int, MaterialProperties>> & props)
399 {
400  // Loop through the elements
401  for (const auto & elem_it : props)
402  {
403  Moose::out << "Element " << elem_it.first->id() << '\n';
404 
405  // Loop through the sides
406  for (const auto & side_it : elem_it.second)
407  {
408  Moose::out << " Side " << side_it.first << '\n';
409 
410  // Loop over properties
411  unsigned int cnt = 0;
412  for (const auto & mat_prop : side_it.second)
413  {
414  MaterialProperty<Real> * mp = dynamic_cast<MaterialProperty<Real> *>(mat_prop);
415  if (mp)
416  {
417  Moose::out << " Property " << cnt << '\n';
418  cnt++;
419 
420  // Loop over quadrature points
421  for (unsigned int qp = 0; qp < mp->size(); ++qp)
422  Moose::out << " prop[" << qp << "] = " << (*mp)[qp] << '\n';
423  }
424  }
425  }
426  }
427 }
428 
429 std::string &
430 removeColor(std::string & msg)
431 {
432  pcrecpp::RE re("(\\33\\[3[0-7]m))", pcrecpp::DOTALL());
433  re.GlobalReplace(std::string(""), &msg);
434  return msg;
435 }
436 
437 void
438 indentMessage(const std::string & prefix,
439  std::string & message,
440  const char * color /*= COLOR_CYAN*/)
441 {
442  // First we need to see if the message we need to indent (with color) also contains color codes
443  // that span lines.
444  // The code matches all of the XTERM constants (see XTermConstants.h). If it does, then we'll work
445  // on formatting
446  // each colored multiline chunk one at a time with the right codes.
447  std::string colored_message;
448  std::string curr_color = COLOR_DEFAULT; // tracks last color code before newline
449  std::string line, color_code;
450 
451  std::istringstream iss(message);
452  for (std::string line; std::getline(iss, line);) // loop over each line
453  {
454  const static pcrecpp::RE match_color(".*(\\33\\[3\\dm)((?!\\33\\[3\\d)[^\n])*");
455  pcrecpp::StringPiece line_piece(line);
456  match_color.FindAndConsume(&line_piece, &color_code);
457  colored_message += color + prefix + ": " + curr_color + line + "\n";
458 
459  if (!color_code.empty())
460  curr_color = color_code; // remember last color of this line
461  }
462  message = colored_message;
463 }
464 
465 std::list<std::string>
466 getFilesInDirs(const std::list<std::string> & directory_list)
467 {
468  std::list<std::string> files;
469 
470  for (const auto & dir_name : directory_list)
471  {
472  tinydir_dir dir;
473  dir.has_next = 0; // Avoid a garbage value in has_next (clang StaticAnalysis)
474  tinydir_open(&dir, dir_name.c_str());
475 
476  while (dir.has_next)
477  {
478  tinydir_file file;
479  file.is_dir = 0; // Avoid a garbage value in is_dir (clang StaticAnalysis)
480  tinydir_readfile(&dir, &file);
481 
482  if (!file.is_dir)
483  files.push_back(dir_name + "/" + file.name);
484 
485  tinydir_next(&dir);
486  }
487 
488  tinydir_close(&dir);
489  }
490 
491  return files;
492 }
493 
494 std::string
495 getLatestMeshCheckpointFile(const std::list<std::string> & checkpoint_files)
496 {
497  const static std::vector<std::string> extensions{"cpr"};
498 
499  return getLatestCheckpointFileHelper(checkpoint_files, extensions, true);
500 }
501 
502 std::string
503 getLatestAppCheckpointFileBase(const std::list<std::string> & checkpoint_files)
504 {
505  const static std::vector<std::string> extensions{"xda", "xdr"};
506 
507  return getLatestCheckpointFileHelper(checkpoint_files, extensions, false);
508 }
509 
510 bool
511 wildCardMatch(std::string name, std::string search_string)
512 {
513  // Assume that an empty string matches anything
514  if (search_string == "")
515  return true;
516 
517  // transform to lower for case insenstive matching
518  std::transform(name.begin(), name.end(), name.begin(), (int (*)(int))std::toupper);
519  std::transform(search_string.begin(),
520  search_string.end(),
521  search_string.begin(),
522  (int (*)(int))std::toupper);
523 
524  // exact match!
525  if (search_string.find("*") == std::string::npos)
526  return search_string == name;
527 
528  // wildcard
529  std::vector<std::string> tokens;
530  MooseUtils::tokenize(search_string, tokens, 1, "*");
531 
532  size_t pos = 0;
533  for (unsigned int i = 0; i < tokens.size() && pos != std::string::npos; ++i)
534  {
535  pos = name.find(tokens[i], pos);
536  // See if we have a leading wildcard
537  if (search_string[0] != '*' && i == 0 && pos != 0)
538  return false;
539  }
540 
541  if (pos != std::string::npos && tokens.size() > 0)
542  {
543  // Now see if we have a trailing wildcard
544  size_t last_token_length = tokens.back().length();
545  if (*search_string.rbegin() == '*' || pos == name.size() - last_token_length)
546  return true;
547  else
548  return false;
549  }
550  else
551  return false;
552 }
553 
554 std::string
555 toUpper(const std::string & name)
556 {
557  std::string upper(name);
558  std::transform(upper.begin(), upper.end(), upper.begin(), ::toupper);
559  return upper;
560 }
561 
562 } // MooseUtils namespace
563 
564 std::string
565 getLatestCheckpointFileHelper(const std::list<std::string> & checkpoint_files,
566  const std::vector<std::string> extensions,
567  bool keep_extension)
568 {
569  // Create storage for newest restart files
570  // Note that these might have the same modification time if the simulation was fast.
571  // In that case we're going to save all of the "newest" files and sort it out momentarily
572  time_t newest_time = 0;
573  std::list<std::string> newest_restart_files;
574 
575  // Loop through all possible files and store the newest
576  for (const auto & cp_file : checkpoint_files)
577  {
578  if (find_if(extensions.begin(), extensions.end(), [cp_file](const std::string & ext) {
579  return MooseUtils::hasExtension(cp_file, ext);
580  }) != extensions.end())
581  {
582  struct stat stats;
583  stat(cp_file.c_str(), &stats);
584 
585  time_t mod_time = stats.st_mtime;
586  if (mod_time > newest_time)
587  {
588  newest_restart_files.clear(); // If the modification time is greater, clear the list
589  newest_time = mod_time;
590  }
591 
592  if (mod_time == newest_time)
593  newest_restart_files.push_back(cp_file);
594  }
595  }
596 
597  // Loop through all of the newest files according the number in the file name
598  int max_file_num = -1;
599  std::string max_base;
600  std::string max_file;
601 
602  pcrecpp::RE re_file_num(".*?(\\d+)(?:_mesh)?$"); // Pull out the embedded number from the file
603 
604  // Now, out of the newest files find the one with the largest number in it
605  for (const auto & res_file : newest_restart_files)
606  {
607  auto dot_pos = res_file.find_last_of(".");
608  auto the_base = res_file.substr(0, dot_pos);
609  int file_num = 0;
610 
611  re_file_num.FullMatch(the_base, &file_num);
612 
613  if (file_num > max_file_num)
614  {
615  max_file_num = file_num;
616  max_base = the_base;
617  max_file = res_file;
618  }
619  }
620 
621  // Error if nothing was located
622  if (max_file_num == -1)
623  {
624  max_base.clear();
625  max_file.clear();
626  }
627 
628  return keep_extension ? max_file : max_base;
629 }
bool relativeFuzzyEqual(const libMesh::Real &var1, const libMesh::Real &var2, const libMesh::Real &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether two variables are equal within a relative tolerance.
bool absoluteFuzzyGreaterEqual(const libMesh::Real &var1, const libMesh::Real &var2, const libMesh::Real &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether a variable is greater than or equal to another variable within an absolute ...
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 ...
Definition: MooseUtils.h:350
HashMap is an abstraction for dictionary data type, we make it thread-safe by locking inserts...
Definition: HashMap.h:24
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
Definition: MooseUtils.C:555
void serialBegin(const libMesh::Parallel::Communicator &comm)
This function marks the begin of a section of code that is executed in serial rank by rank...
Definition: MooseUtils.C:197
void MaterialPropertyStorageDump(const HashMap< const libMesh::Elem *, HashMap< unsigned int, MaterialProperties >> &props)
Function to dump the contents of MaterialPropertyStorage for debugging purposes.
Definition: MooseUtils.C:397
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
void indentMessage(const std::string &prefix, std::string &message, const char *color=COLOR_CYAN)
Indents the supplied message given the prefix and color.
Definition: MooseUtils.C:438
std::list< std::string > getFilesInDirs(const std::list< std::string > &directory_list)
Retrieves the names of all of the files contained within the list of directories passed into the rout...
Definition: MooseUtils.C:466
bool absoluteFuzzyLessThan(const libMesh::Real &var1, const libMesh::Real &var2, const libMesh::Real &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether a variable is less than another variable within an absolute tolerance...
bool relativeFuzzyLessThan(const libMesh::Real &var1, const libMesh::Real &var2, const libMesh::Real &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether a variable is less than another variable within a relative tolerance...
static PetscErrorCode Vec x
std::string camelCaseToUnderscore(const std::string &camel_case_name)
Function for converting a camel case name to a name containing underscores.
Definition: MooseUtils.C:281
std::string shortName(const std::string &name)
Function for stripping name after the file / in parser block.
Definition: MooseUtils.C:325
std::string getLatestAppCheckpointFileBase(const std::list< std::string > &checkpoint_files)
Definition: MooseUtils.C:503
bool checkFileReadable(const std::string &filename, bool check_line_endings=false, bool throw_on_unreadable=true)
Checks to see if a file is readable (exists and permissions)
Definition: MooseUtils.C:121
std::pair< std::string, std::string > splitFileName(std::string full_file)
Function for splitting path and filename.
Definition: MooseUtils.C:251
bool relativeFuzzyLessEqual(const libMesh::Real &var1, const libMesh::Real &var2, const libMesh::Real &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether a variable is less than or equal to another variable within a relative tole...
std::string underscoreToCamelCase(const std::string &underscore_name, bool leading_upper_case)
Function for converting an underscore name to a camel case name.
Definition: MooseUtils.C:293
bool hasExtension(const std::string &filename, std::string ext, bool strip_exodus_ext=false)
Function tests if the supplied filename as the desired extension.
Definition: MooseUtils.C:227
std::string & removeColor(std::string &msg)
remove ANSI escape sequences for teminal color from msg
Definition: MooseUtils.C:430
std::string getLatestMeshCheckpointFile(const std::list< std::string > &checkpoint_files)
Returns the most recent checkpoint or mesh file given a list of files.
Definition: MooseUtils.C:495
bool checkFileWriteable(const std::string &filename, bool throw_on_unwritable=true)
Check if the file is writable (path exists and permissions)
Definition: MooseUtils.C:151
std::string getLatestCheckpointFileHelper(const std::list< std::string > &checkpoint_files, const std::vector< std::string > extensions, bool keep_extension)
Definition: MooseUtils.C:565
std::string baseName(const std::string &name)
Function for string the information before the final / in a parser block.
Definition: MooseUtils.C:331
bool wildCardMatch(std::string name, std::string search_string)
Definition: MooseUtils.C:511
bool absoluteFuzzyGreaterThan(const libMesh::Real &var1, const libMesh::Real &var2, const libMesh::Real &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether a variable is greater than another variable within an absolute tolerance...
std::string trim(const std::string &str, const std::string &white_space=" \t\n\v\f\r")
Standard scripting language trim function.
Definition: MooseUtils.C:95
MPI_Comm comm
unsigned int size() const
int levenshteinDist(const std::string &s1, const std::string &s2)
Computes and returns the Levenshtein distance between strings s1 and s2.
Definition: MooseUtils.C:46
bool absoluteFuzzyEqual(const libMesh::Real &var1, const libMesh::Real &var2, const libMesh::Real &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether two variables are equal within an absolute tolerance.
bool relativeFuzzyGreaterEqual(const libMesh::Real &var1, const libMesh::Real &var2, const libMesh::Real &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether a variable is greater than or equal to another variable within a relative t...
bool absoluteFuzzyLessEqual(const libMesh::Real &var1, const libMesh::Real &var2, const libMesh::Real &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether a variable is less than or equal to another variable within an absolute tol...
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...
Definition: MooseUtils.C:105
void parallelBarrierNotify(const libMesh::Parallel::Communicator &comm)
This function implements a parallel barrier function but writes progress to stdout.
void escape(std::string &str)
This function will escape all of the standard C++ escape characters so that they can be printed...
Definition: MooseUtils.C:77
void serialEnd(const libMesh::Parallel::Communicator &comm)
Closes a section of code that is executed in serial rank by rank, and that was opened with a call to ...
Definition: MooseUtils.C:211
bool relativeFuzzyGreaterThan(const libMesh::Real &var1, const libMesh::Real &var2, const libMesh::Real &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether a variable is greater than another variable within a relative tolerance...
void mooseWarning(Args &&...args)
Emit a warning message with the given stringified, concatenated args.
Definition: MooseError.h:194