https://mooseframework.inl.gov
ADInterfaceOrientationMaterial.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 #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(declareADProperty<Real>("eps")),
38  _deps(declareADProperty<Real>("deps")),
39  _op(adCoupledValue("op")),
40  _grad_op(adCoupledGradient("op"))
41 {
42  // this currently only works in 2D simulations
43  if (_mesh.dimension() != 2)
44  mooseError("ADInterfaceOrientationMaterial requires a two-dimensional mesh.");
45 }
46 
47 void
49 {
50  const Real tol = 1e-9;
51  const Real cutoff = 1.0 - tol;
52 
53  // cosine of the gradient orientation angle
54  ADReal n = 0.0;
55  const ADReal nsq = _grad_op[_qp].norm_sq();
56  if (nsq > tol)
57  n = std::max(-cutoff, std::min(_grad_op[_qp](0) / std::sqrt(nsq), cutoff));
58 
59  // Calculate interfacial parameter epsilon and its derivative
60  const ADReal angle = std::acos(n) * MathUtils::sign(_grad_op[_qp](1));
61  _eps[_qp] = _eps_bar * (_delta * std::cos(_j * (angle - _theta0 * libMesh::pi / 180.0)) + 1.0);
62  _deps[_qp] = -_eps_bar * _delta * _j * std::sin(_j * (angle - _theta0 * libMesh::pi / 180.0));
63 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const double tol
Material to compute the angular orientation of order parameter interfaces.
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)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
registerMooseObject("PhaseFieldApp", ADInterfaceOrientationMaterial)
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
ADInterfaceOrientationMaterial(const InputParameters &parameters)
void ErrorVector unsigned int
const Real pi