https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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:
 
std::string mooseMsgFmt (const std::string &msg, const std::string &title, const std::string &color)
 Format a message for output with a title.
 
std::string mooseMsgFmt (const std::string &msg, const std::string &color)
 Format a message for output without a title.
 
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.
 
std::string formatMooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, const std::string &msg)
 Formats a documented error.
 
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)
 
template<typename T >
void dataStoreSizeof (std::ostream &stream, T &v)
 
template<typename T >
void dataLoadSizeof (std::istream &stream, T &v)
 
PerfGraphRegistrygetPerfGraphRegistry ()
 Get the global PerfGraphRegistry singleton.
 
SolutionInvalidityRegistrygetSolutionInvalidityRegistry ()
 Get the global SolutionInvalidityRegistry singleton.
 
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.
 
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.

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.

Referenced by MaterialPropertyInterface::getMaterialDataType().

◆ dataLoadSizeof()

template<typename T >
void moose::internal::dataLoadSizeof ( std::istream &  stream,
T &  v 
)

Definition at line 638 of file DataIO.h.

639{
640 stream.read((char *)&v, sizeof(v));
641 mooseAssert(!stream.bad(), "Failed to load");
642}

◆ dataStoreSizeof()

template<typename T >
void moose::internal::dataStoreSizeof ( std::ostream &  stream,
T &  v 
)

Definition at line 92 of file DataIO.h.

93{
94 stream.write((char *)&v, sizeof(v));
95 mooseAssert(!stream.bad(), "Failed to store");
96}

◆ formatMooseDocumentedError()

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

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

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

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

◆ getPerfGraphRegistry()

PerfGraphRegistry & moose::internal::getPerfGraphRegistry ( )

Get the global PerfGraphRegistry singleton.

So it can be constructed.

Definition at line 20 of file PerfGraphRegistry.C.

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}
The place where all timed sections will be stored.

Referenced by PerfGraphReporter::finalize(), PerfGuard::PerfGuard(), PerfGraphInterface::registerTimedSection(), and PerfGraphInterface::registerTimedSection().

◆ getSolutionInvalidityRegistry()

SolutionInvalidityRegistry & moose::internal::getSolutionInvalidityRegistry ( )

Get the global SolutionInvalidityRegistry singleton.

So it can be constructed.

Definition at line 18 of file SolutionInvalidityRegistry.C.

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}
The place where all sections with solution invalid warnings will be stored.

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

◆ incompatVarMsg()

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

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

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

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().

◆ 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 
)
private

Definition at line 252 of file MooseError.h.

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 {
270 else
272 {
273 libMesh::Threads::spin_mutex::scoped_lock lock(moose_stream_lock);
274 oss << ss.str() << std::endl;
275 };
276 };
277}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
bool _deprecated_is_error
Variable to toggle only deprecated warnings as errors.
Definition Moose.C:910
void write_traceout()
processor_id_type global_n_processors()
void print_trace(std::ostream &out_stream=std::cerr)
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:35
void mooseStreamAll(std::ostringstream &ss)
All of the following are not meant to be called directly - they are called by the normal macros (moos...
Definition MooseError.C:135

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

◆ mooseErrorRaw()

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

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

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

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

◆ mooseInfoStream()

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

Definition at line 245 of file MooseError.h.

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

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

◆ mooseInfoStreamRepeated()

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

Definition at line 232 of file MooseError.h.

233{
234 std::ostringstream ss;
235 mooseStreamAll(ss, args...);
236 std::string msg = mooseMsgFmt(ss.str(), "*** Info ***", COLOR_CYAN);
237 {
238 libMesh::Threads::spin_mutex::scoped_lock lock(moose_stream_lock);
239 oss << msg << std::flush;
240 }
241}

Referenced by mooseInfoRepeated(), and mooseInfoStream().

◆ mooseMsgFmt() [1/2]

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

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

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

◆ mooseMsgFmt() [2/2]

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

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

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

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

◆ mooseStreamAll() [1/2]

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

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

136{
137}

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

◆ mooseStreamAll() [2/2]

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

Definition at line 189 of file MooseError.h.

190{
191 ss << val;
192 mooseStreamAll(ss, std::forward<Args>(args)...);
193}

◆ mooseUnusedStream()

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

Definition at line 216 of file MooseError.h.

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 {
225 libMesh::Threads::spin_mutex::scoped_lock lock(moose_stream_lock);
226 oss << msg << std::flush;
227 }
228}
bool _throw_on_warning
Variable to turn on exceptions during mooseWarning(), should only be used in MOOSE unit tests.
Definition Moose.C:912

Referenced by mooseUnused().

◆ mooseWarningStream()

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

Definition at line 197 of file MooseError.h.

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 {
209 libMesh::Threads::spin_mutex::scoped_lock lock(moose_stream_lock);
210 oss << msg << std::flush;
211 }
212}
bool _warnings_are_errors
Variable to toggle any warning into an error (includes deprecated code warnings)
Definition Moose.C:909

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

◆ operator<<()

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

Definition at line 45 of file SolutionInvalidityRegistry.C.

47{
48 os << name.object_type << ": " << name.message;
49 return os;
50}

◆ rawValueEqualityHelper() [1/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 
)
protected

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(T1 &out, const T2 &in)

◆ rawValueEqualityHelper() [2/3]

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

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}

◆ rawValueEqualityHelper() [3/3]

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

Variable Documentation

◆ moose_stream_lock

libMesh::Threads::spin_mutex moose::internal::moose_stream_lock
inlineprivate