www.mooseframework.org
CrankNicolson.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 "CrankNicolson.h"
16 #include "NonlinearSystem.h"
17 #include "FEProblem.h"
18 
19 template <>
22 {
24 
25  return params;
26 }
27 
29  : TimeIntegrator(parameters), _residual_old(_nl.addVector("residual_old", false, GHOSTED))
30 {
31 }
32 
34 
35 void
37 {
38  _u_dot = *_solution;
40  _u_dot *= 2. / _dt;
41  _u_dot.close();
42 
43  _du_dot_du = 2. / _dt;
44 }
45 
46 void
48 {
49  if (_t_step == 1)
50  {
51  // make sure that time derivative contribution is zero in the first pre-solve step
52  _u_dot.zero();
53  _u_dot.close();
54 
55  _du_dot_du = 0;
56 
57  // for the first time step, compute residual for the old time step
59  _residual_old = _nl.RHS();
60  _residual_old.close();
61  }
62 }
63 
64 void
65 CrankNicolson::postStep(NumericVector<Number> & residual)
66 {
67  residual += _Re_time;
68  residual += _Re_non_time;
69  residual += _residual_old;
70 }
71 
72 void
74 {
75  // shift the residual in time
77  _residual_old.close();
78 }
NonlinearSystemBase & _nl
virtual void postStep(NumericVector< Number > &residual)
Callback to the TimeIntegrator called immediately after the residuals are computed in NonlinearSystem...
Definition: CrankNicolson.C:65
virtual void computeTimeDerivatives()
Definition: CrankNicolson.C:36
NumericVector< Number > & _u_dot
solution vector for u^dot
virtual void computeResidualType(const NumericVector< Number > &soln, NumericVector< Number > &residual, Moose::KernelType type=Moose::KT_ALL)
FEProblemBase & _fe_problem
NumericVector< Number > & _Re_non_time
residual vector for non-time contributions
virtual void preSolve()
Definition: CrankNicolson.C:47
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
NumericVector< Number > & _residual_old
Definition: CrankNicolson.h:46
InputParameters validParams< TimeIntegrator >()
CrankNicolson(const InputParameters &parameters)
Definition: CrankNicolson.C:28
virtual void postSolve()
Callback to the TimeIntegrator called immediately after TimeIntegrator::solve() (so the name does mak...
Definition: CrankNicolson.C:73
Real & _du_dot_du
solution vector for
virtual NumericVector< Number > & RHS()=0
Base class for time integrators.
NumericVector< Number > & _Re_time
residual vector for time contributions
const NumericVector< Number > & _solution_old
virtual ~CrankNicolson()
Definition: CrankNicolson.C:33
const NumericVector< Number > *& _solution
solution vectors
InputParameters validParams< CrankNicolson >()
Definition: CrankNicolson.C:21