https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SolutionInvalidityRegistry.C
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
11
12#include "DataIO.h"
13
14namespace moose::internal
15{
16
17SolutionInvalidityRegistry &
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}
25
31
33SolutionInvalidityRegistry::registerInvalidity(const std::string & object_type,
34 const std::string & message,
35 const bool warning)
36{
37 const SolutionInvalidityName name(object_type, message);
38 if (keyExists(name))
39 mooseAssert(item(id(name)).warning == warning, "Inconsistent registration for a warning");
40 const auto create_item = [&object_type, &message, &warning](const std::size_t id)
41 { return SolutionInvalidityInfo(object_type, message, id, warning); };
42 return registerItem(name, create_item);
43}
44
45std::ostream &
46operator<<(std::ostream & os, const SolutionInvalidityName & name)
47{
48 os << name.object_type << ": " << name.message;
49 return os;
50}
51}
unsigned int InvalidSolutionID
Definition MooseTypes.h:241
std::size_t registerItem(const SolutionInvalidityName &key, CreateItem &create_item)
Registers an item with key key if said key does not exist.
Helper class that stores the info associated with an invalid solution.
Helper class that stores the name associated with an invalid solution.
The place where all sections with solution invalid warnings will be stored.
InvalidSolutionID registerInvalidity(const std::string &object_type, const std::string &message, const bool warning)
Call to register an invalid calculation.
SolutionInvalidityRegistry & getSolutionInvalidityRegistry()
Get the global SolutionInvalidityRegistry singleton.
std::ostream & operator<<(std::ostream &os, const SolutionInvalidityName &name)
Helper class that hash the name associated with an invalid solution.