https://mooseframework.inl.gov
GradientComponent.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 "GradientComponent.h"
11 
12 registerMooseObject("PhaseFieldApp", GradientComponent);
13 
16 {
18  params.addClassDescription(
19  "Set the kernel variable to a specified component of the gradient of a coupled variable.");
20  params.addRequiredCoupledVar("v", "Coupled variable to match gradient component of");
21  params.addRequiredParam<unsigned int>("component",
22  "Component of the gradient of the coupled variable v");
23  return params;
24 }
25 
27  : Kernel(parameters),
28  _v_var(coupled("v")),
29  _grad_v(coupledGradient("v")),
30  _component(getParam<unsigned int>("component"))
31 {
32  if (_component >= LIBMESH_DIM)
33  paramError("component", "Component too large for LIBMESH_DIM");
34 }
35 
36 Real
38 {
39  return (_u[_qp] - _grad_v[_qp](_component)) * _test[_i][_qp];
40 }
41 
42 Real
44 {
45  return _phi[_j][_qp] * _test[_i][_qp];
46 }
47 
48 Real
50 {
51  if (jvar == _v_var)
52  return -_grad_phi[_j][_qp](_component) * _test[_i][_qp];
53  return 0.0;
54 }
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
static InputParameters validParams()
GradientComponent(const InputParameters &parameters)
const VariableGradient & _grad_v
Gradient of the coupled variable.
static InputParameters validParams()
const VariablePhiGradient & _grad_phi
virtual Real computeQpJacobian()
const unsigned int _component
Component of the gradient vector to match.
virtual Real computeQpResidual()
void addRequiredParam(const std::string &name, const std::string &doc_string)
const unsigned int _v_var
Identity of the coupled variable.
const VariableTestValue & _test
registerMooseObject("PhaseFieldApp", GradientComponent)
unsigned int _i
void paramError(const std::string &param, Args... args) const
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
unsigned int _j
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
const VariablePhiValue & _phi
void ErrorVector unsigned int
const VariableValue & _u
unsigned int _qp