www.mooseframework.org
BDF2.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 "BDF2.h"
16 #include "NonlinearSystem.h"
17 
18 template <>
21 {
23 
24  return params;
25 }
26 
27 BDF2::BDF2(const InputParameters & parameters)
28  : TimeIntegrator(parameters), _weight(declareRestartableData<std::vector<Real>>("weight"))
29 {
30  _weight.resize(3);
31 }
32 
34 
35 void
37 {
38  if (_t_step > 1)
39  {
40  Real sum = _dt + _dt_old;
41  _weight[0] = 1. + _dt / sum;
42  _weight[1] = -sum / _dt_old;
43  _weight[2] = _dt * _dt / _dt_old / sum;
44  }
45 }
46 
47 void
49 {
50  if (_t_step == 1)
51  {
52  _u_dot = *_solution;
54  _u_dot *= 1 / _dt;
55  _u_dot.close();
56 
57  _du_dot_du = 1.0 / _dt;
58  }
59  else
60  {
61  _u_dot.zero();
62  _u_dot.add(_weight[0], *_solution);
63  _u_dot.add(_weight[1], _solution_old);
65  _u_dot.scale(1. / _dt);
66  _u_dot.close();
67 
68  _du_dot_du = _weight[0] / _dt;
69  }
70 }
71 
72 void
73 BDF2::postStep(NumericVector<Number> & residual)
74 {
75  residual += _Re_time;
76  residual += _Re_non_time;
77  residual.close();
78 }
virtual void computeTimeDerivatives()
Definition: BDF2.C:48
NumericVector< Number > & _u_dot
solution vector for u^dot
NumericVector< Number > & _Re_non_time
residual vector for non-time contributions
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual ~BDF2()
Definition: BDF2.C:33
std::vector< Real > & _weight
Definition: BDF2.h:40
InputParameters validParams< TimeIntegrator >()
const NumericVector< Number > & _solution_older
BDF2(const InputParameters &parameters)
Definition: BDF2.C:27
Real & _du_dot_du
solution vector for
Base class for time integrators.
InputParameters validParams< BDF2 >()
Definition: BDF2.C:20
virtual void preStep()
Definition: BDF2.C:36
NumericVector< Number > & _Re_time
residual vector for time contributions
const NumericVector< Number > & _solution_old
const NumericVector< Number > *& _solution
solution vectors
virtual void postStep(NumericVector< Number > &residual)
Callback to the TimeIntegrator called immediately after the residuals are computed in NonlinearSystem...
Definition: BDF2.C:73