www.mooseframework.org
KKSMultiACBulkBase.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "KKSMultiACBulkBase.h"
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = ACBulk<Real>::validParams();
17  params.addClassDescription("Multi-order parameter KKS model kernel for the Bulk Allen-Cahn. This "
18  "operates on one of the order parameters 'eta_i' as the non-linear "
19  "variable");
20  params.addRequiredParam<std::vector<MaterialPropertyName>>(
21  "Fj_names", "List of free energies for each phase. Place in same order as hj_names!");
22  params.addRequiredParam<std::vector<MaterialPropertyName>>(
23  "hj_names", "Switching Function Materials that provide h. Place in same order as Fj_names!");
24  params.addRequiredCoupledVar("eta_i",
25  "Order parameter that derivatives are taken with respect to");
26  return params;
27 }
28 
29 KKSMultiACBulkBase::KKSMultiACBulkBase(const InputParameters & parameters)
30  : ACBulk<Real>(parameters),
31  _nvar(_coupled_moose_vars.size()), // number of coupled variables
32  _etai_name(getVar("eta_i", 0)->name()),
33  _etai_var(coupled("eta_i", 0)),
34  _Fj_names(getParam<std::vector<MaterialPropertyName>>("Fj_names")),
35  _num_j(_Fj_names.size()),
36  _prop_Fj(_num_j),
37  _prop_dFjdarg(_num_j),
38  _hj_names(getParam<std::vector<MaterialPropertyName>>("hj_names")),
39  _prop_hj(_num_j),
40  _prop_dhjdetai(_num_j),
41  _prop_d2hjdetai2(_num_j),
42  _prop_d2hjdetaidarg(_num_j)
43 {
44  // check passed in parameter vectors
45  if (_num_j != _hj_names.size())
46  paramError("hj_names", "Need to pass in as many hj_names as Fj_names");
47 
48  // reserve space and set phase material properties
49  for (unsigned int n = 0; n < _num_j; ++n)
50  {
51  // get phase free energy
52  _prop_Fj[n] = &getMaterialPropertyByName<Real>(_Fj_names[n]);
53  _prop_dFjdarg[n].resize(_nvar);
54 
55  // get switching function and derivatives wrt eta_i, the nonlinear variable
56  _prop_hj[n] = &getMaterialPropertyByName<Real>(_hj_names[n]);
57  _prop_dhjdetai[n] = &getMaterialPropertyDerivative<Real>(_hj_names[n], _etai_name);
58  _prop_d2hjdetai2[n] =
59  &getMaterialPropertyDerivative<Real>(_hj_names[n], _etai_name, _etai_name);
60  _prop_d2hjdetaidarg[n].resize(_nvar);
61 
62  for (unsigned int i = 0; i < _nvar; ++i)
63  {
64  MooseVariableFEBase * cvar = _coupled_moose_vars[i];
65  // Get derivatives of all Fj wrt all coupled variables
66  _prop_dFjdarg[n][i] = &getMaterialPropertyDerivative<Real>(_Fj_names[n], cvar->name());
67 
68  // Get second derivatives of all hj wrt eta_i and all coupled variables
69  _prop_d2hjdetaidarg[n][i] =
70  &getMaterialPropertyDerivative<Real>(_hj_names[n], _etai_name, cvar->name());
71  }
72  }
73 }
74 
75 void
77 {
79 
80  for (unsigned int n = 0; n < _num_j; ++n)
81  {
82  validateNonlinearCoupling<Real>(_Fj_names[n]);
83  validateNonlinearCoupling<Real>(_hj_names[n]);
84  }
85 }
KKSMultiACBulkBase.h
KKSMultiACBulkBase::initialSetup
virtual void initialSetup()
Definition: KKSMultiACBulkBase.C:76
KKSMultiACBulkBase::_prop_dFjdarg
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_dFjdarg
Derivatives of the free energy functions (needed for off-diagonal Jacobians)
Definition: KKSMultiACBulkBase.h:52
ACBulk
This is the Allen-Cahn equation base class that implements the bulk or local energy term of the equat...
Definition: ACBulk.h:24
KKSMultiACBulkBase::KKSMultiACBulkBase
KKSMultiACBulkBase(const InputParameters &parameters)
Definition: KKSMultiACBulkBase.C:29
KKSMultiACBulkBase::_num_j
unsigned int _num_j
Definition: KKSMultiACBulkBase.h:46
KKSMultiACBulkBase::_prop_Fj
std::vector< const MaterialProperty< Real > * > _prop_Fj
Values of the free energy functions for each phase .
Definition: KKSMultiACBulkBase.h:49
KKSMultiACBulkBase::_prop_hj
std::vector< const MaterialProperty< Real > * > _prop_hj
Values of the switching functions for each phase .
Definition: KKSMultiACBulkBase.h:58
KKSMultiACBulkBase::_Fj_names
std::vector< MaterialPropertyName > _Fj_names
Names of free energy functions for each phase .
Definition: KKSMultiACBulkBase.h:45
KKSMultiACBulkBase::_prop_d2hjdetaidarg
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_d2hjdetaidarg
Second derivatives of the switching functions (needed for off-diagonal Jacobians)
Definition: KKSMultiACBulkBase.h:67
KKSMultiACBulkBase::_hj_names
std::vector< MaterialPropertyName > _hj_names
switching function names
Definition: KKSMultiACBulkBase.h:55
validParams< KKSMultiACBulkBase >
InputParameters validParams< KKSMultiACBulkBase >()
Definition: KKSMultiACBulkBase.C:14
name
const std::string name
Definition: Setup.h:21
ACBulk::initialSetup
virtual void initialSetup()
Definition: ACBulk.h:85
KKSMultiACBulkBase::_etai_name
VariableName _etai_name
name of order parameter that derivatives are taken wrt (needed to retrieve the derivative material pr...
Definition: KKSMultiACBulkBase.h:39
ACBulk::validParams
static InputParameters validParams()
Definition: ACBulk.h:74
KKSMultiACBulkBase::_prop_dhjdetai
std::vector< const MaterialProperty< Real > * > _prop_dhjdetai
Derivatives of the switching functions wrt the order parameter for this kernel.
Definition: KKSMultiACBulkBase.h:61
KKSMultiACBulkBase::_prop_d2hjdetai2
std::vector< const MaterialProperty< Real > * > _prop_d2hjdetai2
Second derivatives of the switching functions wrt the order parameter for this kernel.
Definition: KKSMultiACBulkBase.h:64
KKSMultiACBulkBase::_nvar
unsigned int _nvar
Number of coupled variables.
Definition: KKSMultiACBulkBase.h:36