www.mooseframework.org
PFCEnergyDensity.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 #include "PFCEnergyDensity.h"
9 #include "libmesh/utility.h"
10 
11 template <>
12 InputParameters
14 {
15  InputParameters params = validParams<AuxKernel>();
16  params.addRequiredCoupledVar("v", "Array of coupled variables");
17  return params;
18 }
19 
20 PFCEnergyDensity::PFCEnergyDensity(const InputParameters & parameters)
21  : AuxKernel(parameters),
22  _order(coupledComponents("v")),
23  _a(getMaterialProperty<Real>("a")),
24  _b(getMaterialProperty<Real>("b"))
25 {
26  _vals.resize(_order);
27  _coeff.resize(_order);
28 
29  std::string coeff_name_base = "C";
30 
31  for (unsigned int i = 0; i < _order; ++i)
32  {
33  _vals[i] = &coupledValue("v", i);
34  std::string coeff_name = coeff_name_base;
35  std::stringstream out;
36  out << i * 2;
37  coeff_name.append(out.str());
38  _console << coeff_name << std::endl;
39  _coeff[i] = &getMaterialProperty<Real>(coeff_name);
40  }
41 }
42 
43 Real
45 {
46  Real val = Utility::pow<2>((*_vals[0])[_qp]) * (1.0 - (*_coeff[0])[_qp]) / 2.0;
47 
48  // Loop Through Variables
49  // the sign of negative terms have been taken care of by changing the sign of the coefficients;
50  for (unsigned int i = 1; i < _order; ++i)
51  val += (*_coeff[i])[_qp] * (*_vals[0])[_qp] * (*_vals[i])[_qp] / 2.0;
52 
53  val += (_b[_qp] / 12.0 * Utility::pow<4>((*_vals[0])[_qp])) -
54  (_a[_qp] / 6.0 * Utility::pow<3>((*_vals[0])[_qp]));
55 
56  return val;
57 }
const MaterialProperty< Real > & _a
virtual Real computeValue()
std::vector< const VariableValue * > _vals
const MaterialProperty< Real > & _b
std::vector< const MaterialProperty< Real > * > _coeff
InputParameters validParams< PFCEnergyDensity >()
unsigned int _order
PFCEnergyDensity(const InputParameters &parameters)