https://mooseframework.inl.gov
PFCEnergyDensity.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 "PFCEnergyDensity.h"
11 #include "libmesh/utility.h"
12 
13 registerMooseObject("PhaseFieldApp", PFCEnergyDensity);
14 
17 {
19  params.addClassDescription("Computes the crystal free energy density");
20  params.addRequiredCoupledVar("v", "Array of coupled variables");
21  return params;
22 }
23 
25  : AuxKernel(parameters),
26  _vals(coupledValues("v")),
27  _order(coupledComponents("v")),
28  _a(getMaterialProperty<Real>("a")),
29  _b(getMaterialProperty<Real>("b"))
30 {
31  _coeff.resize(_order);
32 
33  std::string coeff_name_base = "C";
34 
35  for (unsigned int i = 0; i < _order; ++i)
36  {
37  std::string coeff_name = coeff_name_base;
38  std::stringstream out;
39  out << i * 2;
40  coeff_name.append(out.str());
41  _console << coeff_name << std::endl;
42  _coeff[i] = &getMaterialProperty<Real>(coeff_name);
43  }
44 }
45 
46 Real
48 {
49  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  for (unsigned int i = 1; i < _order; ++i)
54  val += (*_coeff[i])[_qp] * (*_vals[0])[_qp] * (*_vals[i])[_qp] / 2.0;
55 
56  val += (_b[_qp] / 12.0 * Utility::pow<4>((*_vals[0])[_qp])) -
57  (_a[_qp] / 6.0 * Utility::pow<3>((*_vals[0])[_qp]));
58 
59  return val;
60 }
const MaterialProperty< Real > & _a
virtual Real computeValue()
const std::vector< const VariableValue * > _vals
const MaterialProperty< Real > & _b
static InputParameters validParams()
std::vector< const MaterialProperty< Real > * > _coeff
unsigned int _order
registerMooseObject("PhaseFieldApp", PFCEnergyDensity)
PFCEnergyDensity(const InputParameters &parameters)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
OStreamProxy out
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
const ConsoleStream _console