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

DerivativeMaterial child class to evaluate a parsed function for the free energy and automatically provide all derivatives. More...

#include <DerivativeMultiPhaseBase.h>

Inheritance diagram for DerivativeMultiPhaseBase:
[legend]

Public Member Functions

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

Protected Member Functions

virtual Real computeF ()
 

Protected Attributes

std::vector< int > _eta_index
 If the variable a non-conserved OP this array holds the index into the etas parameter vector for a given arg index, otherwise it holds -1. More...
 
std::vector< VariableValue * > _etas
 Phase parameter (0=A-phase, 1=B-phase) More...
 
unsigned int _num_etas
 name of the order parameter variable More...
 
std::vector< VariableName > _eta_names
 
std::vector< unsigned int > _eta_vars
 
std::vector< MaterialPropertyName > _fi_names
 phase derivative material names More...
 
unsigned int _num_fi
 
std::vector< const MaterialProperty< Real > * > _prop_Fi
 Function value of the i phase. More...
 
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_dFi
 Derivatives of Fi w.r.t. arg[i]. More...
 
std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > _prop_d2Fi
 Second derivatives of Fi. More...
 
std::vector< std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > > _prop_d3Fi
 Third derivatives of Fi. More...
 
std::vector< MaterialPropertyName > _hi_names
 phase switching function names More...
 
unsigned int _num_hi
 
std::vector< const MaterialProperty< Real > * > _hi
 Switching functions. More...
 
MaterialPropertyName _g_name
 Barrier function name. More...
 
const MaterialProperty< Real > & _g
 Barrier function \( g(\eta_0, \eta_1, \dots, \eta_{n-1}) \). More...
 
std::vector< const MaterialProperty< Real > * > _dg
 Barrier function derivatives. More...
 
std::vector< std::vector< const MaterialProperty< Real > * > > _d2g
 
std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > _d3g
 
Real _W
 Phase transformation energy barrier. More...
 

Detailed Description

DerivativeMaterial child class to evaluate a parsed function for the free energy and automatically provide all derivatives.

This requires the autodiff patch (https://github.com/libMesh/libmesh/pull/238) to Function Parser in libmesh.

Definition at line 27 of file DerivativeMultiPhaseBase.h.

Constructor & Destructor Documentation

◆ DerivativeMultiPhaseBase()

DerivativeMultiPhaseBase::DerivativeMultiPhaseBase ( const InputParameters &  parameters)

Definition at line 39 of file DerivativeMultiPhaseBase.C.

40  : DerivativeFunctionMaterialBase(parameters),
41  _eta_index(_nargs, -1),
42  _num_etas(coupledComponents("etas")),
45  _fi_names(getParam<std::vector<MaterialPropertyName>>("fi_names")),
46  _num_fi(_fi_names.size()),
51  _hi_names(getParam<std::vector<MaterialPropertyName>>("hi_names")),
52  _num_hi(_hi_names.size()),
53  _hi(_num_hi),
54  _g(getMaterialProperty<Real>("g")),
55  _dg(_num_etas),
56  _d2g(_num_etas),
57  _d3g(_num_etas),
58  _W(getParam<Real>("W"))
59 {
60  // check passed in parameter vectors
61  if (_num_fi != _num_hi)
62  mooseError("Need to pass in as many hi_names as fi_names in DerivativeMultiPhaseBase ", name());
63 
64  // get order parameter names and libmesh variable names, set barrier function derivatives
65  for (unsigned int i = 0; i < _num_etas; ++i)
66  {
67  _eta_names[i] = getVar("etas", i)->name();
68  _eta_vars[i] = coupled("etas", i);
69 
70  // for each coupled variable we need to know if it was coupled through "etas"
71  // and - if so - which coupled component of "etas" it comes from
72  _eta_index[argIndex(_eta_vars[i])] = i;
73 
74  // barrier function derivatives
75  _dg[i] = &getMaterialPropertyDerivative<Real>("g", _eta_names[i]);
76  _d2g[i].resize(_num_etas);
77  if (_third_derivatives)
78  _d3g[i].resize(_num_etas);
79 
80  for (unsigned int j = 0; j < _num_etas; ++j)
81  {
82  _d2g[i][j] = &getMaterialPropertyDerivative<Real>("g", _eta_names[i], _eta_names[j]);
83 
84  if (_third_derivatives)
85  {
86  _d3g[i][j].resize(_num_etas);
87  for (unsigned int k = 0; k < _num_etas; ++k)
88  _d3g[i][j][k] = &getMaterialPropertyDerivative<Real>(
89  "g", _eta_names[i], _eta_names[j], _eta_names[k]);
90  }
91  }
92  }
93 
94  // reserve space and set phase material properties
95  for (unsigned int n = 0; n < _num_fi; ++n)
96  {
97  // get phase free energy
98  _prop_Fi[n] = &getMaterialPropertyByName<Real>(_fi_names[n]);
99  _prop_dFi[n].resize(_nargs);
100  _prop_d2Fi[n].resize(_nargs);
101  _prop_d3Fi[n].resize(_nargs);
102 
103  // get switching function
104  _hi[n] = &getMaterialPropertyByName<Real>(_hi_names[n]);
105 
106  for (unsigned int i = 0; i < _nargs; ++i)
107  {
108  _prop_dFi[n][i] = &getMaterialPropertyDerivative<Real>(_fi_names[n], _arg_names[i]);
109  _prop_d2Fi[n][i].resize(_nargs);
110 
111  if (_third_derivatives)
112  _prop_d3Fi[n][i].resize(_nargs);
113 
114  for (unsigned int j = 0; j < _nargs; ++j)
115  {
116  _prop_d2Fi[n][i][j] =
117  &getMaterialPropertyDerivative<Real>(_fi_names[n], _arg_names[i], _arg_names[j]);
118 
119  if (_third_derivatives)
120  {
121  _prop_d3Fi[n][i][j].resize(_nargs);
122 
123  for (unsigned int k = 0; k < _nargs; ++k)
124  _prop_d3Fi[n][i][j][k] = &getMaterialPropertyDerivative<Real>(
125  _fi_names[n], _arg_names[i], _arg_names[j], _arg_names[k]);
126  }
127  }
128  }
129  }
130 }
std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > _prop_d2Fi
Second derivatives of Fi.
std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > _d3g
std::vector< const MaterialProperty< Real > * > _dg
Barrier function derivatives.
const MaterialProperty< Real > & _g
Barrier function .
std::vector< MaterialPropertyName > _hi_names
phase switching function names
unsigned int _num_etas
name of the order parameter variable
std::vector< std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > > _prop_d3Fi
Third derivatives of Fi.
Real _W
Phase transformation energy barrier.
std::vector< MaterialPropertyName > _fi_names
phase derivative material names
std::vector< const MaterialProperty< Real > * > _hi
Switching functions.
const std::string name
Definition: Setup.h:22
std::vector< VariableName > _eta_names
std::vector< std::vector< const MaterialProperty< Real > * > > _d2g
std::vector< int > _eta_index
If the variable a non-conserved OP this array holds the index into the etas parameter vector for a gi...
std::vector< const MaterialProperty< Real > * > _prop_Fi
Function value of the i phase.
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_dFi
Derivatives of Fi w.r.t. arg[i].
std::vector< unsigned int > _eta_vars

Member Function Documentation

◆ computeF()

Real DerivativeMultiPhaseBase::computeF ( )
protectedvirtual

Definition at line 140 of file DerivativeMultiPhaseBase.C.

141 {
142  Real F = 0.0;
143  for (unsigned n = 0; n < _num_fi; ++n)
144  F += (*_hi[n])[_qp] * (*_prop_Fi[n])[_qp];
145  return F + _W * _g[_qp];
146 }
const MaterialProperty< Real > & _g
Barrier function .
Real _W
Phase transformation energy barrier.
std::vector< const MaterialProperty< Real > * > _hi
Switching functions.
std::vector< const MaterialProperty< Real > * > _prop_Fi
Function value of the i phase.

◆ initialSetup()

void DerivativeMultiPhaseBase::initialSetup ( )
virtual

Definition at line 133 of file DerivativeMultiPhaseBase.C.

134 {
135  for (unsigned int n = 0; n < _num_fi; ++n)
136  validateCoupling<Real>(_fi_names[n]);
137 }
std::vector< MaterialPropertyName > _fi_names
phase derivative material names

Member Data Documentation

◆ _d2g

std::vector<std::vector<const MaterialProperty<Real> *> > DerivativeMultiPhaseBase::_d2g
protected

◆ _d3g

std::vector<std::vector<std::vector<const MaterialProperty<Real> *> > > DerivativeMultiPhaseBase::_d3g
protected

◆ _dg

std::vector<const MaterialProperty<Real> *> DerivativeMultiPhaseBase::_dg
protected

Barrier function derivatives.

Definition at line 81 of file DerivativeMultiPhaseBase.h.

Referenced by DerivativeMultiPhaseMaterial::computeDF(), and DerivativeMultiPhaseBase().

◆ _eta_index

std::vector<int> DerivativeMultiPhaseBase::_eta_index
protected

If the variable a non-conserved OP this array holds the index into the etas parameter vector for a given arg index, otherwise it holds -1.

Definition at line 41 of file DerivativeMultiPhaseBase.h.

Referenced by DerivativeMultiPhaseMaterial::computeD2F(), DerivativeMultiPhaseMaterial::computeD3F(), DerivativeMultiPhaseMaterial::computeDF(), and DerivativeMultiPhaseBase().

◆ _eta_names

std::vector<VariableName> DerivativeMultiPhaseBase::_eta_names
protected

◆ _eta_vars

std::vector<unsigned int> DerivativeMultiPhaseBase::_eta_vars
protected

Definition at line 49 of file DerivativeMultiPhaseBase.h.

Referenced by DerivativeMultiPhaseBase().

◆ _etas

std::vector<VariableValue *> DerivativeMultiPhaseBase::_etas
protected

Phase parameter (0=A-phase, 1=B-phase)

Definition at line 44 of file DerivativeMultiPhaseBase.h.

◆ _fi_names

std::vector<MaterialPropertyName> DerivativeMultiPhaseBase::_fi_names
protected

phase derivative material names

Definition at line 52 of file DerivativeMultiPhaseBase.h.

Referenced by DerivativeMultiPhaseBase(), and initialSetup().

◆ _g

const MaterialProperty<Real>& DerivativeMultiPhaseBase::_g
protected

Barrier function \( g(\eta_0, \eta_1, \dots, \eta_{n-1}) \).

Definition at line 78 of file DerivativeMultiPhaseBase.h.

Referenced by computeF().

◆ _g_name

MaterialPropertyName DerivativeMultiPhaseBase::_g_name
protected

Barrier function name.

Definition at line 75 of file DerivativeMultiPhaseBase.h.

◆ _hi

std::vector<const MaterialProperty<Real> *> DerivativeMultiPhaseBase::_hi
protected

◆ _hi_names

std::vector<MaterialPropertyName> DerivativeMultiPhaseBase::_hi_names
protected

phase switching function names

Definition at line 68 of file DerivativeMultiPhaseBase.h.

Referenced by DerivativeMultiPhaseBase(), and DerivativeMultiPhaseMaterial::DerivativeMultiPhaseMaterial().

◆ _num_etas

unsigned int DerivativeMultiPhaseBase::_num_etas
protected

name of the order parameter variable

Definition at line 47 of file DerivativeMultiPhaseBase.h.

Referenced by DerivativeMultiPhaseBase(), and DerivativeMultiPhaseMaterial::DerivativeMultiPhaseMaterial().

◆ _num_fi

unsigned int DerivativeMultiPhaseBase::_num_fi
protected

◆ _num_hi

unsigned int DerivativeMultiPhaseBase::_num_hi
protected

◆ _prop_d2Fi

std::vector<std::vector<std::vector<const MaterialProperty<Real> *> > > DerivativeMultiPhaseBase::_prop_d2Fi
protected

◆ _prop_d3Fi

std::vector<std::vector<std::vector<std::vector<const MaterialProperty<Real> *> > > > DerivativeMultiPhaseBase::_prop_d3Fi
protected

Third derivatives of Fi.

Definition at line 65 of file DerivativeMultiPhaseBase.h.

Referenced by DerivativeMultiPhaseMaterial::computeD3F(), and DerivativeMultiPhaseBase().

◆ _prop_dFi

std::vector<std::vector<const MaterialProperty<Real> *> > DerivativeMultiPhaseBase::_prop_dFi
protected

◆ _prop_Fi

std::vector<const MaterialProperty<Real> *> DerivativeMultiPhaseBase::_prop_Fi
protected

◆ _W

Real DerivativeMultiPhaseBase::_W
protected

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