www.mooseframework.org
ODEKernel.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 "ODEKernel.h"
16 
17 // MOOSE includes
18 #include "Assembly.h"
19 #include "MooseVariableScalar.h"
20 #include "SystemBase.h"
21 
22 template <>
25 {
27  return params;
28 }
29 
30 ODEKernel::ODEKernel(const InputParameters & parameters) : ScalarKernel(parameters) {}
31 
32 void
34 {
35 }
36 
37 void
39 {
40  DenseVector<Number> & re = _assembly.residualBlock(_var.number());
41  for (_i = 0; _i < _var.order(); _i++)
42  re(_i) += computeQpResidual();
43 }
44 
45 void
47 {
48  DenseMatrix<Number> & ke = _assembly.jacobianBlock(_var.number(), _var.number());
49 
50  for (_i = 0; _i < _var.order(); _i++)
51  for (_j = 0; _j < _var.order(); _j++)
52  ke(_i, _j) += computeQpJacobian();
53 
54  // compute off-diagonal jacobians wrt scalar variables
55  const std::vector<MooseVariableScalar *> & scalar_vars = _sys.getScalarVariables(_tid);
56  for (const auto & var : scalar_vars)
57  computeOffDiagJacobian(var->number());
58 }
59 
60 void
62 {
63  if (_sys.isScalarVariable(jvar))
64  {
65  DenseMatrix<Number> & ke = _assembly.jacobianBlock(_var.number(), jvar);
67  for (_i = 0; _i < _var.order(); _i++)
68  for (_j = 0; _j < var_j.order(); _j++)
69  {
70  if (jvar != _var.number())
71  ke(_i, _j) += computeQpOffDiagJacobian(jvar);
72  }
73  }
74 }
75 
76 Real
78 {
79  return 0.;
80 }
81 
82 Real
84 {
85  return 0.;
86 }
virtual void computeJacobian() override
Definition: ODEKernel.C:46
InputParameters validParams< ODEKernel >()
Definition: ODEKernel.C:24
InputParameters validParams< ScalarKernel >()
Definition: ScalarKernel.C:25
const std::vector< MooseVariableScalar * > & getScalarVariables(THREAD_ID tid)
Definition: SystemBase.h:422
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Assembly & _assembly
Definition: ScalarKernel.h:79
DenseVector< Number > & residualBlock(unsigned int var_num, Moose::KernelType type=Moose::KT_NONTIME)
Definition: Assembly.h:504
virtual void computeOffDiagJacobian(unsigned int jvar) override
Definition: ODEKernel.C:61
ODEKernel(const InputParameters &parameters)
Definition: ODEKernel.C:30
MooseVariableScalar & _var
Scalar variable.
Definition: ScalarKernel.h:81
THREAD_ID _tid
Definition: ScalarKernel.h:77
virtual bool isScalarVariable(unsigned int var_name)
Definition: SystemBase.C:574
Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int...
SystemBase & _sys
Definition: ScalarKernel.h:75
unsigned int number() const
Get variable number coming from libMesh.
virtual void computeResidual() override
Definition: ODEKernel.C:38
Class for scalar variables (they are different).
virtual Real computeQpResidual()=0
DenseMatrix< Number > & jacobianBlock(unsigned int ivar, unsigned int jvar)
Definition: Assembly.C:887
unsigned int _i
Definition: ScalarKernel.h:84
virtual void reinit() override
Definition: ODEKernel.C:33
virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid, const std::string &var_name)
Gets a reference to a scalar variable with specified number.
Definition: SystemBase.C:121
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: ODEKernel.C:83
virtual Real computeQpJacobian()
Definition: ODEKernel.C:77
unsigned int _j
Definition: ScalarKernel.h:84