www.mooseframework.org
InterfaceOrientationMaterial.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 
9 #include "MooseMesh.h"
10 #include "MathUtils.h"
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<Material>();
17  params.addParam<Real>(
18  "anisotropy_strength", 0.04, "Strength of the anisotropy (typically < 0.05)");
19  params.addParam<unsigned int>("mode_number", 6, "Mode number for anisotropy");
20  params.addParam<Real>("reference_angle", 90, "Reference angle for defining anistropy in degrees");
21  params.addParam<Real>("eps_bar", 0.01, "Average value of the interface parameter epsilon");
22  params.addRequiredCoupledVar("op", "Order parameter defining the solid phase");
23  return params;
24 }
25 
27  : Material(parameters),
28  _delta(getParam<Real>("anisotropy_strength")),
29  _j(getParam<unsigned int>("mode_number")),
30  _theta0(getParam<Real>("reference_angle")),
31  _eps_bar(getParam<Real>("eps_bar")),
32  _eps(declareProperty<Real>("eps")),
33  _deps(declareProperty<Real>("deps")),
34  _depsdgrad_op(declareProperty<RealGradient>("depsdgrad_op")),
35  _ddepsdgrad_op(declareProperty<RealGradient>("ddepsdgrad_op")),
36  _op(coupledValue("op")),
37  _grad_op(coupledGradient("op"))
38 {
39  // this currently only works in 2D simulations
40  if (_mesh.dimension() != 2)
41  mooseError("InterfaceOrientationMaterial requires a two-dimensional mesh.");
42 }
43 
44 void
46 {
47  const Real tol = 1e-9;
48  const Real cutoff = 1.0 - tol;
49 
50  // cosine of the gradient orientation angle
51  Real n = 0.0;
52  const Real nsq = _grad_op[_qp].norm_sq();
53  if (nsq > tol)
54  n = _grad_op[_qp](0) / std::sqrt(nsq);
55 
56  if (n > cutoff)
57  n = cutoff;
58 
59  if (n < -cutoff)
60  n = -cutoff;
61 
62  const Real angle = std::acos(n) * MathUtils::sign(_grad_op[_qp](1));
63 
64  // Compute derivative of angle wrt n
65  const Real dangledn = -MathUtils::sign(_grad_op[_qp](1)) / std::sqrt(1.0 - n * n);
66 
67  // Compute derivative of n with respect to grad_op
68  RealGradient dndgrad_op;
69  if (nsq > tol)
70  {
71  dndgrad_op(0) = _grad_op[_qp](1) * _grad_op[_qp](1);
72  dndgrad_op(1) = -_grad_op[_qp](0) * _grad_op[_qp](1);
73  dndgrad_op /= (_grad_op[_qp].norm_sq() * _grad_op[_qp].norm());
74  }
75 
76  // Calculate interfacial parameter epsilon and its derivatives
77  _eps[_qp] = _eps_bar * (_delta * std::cos(_j * (angle - _theta0 * libMesh::pi / 180.0)) + 1.0);
78  _deps[_qp] = -_eps_bar * _delta * _j * std::sin(_j * (angle - _theta0 * libMesh::pi / 180.0));
79  Real d2eps =
80  -_eps_bar * _delta * _j * _j * std::cos(_j * (angle - _theta0 * libMesh::pi / 180.0));
81 
82  // Compute derivatives of epsilon and its derivative wrt grad_op
83  _depsdgrad_op[_qp] = _deps[_qp] * dangledn * dndgrad_op;
84  _ddepsdgrad_op[_qp] = d2eps * dangledn * dndgrad_op;
85 }
MaterialProperty< RealGradient > & _depsdgrad_op
Real sign(Real x)
Definition: MathUtils.h:24
InterfaceOrientationMaterial(const InputParameters &parameters)
MaterialProperty< RealGradient > & _ddepsdgrad_op
InputParameters validParams< InterfaceOrientationMaterial >()
static const double tol
Definition: XFEMFuncs.h:26