www.mooseframework.org
SimplePredictor.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 #include "SimplePredictor.h"
16 #include "NonlinearSystem.h"
17 
18 template <>
21 {
23 
24  return params;
25 }
26 
27 SimplePredictor::SimplePredictor(const InputParameters & parameters) : Predictor(parameters) {}
28 
29 bool
31 {
32  bool should_apply = true;
33  should_apply = Predictor::shouldApply();
34 
35  if (_t_step < 2 || _dt_old <= 0)
36  should_apply = false;
37 
38  if (!should_apply)
39  _console << " Skipping predictor this step" << std::endl;
40 
41  return should_apply;
42 }
43 
44 void
45 SimplePredictor::apply(NumericVector<Number> & sln)
46 {
47  // Save the original stream flags
48  std::ios_base::fmtflags out_flags = Moose::out.flags();
49 
50  _console << " Applying predictor with scale factor = " << std::fixed << std::setprecision(2)
51  << _scale << std::endl;
52 
53  // Restore the flags
54  Moose::out.flags(out_flags);
55 
56  Real dt_adjusted_scale_factor = _scale * _dt / _dt_old;
57  if (dt_adjusted_scale_factor != 0.0)
58  {
59  sln *= (1.0 + dt_adjusted_scale_factor);
60  sln.add(-dt_adjusted_scale_factor, _solution_older);
61  }
62 }
Base class for predictors.
Definition: Predictor.h:39
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:58
NumericVector< Number > & _solution_older
Definition: Predictor.h:61
virtual void apply(NumericVector< Number > &sln) override
InputParameters validParams< SimplePredictor >()
InputParameters validParams< Predictor >()
Definition: Predictor.C:24
Real & _dt
Definition: Predictor.h:57
Real _scale
Amount by which to scale the predicted value. Must be in [0,1].
Definition: Predictor.h:65
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
int & _t_step
Definition: Predictor.h:56
virtual bool shouldApply()
Definition: Predictor.C:69