https://mooseframework.inl.gov
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 
15 template <typename T>
16 struct GradientType;
17 
18 template <>
20 {
22 };
23 
29 template <>
31 {
33 };
34 
35 template <typename T>
37 {
38 public:
40 
42 
43 protected:
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 
59 template <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 
77 template <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")
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] =
91  &this->template getMaterialPropertyDerivative<typename GradientType<T>::type>(
92  this->isParamValid("D_name") ? "D_name" : "diffusivity",
93  ("gradgr" + Moose::stringify(j)));
94 }
95 
96 template <typename T>
97 Real
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 unsigned int invalid_uint
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
unsigned int _surface_op_var
For solid-pore systems, mame of the order parameter identifies the solid-pore surface.
const InputParameters & parameters() const
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative(const std::string &base, const std::vector< VariableName > &c)
TensorValue< Real > RealTensorValue
const MaterialProperty< typename GradientType< T >::type > & _dDdgradc
diffusion coefficient derivatives w.r.t. variables that have explicit dependence on gradients ...
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
std::string stringify(const T &t)
static InputParameters validParams()
void addCoupledVar(const std::string &name, const std::string &doc_string)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addCoupledVarWithAutoBuild(const std::string &name, const std::string &base_name, const std::string &num_name, const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
bool isParamValid(const std::string &name) const
PolycrystalMatDiffusionBase(const InputParameters &parameters)
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
const unsigned int _op_num
Number of grain order parameters for cases where there is dependence on grain OP gradients.
static const std::string k
Definition: NS.h:130