www.mooseframework.org
SimplePredictor.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 #include "SimplePredictor.h"
11 #include "NonlinearSystem.h"
12 
14 
17 {
19  params.addClassDescription(
20  "Algorithm that will predict the next solution based on previous solutions.");
21  return params;
22 }
23 
24 SimplePredictor::SimplePredictor(const InputParameters & parameters) : Predictor(parameters) {}
25 
26 bool
28 {
29  bool should_apply = true;
30  should_apply = Predictor::shouldApply();
31 
32  if (_t_step < 2 || _dt_old <= 0)
33  should_apply = false;
34 
35  if (!should_apply)
36  _console << " Skipping predictor this step" << std::endl;
37 
38  return should_apply;
39 }
40 
41 void
43 {
44  _console << " Applying predictor with scale factor = " << _scale << std::endl;
45 
46  Real dt_adjusted_scale_factor = _scale * _dt / _dt_old;
47  if (dt_adjusted_scale_factor != 0.0)
48  {
49  sln *= (1.0 + dt_adjusted_scale_factor);
50  sln.add(-dt_adjusted_scale_factor, _solution_older);
51  }
52 }
static InputParameters validParams()
Base class for predictors.
Definition: Predictor.h:28
registerMooseObject("MooseApp", SimplePredictor)
virtual bool shouldApply() override
SimplePredictor(const InputParameters &parameters)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Real & _dt_old
Definition: Predictor.h:49
A SimplePredictor uses an algorithm that will predict the next solution based on previous solutions...
NumericVector< Number > & _solution_older
Definition: Predictor.h:52
virtual void apply(NumericVector< Number > &sln) override
static InputParameters validParams()
Definition: Predictor.C:19
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real & _dt
Definition: Predictor.h:48
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
Real _scale
Amount by which to scale the predicted value. Must be in [0,1].
Definition: Predictor.h:58
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
virtual void add(const numeric_index_type i, const Number value)=0
int & _t_step
Definition: Predictor.h:47
virtual bool shouldApply()
Definition: Predictor.C:82