https://mooseframework.inl.gov
GradField.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 "GradField.h"
11 #include "Assembly.h"
12 
13 registerMooseObject("MooseApp", GradField);
14 
17 {
19  params.addClassDescription("The gradient operator optionally scaled by a constant scalar "
20  "coefficient. Weak form: $(\\nabla \\cdot \\vec{\\psi_i}, k v)$.");
21  params.addRequiredCoupledVar("coupled_scalar_variable", "The scalar field");
22  params.addParam<Real>("coeff", 1.0, "The constant coefficient");
23  return params;
24 }
25 
27  : VectorKernel(parameters),
28  _p_var(*getVar("coupled_scalar_variable", 0)),
29  _p_var_num(coupled("coupled_scalar_variable")),
30  _p(coupledValue("coupled_scalar_variable")),
31  _p_phi(_assembly.phi(_p_var)),
32  _div_test(_var.divPhi()),
33  _coeff(getParam<Real>("coeff"))
34 {
35 }
36 
37 Real
39 {
40  return _coeff * _p[_qp] * _div_test[_i][_qp];
41 }
42 
43 Real
45 {
46  if (_p_var_num == jvar)
47  return _coeff * _p_phi[_j][_qp] * _div_test[_i][_qp];
48 
49  return 0.0;
50 }
const VectorVariableTestDivergence & _div_test
div of the test function
Definition: GradField.h:39
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const VariableValue & _p
value of the coupled scalar variable
Definition: GradField.h:33
static InputParameters validParams()
Definition: GradField.C:16
const VariablePhiValue & _p_phi
shape function of the coupled scalar variable
Definition: GradField.h:36
GradField(const InputParameters &parameters)
Definition: GradField.C:26
Real _coeff
scalar coefficient
Definition: GradField.h:42
virtual Real computeQpResidual() override
Compute this Kernel&#39;s contribution to the residual at the current quadrature point.
Definition: GradField.C:38
unsigned int _i
current index for the test function
Definition: KernelBase.h:58
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
registerMooseObject("MooseApp", GradField)
unsigned int _j
current index for the shape function
Definition: KernelBase.h:61
Weak form contribution corresponding to -k*grad(p)
Definition: GradField.h:17
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static InputParameters validParams()
Definition: VectorKernel.C:21
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...
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...
unsigned int _p_var_num
Definition: GradField.h:30
virtual Real computeQpOffDiagJacobian(unsigned jvar) override
This is the virtual that derived classes should override for computing an off-diagonal Jacobian compo...
Definition: GradField.C:44
unsigned int _qp
The current quadrature point index.
Definition: KernelBase.h:43