www.mooseframework.org
AdamsPredictor.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 "AdamsPredictor.h"
11 #include "NonlinearSystem.h"
12 
13 #include "libmesh/numeric_vector.h"
14 
16 
19 {
21  params.addClassDescription(
22  "Implements an explicit Adams predictor based on two old solution vectors.");
23  params.addParam<int>("order", 2, "The maximum reachable order of the Adams-Bashforth Predictor");
24  return params;
25 }
26 
28  : Predictor(parameters),
29  _order(getParam<int>("order")),
30  _current_old_solution(_nl.addVector("AB2_current_old_solution", true, GHOSTED)),
31  _older_solution(_nl.addVector("AB2_older_solution", true, GHOSTED)),
32  _oldest_solution(_nl.addVector("AB2_rejected_solution", true, GHOSTED)),
33  _tmp_previous_solution(_nl.addVector("tmp_previous_solution", true, GHOSTED)),
34  _tmp_residual_old(_nl.addVector("tmp_residual_old", true, GHOSTED)),
35  _tmp_third_vector(_nl.addVector("tmp_third_vector", true, GHOSTED)),
36  _dt_older(declareRestartableData<Real>("dt_older", 0)),
37  _dtstorage(declareRestartableData<Real>("dtstorage", 0))
38 {
39 }
40 
41 void
43 {
45 
46  // if the time step number hasn't changed (=repeated timestep) then do nothing
48  return;
49 
50  // Otherwise move back the previous old solution and copy the current old solution,
51  // This will probably not work with DT2, but I don't need to get it to work with dt2.
53  // Set older solution to hold the previous old solution
55  // Set current old solution to hold what it says.
57  // Same thing for dt
60 }
61 
62 bool
64 {
66  return false;
67 
68  // AB2 can only be applied if there are enough old solutions
69  // AB1 could potentially be used for the time step prior?
70  // It would be possible to do VSVO Adams, Kevin has the info
71  // Doing so requires a time stack of some sort....
72  if (_dt == 0 || _dt_old == 0 || _dt_older == 0 || _t_step < 2)
73  return false;
74  else
75  return true;
76 }
77 
78 void
80 {
81  // localize current solution to working vec
83  // NumericVector<Number> & vector1 = _tmp_previous_solution;
86 
87  Real commonpart = _dt / _dt_old;
88  Real firstpart = (1 + .5 * commonpart);
89  Real secondpart = .5 * _dt / _dt_older;
90 
91  _older_solution.localize(vector2);
92  _oldest_solution.localize(vector3);
93 
94  _solution_predictor *= 1 + commonpart * firstpart;
95  vector2 *= -1. * commonpart * (firstpart + secondpart);
96  vector3 *= commonpart * secondpart;
97 
98  _solution_predictor += vector2;
99  _solution_predictor += vector3;
100 
102 }
AdamsPredictor(const InputParameters &parameters)
NumericVector< Number > & _tmp_third_vector
virtual void apply(NumericVector< Number > &sln) override
NumericVector< Number > & _current_old_solution
Base class for predictors.
Definition: Predictor.h:28
NonlinearSystemBase & _nl
Definition: Predictor.h:45
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Real & _dt_old
Definition: Predictor.h:49
Implements an explicit Adams predictor based on two old solution vectors.
static InputParameters validParams()
virtual void timestepSetup()
Definition: Predictor.C:69
NumericVector< Number > & _solution_predictor
Definition: Predictor.h:53
GHOSTED
static InputParameters validParams()
Definition: Predictor.C:19
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real & _dt
Definition: Predictor.h:48
virtual void timestepSetup() override
NumericVector< Number > & _oldest_solution
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...
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...
bool & _is_repeated_timestep
Definition: Predictor.h:55
NumericVector< Number > & _tmp_residual_old
NumericVector< Number > & solutionOld()
Definition: SystemBase.h:183
int & _t_step
Definition: Predictor.h:47
NumericVector< Number > & _older_solution
virtual bool shouldApply()
Definition: Predictor.C:82
void ErrorVector unsigned int
registerMooseObject("MooseApp", AdamsPredictor)
virtual bool shouldApply() override
virtual void localize(std::vector< Number > &v_local) const =0