https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
47void
49{
50 using std::max, std::min, std::sqrt, std::acos, std::cos, std::sin;
51
52 const Real tol = 1e-9;
53 const Real cutoff = 1.0 - tol;
54
55 // cosine of the gradient orientation angle
56 ADReal n = 0.0;
57 const ADReal nsq = _grad_op[_qp].norm_sq();
58 if (nsq > tol)
59 n = max(-cutoff, min(_grad_op[_qp](0) / sqrt(nsq), cutoff));
60
61 // Calculate interfacial parameter epsilon and its derivative
62 const ADReal angle = acos(n) * MathUtils::sign(_grad_op[_qp](1));
63 _eps[_qp] = _eps_bar * (_delta * cos(_j * (angle - _theta0 * libMesh::pi / 180.0)) + 1.0);
64 _deps[_qp] = -_eps_bar * _delta * _j * sin(_j * (angle - _theta0 * libMesh::pi / 180.0));
65}
registerMooseObject("PhaseFieldApp", ADInterfaceOrientationMaterial)
DualNumber< Real, DNDerivativeType, true > ADReal
const double tol
void ErrorVector unsigned int
Material to compute the angular orientation of order parameter interfaces.
ADInterfaceOrientationMaterial(const InputParameters &parameters)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
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)
unsigned int _qp
MooseMesh & _mesh
static InputParameters validParams()
void mooseError(Args &&... args) const
virtual unsigned int dimension() const
T sign(T x)
const Real pi