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 "DiffusionFluxAux.h" 11 : #include "Assembly.h" 12 : 13 : registerMooseObject("MooseApp", DiffusionFluxAux); 14 : 15 : InputParameters 16 14640 : DiffusionFluxAux::validParams() 17 : { 18 14640 : InputParameters params = AuxKernel::validParams(); 19 14640 : MooseEnum component("x y z normal"); 20 14640 : params.addClassDescription("Compute components of flux vector for diffusion problems " 21 : "$(\\vec{J} = -D \\nabla C)$."); 22 14640 : params.addRequiredParam<MooseEnum>("component", component, "The desired component of flux."); 23 14640 : params.addRequiredCoupledVar("diffusion_variable", "The name of the variable"); 24 14640 : params.addRequiredParam<MaterialPropertyName>( 25 : "diffusivity", 26 : "The name of the diffusivity material property that will be used in the flux computation."); 27 29280 : return params; 28 14640 : } 29 : 30 195 : DiffusionFluxAux::DiffusionFluxAux(const InputParameters & parameters) 31 : : AuxKernel(parameters), 32 195 : _use_normal(getParam<MooseEnum>("component") == "normal"), 33 195 : _component(getParam<MooseEnum>("component")), 34 195 : _grad_u(coupledGradient("diffusion_variable")), 35 390 : _diffusion_coef(hasMaterialProperty<Real>("diffusivity") 36 195 : ? &getMaterialProperty<Real>("diffusivity") 37 : : nullptr), 38 195 : _ad_diffusion_coef(!_diffusion_coef ? &getADMaterialProperty<Real>("diffusivity") : nullptr), 39 390 : _normals(_assembly.normals()) 40 : { 41 195 : if (_use_normal && !isParamValid("boundary")) 42 0 : paramError("boundary", "A boundary must be provided if using the normal component!"); 43 195 : } 44 : 45 : Real 46 1390336 : DiffusionFluxAux::computeValue() 47 : { 48 1390336 : const Real gradient = _use_normal ? _grad_u[_qp] * _normals[_qp] : _grad_u[_qp](_component); 49 1390336 : const Real diffusion_coef = _diffusion_coef ? (*_diffusion_coef)[_qp] 50 521856 : : MetaPhysicL::raw_value((*_ad_diffusion_coef)[_qp]); 51 1390336 : return -diffusion_coef * gradient; 52 : }