www.mooseframework.org
ADACInterface.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 "ADACInterface.h"
11 
12 registerADMooseObject("PhaseFieldApp", ADACInterface);
13 
15  ADACInterface, ADKernel, params.addClassDescription("Gradient energy Allen-Cahn Kernel");
16  params.addParam<MaterialPropertyName>("mob_name", "L", "The mobility used with the kernel");
17  params.addParam<MaterialPropertyName>("kappa_name",
18  "kappa_op",
19  "The kappa used with the kernel");
20  params.addCoupledVar("args", "Vector of nonlinear variable arguments this object depends on");
21  params.addParam<bool>("variable_L",
22  true,
23  "The mobility is a function of any MOOSE variable (if "
24  "this is set to false L must be constant over the "
25  "entire domain!)"););
26 
27 template <ComputeStage compute_stage>
28 ADACInterface<compute_stage>::ADACInterface(const InputParameters & parameters)
29  : ADKernel<compute_stage>(parameters),
30  _prop_L(getADMaterialProperty<Real>("mob_name")),
31  _name_L(getParam<MaterialPropertyName>("mob_name")),
32  _kappa(getADMaterialProperty<Real>("kappa_name")),
33  _variable_L(getParam<bool>("variable_L")),
34  _dLdop(_variable_L
35  ? &getADMaterialProperty<Real>(derivativePropertyNameFirst(_name_L, _var.name()))
36  : nullptr),
37  _nvar(Coupleable::_coupled_standard_moose_vars.size()),
38  _dLdarg(_nvar),
39  _gradarg(_nvar)
40 {
41  // Get mobility and kappa derivatives and coupled variable gradients
42  if (_variable_L)
43  for (unsigned int i = 0; i < _nvar; ++i)
44  {
45  MooseVariable * ivar = _coupled_standard_moose_vars[i];
46  const VariableName iname = ivar->name();
47  if (iname == _var.name())
48  paramError("args",
49  "The kernel variable should not be specified in the coupled `args` parameter.");
50 
51  _dLdarg[i] = &getADMaterialProperty<Real>(derivativePropertyNameFirst(_name_L, iname));
52  _gradarg[i] = &(ivar->adGradSln<compute_stage>());
53  }
54 }
55 
56 template <ComputeStage compute_stage>
57 ADReal
59 {
60  // nabla_Lpsi is the product rule gradient \f$ \nabla (L\psi) \f$
61  ADRealVectorValue nabla_Lpsi = _prop_L[_qp] * _grad_test[_i][_qp];
62 
63  if (_variable_L)
64  {
65  ADRealVectorValue grad_L = _grad_u[_qp] * (*_dLdop)[_qp];
66  for (unsigned int i = 0; i < _nvar; ++i)
67  grad_L += (*_gradarg[i])[_qp] * (*_dLdarg[i])[_qp];
68 
69  nabla_Lpsi += grad_L * _test[_i][_qp];
70  }
71 
72  return _grad_u[_qp] * _kappa[_qp] * nabla_Lpsi;
73 }
74 
defineADValidParams
defineADValidParams(ADACInterface, ADKernel, params.addClassDescription("Gradient energy Allen-Cahn Kernel");params.addParam< MaterialPropertyName >("mob_name", "L", "The mobility used with the kernel");params.addParam< MaterialPropertyName >("kappa_name", "kappa_op", "The kappa used with the kernel");params.addCoupledVar("args", "Vector of nonlinear variable arguments this object depends on");params.addParam< bool >("variable_L", true, "The mobility is a function of any MOOSE variable (if " "this is set to false L must be constant over the " "entire domain!)");)
ADACInterface::_variable_L
const bool _variable_L
flag set if L is a function of non-linear variables in args
Definition: ADACInterface.h:53
ADACInterface.h
ADACInterface::_nvar
const unsigned int _nvar
number of coupled variables
Definition: ADACInterface.h:59
ADACInterface::_dLdarg
std::vector< const ADMaterialProperty(Real) * > _dLdarg
Mobility derivative w.r.t. other coupled variables.
Definition: ADACInterface.h:62
ADACInterface::computeQpResidual
virtual ADReal computeQpResidual()
Definition: ADACInterface.C:58
ADACInterface::ADACInterface
ADACInterface(const InputParameters &parameters)
Definition: ADACInterface.C:28
registerADMooseObject
registerADMooseObject("PhaseFieldApp", ADACInterface)
ADACInterface::_gradarg
std::vector< const ADVariableGradient * > _gradarg
Gradients for all coupled variables.
Definition: ADACInterface.h:65
name
const std::string name
Definition: Setup.h:21
ADACInterface
Compute the Allen-Cahn interface term with the weak form residual .
Definition: ADACInterface.h:27
adBaseClass
adBaseClass(ADACInterface)
ADACInterface::_name_L
const MaterialPropertyName & _name_L
Mobility property name.
Definition: ADACInterface.h:47