https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ForceDensityMaterial.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
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)
47 if (!isCoupledConstant(_vals_name[i]))
48 _dFdgradeta[i] =
49 &declarePropertyDerivative<std::vector<Real>>("force_density", _vals_name[i]);
50}
51
52void
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}
registerMooseObject("PhaseFieldApp", ForceDensityMaterial)
This Material calculates the force density acting on a particle/grain due to interaction between part...
const VariableValue & _c
concentration field considered to be the density of particles
Real _cgb
thresold value for identifying grain boundaries
std::vector< RealGradient > _sum_grad_etas
Real _ceq
equilibrium density at the grain boundaries
static InputParameters validParams()
const std::vector< VariableName > _vals_name
MaterialProperty< std::vector< RealGradient > > & _dF
force density material
std::vector< Real > _product_etas
Real _k
stiffness constant
const std::vector< const VariableValue * > _vals
const std::vector< const VariableGradient * > _grad_vals
MaterialProperty< std::vector< RealGradient > > & _dFdc
first order derivative of force density material w.r.t c
std::vector< MaterialProperty< std::vector< Real > > * > _dFdgradeta
first order derivative of force density material w.r.t etas
virtual void computeQpProperties()
ForceDensityMaterial(const InputParameters &parameters)
const unsigned int _op_num
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)
virtual void resize(const std::size_t size) override final
static InputParameters validParams()