www.mooseframework.org
PFCEnergyDensity.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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.addRequiredCoupledVar("v", "Array of coupled variables");
20  return params;
21 }
22 
24  : AuxKernel(parameters),
25  _vals(coupledValues("v")),
26  _order(coupledComponents("v")),
27  _a(getMaterialProperty<Real>("a")),
28  _b(getMaterialProperty<Real>("b"))
29 {
30  _coeff.resize(_order);
31 
32  std::string coeff_name_base = "C";
33 
34  for (unsigned int i = 0; i < _order; ++i)
35  {
36  std::string coeff_name = coeff_name_base;
37  std::stringstream out;
38  out << i * 2;
39  coeff_name.append(out.str());
40  _console << coeff_name << std::endl;
41  _coeff[i] = &getMaterialProperty<Real>(coeff_name);
42  }
43 }
44 
45 Real
47 {
48  Real val = Utility::pow<2>((*_vals[0])[_qp]) * (1.0 - (*_coeff[0])[_qp]) / 2.0;
49 
50  // Loop Through Variables
51  // the sign of negative terms have been taken care of by changing the sign of the coefficients;
52  for (unsigned int i = 1; i < _order; ++i)
53  val += (*_coeff[i])[_qp] * (*_vals[0])[_qp] * (*_vals[i])[_qp] / 2.0;
54 
55  val += (_b[_qp] / 12.0 * Utility::pow<4>((*_vals[0])[_qp])) -
56  (_a[_qp] / 6.0 * Utility::pow<3>((*_vals[0])[_qp]));
57 
58  return val;
59 }
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
static InputParameters validParams()
const ConsoleStream _console