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 
16 template <>
17 InputParameters
19 {
20  InputParameters params = validParams<Material>();
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 }
InterfaceOrientationMaterial
Material to compute the angular orientation of order parameter interfaces.
Definition: InterfaceOrientationMaterial.h:25
InterfaceOrientationMaterial::_eps_bar
Real _eps_bar
Definition: InterfaceOrientationMaterial.h:37
InterfaceOrientationMaterial::_ddepsdgrad_op
MaterialProperty< RealGradient > & _ddepsdgrad_op
Definition: InterfaceOrientationMaterial.h:42
libMesh::RealGradient
VectorValue< Real > RealGradient
Definition: GrainForceAndTorqueInterface.h:17
InterfaceOrientationMaterial.h
InterfaceOrientationMaterial::_eps
MaterialProperty< Real > & _eps
Definition: InterfaceOrientationMaterial.h:39
InterfaceOrientationMaterial::_depsdgrad_op
MaterialProperty< RealGradient > & _depsdgrad_op
Definition: InterfaceOrientationMaterial.h:41
InterfaceOrientationMaterial::_j
unsigned int _j
Definition: InterfaceOrientationMaterial.h:35
InterfaceOrientationMaterial::_grad_op
const VariableGradient & _grad_op
Definition: InterfaceOrientationMaterial.h:45
InterfaceOrientationMaterial::_theta0
Real _theta0
Definition: InterfaceOrientationMaterial.h:36
InterfaceOrientationMaterial::computeQpProperties
virtual void computeQpProperties()
Definition: InterfaceOrientationMaterial.C:50
validParams< InterfaceOrientationMaterial >
InputParameters validParams< InterfaceOrientationMaterial >()
Definition: InterfaceOrientationMaterial.C:18
tol
const double tol
Definition: Setup.h:18
registerMooseObject
registerMooseObject("PhaseFieldApp", InterfaceOrientationMaterial)
InterfaceOrientationMaterial::_deps
MaterialProperty< Real > & _deps
Definition: InterfaceOrientationMaterial.h:40
InterfaceOrientationMaterial::_delta
Real _delta
Definition: InterfaceOrientationMaterial.h:34
InterfaceOrientationMaterial::InterfaceOrientationMaterial
InterfaceOrientationMaterial(const InputParameters &parameters)
Definition: InterfaceOrientationMaterial.C:31