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, const bool show_trace=true)
 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, const bool show_trace, 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 142 of file MooseError.C.

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

145 {
146  const auto & repo_url = Registry::getRepositoryURL(repo_name);
147  std::stringstream oss;
148  oss << msg << "\n\nThis error is documented at " << repo_url << "/issues/" << issue_num << ".";
149  return oss.str();
150 }
static const std::string & getRepositoryURL(const std::string &repo_name)
Returns the repository URL associated with repo_name.
Definition: Registry.C:189

◆ 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(), PerfGraphReporter::finalize(), PerfGuard::PerfGuard(), and PerfGraphInterface::registerTimedSection().

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,
const bool  show_trace,
Args &&...  args 
)

Definition at line 252 of file MooseError.h.

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

254 {
256  mooseError("\n\nDeprecated code:\n", std::forward<Args>(args)...);
257 
258  std::ostringstream ss;
259  mooseStreamAll(ss, args...);
260 
261  const auto color = expired ? COLOR_RED : COLOR_YELLOW;
262  std::string msg = print_title ? mooseMsgFmt(ss.str(), "*** Deprecation Warning ***", color)
263  : mooseMsgFmt(ss.str(), color);
264  oss << msg;
265  ss.str("");
266  if (show_trace)
267  {
268  if (libMesh::global_n_processors() == 1)
270  else
272  {
274  oss << ss.str() << std::endl;
275  };
276  };
277 }
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:311
void write_traceout()
bool _deprecated_is_error
Variable to toggle only deprecated warnings as errors.
Definition: Moose.C:844
void mooseStreamAll(std::ostringstream &ss, T &&val, Args &&... args)
Definition: MooseError.h:189
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:140

◆ mooseErrorRaw()

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

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
show_traceWhether or not to show a stack trace, defaults to true

Definition at line 53 of file MooseError.C.

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

57 {
59  throw MooseRuntimeError(msg, node);
60 
61  // Atomic that will be set as soon as any thread hits this method
62  static std::atomic_flag aborting = ATOMIC_FLAG_INIT;
63 
64  // Per-thread bool that will avoid us getting stuck in pause() if one
65  // thread hits this method twice.
66  thread_local static bool this_thread_aborting = false;
67 
68  // This branch will be hit after another thread has already set the atomic.
69  // MPI_Abort, despite its name, does not behave like std::abort but instead
70  // calls exit handlers and destroys statics. So we don't want to touch
71  // anything static at this point. We'll just wait until the winning thread
72  // has incurred program exit
73  if (aborting.test_and_set(std::memory_order_acq_rel) && !this_thread_aborting)
74  {
75  // Waiting for the other thread(s), not burning CPU
76  for (;;)
77  pause();
78  }
79  // We're the first thread to hit this method (we set the atomic), so we're
80  // responsible for dumping the error and trace(s) while the remaining
81  // threads wait for us to exit (via libmesh_abort())
82  else
83  {
84  // No, really, terminate. libmesh_abort() may throw an
85  // exception, and if we catch that exception (or a bad_alloc, or
86  // anything thrown) and mooseError because we didn't understand
87  // it, we just want to continue up the stack.
88  if (this_thread_aborting)
89  libmesh_abort();
90 
91  this_thread_aborting = true;
92 
93  // Output the message if there is one, but flush it without the trace
94  // as trace retrieval can be slow in some circumstances and we want to
95  // get the error message out ASAP
96  if (!msg.empty())
97  {
98  // If we have a node available, add in the hit context (file location)
99  if (node)
100  msg = Moose::hitMessagePrefix(*node) + msg;
101 
102  msg = mooseMsgFmt(msg, "*** ERROR ***", COLOR_RED) + "\n";
103  if (!prefix.empty()) // multiapp prefix
104  MooseUtils::indentMessage(prefix, msg);
105 
106  {
107  Threads::spin_mutex::scoped_lock lock(moose_stream_lock);
108  Moose::err << msg << std::flush;
109  }
110  }
111 
112  // Print the trace if enabled and on a single rank
113  if (show_trace && libMesh::global_n_processors() == 1)
114  {
115  std::ostringstream oss;
116  print_trace(oss);
117  auto trace = oss.str();
118  if (!prefix.empty()) // multiapp prefix
119  MooseUtils::indentMessage(prefix, trace);
120 
121  {
122  Threads::spin_mutex::scoped_lock lock(moose_stream_lock);
123  Moose::err << trace << std::flush;
124  }
125  }
126 
127  // In parallel with libMesh configured with --enable-tracefiles, this will
128  // dump a trace for each rank to file
131 
132  libmesh_abort();
133  }
134 }
processor_id_type global_n_processors()
Real trace(const RealTensor &A, const unsigned int &dim)
void write_traceout()
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
void libmesh_abort()
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:832
Exception to be thrown whenever we have _throw_on_error set and a mooseError() is emitted...
Definition: MooseError.h:117
libMesh::Threads::spin_mutex moose_stream_lock
Definition: MooseError.h:140
bool _throw_on_error
Variable to turn on exceptions during mooseError(), should only be used within MOOSE unit tests or wh...
Definition: Moose.C:845
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 245 of file MooseError.h.

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

246 {
247  mooseDoOnce(mooseInfoStreamRepeated(oss, args...););
248 }
void mooseInfoStreamRepeated(S &oss, Args &&... args)
Definition: MooseError.h:232

◆ mooseInfoStreamRepeated()

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

Definition at line 232 of file MooseError.h.

Referenced by mooseInfoRepeated(), and mooseInfoStream().

233 {
234  std::ostringstream ss;
235  mooseStreamAll(ss, args...);
236  std::string msg = mooseMsgFmt(ss.str(), "*** Info ***", COLOR_CYAN);
237  {
239  oss << msg << std::flush;
240  }
241 }
void mooseStreamAll(std::ostringstream &ss, T &&val, Args &&... args)
Definition: MooseError.h:189
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:140

◆ 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 137 of file MooseError.C.

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

138 {
139 }

◆ mooseStreamAll() [2/2]

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

Definition at line 189 of file MooseError.h.

190 {
191  ss << val;
192  mooseStreamAll(ss, std::forward<Args>(args)...);
193 }
void mooseStreamAll(std::ostringstream &ss, T &&val, Args &&... args)
Definition: MooseError.h:189

◆ mooseUnusedStream()

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

Definition at line 216 of file MooseError.h.

Referenced by mooseUnused().

217 {
218  std::ostringstream ss;
219  mooseStreamAll(ss, args...);
220  std::string msg = mooseMsgFmt(ss.str(), "*** Warning ***", COLOR_YELLOW);
222  throw std::runtime_error(msg);
223 
224  {
226  oss << msg << std::flush;
227  }
228 }
void mooseStreamAll(std::ostringstream &ss, T &&val, Args &&... args)
Definition: MooseError.h:189
bool _throw_on_warning
Variable to turn on exceptions during mooseWarning(), should only be used in MOOSE unit tests...
Definition: Moose.C:846
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:140

◆ mooseWarningStream()

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

Definition at line 197 of file MooseError.h.

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

198 {
200  mooseError(std::forward<Args>(args)...);
201 
202  std::ostringstream ss;
203  mooseStreamAll(ss, args...);
204  std::string msg = mooseMsgFmt(ss.str(), "*** Warning ***", COLOR_YELLOW);
206  throw std::runtime_error(msg);
207 
208  {
210  oss << msg << std::flush;
211  }
212 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
bool _warnings_are_errors
Variable to toggle any warning into an error (includes deprecated code warnings)
Definition: Moose.C:843
void mooseStreamAll(std::ostringstream &ss, T &&val, Args &&... args)
Definition: MooseError.h:189
bool _throw_on_warning
Variable to turn on exceptions during mooseWarning(), should only be used in MOOSE unit tests...
Definition: Moose.C:846
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:140

◆ 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:34

◆ 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:100
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