https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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
37Real
42
43Real
45{
46 if (_p_var_num == jvar)
47 return _coeff * _p_phi[_j][_qp] * _div_test[_i][_qp];
48
49 return 0.0;
50}
registerMooseObject("MooseApp", GradField)
Weak form contribution corresponding to -k*grad(p)
Definition GradField.h:18
const VariablePhiValue & _p_phi
shape function of the coupled scalar variable
Definition GradField.h:36
const VariableValue & _p
value of the coupled scalar variable
Definition GradField.h:33
const VectorVariableTestDivergence & _div_test
div of the test function
Definition GradField.h:39
virtual Real computeQpOffDiagJacobian(unsigned jvar) override
Definition GradField.C:44
unsigned int _p_var_num
Definition GradField.h:30
static InputParameters validParams()
Definition GradField.C:16
virtual Real computeQpResidual() override
Compute this Kernel's contribution to the residual at the current quadrature point.
Definition GradField.C:38
GradField(const InputParameters &parameters)
Definition GradField.C:26
Real _coeff
scalar coefficient
Definition GradField.h:42
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
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.
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.
unsigned int _qp
The current quadrature point index.
Definition KernelBase.h:43
unsigned int _j
current index for the shape function
Definition KernelBase.h:61
unsigned int _i
current index for the test function
Definition KernelBase.h:58
static InputParameters validParams()