Line data Source code
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 "CrossTermGradientFreeEnergy.h" 11 : 12 : registerMooseObject("PhaseFieldApp", CrossTermGradientFreeEnergy); 13 : 14 : InputParameters 15 28 : CrossTermGradientFreeEnergy::validParams() 16 : { 17 28 : InputParameters params = TotalFreeEnergyBase::validParams(); 18 28 : params.addClassDescription("Free energy contribution from the cross terms in ACMultiInterface"); 19 56 : 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 28 : return params; 24 0 : } 25 : 26 15 : CrossTermGradientFreeEnergy::CrossTermGradientFreeEnergy(const InputParameters & parameters) 27 15 : : TotalFreeEnergyBase(parameters), _kappas(_nvars) 28 : { 29 : // Error check to ensure size of interfacial_vars is the same as kappa_names 30 15 : if (_nvars * _nvars != _nkappas) 31 0 : 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 60 : for (unsigned int i = 0; i < _nvars; ++i) 37 : { 38 45 : _kappas[i].resize(_nvars); 39 : 40 180 : for (unsigned int j = 0; j < _nvars; ++j) 41 135 : _kappas[i][j] = &getMaterialPropertyByName<Real>(_kappa_names[i * _nvars + j]); 42 : } 43 15 : } 44 : 45 : Real 46 129600 : CrossTermGradientFreeEnergy::computeValue() 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 129600 : Real total_energy = _additional_free_energy[_qp]; 52 : 53 : // Calculate interfacial energy of each variable combination 54 518400 : for (unsigned int i = 0; i < _nvars; ++i) 55 777600 : for (unsigned int j = 0; j < i; ++j) 56 : { 57 : const RealGradient cross = 58 388800 : (*_vars[i])[_qp] * (*_grad_vars[j])[_qp] + (*_vars[j])[_qp] * (*_grad_vars[i])[_qp]; 59 388800 : total_energy += (*_kappas[i][j])[_qp] / 2.0 * cross * cross; 60 : } 61 129600 : return total_energy; 62 : }