www.mooseframework.org
TotalFreeEnergy.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 /****************************************************************/
7 #include "TotalFreeEnergy.h"
8 
9 template <>
10 InputParameters
12 {
13  InputParameters params = validParams<TotalFreeEnergyBase>();
14  params.addClassDescription("Total free energy (both the bulk and gradient parts), where the bulk "
15  "free energy has been defined in a material");
16  params.addParam<MaterialPropertyName>("f_name", "F", " Base name of the free energy function");
17  params.addParam<std::vector<MaterialPropertyName>>("kappa_names",
18  std::vector<MaterialPropertyName>(),
19  "Vector of kappa names corresponding to "
20  "each variable name in interfacial_vars "
21  "in the same order.");
22  return params;
23 }
24 
25 TotalFreeEnergy::TotalFreeEnergy(const InputParameters & parameters)
26  : TotalFreeEnergyBase(parameters), _F(getMaterialProperty<Real>("f_name")), _kappas(_nkappas)
27 {
28  // Error check to ensure size of interfacial_vars is the same as kappa_names
29  if (_nvars != _nkappas)
30  mooseError(
31  "Size of interfacial_vars is not equal to the size of kappa_names in TotalFreeEnergy");
32 
33  // Assign kappa values
34  for (unsigned int i = 0; i < _nkappas; ++i)
35  _kappas[i] = &getMaterialPropertyByName<Real>(_kappa_names[i]);
36 }
37 
38 Real
40 {
41  // Include bulk energy contribution and additional contributions
42  Real total_energy = _F[_qp] + _additional_free_energy[_qp];
43 
44  // Calculate interfacial energy of each variable
45  for (unsigned int i = 0; i < _nvars; ++i)
46  total_energy += (*_kappas[i])[_qp] / 2.0 * (*_grad_vars[i])[_qp].norm_sq();
47 
48  return total_energy;
49 }
Total free energy (both the bulk and gradient parts), where the bulk free energy has been defined in ...
unsigned int _nvars
Coupled interface variables.
TotalFreeEnergy(const InputParameters &parameters)
const VariableValue & _additional_free_energy
Additional free energy contribution.
const MaterialProperty< Real > & _F
Bulk free energy material property.
std::vector< const MaterialProperty< Real > * > _kappas
Gradient interface free energy coefficients.
InputParameters validParams< TotalFreeEnergy >()
InputParameters validParams< TotalFreeEnergyBase >()
virtual Real computeValue()
const std::string total_energy
Definition: NS.h:19
std::vector< const VariableGradient * > _grad_vars
std::vector< MaterialPropertyName > _kappa_names
Gradient free energy prefactor kappa.