https://mooseframework.inl.gov
Classes | Functions | Variables
moose::internal Namespace Reference

Classes

class  ConvergenceIterationTypeRegistry
 Registry for Convergence iteration types. More...
 
class  ExecFlagRegistry
 Registry for statically defining execute flags with consistent numbering. More...
 
class  PerfGraphRegistry
 The place where all timed sections will be stored. More...
 
class  PerfGraphSectionInfo
 Used to hold metadata about the registered sections Note: this is a class instead of a struct because structs are not able to be created in place using emplace_back in C++11. More...
 
struct  SoltionInvalidityNameHash
 Helper class that hash the name associated with an invalid solution. More...
 
class  SolutionInvalidityInfo
 Helper class that stores the info associated with an invalid solution. More...
 
class  SolutionInvalidityName
 Helper class that stores the name associated with an invalid solution. More...
 
class  SolutionInvalidityRegistry
 The place where all sections with solution invalid warnings will be stored. More...
 

Functions

std::string incompatVarMsg (MooseVariableFieldBase &var1, MooseVariableFieldBase &var2)
 Builds and returns a string of the form: More...
 
std::string mooseMsgFmt (const std::string &msg, const std::string &title, const std::string &color)
 Format a message for output with a title. More...
 
std::string mooseMsgFmt (const std::string &msg, const std::string &color)
 Format a message for output without a title. More...
 
void mooseErrorRaw (std::string msg, const std::string &prefix="", const hit::Node *node=nullptr)
 Main callback for emitting a moose error. More...
 
std::string formatMooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, const std::string &msg)
 Formats a documented error. More...
 
template<typename T1 , typename T2 >
void rawValueEqualityHelper (T1 &out, const T2 &in)
 
template<typename T1 , typename T2 >
void rawValueEqualityHelper (std::vector< T1 > &out, const std::vector< T2 > &in)
 
template<typename T1 , typename T2 , std::size_t N>
void rawValueEqualityHelper (std::array< T1, N > &out, const std::array< T2, N > &in)
 
PerfGraphRegistrygetPerfGraphRegistry ()
 Get the global PerfGraphRegistry singleton. More...
 
SolutionInvalidityRegistrygetSolutionInvalidityRegistry ()
 Get the global SolutionInvalidityRegistry singleton. More...
 
std::ostream & operator<< (std::ostream &os, const SolutionInvalidityName &name)
 
bool boundaryRestricted (const std::set< BoundaryID > &boundary_ids)
 
void mooseStreamAll (std::ostringstream &ss)
 All of the following are not meant to be called directly - they are called by the normal macros (mooseError(), etc.) down below. More...
 
template<typename T , typename... Args>
void mooseStreamAll (std::ostringstream &ss, T &&val, Args &&... args)
 
template<typename S , typename... Args>
void mooseWarningStream (S &oss, Args &&... args)
 
template<typename S , typename... Args>
void mooseUnusedStream (S &oss, Args &&... args)
 
template<typename S , typename... Args>
void mooseInfoStreamRepeated (S &oss, Args &&... args)
 
template<typename S , typename... Args>
void mooseInfoStream (S &oss, Args &&... args)
 
template<typename S , typename... Args>
void mooseDeprecatedStream (S &oss, const bool expired, const bool print_title, Args &&... args)
 

Variables

libMesh::Threads::spin_mutex moose_stream_lock
 

Function Documentation

◆ boundaryRestricted()

bool moose::internal::boundaryRestricted ( const std::set< BoundaryID > &  boundary_ids)

Definition at line 46 of file MaterialPropertyInterface.C.

Referenced by MaterialPropertyInterface::getMaterialDataType().

47 {
48  return !boundary_ids.empty() && BoundaryRestrictable::restricted(boundary_ids);
49 }
static bool restricted(const std::set< BoundaryID > &ids)
Helper for determining if the object is boundary restricted.

◆ formatMooseDocumentedError()

std::string moose::internal::formatMooseDocumentedError ( const std::string &  repo_name,
const unsigned int  issue_num,
const std::string &  msg 
)

Formats a documented error.

A documented error is an error that has an issue associated with it.

The repository name repo_name links a named repository to a URL and should be registered at the application level with registerRepository(). See Moose.C for an example of the "moose" repository registration.

Parameters
repo_nameThe repository name where the issue resides
issue_numThe number of the issue
msgThe specific error message

Definition at line 128 of file MooseError.C.

Referenced by MooseBase::mooseDocumentedError(), and mooseDocumentedError().

131 {
132  const auto & repo_url = Registry::getRepositoryURL(repo_name);
133  std::stringstream oss;
134  oss << msg << "\n\nThis error is documented at " << repo_url << "/issues/" << issue_num << ".";
135  return oss.str();
136 }
static const std::string & getRepositoryURL(const std::string &repo_name)
Returns the repository URL associated with repo_name.
Definition: Registry.C:173

◆ getPerfGraphRegistry()

PerfGraphRegistry & moose::internal::getPerfGraphRegistry ( )

Get the global PerfGraphRegistry singleton.

So it can be constructed.

Definition at line 20 of file PerfGraphRegistry.C.

Referenced by dataLoad(), dataStore(), PerfGraphInterface::registerTimedSection(), and to_json().

21 {
22  // In C++11 this is even thread safe! (Lookup "Static Initializers")
23  static PerfGraphRegistry perf_graph_registry_singleton;
24 
25  return perf_graph_registry_singleton;
26 }

◆ getSolutionInvalidityRegistry()

SolutionInvalidityRegistry & moose::internal::getSolutionInvalidityRegistry ( )

Get the global SolutionInvalidityRegistry singleton.

So it can be constructed.

Definition at line 18 of file SolutionInvalidityRegistry.C.

Referenced by dataLoad(), SolutionInvalidInterface::flagInvalidSolutionInternal(), SolutionInvalidInterface::registerInvalidSolutionInternal(), SolutionInvalidity::syncIteration(), and to_json().

19 {
20  // In C++11 this is even thread safe! (Lookup "Static Initializers")
21  static SolutionInvalidityRegistry solution_invalid_registry_singleton;
22 
23  return solution_invalid_registry_singleton;
24 }

◆ incompatVarMsg()

std::string moose::internal::incompatVarMsg ( MooseVariableFieldBase var1,
MooseVariableFieldBase var2 
)

Builds and returns a string of the form:

[var1-elemtype],ORDER[var1-order] != [var2-elemtype],ORDER[var2-order]

This is a convenience function to be used when error messages (especially with paramError) need to report that variable types are incompatible (e.g. with residual save-in).

Definition at line 26 of file MooseError.C.

Referenced by ADDGKernel::ADDGKernel(), ADIntegratedBCTempl< T >::ADIntegratedBCTempl(), ADKernelTempl< T >::ADKernelTempl(), ArrayDGKernel::ArrayDGKernel(), ArrayIntegratedBC::ArrayIntegratedBC(), ArrayKernel::ArrayKernel(), DGKernel::DGKernel(), IntegratedBC::IntegratedBC(), Kernel::Kernel(), NodalBC::NodalBC(), NodalKernel::NodalKernel(), and MultiAppDofCopyTransfer::transfer().

27 {
28  std::stringstream ss;
29  ss << libMesh::Utility::enum_to_string<FEFamily>(var1.feType().family) << ",ORDER"
30  << var1.feType().order
31  << " != " << libMesh::Utility::enum_to_string<FEFamily>(var2.feType().family) << ",ORDER"
32  << var2.feType().order;
33  return ss.str();
34 }
const libMesh::FEType & feType() const
Get the type of finite element object.
OrderWrapper order

◆ mooseDeprecatedStream()

template<typename S , typename... Args>
void moose::internal::mooseDeprecatedStream ( S &  oss,
const bool  expired,
const bool  print_title,
Args &&...  args 
)

Definition at line 265 of file MooseError.h.

Referenced by Moose::Builder::build(), MooseBase::mooseDeprecated(), mooseDeprecated(), and mooseDeprecationExpired().

266 {
268  mooseError("\n\nDeprecated code:\n", std::forward<Args>(args)...);
269 
270  std::ostringstream ss;
271  mooseStreamAll(ss, args...);
272 
273  const auto color = expired ? COLOR_RED : COLOR_YELLOW;
274  std::string msg = print_title ? mooseMsgFmt(ss.str(), "*** Deprecation Warning ***", color)
275  : mooseMsgFmt(ss.str(), color);
276  oss << msg;
277  ss.str("");
278  if (Moose::show_trace)
279  {
280  if (libMesh::global_n_processors() == 1)
282  else
284  {
286  oss << ss.str() << std::endl;
287  };
288  };
289 }
bool show_trace
Set to true (the default) to print the stack trace with error and warning messages - false to omit it...
Definition: Moose.C:794
processor_id_type global_n_processors()
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
void write_traceout()
bool _deprecated_is_error
Variable to toggle only deprecated warnings as errors.
Definition: Moose.C:790
void mooseStreamAll(std::ostringstream &ss, T &&val, Args &&... args)
Definition: MooseError.h:202
void print_trace(std::ostream &out_stream=std::cerr)
std::string mooseMsgFmt(const std::string &msg, const std::string &color)
Format a message for output without a title.
Definition: MooseError.C:45
libMesh::Threads::spin_mutex moose_stream_lock
Definition: MooseError.h:156

◆ mooseErrorRaw()

void moose::internal::mooseErrorRaw ( std::string  msg,
const std::string &  prefix = "",
const hit::Node *  node = nullptr 
)

Main callback for emitting a moose error.

Parameters
msgThe error message
prefixOptional prefix to add to every line of the error (for multiapp prefixes)
nodeOptional HIT node to associate with the error, adding file path context

Definition at line 53 of file MooseError.C.

Referenced by MooseBase::callMooseError(), mooseDocumentedError(), and mooseError().

56 {
58  throw MooseRuntimeError(msg, node);
59 
60  // Atomic that will be set as soon as any thread hits this method
61  static std::atomic_flag aborting = ATOMIC_FLAG_INIT;
62 
63  // This branch will be hit after another thread has already set the atomic.
64  // MPI_Abort, despite its name, does not behave like std::abort but instead
65  // calls exit handlers and destroys statics. So we don't want to touch
66  // anything static at this point. We'll just wait until the winning thread
67  // has incurred program exit
68  if (aborting.test_and_set(std::memory_order_acq_rel))
69  {
70  // Waiting for the other thread(s), not burning CPU
71  for (;;)
72  pause();
73  }
74  // We're the first thread to hit this method (we set the atomic), so we're
75  // responsible for dumping the error and trace(s) while the remaining
76  // threads wait for us to exit (via MOOSE_ABORT)
77  else
78  {
79  // Output the message if there is one, but flush it without the trace
80  // as trace retrieval can be slow in some circumstances and we want to
81  // get the error message out ASAP
82  if (!msg.empty())
83  {
84  // If we have a node available, add in the hit context (file location)
85  if (node)
86  msg = Moose::hitMessagePrefix(*node) + msg;
87 
88  msg = mooseMsgFmt(msg, "*** ERROR ***", COLOR_RED) + "\n";
89  if (!prefix.empty()) // multiapp prefix
90  MooseUtils::indentMessage(prefix, msg);
91 
92  {
93  Threads::spin_mutex::scoped_lock lock(moose_stream_lock);
94  Moose::err << msg << std::flush;
95  }
96  }
97 
98  // Print the trace if enabled and on a single rank
100  {
101  std::ostringstream oss;
102  print_trace(oss);
103  auto trace = oss.str();
104  if (!prefix.empty()) // multiapp prefix
105  MooseUtils::indentMessage(prefix, trace);
106 
107  {
108  Threads::spin_mutex::scoped_lock lock(moose_stream_lock);
109  Moose::err << trace << std::flush;
110  }
111  }
112 
113  // In parallel with libMesh configured with --enable-tracefiles, this will
114  // dump a trace for each rank to file
117 
118  MOOSE_ABORT;
119  }
120 }
bool show_trace
Set to true (the default) to print the stack trace with error and warning messages - false to omit it...
Definition: Moose.C:794
processor_id_type global_n_processors()
void write_traceout()
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.
Definition: MooseUtils.C:734
void print_trace(std::ostream &out_stream=std::cerr)
std::string hitMessagePrefix(const hit::Node &node)
Get the prefix to be associated with a hit node for a message.
Definition: Moose.C:778
Exception to be thrown whenever we have _throw_on_error set and a mooseError() is emitted...
Definition: MooseError.h:133
libMesh::Threads::spin_mutex moose_stream_lock
Definition: MooseError.h:156
bool _throw_on_error
Variable to turn on exceptions during mooseError(), should only be used within MOOSE unit tests or wh...
Definition: Moose.C:791
std::string mooseMsgFmt(const std::string &msg, const std::string &title, const std::string &color)
Format a message for output with a title.
Definition: MooseError.C:37

◆ mooseInfoStream()

template<typename S , typename... Args>
void moose::internal::mooseInfoStream ( S &  oss,
Args &&...  args 
)

Definition at line 258 of file MooseError.h.

Referenced by MooseBase::mooseInfo(), and mooseInfo().

259 {
260  mooseDoOnce(mooseInfoStreamRepeated(oss, args...););
261 }
void mooseInfoStreamRepeated(S &oss, Args &&... args)
Definition: MooseError.h:245

◆ mooseInfoStreamRepeated()

template<typename S , typename... Args>
void moose::internal::mooseInfoStreamRepeated ( S &  oss,
Args &&...  args 
)

Definition at line 245 of file MooseError.h.

Referenced by mooseInfoRepeated(), and mooseInfoStream().

246 {
247  std::ostringstream ss;
248  mooseStreamAll(ss, args...);
249  std::string msg = mooseMsgFmt(ss.str(), "*** Info ***", COLOR_CYAN);
250  {
252  oss << msg << std::flush;
253  }
254 }
void mooseStreamAll(std::ostringstream &ss, T &&val, Args &&... args)
Definition: MooseError.h:202
std::string mooseMsgFmt(const std::string &msg, const std::string &color)
Format a message for output without a title.
Definition: MooseError.C:45
libMesh::Threads::spin_mutex moose_stream_lock
Definition: MooseError.h:156

◆ mooseMsgFmt() [1/2]

std::string moose::internal::mooseMsgFmt ( const std::string &  msg,
const std::string &  title,
const std::string &  color 
)

Format a message for output with a title.

Parameters
msgThe message to print
titleThe title that will go on a line before the message
colorThe color to print the message in
Returns
The formatted message

Definition at line 37 of file MooseError.C.

Referenced by mooseDeprecatedStream(), mooseErrorRaw(), mooseInfoStreamRepeated(), mooseUnusedStream(), and mooseWarningStream().

38 {
39  std::ostringstream oss;
40  oss << "\n" << color << "\n" << title << "\n" << msg << COLOR_DEFAULT << "\n";
41  return oss.str();
42 }

◆ mooseMsgFmt() [2/2]

std::string moose::internal::mooseMsgFmt ( const std::string &  msg,
const std::string &  color 
)

Format a message for output without a title.

Parameters
msgThe message to print
colorThe color to print the message in
Returns
The formatted message

Definition at line 45 of file MooseError.C.

46 {
47  std::ostringstream oss;
48  oss << "\n" << color << "\n" << msg << COLOR_DEFAULT << "\n";
49  return oss.str();
50 }

◆ mooseStreamAll() [1/2]

void moose::internal::mooseStreamAll ( std::ostringstream &  ss)

All of the following are not meant to be called directly - they are called by the normal macros (mooseError(), etc.) down below.

Definition at line 123 of file MooseError.C.

Referenced by mooseDeprecatedStream(), mooseDocumentedError(), mooseError(), InputParameters::mooseError(), mooseInfoStreamRepeated(), mooseStreamAll(), mooseUnusedStream(), mooseWarningStream(), InputParameters::paramError(), and InputParameters::paramMessage().

124 {
125 }

◆ mooseStreamAll() [2/2]

template<typename T , typename... Args>
void moose::internal::mooseStreamAll ( std::ostringstream &  ss,
T &&  val,
Args &&...  args 
)

Definition at line 202 of file MooseError.h.

203 {
204  ss << val;
205  mooseStreamAll(ss, std::forward<Args>(args)...);
206 }
void mooseStreamAll(std::ostringstream &ss, T &&val, Args &&... args)
Definition: MooseError.h:202

◆ mooseUnusedStream()

template<typename S , typename... Args>
void moose::internal::mooseUnusedStream ( S &  oss,
Args &&...  args 
)

Definition at line 229 of file MooseError.h.

Referenced by mooseUnused().

230 {
231  std::ostringstream ss;
232  mooseStreamAll(ss, args...);
233  std::string msg = mooseMsgFmt(ss.str(), "*** Warning ***", COLOR_YELLOW);
235  throw std::runtime_error(msg);
236 
237  {
239  oss << msg << std::flush;
240  }
241 }
void mooseStreamAll(std::ostringstream &ss, T &&val, Args &&... args)
Definition: MooseError.h:202
bool _throw_on_warning
Variable to turn on exceptions during mooseWarning(), should only be used in MOOSE unit tests...
Definition: Moose.C:792
std::string mooseMsgFmt(const std::string &msg, const std::string &color)
Format a message for output without a title.
Definition: MooseError.C:45
libMesh::Threads::spin_mutex moose_stream_lock
Definition: MooseError.h:156

◆ mooseWarningStream()

template<typename S , typename... Args>
void moose::internal::mooseWarningStream ( S &  oss,
Args &&...  args 
)

Definition at line 210 of file MooseError.h.

Referenced by MooseBase::mooseWarning(), mooseWarning(), and MooseBase::mooseWarningNonPrefixed().

211 {
213  mooseError(std::forward<Args>(args)...);
214 
215  std::ostringstream ss;
216  mooseStreamAll(ss, args...);
217  std::string msg = mooseMsgFmt(ss.str(), "*** Warning ***", COLOR_YELLOW);
219  throw std::runtime_error(msg);
220 
221  {
223  oss << msg << std::flush;
224  }
225 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
bool _warnings_are_errors
Variable to toggle any warning into an error (includes deprecated code warnings)
Definition: Moose.C:789
void mooseStreamAll(std::ostringstream &ss, T &&val, Args &&... args)
Definition: MooseError.h:202
bool _throw_on_warning
Variable to turn on exceptions during mooseWarning(), should only be used in MOOSE unit tests...
Definition: Moose.C:792
std::string mooseMsgFmt(const std::string &msg, const std::string &color)
Format a message for output without a title.
Definition: MooseError.C:45
libMesh::Threads::spin_mutex moose_stream_lock
Definition: MooseError.h:156

◆ operator<<()

std::ostream & moose::internal::operator<< ( std::ostream &  os,
const SolutionInvalidityName name 
)

Definition at line 46 of file SolutionInvalidityRegistry.C.

47 {
48  os << name.object_type << ": " << name.message;
49  return os;
50 }
std::string name(const ElemQuality q)
std::basic_ostream< charT, traits > * os
Definition: InfixIterator.h:33

◆ rawValueEqualityHelper() [1/3]

template<typename T1 , typename T2 >
void moose::internal::rawValueEqualityHelper ( T1 &  out,
const T2 &  in 
)

Definition at line 216 of file MaterialProperty.h.

Referenced by MaterialPropertyBase< T, false >::qpCopy(), rawValueEqualityHelper(), and MaterialPropertyBase< T, false >::swap().

217 {
219 }
auto raw_value(const Eigen::Map< T > &in)
Definition: EigenADReal.h:73
OStreamProxy out

◆ rawValueEqualityHelper() [2/3]

template<typename T1 , typename T2 >
void moose::internal::rawValueEqualityHelper ( std::vector< T1 > &  out,
const std::vector< T2 > &  in 
)

Definition at line 223 of file MaterialProperty.h.

224 {
225  out.resize(in.size());
226  for (MooseIndex(in) i = 0; i < in.size(); ++i)
227  rawValueEqualityHelper(out[i], in[i]);
228 }
void rawValueEqualityHelper(std::array< T1, N > &out, const std::array< T2, N > &in)
OStreamProxy out

◆ rawValueEqualityHelper() [3/3]

template<typename T1 , typename T2 , std::size_t N>
void moose::internal::rawValueEqualityHelper ( std::array< T1, N > &  out,
const std::array< T2, N > &  in 
)

Definition at line 232 of file MaterialProperty.h.

233 {
234  for (MooseIndex(in) i = 0; i < in.size(); ++i)
235  rawValueEqualityHelper(out[i], in[i]);
236 }
void rawValueEqualityHelper(std::array< T1, N > &out, const std::array< T2, N > &in)

Variable Documentation

◆ moose_stream_lock

libMesh::Threads::spin_mutex moose::internal::moose_stream_lock
inline