https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PolycrystalMatDiffusionBase.h
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#pragma once
11
12#include "MatDiffusionBase.h"
13#include "RankThreeTensor.h"
14
15template <typename T>
17
18template <>
19struct GradientType<Real>
20{
21 typedef RealVectorValue type;
22};
23
29template <>
30struct GradientType<RealTensorValue>
31{
33};
34
35template <typename T>
37{
38public:
40
42
43protected:
44 virtual Real computeQpOffDiagJacobian(unsigned int jvar) override;
46 const unsigned int _op_num;
47
50 std::vector<const MaterialProperty<typename GradientType<T>::type> *> _dDdgradeta;
51
53 unsigned int _surface_op_var;
54
57};
58
59template <typename T>
62{
64 params.addCoupledVar(
65 "surface_op_var",
66 "Name of the order parameter for solid-pore surface. For use when diffusivity "
67 "depends on these OP gradients, leave this parameter un-set otherwise. ");
69 "grain_op_vars", "var_name_base", "op_num", "Array of grain order parameter variables");
70 params.addParam<bool>(
71 "add_grain_op_gradients",
72 true,
73 "Whether grain order parameter gradient contributions are added to Jacobian.");
74 return params;
75}
76
77template <typename T>
79 : MatDiffusionBase<T>(parameters),
80 _op_num(this->coupledComponents("grain_op_vars")),
81 _dDdgradc(this->template getMaterialPropertyDerivative<typename GradientType<T>::type>(
82 this->isParamValid("D_name") ? "D_name" : "diffusivity", "gradc")),
83 _dDdgradeta(_op_num),
84 _surface_op_var(this->isCoupled("surface_op_var") ? this->coupled("surface_op_var")
85 : libMesh::invalid_uint),
86 _add_grain_op_gradients(this->template getParam<bool>("add_grain_op_gradients"))
87{
89 for (unsigned int j = 0; j < _op_num; ++j)
90 _dDdgradeta[j] =
92 this->isParamValid("D_name") ? "D_name" : "diffusivity",
93 ("gradgr" + Moose::stringify(j)));
94}
95
96template <typename T>
97Real
99{
101 if (jvar == _surface_op_var)
102 sum += _dDdgradc[this->_qp] * this->_grad_phi[this->_j][this->_qp] * this->_grad_v[this->_qp] *
103 this->_grad_test[this->_i][this->_qp];
104
105 if (_add_grain_op_gradients)
106 {
107 for (unsigned int k = 0; k < _op_num; ++k)
108 if (jvar == this->coupled("grain_op_vars", k))
109 sum += (*_dDdgradeta[k])[this->_qp] * this->_grad_phi[this->_j][this->_qp] *
110 this->_grad_v[this->_qp] * this->_grad_test[this->_i][this->_qp];
111 }
112
113 return sum;
114}
const double T
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative(const std::string &base, const std::vector< VariableName > &c)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addCoupledVarWithAutoBuild(const std::string &name, const std::string &base_name, const std::string &num_name, const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
static InputParameters validParams()
const bool _add_grain_op_gradients
Variable to allow user to control whether grain OP gradient contributions are added to Jacobian.
std::vector< const MaterialProperty< typename GradientType< T >::type > * > _dDdgradeta
unsigned int _surface_op_var
For solid-pore systems, mame of the order parameter identifies the solid-pore surface.
const MaterialProperty< typename GradientType< T >::type > & _dDdgradc
diffusion coefficient derivatives w.r.t. variables that have explicit dependence on gradients
const unsigned int _op_num
Number of grain order parameters for cases where there is dependence on grain OP gradients.
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
PolycrystalMatDiffusionBase(const InputParameters &parameters)
std::string stringify(const T &t)
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...