https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SplitCHWResBase.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 "Kernel.h"
13#include "JvarMapInterface.h"
15
22template <typename T>
23class SplitCHWResBase : public DerivativeMaterialInterface<JvarMapKernelInterface<Kernel>>
24{
25public:
27
28 SplitCHWResBase(const InputParameters & parameters);
29
30protected:
31 virtual Real computeQpResidual();
32 virtual Real computeQpJacobian();
33 virtual Real computeQpWJacobian();
34 virtual Real computeQpOffDiagJacobian(unsigned int jvar);
35
36 const MaterialPropertyName _mob_name;
38
40 const bool _is_coupled;
41
43 unsigned int _w_var;
44
47
49 std::vector<const MaterialProperty<T> *> _dmobdarg;
50};
51
52template <typename T>
55 _mob_name(getParam<MaterialPropertyName>("mob_name")),
56 _mob(getMaterialProperty<T>("mob_name")),
57 _is_coupled(isCoupled("w")),
58 _w_var(_is_coupled ? coupled("w") : _var.number()),
59 _grad_w(_is_coupled ? coupledGradient("w") : _grad_u),
60 _dmobdarg(_n_args)
61{
62 // Iterate over all coupled variables
63 for (unsigned int i = 0; i < _n_args; ++i)
64 _dmobdarg[i] = &getMaterialPropertyDerivative<T>(_mob_name, i);
65}
66
67template <typename T>
68Real
70{
71 return _mob[_qp] * _grad_w[_qp] * _grad_test[_i][_qp];
72}
73
74template <typename T>
75Real
77{
78 return (_is_coupled && _w_var != _var.number()) ? 0.0 : computeQpWJacobian();
79}
80
81template <typename T>
82Real
84{
85 return _mob[_qp] * _grad_phi[_j][_qp] * _grad_test[_i][_qp];
86}
87
88template <typename T>
89Real
91{
92 // c Off-Diagonal Jacobian
93 if (_w_var == jvar)
94 return computeQpWJacobian();
95
96 // get the coupled variable jvar is referring to
97 const unsigned int cvar = mapJvarToCvar(jvar);
98
99 return (*_dmobdarg[cvar])[_qp] * _phi[_j][_qp] * _grad_w[_qp] * _grad_test[_i][_qp];
100}
101
102template <typename T>
105{
107 params.addClassDescription(
108 "Split formulation Cahn-Hilliard Kernel for the chemical potential variable");
109 params.addParam<MaterialPropertyName>("mob_name", "mobtemp", "The mobility used with the kernel");
110 params.addCoupledVar("coupled_variables", "Vector of variable arguments of the mobility");
111 params.addCoupledVar(
112 "w", "Coupled chemical potential (if not specified kernel variable will be used)");
113 return params;
114}
const double T
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)
static InputParameters validParams()
SplitCHWresBase implements the residual for the chemical potential in the split form of the Cahn-Hill...
static InputParameters validParams()
virtual Real computeQpResidual()
virtual Real computeQpWJacobian()
const MaterialProperty< T > & _mob
unsigned int _w_var
int label for the chemical potential
virtual Real computeQpJacobian()
const VariableGradient & _grad_w
Variable value for the chemical potential.
SplitCHWResBase(const InputParameters &parameters)
const bool _is_coupled
is the kernel used in a coupled form?
const MaterialPropertyName _mob_name
std::vector< const MaterialProperty< T > * > _dmobdarg
derivatives of the mobility
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
VariableGradientTempl< false > VariableGradient