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 "PhaseNormalTensor.h" 11 : 12 : registerMooseObject("PhaseFieldApp", PhaseNormalTensor); 13 : 14 : InputParameters 15 0 : PhaseNormalTensor::validParams() 16 : { 17 0 : InputParameters params = Material::validParams(); 18 0 : params.addClassDescription("Calculate normal tensor of a phase based on gradient"); 19 0 : params.addRequiredCoupledVar("phase", "Phase variable"); 20 0 : params.addRequiredParam<MaterialPropertyName>("normal_tensor_name", "Name of normal tensor"); 21 0 : return params; 22 0 : } 23 : 24 0 : PhaseNormalTensor::PhaseNormalTensor(const InputParameters & parameters) 25 : : DerivativeMaterialInterface<Material>(parameters), 26 0 : _grad_u(coupledGradient("phase")), 27 0 : _normal_tensor( 28 0 : declareProperty<RankTwoTensor>(getParam<MaterialPropertyName>("normal_tensor_name"))) 29 : { 30 0 : } 31 : 32 : void 33 0 : PhaseNormalTensor::initQpStatefulProperties() 34 : { 35 0 : _normal_tensor[_qp].zero(); 36 0 : } 37 : 38 : void 39 0 : PhaseNormalTensor::computeQpProperties() 40 : { 41 0 : const Real magnitude = _grad_u[_qp].norm(); 42 : 43 0 : if (magnitude > 0.0) 44 : { 45 : const RealVectorValue vector = _grad_u[_qp] / magnitude; 46 0 : _normal_tensor[_qp] = RankTwoTensor::selfOuterProduct(vector); 47 : } 48 : else 49 0 : _normal_tensor[_qp].zero(); 50 0 : }