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 "PFCEnergyDensity.h" 11 : #include "libmesh/utility.h" 12 : 13 : registerMooseObject("PhaseFieldApp", PFCEnergyDensity); 14 : 15 : InputParameters 16 15 : PFCEnergyDensity::validParams() 17 : { 18 15 : InputParameters params = AuxKernel::validParams(); 19 15 : params.addClassDescription("Computes the crystal free energy density"); 20 30 : params.addRequiredCoupledVar("v", "Array of coupled variables"); 21 15 : return params; 22 0 : } 23 : 24 8 : PFCEnergyDensity::PFCEnergyDensity(const InputParameters & parameters) 25 : : AuxKernel(parameters), 26 16 : _vals(coupledValues("v")), 27 8 : _order(coupledComponents("v")), 28 8 : _a(getMaterialProperty<Real>("a")), 29 16 : _b(getMaterialProperty<Real>("b")) 30 : { 31 8 : _coeff.resize(_order); 32 : 33 8 : std::string coeff_name_base = "C"; 34 : 35 32 : for (unsigned int i = 0; i < _order; ++i) 36 : { 37 24 : std::string coeff_name = coeff_name_base; 38 24 : std::stringstream out; 39 24 : out << i * 2; 40 24 : coeff_name.append(out.str()); 41 24 : _console << coeff_name << std::endl; 42 24 : _coeff[i] = &getMaterialProperty<Real>(coeff_name); 43 24 : } 44 8 : } 45 : 46 : Real 47 9900 : PFCEnergyDensity::computeValue() 48 : { 49 9900 : Real val = Utility::pow<2>((*_vals[0])[_qp]) * (1.0 - (*_coeff[0])[_qp]) / 2.0; 50 : 51 : // Loop Through Variables 52 : // the sign of negative terms have been taken care of by changing the sign of the coefficients; 53 29700 : for (unsigned int i = 1; i < _order; ++i) 54 19800 : val += (*_coeff[i])[_qp] * (*_vals[0])[_qp] * (*_vals[i])[_qp] / 2.0; 55 : 56 9900 : val += (_b[_qp] / 12.0 * Utility::pow<4>((*_vals[0])[_qp])) - 57 9900 : (_a[_qp] / 6.0 * Utility::pow<3>((*_vals[0])[_qp])); 58 : 59 9900 : return val; 60 : }