https://mooseframework.inl.gov
Loading...
Searching...
No Matches
KKSMultiACBulkC.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 "KKSMultiACBulkC.h"
11
13
16{
18 params.addClassDescription("Multi-phase KKS model kernel (part 2 of 2) for the Bulk Allen-Cahn. "
19 "This includes all terms dependent on chemical potential.");
21 "cj_names", "Array of phase concentrations cj. Place in same order as Fj_names!");
22 return params;
23}
24
26 : KKSMultiACBulkBase(parameters),
27 // Can use any dFj/dcj since they are equal so pick first cj in the list
28 _c1_name(coupledName("cj_names", 0)),
29 _cjs(coupledValues("cj_names")),
30 _cjs_var(coupledIndices("cj_names")),
31 _prop_dF1dc1(getMaterialPropertyDerivative<Real>(_Fj_names[0],
32 _c1_name)), // Use first Fj in list for dFj/dcj
33 _prop_d2F1dc12(getMaterialPropertyDerivative<Real>(_Fj_names[0], _c1_name, _c1_name)),
34 _prop_d2F1dc1darg(_n_args)
35{
36 if (_num_j != coupledComponents("cj_names"))
37 paramError("cj_names", "Need to pass in as many cj_names as Fj_names");
38
39 // get second partial derivatives wrt c1 and other coupled variable
40 for (unsigned int i = 0; i < _n_args; ++i)
41 _prop_d2F1dc1darg[i] = &getMaterialPropertyDerivative<Real>(_Fj_names[0], _c1_name, i);
42}
43
44Real
46{
47 Real sum = 0.0;
48
49 switch (type)
50 {
51 case Residual:
52 for (unsigned int n = 0; n < _num_j; ++n)
53 sum += (*_prop_dhjdetai[n])[_qp] * (*_cjs[n])[_qp];
54
55 return -_prop_dF1dc1[_qp] * sum;
56
57 case Jacobian:
58 // For when this kernel is used in the Lagrange multiplier equation
59 // In that case the Lagrange multiplier is the nonlinear variable
60 if (_etai_var != _var.number())
61 return 0.0;
62
63 // For when eta_i is the nonlinear variable
64 for (unsigned int n = 0; n < _num_j; ++n)
65 sum += (*_prop_d2hjdetai2[n])[_qp] * (*_cjs[n])[_qp];
66
67 return -_phi[_j][_qp] * _prop_dF1dc1[_qp] * sum;
68 }
69
70 mooseError("Invalid type passed in");
71}
72
73Real
75{
76 // first get dependence of mobility _L on other variables using parent class
77 // member function
79
80 Real sum = 0.0;
81 // Then add dependence of KKSACBulkC on other variables
82 // Treat cj variables specially, as they appear in the residual
83 if (jvar == _cjs_var[0])
84 {
85 for (unsigned int n = 0; n < _num_j; ++n)
86 sum += (*_prop_dhjdetai[n])[_qp] * (*_cjs[n])[_qp];
87
88 res -= _L[_qp] * (sum * _prop_d2F1dc12[_qp] + _prop_dF1dc1[_qp] * (*_prop_dhjdetai[0])[_qp]) *
89 _phi[_j][_qp] * _test[_i][_qp];
90 return res;
91 }
92
93 for (unsigned int i = 1; i < _num_j; ++i)
94 {
95 if (jvar == _cjs_var[i])
96 {
97 res -=
98 _L[_qp] * _prop_dF1dc1[_qp] * (*_prop_dhjdetai[i])[_qp] * _phi[_j][_qp] * _test[_i][_qp];
99 return res;
100 }
101 }
102
103 // for all other vars get the coupled variable jvar is referring to
104 const unsigned int cvar = mapJvarToCvar(jvar);
105
106 for (unsigned int n = 0; n < _num_j; ++n)
107 sum += _prop_dF1dc1[_qp] * (*_prop_d2hjdetaidarg[n][cvar])[_qp] * (*_cjs[n])[_qp] +
108 (*_prop_d2F1dc1darg[cvar])[_qp] * (*_prop_dhjdetai[n])[_qp] * (*_cjs[n])[_qp];
109
110 res -= _L[_qp] * sum * _phi[_j][_qp] * _test[_i][_qp];
111
112 return res;
113}
registerMooseObject("PhaseFieldApp", KKSMultiACBulkC)
void mooseError(Args &&... args)
const MaterialProperty< Real > & _L
Mobility.
Definition ACBulk.h:46
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition ACBulk.h:110
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
ACBulk child class that sets up necessary variables and materials for calculation of residual contrib...
std::vector< MaterialPropertyName > _Fj_names
Names of free energy functions for each phase .
unsigned int _etai_var
index of order parameter that derivatives are taken wrt
std::vector< const MaterialProperty< Real > * > _prop_dhjdetai
Derivatives of the switching functions wrt the order parameter for this kernel.
static InputParameters validParams()
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_d2hjdetaidarg
Second derivatives of the switching functions (needed for off-diagonal Jacobians)
std::vector< const MaterialProperty< Real > * > _prop_d2hjdetai2
Second derivatives of the switching functions wrt the order parameter for this kernel.
KKSACBulkBase child class for the phase concentration term in the the Allen-Cahn bulk residual.
virtual Real computeDFDOP(PFFunctionType type)
const MaterialProperty< Real > & _prop_dF1dc1
Derivative of the free energy function .
const std::vector< unsigned int > _cjs_var
MaterialPropertyName _c1_name
Names of phase concentration variables.
std::vector< const MaterialProperty< Real > * > _prop_d2F1dc1darg
Mixed partial derivatives of the free energy function wrt c1 and any other coupled variables .
KKSMultiACBulkC(const InputParameters &parameters)
const std::vector< const VariableValue * > _cjs
const MaterialProperty< Real > & _prop_d2F1dc12
Second derivative of the free energy function .
static InputParameters validParams()
virtual Real computeQpOffDiagJacobian(unsigned int jvar)