www.mooseframework.org
CrossTermGradientFreeEnergy.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
8 
9 template <>
10 InputParameters
12 {
13  InputParameters params = validParams<TotalFreeEnergyBase>();
14  params.addClassDescription("Free energy contribution from the cross terms in ACMultiInetrface");
15  params.addRequiredParam<std::vector<MaterialPropertyName>>(
16  "kappa_names",
17  "Matrix of kappa names with rows and columns corresponding to each variable "
18  "name in interfacial_vars in the same order (should be symmetric).");
19  return params;
20 }
21 
23  : TotalFreeEnergyBase(parameters), _kappas(_nvars)
24 {
25  // Error check to ensure size of interfacial_vars is the same as kappa_names
26  if (_nvars * _nvars != _nkappas)
27  mooseError("Size of interfacial_vars squared is not equal to the size of kappa_names in "
28  "CrossTermGradientFreeEnergy");
29 
30  // Assign kappa values
31  for (unsigned int i = 0; i < _nvars; ++i)
32  {
33  _kappas[i].resize(_nvars);
34 
35  for (unsigned int j = 0; j < _nvars; ++j)
36  _kappas[i][j] = &getMaterialPropertyByName<Real>(_kappa_names[i * _nvars + j]);
37  }
38 }
39 
40 Real
42 {
43  // This kernel does _not_ include the bulk energy contribution.
44  // It is to be used as an additional free energy component in TotalFreeEnergy.
45  // additional_free_energy can be used to daisy chain contributions!
47 
48  // Calculate interfacial energy of each variable combination
49  for (unsigned int i = 0; i < _nvars; ++i)
50  for (unsigned int j = 0; j < i; ++j)
51  {
52  const RealGradient cross =
53  (*_vars[i])[_qp] * (*_grad_vars[j])[_qp] + (*_vars[j])[_qp] * (*_grad_vars[i])[_qp];
54  total_energy += (*_kappas[i][j])[_qp] / 2.0 * cross * cross;
55  }
56  return total_energy;
57 }
Total free energy (both the bulk and gradient parts), where the bulk free energy has been defined in ...
unsigned int _nvars
Coupled interface variables.
const VariableValue & _additional_free_energy
Additional free energy contribution.
std::vector< std::vector< const MaterialProperty< Real > * > > _kappas
InputParameters validParams< CrossTermGradientFreeEnergy >()
InputParameters validParams< TotalFreeEnergyBase >()
const std::string total_energy
Definition: NS.h:19
std::vector< const VariableGradient * > _grad_vars
std::vector< const VariableValue * > _vars
CrossTermGradientFreeEnergy(const InputParameters &parameters)
std::vector< MaterialPropertyName > _kappa_names
Gradient free energy prefactor kappa.