https://mooseframework.inl.gov
DivField.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 "DivField.h"
11 #include "Assembly.h"
12 
13 registerMooseObject("MooseApp", DivField);
14 
17 {
19  params.addClassDescription("The divergence operator optionally scaled by a constant scalar "
20  "coefficient. Weak form: $(\\psi_i, k \\nabla \\cdot \\vec{u})$.");
21  params.addRequiredCoupledVar("coupled_vector_variable", "The vector field");
22  params.addParam<Real>("coeff", 1.0, "The constant coefficient");
23  return params;
24 }
25 
27  : Kernel(parameters),
28  _u_var(*getVectorVar("coupled_vector_variable", 0)),
29  _u_var_num(coupled("coupled_vector_variable")),
30  _div_u(coupledDiv("coupled_vector_variable")),
31  _div_phi(_assembly.divPhi(_u_var)),
32  _coeff(getParam<Real>("coeff"))
33 {
34 }
35 
36 Real
38 {
39  return _coeff * _div_u[_qp] * _test[_i][_qp];
40 }
41 
42 Real
44 {
45  if (_u_var_num == jvar)
46  return _coeff * _div_phi[_j][_qp] * _test[_i][_qp];
47 
48  return 0.0;
49 }
static InputParameters validParams()
Definition: Kernel.C:24
registerMooseObject("MooseApp", DivField)
static InputParameters validParams()
Definition: DivField.C:16
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const VectorVariablePhiDivergence & _div_phi
div of the shape function of the coupled vector variable
Definition: DivField.h:36
Weak form contribution corresponding to k*div(u)
Definition: DivField.h:17
const VariableTestValue & _test
the current test function
Definition: Kernel.h:75
const VectorVariableDivergence & _div_u
div of the coupled vector variable
Definition: DivField.h:33
unsigned int _u_var_num
Definition: DivField.h:30
unsigned int _i
current index for the test function
Definition: KernelBase.h:58
Real _coeff
scalar coefficient
Definition: DivField.h:39
virtual Real computeQpOffDiagJacobian(unsigned jvar) override
Definition: DivField.C:43
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
unsigned int _j
current index for the shape function
Definition: KernelBase.h:61
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: Kernel.h:15
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...
DivField(const InputParameters &parameters)
Definition: DivField.C:26
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...
virtual Real computeQpResidual() override
Compute this Kernel&#39;s contribution to the residual at the current quadrature point.
Definition: DivField.C:37
unsigned int _qp
The current quadrature point index.
Definition: KernelBase.h:43