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 "MooseBase.h"
13 #include "MooseApp.h"
14 #include "FEProblemBase.h"
16 
18  const InputParameters & parameters)
19  : _si_moose_base(*moose_base),
20  _si_problem(
21  parameters.isParamValid("_fe_problem_base") ?
22  // MooseObjects get the problem that way
23  parameters.get<FEProblemBase *>("_fe_problem_base")
24  :
25  // Actions get the problem that way
26  parameters.getCheckedPointerParam<ActionWarehouse *>("awh")->problemBase().get())
27 {
28 }
29 
30 #ifdef MOOSE_KOKKOS_ENABLED
33  : _si_moose_base(object._si_moose_base), _si_problem(object._si_problem)
34 {
35 }
36 #endif
37 
39 template <bool warning>
40 void
42  const InvalidSolutionID invalid_solution_id) const
43 {
44  mooseAssert(
45  warning == moose::internal::getSolutionInvalidityRegistry().item(invalid_solution_id).warning,
46  "Inconsistent warning flag");
47  auto & solution_invalidity = _si_moose_base.getMooseApp().solutionInvalidity();
48  if constexpr (!warning)
50  solution_invalidity.printDebug(invalid_solution_id);
51  return solution_invalidity.flagInvalidSolutionInternal(invalid_solution_id);
52 }
53 
56  const bool warning) const
57 {
59  _si_moose_base.type(), message, warning);
60 }
61 
62 template void SolutionInvalidInterface::flagInvalidSolutionInternal<true>(
63  const InvalidSolutionID invalid_solution_id) const;
64 template void SolutionInvalidInterface::flagInvalidSolutionInternal<false>(
65  const InvalidSolutionID invalid_solution_id) const;
const FEProblemBase * _si_problem
A pointer to FEProblem base.
Base class for everything in MOOSE with a name and a type.
Definition: MooseBase.h:49
unsigned int InvalidSolutionID
Definition: MooseTypes.h:213
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1135
void printDebug(InvalidSolutionID _invalid_solution_id) const
Immediately print the section and message for debug purpose.
Storage for action instances.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
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.
SolutionInvalidity & solutionInvalidity()
Get the SolutionInvalidity for this app.
Definition: MooseApp.h:179
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:93
SolutionInvalidityRegistry & getSolutionInvalidityRegistry()
Get the global SolutionInvalidityRegistry singleton.
void flagInvalidSolutionInternal(const InvalidSolutionID invalid_solution_id) const
Set solution invalid mark for the given solution ID.
SolutionInvalidInterface(const MooseBase *const moose_base, const InputParameters &params)
bool immediatelyPrintInvalidSolution() const
Whether or not the solution invalid warnings are printed out immediately.
const MooseBase & _si_moose_base
The MooseBase that owns this interface.