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 "TotalFreeEnergy.h" 11 : 12 : registerMooseObject("PhaseFieldApp", TotalFreeEnergy); 13 : 14 : InputParameters 15 234 : TotalFreeEnergy::validParams() 16 : { 17 234 : InputParameters params = TotalFreeEnergyBase::validParams(); 18 234 : params.addClassDescription("Total free energy (both the bulk and gradient parts), where the bulk " 19 : "free energy has been defined in a material"); 20 468 : params.addParam<MaterialPropertyName>("f_name", "F", " Base name of the free energy function"); 21 234 : params.addParam<std::vector<MaterialPropertyName>>("kappa_names", 22 234 : std::vector<MaterialPropertyName>(), 23 : "Vector of kappa names corresponding to " 24 : "each variable name in interfacial_vars " 25 : "in the same order."); 26 234 : return params; 27 0 : } 28 : 29 123 : TotalFreeEnergy::TotalFreeEnergy(const InputParameters & parameters) 30 123 : : 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 123 : if (_nvars != _nkappas) 34 0 : mooseError( 35 : "Size of interfacial_vars is not equal to the size of kappa_names in TotalFreeEnergy"); 36 : 37 : // Assign kappa values 38 282 : for (unsigned int i = 0; i < _nkappas; ++i) 39 159 : _kappas[i] = &getMaterialPropertyByName<Real>(_kappa_names[i]); 40 123 : } 41 : 42 : Real 43 3726336 : TotalFreeEnergy::computeValue() 44 : { 45 : // Include bulk energy contribution and additional contributions 46 3726336 : Real total_energy = _F[_qp] + _additional_free_energy[_qp]; 47 : 48 : // Calculate interfacial energy of each variable 49 8302608 : for (unsigned int i = 0; i < _nvars; ++i) 50 4576272 : total_energy += (*_kappas[i])[_qp] / 2.0 * (*_grad_vars[i])[_qp].norm_sq(); 51 : 52 3726336 : return total_energy; 53 : }