Line data Source code
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 : 10 : #include "ADInterfaceOrientationMaterial.h" 11 : #include "MooseMesh.h" 12 : #include "MathUtils.h" 13 : 14 : registerMooseObject("PhaseFieldApp", ADInterfaceOrientationMaterial); 15 : 16 : InputParameters 17 31 : ADInterfaceOrientationMaterial::validParams() 18 : { 19 31 : InputParameters params = Material::validParams(); 20 31 : params.addClassDescription("2D interfacial anisotropy"); 21 62 : params.addParam<Real>( 22 62 : "anisotropy_strength", 0.04, "Strength of the anisotropy (typically < 0.05)"); 23 62 : params.addParam<unsigned int>("mode_number", 6, "Mode number for anisotropy"); 24 62 : params.addParam<Real>( 25 62 : "reference_angle", 90, "Reference angle for defining anisotropy in degrees"); 26 62 : params.addParam<Real>("eps_bar", 0.01, "Average value of the interface parameter epsilon"); 27 62 : params.addRequiredCoupledVar("op", "Order parameter defining the solid phase"); 28 31 : return params; 29 0 : } 30 : 31 24 : ADInterfaceOrientationMaterial::ADInterfaceOrientationMaterial(const InputParameters & parameters) 32 : : Material(parameters), 33 24 : _delta(getParam<Real>("anisotropy_strength")), 34 48 : _j(getParam<unsigned int>("mode_number")), 35 48 : _theta0(getParam<Real>("reference_angle")), 36 48 : _eps_bar(getParam<Real>("eps_bar")), 37 24 : _eps(declareADProperty<Real>("eps")), 38 24 : _deps(declareADProperty<Real>("deps")), 39 24 : _op(adCoupledValue("op")), 40 48 : _grad_op(adCoupledGradient("op")) 41 : { 42 : // this currently only works in 2D simulations 43 24 : if (_mesh.dimension() != 2) 44 0 : mooseError("ADInterfaceOrientationMaterial requires a two-dimensional mesh."); 45 24 : } 46 : 47 : void 48 1544192 : ADInterfaceOrientationMaterial::computeQpProperties() 49 : { 50 : using std::max, std::min, std::sqrt, std::acos, std::cos, std::sin; 51 : 52 : const Real tol = 1e-9; 53 1544192 : const Real cutoff = 1.0 - tol; 54 : 55 : // cosine of the gradient orientation angle 56 1544192 : ADReal n = 0.0; 57 1544192 : const ADReal nsq = _grad_op[_qp].norm_sq(); 58 1544192 : if (nsq > tol) 59 2299312 : n = max(-cutoff, min(_grad_op[_qp](0) / sqrt(nsq), cutoff)); 60 : 61 : // Calculate interfacial parameter epsilon and its derivative 62 3088384 : const ADReal angle = acos(n) * MathUtils::sign(_grad_op[_qp](1)); 63 6176768 : _eps[_qp] = _eps_bar * (_delta * cos(_j * (angle - _theta0 * libMesh::pi / 180.0)) + 1.0); 64 4632576 : _deps[_qp] = -_eps_bar * _delta * _j * sin(_j * (angle - _theta0 * libMesh::pi / 180.0)); 65 1544192 : }