www.mooseframework.org
ForceDensityMaterial.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 "ForceDensityMaterial.h"
11 
13 
16 {
18  params.addClassDescription("Calculating the force density acting on a grain");
19  params.addCoupledVar("etas", "Array of coupled order parameters");
20  params.addCoupledVar("c", "Concentration field");
21  params.addParam<Real>("ceq", 0.9816, "Equilibrium density");
22  params.addParam<Real>("cgb", 0.25, "Threshold Concentration for GB");
23  params.addParam<Real>("k", 100.0, "stiffness constant");
24  return params;
25 }
26 
29  _c(coupledValue("c")),
30  _c_name(coupledName("c", 0)),
31  _ceq(getParam<Real>("ceq")),
32  _cgb(getParam<Real>("cgb")),
33  _k(getParam<Real>("k")),
34  _op_num(coupledComponents(
35  "etas")), // determine number of grains from the number of names passed in.
36  _vals(coupledValues("etas")),
37  _grad_vals(coupledGradients("etas")),
38  _vals_name(coupledNames("etas")),
39  _product_etas(_op_num),
40  _sum_grad_etas(_op_num),
41  _dF(declareProperty<std::vector<RealGradient>>("force_density")),
42  _dFdc(declarePropertyDerivative<std::vector<RealGradient>>("force_density", _c_name)),
43  _dFdgradeta(_op_num)
44 {
45  // Loop through grains and load derivatives
46  for (unsigned int i = 0; i < _op_num; ++i)
48  _dFdgradeta[i] =
49  &declarePropertyDerivative<std::vector<Real>>("force_density", _vals_name[i]);
50 }
51 
52 void
54 {
55  _dF[_qp].resize(_op_num);
56  _dFdc[_qp].resize(_op_num);
57 
58  for (unsigned int i = 0; i < _op_num; ++i)
59  {
60  _sum_grad_etas[i] = 0.0;
61  for (unsigned int j = 0; j < _op_num; ++j)
62  if (j != i)
63  {
64  _product_etas[i] = (*_vals[i])[_qp] * (*_vals[j])[_qp] >= _cgb ? 1.0 : 0.0;
65  _sum_grad_etas[i] += _product_etas[i] * ((*_grad_vals[i])[_qp] - (*_grad_vals[j])[_qp]);
66  }
67  _dF[_qp][i] = _k * (_c[_qp] - _ceq) * _sum_grad_etas[i];
68  _dFdc[_qp][i] = _k * _sum_grad_etas[i];
69  }
70 
71  for (unsigned int i = 0; i < _op_num; ++i)
72  {
73  if (_dFdgradeta[i])
74  (*_dFdgradeta[i])[_qp].resize(_op_num);
75  for (unsigned int j = 0; j < _op_num; ++j)
76  {
77  for (unsigned int k = 0; k < _op_num; ++k)
78  if (k != j)
79  _product_etas[j] = (*_vals[j])[_qp] * (*_vals[k])[_qp] >= _cgb ? 1.0 : 0.0;
80 
81  if (_dFdgradeta[i])
82  {
83  if (j == i)
84  (*_dFdgradeta[i])[_qp][j] = _k * _product_etas[j] * (_c[_qp] - _ceq);
85  else
86  (*_dFdgradeta[i])[_qp][j] = -_k * _product_etas[j] * (_c[_qp] - _ceq);
87  }
88  }
89  }
90 }
MaterialProperty< std::vector< RealGradient > > & _dFdc
first order derivative of force density material w.r.t c
const std::vector< const VariableValue * > _vals
virtual bool isCoupledConstant(const std::string &var_name) const
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const std::vector< VariableName > _vals_name
const unsigned int _op_num
This Material calculates the force density acting on a particle/grain due to interaction between part...
std::vector< MaterialProperty< std::vector< Real > > * > _dFdgradeta
first order derivative of force density material w.r.t etas
std::vector< RealGradient > _sum_grad_etas
std::vector< Real > _product_etas
static InputParameters validParams()
static InputParameters validParams()
const std::vector< const VariableGradient * > _grad_vals
const VariableValue & _c
concentration field considered to be the density of particles
void addCoupledVar(const std::string &name, const std::string &doc_string)
virtual void computeQpProperties()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real _k
stiffness constant
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
registerMooseObject("PhaseFieldApp", ForceDensityMaterial)
MaterialProperty< std::vector< RealGradient > > & _dF
force density material
ForceDensityMaterial(const InputParameters &parameters)
Real _ceq
equilibrium density at the grain boundaries
static const std::string k
Definition: NS.h:124
Real _cgb
thresold value for identifying grain boundaries