https://mooseframework.inl.gov
SolutionInvalidInterface.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 
10 // MOOSE includes
12 #include "MooseObject.h"
13 #include "MooseApp.h"
14 #include "FEProblemBase.h"
16 
18  : _si_moose_object(*moose_object),
19  _si_problem(
20  *_si_moose_object.parameters().getCheckedPointerParam<FEProblemBase *>("_fe_problem_base"))
21 {
22 }
23 
24 #ifdef MOOSE_KOKKOS_ENABLED
27  : _si_moose_object(object._si_moose_object), _si_problem(object._si_problem)
28 {
29 }
30 #endif
31 
33 template <bool warning>
34 void
36  const InvalidSolutionID invalid_solution_id) const
37 {
38  mooseAssert(
39  warning == moose::internal::getSolutionInvalidityRegistry().item(invalid_solution_id).warning,
40  "Inconsistent warning flag");
41  auto & solution_invalidity = _si_moose_object.getMooseApp().solutionInvalidity();
42  if constexpr (!warning)
44  solution_invalidity.printDebug(invalid_solution_id);
45  return solution_invalidity.flagInvalidSolutionInternal(invalid_solution_id);
46 }
47 
50  const bool warning) const
51 {
53  _si_moose_object.type(), message, warning);
54 }
55 
56 template void SolutionInvalidInterface::flagInvalidSolutionInternal<true>(
57  const InvalidSolutionID invalid_solution_id) const;
58 template void SolutionInvalidInterface::flagInvalidSolutionInternal<false>(
59  const InvalidSolutionID invalid_solution_id) const;
unsigned int InvalidSolutionID
Definition: MooseTypes.h:213
void printDebug(InvalidSolutionID _invalid_solution_id) const
Immediately print the section and message for debug purpose.
InvalidSolutionID registerInvalidity(const std::string &object_type, const std::string &message, const bool warning)
Call to register an invalid calculation.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
MooseApp & getMooseApp() const
Get the MooseApp this class is associated with.
Definition: MooseBase.h:87
InvalidSolutionID registerInvalidSolutionInternal(const std::string &message, const bool warning) const
An interface that allows the marking of invalid solutions during a solve.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:27
SolutionInvalidity & solutionInvalidity()
Get the SolutionInvalidity for this app.
Definition: MooseApp.h:179
SolutionInvalidInterface(const MooseObject *const moose_object)
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:93
const FEProblemBase & _si_problem
A reference to FEProblem base.
const MooseObject & _si_moose_object
The MooseObject that owns this interface.
SolutionInvalidityRegistry & getSolutionInvalidityRegistry()
Get the global SolutionInvalidityRegistry singleton.
void flagInvalidSolutionInternal(const InvalidSolutionID invalid_solution_id) const
Set solution invalid mark for the given solution ID.
bool immediatelyPrintInvalidSolution() const
Whether or not the solution invalid warnings are printed out immediately.