www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CoupledSwitchingTimeDerivative Class Reference

This kernel adds a contribution \( \left( \frac{\partial F_a}{\partial \eta_{ai}} f_a + \frac{\partial F_b}{\partial \eta_{ai}} f_b + ... \right) \frac{\partial \eta_{ai}}{\partial t} \) where \( a,b,.. \) are the phases, \( h_a, h_b,.. \) are the switching functions, \( \eta_{ai} \) is the order parameter that is the nonlinear variable, \( t \) is time, and \( F_a, F_b,.. \) are functions for each phase. More...

#include <CoupledSwitchingTimeDerivative.h>

Inheritance diagram for CoupledSwitchingTimeDerivative:
[legend]

Public Member Functions

 CoupledSwitchingTimeDerivative (const InputParameters &parameters)
 
virtual void initialSetup ()
 

Protected Member Functions

virtual Real computeQpResidual ()
 
virtual Real computeQpJacobian ()
 
virtual Real computeQpOffDiagJacobian (unsigned int jvar)
 

Protected Attributes

const unsigned int _nvar
 Number of coupled variables. More...
 
const VariableName _v_name
 name of order parameter that derivatives are taken wrt (needed to retrieve the derivative material properties) More...
 
std::vector< MaterialPropertyName > _Fj_names
 Names of functions for each phase \( F_j \). More...
 
const unsigned int _num_j
 Number of phases. More...
 
std::vector< const MaterialProperty< Real > * > _prop_Fj
 Values of the functions for each phase \( F_j \). More...
 
std::vector< const MaterialProperty< Real > * > _prop_dFjdv
 Derivatives of the functions wrt the nonlinear variable for this kernel. More...
 
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_dFjdarg
 Derivatives of the functions (needed for off-diagonal Jacobians) More...
 
std::vector< MaterialPropertyName > _hj_names
 switching function names More...
 
std::vector< const MaterialProperty< Real > * > _prop_dhjdetai
 Derivatives of the switching functions wrt the order parameter for this kernel. More...
 
std::vector< const MaterialProperty< Real > * > _prop_d2hjdetai2
 Second derivatives of the switching functions wrt the order parameter for this kernel. More...
 
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_d2hjdetaidarg
 Second derivatives of the switching functions (needed for off-diagonal Jacobians) More...
 

Detailed Description

This kernel adds a contribution \( \left( \frac{\partial F_a}{\partial \eta_{ai}} f_a + \frac{\partial F_b}{\partial \eta_{ai}} f_b + ... \right) \frac{\partial \eta_{ai}}{\partial t} \) where \( a,b,.. \) are the phases, \( h_a, h_b,.. \) are the switching functions, \( \eta_{ai} \) is the order parameter that is the nonlinear variable, \( t \) is time, and \( F_a, F_b,.. \) are functions for each phase.

For the grand-potential model susceptibility equation, \( F_a \) etc. are the phase densities.

Definition at line 30 of file CoupledSwitchingTimeDerivative.h.

Constructor & Destructor Documentation

CoupledSwitchingTimeDerivative::CoupledSwitchingTimeDerivative ( const InputParameters &  parameters)

Definition at line 25 of file CoupledSwitchingTimeDerivative.C.

26  : DerivativeMaterialInterface<JvarMapKernelInterface<CoupledTimeDerivative>>(parameters),
27  _nvar(_coupled_moose_vars.size()), // number of coupled variables
28  _v_name(getVar("v", 0)->name()),
29  _Fj_names(getParam<std::vector<MaterialPropertyName>>("Fj_names")),
30  _num_j(_Fj_names.size()),
34  _hj_names(getParam<std::vector<MaterialPropertyName>>("hj_names")),
38 {
39  // check passed in parameter vectors
40  if (_num_j != _hj_names.size())
41  mooseError("Need to pass in as many hj_names as Fj_names in CoupledSwitchingTimeDerivative ",
42  name());
43 
44  // reserve space and set phase material properties
45  for (unsigned int n = 0; n < _num_j; ++n)
46  {
47  // get phase free energy and derivatives
48  _prop_Fj[n] = &getMaterialPropertyByName<Real>(_Fj_names[n]);
49  _prop_dFjdv[n] = &getMaterialPropertyDerivative<Real>(_Fj_names[n], _var.name());
50  _prop_dFjdarg[n].resize(_nvar);
51 
52  // get switching function and derivatives wrt eta_i, the nonlinear variable
53  _prop_dhjdetai[n] = &getMaterialPropertyDerivative<Real>(_hj_names[n], _v_name);
54  _prop_d2hjdetai2[n] = &getMaterialPropertyDerivative<Real>(_hj_names[n], _v_name, _v_name);
55  _prop_d2hjdetaidarg[n].resize(_nvar);
56 
57  for (unsigned int i = 0; i < _nvar; ++i)
58  {
59  MooseVariable * cvar = _coupled_moose_vars[i];
60  // Get derivatives of all Fj wrt all coupled variables
61  _prop_dFjdarg[n][i] = &getMaterialPropertyDerivative<Real>(_Fj_names[n], cvar->name());
62 
63  // Get second derivatives of all hj wrt eta_i and all coupled variables
64  _prop_d2hjdetaidarg[n][i] =
65  &getMaterialPropertyDerivative<Real>(_hj_names[n], _v_name, cvar->name());
66  }
67  }
68 }
std::vector< const MaterialProperty< Real > * > _prop_Fj
Values of the functions for each phase .
const unsigned int _nvar
Number of coupled variables.
std::vector< MaterialPropertyName > _Fj_names
Names of functions for each phase .
std::vector< const MaterialProperty< Real > * > _prop_dFjdv
Derivatives of the functions wrt the nonlinear variable for this kernel.
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_d2hjdetaidarg
Second derivatives of the switching functions (needed for off-diagonal Jacobians) ...
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_dFjdarg
Derivatives of the functions (needed for off-diagonal Jacobians)
std::vector< MaterialPropertyName > _hj_names
switching function names
const VariableName _v_name
name of order parameter that derivatives are taken wrt (needed to retrieve the derivative material pr...
std::vector< const MaterialProperty< Real > * > _prop_dhjdetai
Derivatives of the switching functions wrt the order parameter for this kernel.
std::vector< const MaterialProperty< Real > * > _prop_d2hjdetai2
Second derivatives of the switching functions wrt the order parameter for this kernel.
const unsigned int _num_j
Number of phases.

Member Function Documentation

Real CoupledSwitchingTimeDerivative::computeQpJacobian ( )
protectedvirtual

Definition at line 91 of file CoupledSwitchingTimeDerivative.C.

92 {
93  Real sum = 0.0;
94  for (unsigned int n = 0; n < _num_j; ++n)
95  sum += (*_prop_dhjdetai[n])[_qp] * (*_prop_dFjdv[n])[_qp];
96 
97  return CoupledTimeDerivative::computeQpResidual() * sum * _phi[_j][_qp];
98 }
std::vector< const MaterialProperty< Real > * > _prop_dFjdv
Derivatives of the functions wrt the nonlinear variable for this kernel.
std::vector< const MaterialProperty< Real > * > _prop_dhjdetai
Derivatives of the switching functions wrt the order parameter for this kernel.
const unsigned int _num_j
Number of phases.
Real CoupledSwitchingTimeDerivative::computeQpOffDiagJacobian ( unsigned int  jvar)
protectedvirtual

Definition at line 101 of file CoupledSwitchingTimeDerivative.C.

102 {
103  // get the coupled variable jvar is referring to
104  const unsigned int cvar = mapJvarToCvar(jvar);
105 
106  if (jvar == _v_var)
107  {
108  Real sum = 0.0;
109 
110  for (unsigned int n = 0; n < _num_j; ++n)
111  sum +=
112  ((*_prop_d2hjdetai2[n])[_qp] * _v_dot[_qp] + (*_prop_dhjdetai[n])[_qp] * _dv_dot[_qp]) *
113  (*_prop_Fj[n])[_qp];
114 
115  return _phi[_j][_qp] * sum * _test[_i][_qp];
116  }
117 
118  Real sum = 0.0;
119  for (unsigned int n = 0; n < _num_j; ++n)
120  sum += (*_prop_d2hjdetaidarg[n][cvar])[_qp] * (*_prop_Fj[n])[_qp] +
121  (*_prop_dhjdetai[n])[_qp] * (*_prop_dFjdarg[n][cvar])[_qp];
122 
123  return CoupledTimeDerivative::computeQpResidual() * sum * _phi[_j][_qp];
124 }
std::vector< const MaterialProperty< Real > * > _prop_Fj
Values of the functions for each phase .
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_d2hjdetaidarg
Second derivatives of the switching functions (needed for off-diagonal Jacobians) ...
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_dFjdarg
Derivatives of the functions (needed for off-diagonal Jacobians)
std::vector< const MaterialProperty< Real > * > _prop_dhjdetai
Derivatives of the switching functions wrt the order parameter for this kernel.
std::vector< const MaterialProperty< Real > * > _prop_d2hjdetai2
Second derivatives of the switching functions wrt the order parameter for this kernel.
const unsigned int _num_j
Number of phases.
Real CoupledSwitchingTimeDerivative::computeQpResidual ( )
protectedvirtual

Definition at line 81 of file CoupledSwitchingTimeDerivative.C.

82 {
83  Real sum = 0.0;
84  for (unsigned int n = 0; n < _num_j; ++n)
85  sum += (*_prop_dhjdetai[n])[_qp] * (*_prop_Fj[n])[_qp];
86 
87  return CoupledTimeDerivative::computeQpResidual() * sum;
88 }
std::vector< const MaterialProperty< Real > * > _prop_Fj
Values of the functions for each phase .
std::vector< const MaterialProperty< Real > * > _prop_dhjdetai
Derivatives of the switching functions wrt the order parameter for this kernel.
const unsigned int _num_j
Number of phases.
void CoupledSwitchingTimeDerivative::initialSetup ( )
virtual

Definition at line 71 of file CoupledSwitchingTimeDerivative.C.

72 {
73  for (unsigned int n = 0; n < _num_j; ++n)
74  {
75  validateNonlinearCoupling<Real>(_Fj_names[n]);
76  validateNonlinearCoupling<Real>(_hj_names[n]);
77  }
78 }
std::vector< MaterialPropertyName > _Fj_names
Names of functions for each phase .
std::vector< MaterialPropertyName > _hj_names
switching function names
const unsigned int _num_j
Number of phases.

Member Data Documentation

std::vector<MaterialPropertyName> CoupledSwitchingTimeDerivative::_Fj_names
protected

Names of functions for each phase \( F_j \).

Definition at line 50 of file CoupledSwitchingTimeDerivative.h.

Referenced by CoupledSwitchingTimeDerivative(), and initialSetup().

std::vector<MaterialPropertyName> CoupledSwitchingTimeDerivative::_hj_names
protected

switching function names

Definition at line 65 of file CoupledSwitchingTimeDerivative.h.

Referenced by CoupledSwitchingTimeDerivative(), and initialSetup().

const unsigned int CoupledSwitchingTimeDerivative::_num_j
protected
const unsigned int CoupledSwitchingTimeDerivative::_nvar
protected

Number of coupled variables.

Definition at line 43 of file CoupledSwitchingTimeDerivative.h.

Referenced by CoupledSwitchingTimeDerivative().

std::vector<const MaterialProperty<Real> *> CoupledSwitchingTimeDerivative::_prop_d2hjdetai2
protected

Second derivatives of the switching functions wrt the order parameter for this kernel.

Definition at line 71 of file CoupledSwitchingTimeDerivative.h.

Referenced by computeQpOffDiagJacobian(), and CoupledSwitchingTimeDerivative().

std::vector<std::vector<const MaterialProperty<Real> *> > CoupledSwitchingTimeDerivative::_prop_d2hjdetaidarg
protected

Second derivatives of the switching functions (needed for off-diagonal Jacobians)

Definition at line 74 of file CoupledSwitchingTimeDerivative.h.

Referenced by computeQpOffDiagJacobian(), and CoupledSwitchingTimeDerivative().

std::vector<std::vector<const MaterialProperty<Real> *> > CoupledSwitchingTimeDerivative::_prop_dFjdarg
protected

Derivatives of the functions (needed for off-diagonal Jacobians)

Definition at line 62 of file CoupledSwitchingTimeDerivative.h.

Referenced by computeQpOffDiagJacobian(), and CoupledSwitchingTimeDerivative().

std::vector<const MaterialProperty<Real> *> CoupledSwitchingTimeDerivative::_prop_dFjdv
protected

Derivatives of the functions wrt the nonlinear variable for this kernel.

Definition at line 59 of file CoupledSwitchingTimeDerivative.h.

Referenced by computeQpJacobian(), and CoupledSwitchingTimeDerivative().

std::vector<const MaterialProperty<Real> *> CoupledSwitchingTimeDerivative::_prop_dhjdetai
protected

Derivatives of the switching functions wrt the order parameter for this kernel.

Definition at line 68 of file CoupledSwitchingTimeDerivative.h.

Referenced by computeQpJacobian(), computeQpOffDiagJacobian(), computeQpResidual(), and CoupledSwitchingTimeDerivative().

std::vector<const MaterialProperty<Real> *> CoupledSwitchingTimeDerivative::_prop_Fj
protected

Values of the functions for each phase \( F_j \).

Definition at line 56 of file CoupledSwitchingTimeDerivative.h.

Referenced by computeQpOffDiagJacobian(), computeQpResidual(), and CoupledSwitchingTimeDerivative().

const VariableName CoupledSwitchingTimeDerivative::_v_name
protected

name of order parameter that derivatives are taken wrt (needed to retrieve the derivative material properties)

Definition at line 47 of file CoupledSwitchingTimeDerivative.h.

Referenced by CoupledSwitchingTimeDerivative().


The documentation for this class was generated from the following files: