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