SolutionInvalidInterface

The SolutionInvalidInterface defines the method used to mark a solution as "invalid". An invalid solution means that the solution somehow does not satisfy requirements such as a value being out of bounds of a correlation. Solutions are allowed to be invalid _during_ the nonlinear solve - but are not allowed to invalid once it converges. A "converged" solution that is marked as invalid will cause MOOSE to behave as if the solution did NOT converge - including cutting back timesteps, etc.

This can be overridden by setting Problem/allow_invalid_solution=true.


#pragma once

// MOOSE includes
#include "Moose.h"
#include "SolutionInvalidity.h"

// Forward declarations
class MooseObject;
class FEProblemBase;

#define flagInvalidSolution(message)                                                               \
  do                                                                                               \
  {                                                                                                \
    static const auto __invalid_id = this->registerInvalidSolutionInternal(message, false);        \
    this->flagInvalidSolutionInternal<false>(__invalid_id);                                        \
  } while (0)

#define flagSolutionWarning(message)                                                               \
  do                                                                                               \
  {                                                                                                \
    static const auto __invalid_id = this->registerInvalidSolutionInternal(message, true);         \
    this->flagInvalidSolutionInternal<true>(__invalid_id);                                         \
  } while (0)

/**
 * An interface that allows the marking of invalid solutions during a solve
 */
class SolutionInvalidInterface
{
public:
  SolutionInvalidInterface(MooseObject * const moose_object);

protected:
  template <bool warning>
  void flagInvalidSolutionInternal(const InvalidSolutionID invalid_solution_id) const;

  // Register invalid solution with a message
  InvalidSolutionID registerInvalidSolutionInternal(const std::string & message,
                                                    const bool warning) const;

private:
  /// The MooseObject that owns this interface
  MooseObject & _si_moose_object;

  /// A reference to FEProblem base
  FEProblemBase & _si_problem;
};
(moose/framework/include/interfaces/SolutionInvalidInterface.h)