www.mooseframework.org
VariableTimeIntegrationAux.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 
16 
17 template <>
20 {
22  params.addRequiredCoupledVar("variable_to_integrate", "The variable to be integrated");
23  params.addParam<Real>("coefficient", 1.0, "A simple coefficient");
24  params.addParam<unsigned int>(
25  "order", 2, "The order of global truncation error: midpoint=1, trapazoidal=2, Simpson=3");
26  return params;
27 }
28 
30  : AuxKernel(parameters),
31  _coef(getParam<Real>("coefficient")),
32  _order(getParam<unsigned int>("order"))
33 {
34  switch (_order)
35  {
36  case 1:
37  _integration_coef.push_back(1.0);
38  _coupled_vars.push_back(&coupledValue("variable_to_integrate"));
39  break;
40  case 2:
41  _integration_coef.push_back(0.5);
42  _integration_coef.push_back(0.5);
43  _coupled_vars.push_back(&coupledValue("variable_to_integrate"));
44  _coupled_vars.push_back(&coupledValueOld("variable_to_integrate"));
45  break;
46  case 3:
47  _integration_coef.push_back(1.0 / 3.0);
48  _integration_coef.push_back(4.0 / 3.0);
49  _integration_coef.push_back(1.0 / 3.0);
50  _coupled_vars.push_back(&coupledValue("variable_to_integrate"));
51  _coupled_vars.push_back(&coupledValueOld("variable_to_integrate"));
52  _coupled_vars.push_back(&coupledValueOlder("variable_to_integrate"));
53  break;
54  default:
55  mooseError("VariableTimeIntegrationAux: unknown time integraiton order specfied");
56  }
57 }
58 
59 Real
61 {
62  Real integral = getIntegralValue();
63 
64  if (_order == 3)
65  return _u_older[_qp] + _coef * integral;
66 
67  return _u_old[_qp] + _coef * integral;
68 }
69 
70 Real
72 {
73  Real integral_value = 0.0;
74 
75  for (unsigned int i = 0; i < _order; ++i)
76  integral_value += _integration_coef[i] * (*_coupled_vars[i])[_qp] * _dt;
77 
85  if (_order == 3 && _dt != _dt_old)
86  {
87  Real x0 = 0.0;
88  Real x1 = _dt_old;
89  Real x2 = _dt + _dt_old;
90  Real y0 = (*_coupled_vars[2])[_qp];
91  Real y1 = (*_coupled_vars[1])[_qp];
92  Real y2 = (*_coupled_vars[0])[_qp];
93  Real term1 = (x2 - x0) * (y0 + (x2 - x0) * (y1 - y0) / (2.0 * (x1 - x0)));
94  Real term2 = (2.0 * x2 * x2 - x0 * x2 - x0 * x0 + 3.0 * x0 * x1 - 3.0 * x1 * x2) / 6.0;
95  Real term3 = (y2 - y1) / (x2 - x1) - (y1 - y0) / (x1 - x0);
96  integral_value = term1 + term2 * term3;
97  }
98 
99  return integral_value;
100 }
const VariableValue & _u_older
Holds the t-2 solution at the current quadrature point.
Definition: AuxKernel.h:171
virtual Real computeValue() override
Real & _dt_old
Size of the old time step.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Real & _dt
Time step size.
VariableTimeIntegrationAux(const InputParameters &parameters)
InputParameters validParams< VariableTimeIntegrationAux >()
InputParameters validParams< AuxKernel >()
Definition: AuxKernel.C:30
std::vector< const VariableValue * > _coupled_vars
unsigned int _qp
Quadrature point index.
Definition: AuxKernel.h:192
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:51
virtual const VariableValue & coupledValue(const std::string &var_name, unsigned int comp=0)
Returns value of a coupled variable.
Definition: Coupleable.C:167
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
virtual const VariableValue & coupledValueOld(const std::string &var_name, unsigned int comp=0)
Returns an old value from previous time step of a coupled variable.
Definition: Coupleable.C:198
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...
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
virtual const VariableValue & coupledValueOlder(const std::string &var_name, unsigned int comp=0)
Returns an old value from two time steps previous of a coupled variable.
Definition: Coupleable.C:224
const VariableValue & _u_old
Holds the previous solution at the current quadrature point.
Definition: AuxKernel.h:169