https://mooseframework.inl.gov
Loading...
Searching...
No Matches
CrossTermGradientFreeEnergy.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
11
13
16{
18 params.addClassDescription("Free energy contribution from the cross terms in ACMultiInterface");
19 params.addRequiredParam<std::vector<MaterialPropertyName>>(
20 "kappa_names",
21 "Matrix of kappa names with rows and columns corresponding to each variable "
22 "name in interfacial_vars in the same order (should be symmetric).");
23 return params;
24}
25
27 : TotalFreeEnergyBase(parameters), _kappas(_nvars)
28{
29 // Error check to ensure size of interfacial_vars is the same as kappa_names
30 if (_nvars * _nvars != _nkappas)
31 paramError("kappa_names",
32 "Size of interfacial_vars squared is not equal to the size of kappa_names in "
33 "CrossTermGradientFreeEnergy");
34
35 // Assign kappa values
36 for (unsigned int i = 0; i < _nvars; ++i)
37 {
38 _kappas[i].resize(_nvars);
39
40 for (unsigned int j = 0; j < _nvars; ++j)
41 _kappas[i][j] = &getMaterialPropertyByName<Real>(_kappa_names[i * _nvars + j]);
42 }
43}
44
45Real
47{
48 // This kernel does _not_ include the bulk energy contribution.
49 // It is to be used as an additional free energy component in TotalFreeEnergy.
50 // additional_free_energy can be used to daisy chain contributions!
51 Real total_energy = _additional_free_energy[_qp];
52
53 // Calculate interfacial energy of each variable combination
54 for (unsigned int i = 0; i < _nvars; ++i)
55 for (unsigned int j = 0; j < i; ++j)
56 {
57 const RealGradient cross =
58 (*_vars[i])[_qp] * (*_grad_vars[j])[_qp] + (*_vars[j])[_qp] * (*_grad_vars[i])[_qp];
59 total_energy += (*_kappas[i][j])[_qp] / 2.0 * cross * cross;
60 }
61 return total_energy;
62}
registerMooseObject("PhaseFieldApp", CrossTermGradientFreeEnergy)
Cross term gradient free energy contribution used by ACMultiInterface.
CrossTermGradientFreeEnergy(const InputParameters &parameters)
std::vector< std::vector< const MaterialProperty< Real > * > > _kappas
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void paramError(const std::string &param, 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 std::vector< const VariableValue * > _vars
const VariableValue & _additional_free_energy
Additional free energy contribution.
static InputParameters validParams()
unsigned int _nvars
Coupled interface variables.