www.mooseframework.org
GradientComponent.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
14 template <>
15 InputParameters
17 {
18  InputParameters params = validParams<Kernel>();
19  params.addClassDescription(
20  "Set the kernel variable to a specified component of the gradient of a coupled variable.");
21  params.addRequiredCoupledVar("v", "Coupled variable to match gradient component of");
22  params.addRequiredParam<unsigned int>("component",
23  "Component of the gradient of the coupled variable v");
24  return params;
25 }
26 
27 GradientComponent::GradientComponent(const InputParameters & parameters)
28  : Kernel(parameters),
29  _v_var(coupled("v")),
30  _grad_v(coupledGradient("v")),
31  _component(getParam<unsigned int>("component"))
32 {
33  if (_component >= LIBMESH_DIM)
34  paramError("component", "Component too large for LIBMESH_DIM");
35 }
36 
37 Real
39 {
40  return (_u[_qp] - _grad_v[_qp](_component)) * _test[_i][_qp];
41 }
42 
43 Real
45 {
46  return _phi[_j][_qp] * _test[_i][_qp];
47 }
48 
49 Real
51 {
52  if (jvar == _v_var)
53  return -_grad_phi[_j][_qp](_component) * _test[_i][_qp];
54  return 0.0;
55 }
GradientComponent.h
GradientComponent::computeQpOffDiagJacobian
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: GradientComponent.C:50
GradientComponent::_grad_v
const VariableGradient & _grad_v
Gradient of the coupled variable.
Definition: GradientComponent.h:33
GradientComponent::_component
const unsigned int _component
Component of the gradient vector to match.
Definition: GradientComponent.h:36
GradientComponent::computeQpResidual
virtual Real computeQpResidual()
Definition: GradientComponent.C:38
GradientComponent::GradientComponent
GradientComponent(const InputParameters &parameters)
Definition: GradientComponent.C:27
validParams< GradientComponent >
InputParameters validParams< GradientComponent >()
Definition: GradientComponent.C:16
GradientComponent::computeQpJacobian
virtual Real computeQpJacobian()
Definition: GradientComponent.C:44
GradientComponent
Definition: GradientComponent.h:19
GradientComponent::_v_var
const unsigned int _v_var
Identity of the coupled variable.
Definition: GradientComponent.h:30
registerMooseObject
registerMooseObject("PhaseFieldApp", GradientComponent)