www.mooseframework.org
Predictor.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 // MOOSE includes
16 #include "Predictor.h"
17 #include "NonlinearSystem.h"
18 #include "FEProblem.h"
19 
20 #include "libmesh/numeric_vector.h"
21 
22 template <>
25 {
27  params.addRequiredParam<Real>("scale",
28  "The scale factor for the predictor (can range from 0 to 1)");
29  params.addParam<std::vector<Real>>(
30  "skip_times", "Skip the predictor if the current solution time is in this list of times");
31  params.addParam<std::vector<Real>>(
32  "skip_times_old",
33  "Skip the predictor if the previous solution time is in this list of times");
34 
35  params.registerBase("Predictor");
36 
37  return params;
38 }
39 
41  : MooseObject(parameters),
42  Restartable(parameters, "Predictors"),
43  _fe_problem(*parameters.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
44  _nl(_fe_problem.getNonlinearSystemBase()),
45 
46  _t_step(_fe_problem.timeStep()),
47  _dt(_fe_problem.dt()),
48  _dt_old(_fe_problem.dtOld()),
49  _solution(*_nl.currentSolution()),
50  _solution_old(_nl.solutionOld()),
51  _solution_older(_nl.solutionOlder()),
52  _solution_predictor(_nl.addVector("predictor", true, GHOSTED)),
53  _scale(getParam<Real>("scale")),
54  _skip_times(getParam<std::vector<Real>>("skip_times")),
55  _skip_times_old(getParam<std::vector<Real>>("skip_times_old"))
56 {
57  if (_scale < 0.0 || _scale > 1.0)
58  mooseError("Input value for scale = ", _scale, " is outside of permissible range (0 to 1)");
59 }
60 
62 
63 void
65 {
66 }
67 
68 bool
70 {
71  bool should_apply = true;
72 
73  const Real & current_time = _fe_problem.time();
74  const Real & old_time = _fe_problem.timeOld();
75  for (unsigned int i = 0; i < _skip_times.size() && should_apply; ++i)
76  {
77  if (MooseUtils::absoluteFuzzyEqual(current_time, _skip_times[i]))
78  should_apply = false;
79  }
80  for (unsigned int i = 0; i < _skip_times_old.size() && should_apply; ++i)
81  {
83  should_apply = false;
84  }
85  return should_apply;
86 }
virtual Real & timeOld() const
A class for creating restricted objects.
Definition: Restartable.h:31
virtual Real & time() const
std::vector< Real > _skip_times
Times for which the predictor should not be applied.
Definition: Predictor.h:68
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters validParams< Predictor >()
Definition: Predictor.C:24
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System...
virtual void timestepSetup()
Definition: Predictor.C:64
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:36
InputParameters validParams< MooseObject >()
Definition: MooseObject.C:22
bool absoluteFuzzyEqual(const libMesh::Real &var1, const libMesh::Real &var2, const libMesh::Real &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether two variables are equal within an absolute tolerance.
Real _scale
Amount by which to scale the predicted value. Must be in [0,1].
Definition: Predictor.h:65
FEProblemBase & _fe_problem
Definition: Predictor.h:53
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
virtual ~Predictor()
Definition: Predictor.C:61
std::vector< Real > _skip_times_old
Old times for which the predictor should not be applied.
Definition: Predictor.h:71
virtual bool shouldApply()
Definition: Predictor.C:69
Predictor(const InputParameters &parameters)
Definition: Predictor.C:40