https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MatDiffusionBase.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 "MatDiffusionBase.h"
11
12template <typename T, bool is_ad>
15{
17 params.addParam<MaterialPropertyName>(
18 "diffusivity", "D", "The diffusivity value or material property");
19 params.addCoupledVar("v",
20 "Coupled concentration variable for kernel to operate on; if this "
21 "is not specified, the kernel's nonlinear variable will be used as "
22 "usual");
23 return params;
24}
25
26template <typename T>
29{
31 params.addCoupledVar("args",
32 "Optional vector of arguments for the diffusivity. If provided and "
33 "diffusivity is a derivative parsed material, Jacobian contributions from "
34 "the diffusivity will be automatically computed");
35 return params;
36}
37
38template <typename T, bool is_ad>
41 _diffusivity(this->template getGenericMaterialProperty<T, is_ad>("diffusivity")),
42 _grad_v(isCoupled("v") ? this->template coupledGenericGradient<is_ad>("v") : _grad_u)
43{
44}
45
46template <typename T>
48 : MatDiffusionBaseTempl<T, false>(parameters),
49 _ddiffusivity_dc(this->template getMaterialPropertyDerivative<T>("diffusivity", _var.name())),
50 _ddiffusivity_darg(_coupled_moose_vars.size()),
51 _is_coupled(this->isCoupled("v")),
52 _v_var(_is_coupled ? this->coupled("v") : _var.number())
53{
54 // fetch derivatives
55 for (unsigned int i = 0; i < _ddiffusivity_darg.size(); ++i)
56 _ddiffusivity_darg[i] = &this->template getMaterialPropertyDerivative<T>(
57 "diffusivity", _coupled_moose_vars[i]->name());
58}
59
60template <typename T, bool is_ad>
63{
64 return _diffusivity[_qp] * _grad_v[_qp];
65}
66
67template <typename T>
68void
70{
71 this->template validateNonlinearCoupling<T>("diffusivity");
72}
73
74template <typename T>
75RealGradient
77{
78 return _diffusivity[_qp] * _grad_phi[_j][_qp];
79}
80
81template <typename T>
82RealGradient
84{
85 auto sum = _ddiffusivity_dc[_qp] * _phi[_j][_qp] * _grad_v[_qp];
86 if (!_is_coupled)
87 sum += precomputeQpCJacobian();
88
89 return sum;
90}
91
92template <typename T>
93Real
95{
96 // get the coupled variable jvar is referring to
97 const auto cvar = this->mapJvarToCvar(jvar);
98
99 auto sum = (*_ddiffusivity_darg[cvar])[_qp] * _phi[_j][_qp] * _grad_v[_qp];
100 if (_v_var == jvar)
101 sum += precomputeQpCJacobian();
102
103 return sum * _grad_test[_i][_qp];
104}
105
106template class MatDiffusionBase<Real>;
std::conditional_t< is_ad, ADKernelGrad, KernelGrad > GenericKernelGrad
Moose::GenericType< RealVectorValue, is_ad > GenericRealVectorValue
Definition MooseTypes.h:702
Interface class ("Veneer") to provide generator methods for derivative material property names.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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 addCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
Interface class ("Veneer") for Kernel to provide a mapping from 'jvar' in computeQpOffDiagJacobian in...
This class template implements a diffusion kernel with a mobility that can vary spatially and can dep...
static InputParameters validParams()
virtual GenericRealVectorValue< is_ad > precomputeQpResidual() override
MatDiffusionBaseTempl(const InputParameters &parameters)
std::vector< const MaterialProperty< T > * > _ddiffusivity_darg
diffusion coefficient derivatives w.r.t. coupled variables
MatDiffusionBase(const InputParameters &parameters)
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
static InputParameters validParams()
virtual void initialSetup() override
virtual RealGradient precomputeQpCJacobian()
virtual RealGradient precomputeQpJacobian() override