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 "AdvectiveFluxAux.h" 11 : #include "Assembly.h" 12 : 13 : registerMooseObject("MooseApp", AdvectiveFluxAux); 14 : 15 : InputParameters 16 14350 : AdvectiveFluxAux::validParams() 17 : { 18 14350 : InputParameters params = AuxKernel::validParams(); 19 14350 : MooseEnum component("x y z normal"); 20 : 21 14350 : params.addRequiredParam<MooseEnum>("component", component, "The desired component of flux."); 22 14350 : params.addParam<MooseFunctorName>("advected_variable", 0, "The name of the variable"); 23 14350 : params.addRequiredParam<MooseFunctorName>("vel_x", "x-component of the advecting velocity"); 24 14350 : params.addParam<MooseFunctorName>("vel_y", "y-component of the advecting velocity"); 25 14350 : params.addParam<MooseFunctorName>("vel_z", "z-component of the advecting velocity"); 26 43050 : params.addParam<MaterialPropertyName>( 27 : "advected_mat_prop", 28 28700 : 0, 29 : "The advected material property of which to study the flow; " 30 : "useful for finite element simulations"); 31 : 32 14350 : params.addClassDescription("Compute components of flux vector for advection problems " 33 : "$(\\vec{J} \\cdot \\vec{n} = \\vec{v} u \\cdot \\vec{n})$."); 34 : 35 28700 : return params; 36 14350 : } 37 : 38 46 : AdvectiveFluxAux::AdvectiveFluxAux(const InputParameters & parameters) 39 : : AuxKernel(parameters), 40 46 : _use_normal(getParam<MooseEnum>("component") == "normal"), 41 46 : _component(getParam<MooseEnum>("component")), 42 46 : _advected_quantity(getFunctor<Real>("advected_variable")), 43 46 : _normals(_assembly.normals()), 44 46 : _vel_x(getFunctor<Real>("vel_x")), 45 46 : _vel_y(_mesh.dimension() >= 2 ? &getFunctor<Real>("vel_y") : nullptr), 46 46 : _vel_z(_mesh.dimension() == 3 ? &getFunctor<Real>("vel_z") : nullptr), 47 46 : _advected_quantity_supplied(parameters.isParamSetByUser("advected_variable")), 48 46 : _advected_mat_prop_supplied(parameters.isParamSetByUser("advected_mat_prop")), 49 92 : _advected_material_property(getMaterialProperty<Real>("advected_mat_prop")) 50 : { 51 46 : if (_use_normal && !isParamValid("boundary")) 52 0 : paramError("boundary", "A boundary must be provided if using the normal component!"); 53 46 : if (_advected_quantity_supplied && _advected_mat_prop_supplied) 54 0 : mooseError("AdvectiveFluxAux should be provided either an advected variable " 55 : "or an advected material property"); 56 46 : if (dynamic_cast<MooseVariableFV<Real> *>(&_var)) 57 4 : mooseError("AdvectiveFluxAux is designed for use in finite element simulations."); 58 42 : } 59 : 60 : Real 61 1816 : AdvectiveFluxAux::computeValue() 62 : { 63 : using MetaPhysicL::raw_value; 64 : 65 : const Moose::ElemSideQpArg side_arg = { 66 1816 : _current_elem, _current_side, _qp, _qrule, isNodal() ? Point(*_current_node) : _q_point[_qp]}; 67 1816 : const auto state = determineState(); 68 1816 : Real vel_x, vel_y, vel_z = 0; 69 : 70 1816 : vel_x = raw_value(_vel_x(side_arg, state)); 71 1816 : vel_y = _vel_y ? raw_value((*_vel_y)(side_arg, state)) : 0; 72 1816 : vel_z = _vel_z ? raw_value((*_vel_z)(side_arg, state)) : 0; 73 : 74 1816 : if (_advected_quantity_supplied) 75 280 : return (_use_normal ? _advected_quantity(side_arg, state) * 76 0 : RealVectorValue(vel_x, vel_y, vel_z) * _normals[_qp] 77 280 : : _advected_quantity(side_arg, state) * 78 280 : RealVectorValue(vel_x, vel_y, vel_z)(_component)); 79 1536 : else if (_advected_mat_prop_supplied) 80 2304 : return (_use_normal ? _advected_material_property[_qp] * RealVectorValue(vel_x, vel_y, vel_z) * 81 768 : _normals[_qp] 82 768 : : _advected_material_property[_qp] * 83 1536 : RealVectorValue(vel_x, vel_y, vel_z)(_component)); 84 : else 85 0 : return (_use_normal ? RealVectorValue(vel_x, vel_y, vel_z) * _normals[_qp] 86 0 : : RealVectorValue(vel_x, vel_y, vel_z)(_component)); 87 : }