https://mooseframework.inl.gov
Loading...
Searching...
No Matches
TotalFreeEnergy.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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 "TotalFreeEnergy.h"
11
13
16{
18 params.addClassDescription("Total free energy (both the bulk and gradient parts), where the bulk "
19 "free energy has been defined in a material");
20 params.addParam<MaterialPropertyName>("f_name", "F", " Base name of the free energy function");
21 params.addParam<std::vector<MaterialPropertyName>>("kappa_names",
22 std::vector<MaterialPropertyName>(),
23 "Vector of kappa names corresponding to "
24 "each variable name in interfacial_vars "
25 "in the same order.");
26 return params;
27}
28
30 : TotalFreeEnergyBase(parameters), _F(getMaterialProperty<Real>("f_name")), _kappas(_nkappas)
31{
32 // Error check to ensure size of interfacial_vars is the same as kappa_names
33 if (_nvars != _nkappas)
35 "Size of interfacial_vars is not equal to the size of kappa_names in TotalFreeEnergy");
36
37 // Assign kappa values
38 for (unsigned int i = 0; i < _nkappas; ++i)
39 _kappas[i] = &getMaterialPropertyByName<Real>(_kappa_names[i]);
40}
41
42Real
44{
45 // Include bulk energy contribution and additional contributions
46 Real total_energy = _F[_qp] + _additional_free_energy[_qp];
47
48 // Calculate interfacial energy of each variable
49 for (unsigned int i = 0; i < _nvars; ++i)
50 total_energy += (*_kappas[i])[_qp] / 2.0 * (*_grad_vars[i])[_qp].norm_sq();
51
52 return total_energy;
53}
registerMooseObject("PhaseFieldApp", TotalFreeEnergy)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void mooseError(Args &&... args) const
Total free energy (both the bulk and gradient parts), where the bulk free energy has been defined in ...
const std::vector< const VariableGradient * > _grad_vars
std::vector< MaterialPropertyName > _kappa_names
Gradient free energy prefactor kappa.
const VariableValue & _additional_free_energy
Additional free energy contribution.
static InputParameters validParams()
unsigned int _nvars
Coupled interface variables.
Total free energy (both the bulk and gradient parts), where the bulk free energy has been defined in ...
const MaterialProperty< Real > & _F
Bulk free energy material property.
static InputParameters validParams()
std::vector< const MaterialProperty< Real > * > _kappas
Gradient interface free energy coefficients.
TotalFreeEnergy(const InputParameters &parameters)
virtual Real computeValue()