www.mooseframework.org
ForceDensityMaterial.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 #include "ForceDensityMaterial.h"
8 
9 template <>
10 InputParameters
12 {
13  InputParameters params = validParams<Material>();
14  params.addClassDescription("Calculating the force density acting on a grain");
15  params.addCoupledVar("etas", "Array of coupled order parameters");
16  params.addCoupledVar("c", "Concentration field");
17  params.addParam<Real>("ceq", 0.9816, "Equilibrium density");
18  params.addParam<Real>("cgb", 0.25, "Thresold Concentration for GB");
19  params.addParam<Real>("k", 100.0, "stiffness constant");
20  return params;
21 }
22 
23 ForceDensityMaterial::ForceDensityMaterial(const InputParameters & parameters)
24  : DerivativeMaterialInterface<Material>(parameters),
25  _c(coupledValue("c")),
26  _c_name(getVar("c", 0)->name()),
27  _ceq(getParam<Real>("ceq")),
28  _cgb(getParam<Real>("cgb")),
29  _k(getParam<Real>("k")),
30  _op_num(coupledComponents(
31  "etas")), // determine number of grains from the number of names passed in.
32  _vals(_op_num), // Size variable arrays
33  _grad_vals(_op_num),
34  _vals_name(_op_num),
35  _product_etas(_op_num),
36  _sum_grad_etas(_op_num),
37  _dF(declareProperty<std::vector<RealGradient>>("force_density")),
38  _dFdc(declarePropertyDerivative<std::vector<RealGradient>>("force_density", _c_name)),
39  _dFdgradeta(_op_num)
40 {
41  // Loop through grains and load coupled variables into the arrays
42  for (unsigned int i = 0; i < _op_num; ++i)
43  {
44  _vals[i] = &coupledValue("etas", i);
45  _grad_vals[i] = &coupledGradient("etas", i);
46  _vals_name[i] = getVar("etas", i)->name();
47  _dFdgradeta[i] = &declarePropertyDerivative<std::vector<Real>>("force_density", _vals_name[i]);
48  }
49 }
50 
51 void
53 {
54  _dF[_qp].resize(_op_num);
55  _dFdc[_qp].resize(_op_num);
56 
57  for (unsigned int i = 0; i < _op_num; ++i)
58  {
59  _sum_grad_etas[i] = 0.0;
60  for (unsigned int j = 0; j < _op_num; ++j)
61  if (j != i)
62  {
63  _product_etas[i] = (*_vals[i])[_qp] * (*_vals[j])[_qp] >= _cgb ? 1.0 : 0.0;
64  _sum_grad_etas[i] += _product_etas[i] * ((*_grad_vals[i])[_qp] - (*_grad_vals[j])[_qp]);
65  }
66  _dF[_qp][i] = _k * (_c[_qp] - _ceq) * _sum_grad_etas[i];
67  _dFdc[_qp][i] = _k * _sum_grad_etas[i];
68  }
69 
70  for (unsigned int i = 0; i < _op_num; ++i)
71  {
72  (*_dFdgradeta[i])[_qp].resize(_op_num);
73  for (unsigned int j = 0; j < _op_num; ++j)
74  {
75  for (unsigned int k = 0; k < _op_num; ++k)
76  if (k != j)
77  _product_etas[j] = (*_vals[j])[_qp] * (*_vals[k])[_qp] >= _cgb ? 1.0 : 0.0;
78 
79  if (j == i)
80  (*_dFdgradeta[i])[_qp][j] = _k * _product_etas[j] * (_c[_qp] - _ceq);
81  else
82  (*_dFdgradeta[i])[_qp][j] = -_k * _product_etas[j] * (_c[_qp] - _ceq);
83  }
84  }
85 }
MaterialProperty< std::vector< RealGradient > > & _dFdc
first order derivative of force density material w.r.t c
std::vector< const VariableGradient * > _grad_vals
std::vector< MaterialProperty< std::vector< Real > > * > _dFdgradeta
first order derivative of force density material w.r.t etas
InputParameters validParams< ForceDensityMaterial >()
std::vector< RealGradient > _sum_grad_etas
std::vector< Real > _product_etas
const VariableValue & _c
concentration field considered to be the density of particles
std::vector< const VariableValue * > _vals
virtual void computeQpProperties()
Real _k
stiffness constant
MaterialProperty< std::vector< RealGradient > > & _dF
force density material
std::vector< VariableName > _vals_name
ForceDensityMaterial(const InputParameters &parameters)
Real _ceq
equilibrium density at the grain boundaries
Real _cgb
thresold value for identifying grain boundaries