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