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 "WCNSFVScalarFluxBC.h" 11 : #include "NS.h" 12 : 13 : registerMooseObject("NavierStokesApp", WCNSFVScalarFluxBC); 14 : 15 : InputParameters 16 293 : WCNSFVScalarFluxBC::validParams() 17 : { 18 293 : InputParameters params = WCNSFVFluxBCBase::validParams(); 19 293 : params.addClassDescription("Flux boundary conditions for scalar quantity advection."); 20 : 21 : // Two different ways to input an advected scalar flux: 22 : // 1) Postprocessor with the scalar flow rate directly 23 : // 2) Postprocessors for inlet velocity and scalar concentration 24 586 : params.addParam<PostprocessorName>("scalar_flux_pp", 25 : "Postprocessor with the inlet scalar flow rate"); 26 586 : params.addParam<PostprocessorName>("scalar_value_pp", 27 : "Postprocessor with the inlet scalar concentration"); 28 586 : params.addRequiredParam<MooseFunctorName>("passive_scalar", "passive scalar functor"); 29 293 : return params; 30 0 : } 31 : 32 166 : WCNSFVScalarFluxBC::WCNSFVScalarFluxBC(const InputParameters & params) 33 : : WCNSFVFluxBCBase(params), 34 312 : _scalar_value_pp(isParamValid("scalar_value_pp") ? &getPostprocessorValue("scalar_value_pp") 35 : : nullptr), 36 342 : _scalar_flux_pp(isParamValid("scalar_flux_pp") ? &getPostprocessorValue("scalar_flux_pp") 37 : : nullptr), 38 494 : _passive_scalar(getFunctor<ADReal>("passive_scalar")) 39 : { 40 : // Density is often set as global parameters so it is not checked 41 164 : if (_scalar_flux_pp && (_velocity_pp || _mdot_pp || _scalar_value_pp)) 42 2 : mooseWarning( 43 : "If setting the scalar flux directly, no need for inlet velocity, mass flow or scalar " 44 : "concentration"); 45 : 46 : // Need enough information if trying to use a mass flow rate postprocessor 47 162 : if (!_scalar_flux_pp) 48 : { 49 150 : if (!_scalar_value_pp) 50 2 : mooseError("If not providing the scalar flow rate, the inlet scalar concentration should be " 51 : "provided"); 52 148 : if (!_velocity_pp && !_mdot_pp) 53 2 : mooseError("If not providing the scalar flow rate, the inlet velocity or mass flow " 54 : "should be provided"); 55 146 : if (_mdot_pp && !_area_pp) 56 2 : mooseError("If providing the inlet mass flow rate, the inlet flow " 57 : "area should be provided as well"); 58 : } 59 12 : else if (!_area_pp) 60 0 : paramError("scalar_flux_pp", 61 : "If supplying the energy flow rate, the flow area should be provided as well"); 62 156 : } 63 : 64 : ADReal 65 7616 : WCNSFVScalarFluxBC::computeQpResidual() 66 : { 67 7616 : const auto state = determineState(); 68 : 69 7616 : if (!isInflow()) 70 1158 : return varVelocity(state) * _normal * _passive_scalar(singleSidedFaceArg(), state); 71 7037 : else if (_scalar_flux_pp) 72 1075 : return -_scaling_factor * *_scalar_flux_pp / *_area_pp; 73 : 74 11921 : return -_scaling_factor * inflowSpeed(state) * (*_scalar_value_pp); 75 : } 76 : 77 : bool 78 7616 : WCNSFVScalarFluxBC::isInflow() const 79 : { 80 7616 : if (_mdot_pp) 81 4508 : return *_mdot_pp >= 0; 82 3108 : else if (_velocity_pp) 83 2033 : return *_velocity_pp >= 0; 84 1075 : else if (_scalar_flux_pp) 85 1075 : return *_scalar_flux_pp >= 0; 86 : 87 0 : mooseError( 88 : "Either mdot_pp or velocity_pp or scalar_flux_pp need to be provided OR this function " 89 : "must be overridden in derived classes if other input parameter combinations are valid. " 90 : "Neither mdot_pp nor velocity_pp are provided."); 91 : return true; 92 : }