https://mooseframework.inl.gov
Loading...
Searching...
No Matches
AdamsPredictor.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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{
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, libMesh::GHOSTED)),
31 _older_solution(_nl.addVector("AB2_older_solution", true, libMesh::GHOSTED)),
32 _oldest_solution(_nl.addVector("AB2_rejected_solution", true, libMesh::GHOSTED)),
33 _tmp_previous_solution(_nl.addVector("tmp_previous_solution", true, libMesh::GHOSTED)),
34 _tmp_residual_old(_nl.addVector("tmp_residual_old", true, libMesh::GHOSTED)),
35 _tmp_third_vector(_nl.addVector("tmp_third_vector", true, libMesh::GHOSTED)),
36 _dt_older(declareRestartableData<Real>("dt_older", 0)),
37 _dtstorage(declareRestartableData<Real>("dtstorage", 0))
38{
39}
40
41void
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
62bool
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
78void
79AdamsPredictor::apply(NumericVector<Number> & sln)
80{
81 // localize current solution to working vec
82 sln.localize(_solution_predictor);
83 // NumericVector<Number> & vector1 = _tmp_previous_solution;
84 NumericVector<Number> & vector2 = _tmp_residual_old;
85 NumericVector<Number> & vector3 = _tmp_third_vector;
86
87 Real commonpart = _dt / _dt_old;
88 Real firstpart = (1 + .5 * commonpart);
89 Real secondpart = .5 * _dt / _dt_older;
90
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}
registerMooseObject("MooseApp", AdamsPredictor)
void ErrorVector unsigned int
Implements an explicit Adams predictor based on two old solution vectors.
NumericVector< Number > & _tmp_third_vector
virtual void timestepSetup() override
virtual bool shouldApply() override
virtual void apply(NumericVector< Number > &sln) override
NumericVector< Number > & _current_old_solution
NumericVector< Number > & _tmp_residual_old
NumericVector< Number > & _oldest_solution
AdamsPredictor(const InputParameters &parameters)
NumericVector< Number > & _older_solution
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
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.
Base class for predictors.
Definition Predictor.h:29
virtual bool shouldApply()
Definition Predictor.C:84
bool & _is_repeated_timestep
Definition Predictor.h:55
Real & _dt_old
Definition Predictor.h:49
NumericVector< Number > & _solution_predictor
Definition Predictor.h:53
static InputParameters validParams()
Definition Predictor.C:21
NonlinearSystemBase & _nl
Definition Predictor.h:45
virtual void timestepSetup()
Definition Predictor.C:71
Real & _dt
Definition Predictor.h:48
int & _t_step
Definition Predictor.h:47
NumericVector< Number > & solutionOld()
Definition SystemBase.h:204
virtual void localize(std::vector< T > &v_local) const=0
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...