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 "RhieChowInterpolatorBase.h" 11 : #include "INSFVAttributes.h" 12 : #include "GatherRCDataElementThread.h" 13 : #include "GatherRCDataFaceThread.h" 14 : #include "SubProblem.h" 15 : #include "MooseMesh.h" 16 : #include "SystemBase.h" 17 : #include "NS.h" 18 : #include "Assembly.h" 19 : #include "INSFVVelocityVariable.h" 20 : #include "INSFVPressureVariable.h" 21 : #include "PiecewiseByBlockLambdaFunctor.h" 22 : #include "VectorCompositeFunctor.h" 23 : #include "FVElementalKernel.h" 24 : 25 : using namespace libMesh; 26 : 27 : InputParameters 28 9432 : RhieChowInterpolatorBase::validParams() 29 : { 30 9432 : auto params = RhieChowFaceFluxProvider::validParams(); 31 9432 : params += TaggingInterface::validParams(); 32 9432 : params += ADFunctorInterface::validParams(); 33 : 34 9432 : params.addClassDescription( 35 : "Computes the Rhie-Chow velocity based on gathered 'a' coefficient data."); 36 : 37 : // Avoid uninitialized residual objects 38 9432 : params.suppressParameter<bool>("force_preic"); 39 : 40 9432 : params.addRequiredParam<VariableName>(NS::pressure, "The pressure variable."); 41 18864 : params.addRequiredParam<VariableName>("u", "The x-component of velocity"); 42 18864 : params.addParam<VariableName>("v", "The y-component of velocity"); 43 18864 : params.addParam<VariableName>("w", "The z-component of velocity"); 44 : 45 18864 : MooseEnum velocity_interp_method("average rc", "rc"); 46 18864 : params.addParam<MooseEnum>( 47 : "velocity_interp_method", 48 : velocity_interp_method, 49 : "The interpolation to use for the velocity. Options are " 50 : "'average' and 'rc' which stands for Rhie-Chow. The default is Rhie-Chow."); 51 : 52 9432 : return params; 53 9432 : } 54 : 55 4720 : RhieChowInterpolatorBase::RhieChowInterpolatorBase(const InputParameters & params) 56 : : RhieChowFaceFluxProvider(params), 57 : TaggingInterface(this), 58 : ADFunctorInterface(this), 59 9440 : _moose_mesh(UserObject::_subproblem.mesh()), 60 4720 : _mesh(_moose_mesh.getMesh()), 61 4720 : _dim(blocksMaxDimension()), 62 4720 : _p(dynamic_cast<INSFVPressureVariable *>( 63 4720 : &UserObject::_subproblem.getVariable(0, getParam<VariableName>(NS::pressure)))), 64 4720 : _u(dynamic_cast<INSFVVelocityVariable *>( 65 9440 : &UserObject::_subproblem.getVariable(0, getParam<VariableName>("u")))), 66 13756 : _v(isParamValid("v") ? dynamic_cast<INSFVVelocityVariable *>( 67 17668 : &UserObject::_subproblem.getVariable(0, getParam<VariableName>("v"))) 68 : : nullptr), 69 9494 : _w(isParamValid("w") ? dynamic_cast<INSFVVelocityVariable *>( 70 4882 : &UserObject::_subproblem.getVariable(0, getParam<VariableName>("w"))) 71 : : nullptr), 72 4720 : _ps(libMesh::n_threads(), nullptr), 73 4720 : _us(libMesh::n_threads(), nullptr), 74 4720 : _vs(libMesh::n_threads(), nullptr), 75 4720 : _ws(libMesh::n_threads(), nullptr), 76 9440 : _displaced(dynamic_cast<DisplacedProblem *>(&(UserObject::_subproblem))) 77 : { 78 4720 : if (!_p) 79 0 : paramError(NS::pressure, "the pressure must be a INSFVPressureVariable."); 80 4720 : checkBlocks(*_p); 81 : 82 4718 : if (!_u) 83 0 : paramError("u", "the u velocity must be an INSFVVelocityVariable."); 84 4718 : checkBlocks(*_u); 85 4716 : _var_numbers.push_back(_u->number()); 86 : 87 4716 : if (_dim >= 2) 88 : { 89 4312 : if (!_v) 90 0 : mooseError("In two or more dimensions, the v velocity must be supplied and it must be an " 91 : "INSFVVelocityVariable."); 92 4312 : checkBlocks(*_v); 93 4312 : _var_numbers.push_back(_v->number()); 94 : } 95 : 96 4716 : if (_dim >= 3) 97 : { 98 54 : if (!_w) 99 0 : mooseError("In three-dimensions, the w velocity must be supplied and it must be an " 100 : "INSFVVelocityVariable."); 101 54 : checkBlocks(*_w); 102 54 : _var_numbers.push_back(_w->number()); 103 : } 104 : 105 4716 : fillContainer(NS::pressure, _ps); 106 4716 : fillContainer("u", _us); 107 : 108 4716 : if (_dim >= 2) 109 : { 110 4312 : fillContainer("v", _vs); 111 4312 : if (_v->faceInterpolationMethod() != _u->faceInterpolationMethod()) 112 0 : mooseError("x and y velocity component face interpolation methods do not match"); 113 : 114 4312 : if (_dim >= 3) 115 : { 116 54 : fillContainer("w", _ws); 117 54 : if (_w->faceInterpolationMethod() != _u->faceInterpolationMethod()) 118 0 : mooseError("x and z velocity component face interpolation methods do not match"); 119 : } 120 : } 121 : 122 4716 : if (&(UserObject::_subproblem) != &(TaggingInterface::_subproblem)) 123 0 : mooseError("Different subproblems in RhieChowInterpolatorBase!"); 124 : 125 4716 : const auto & velocity_interp_method = params.get<MooseEnum>("velocity_interp_method"); 126 4716 : if (velocity_interp_method == "average") 127 11 : _velocity_interp_method = Moose::FV::InterpMethod::Average; 128 4705 : else if (velocity_interp_method == "rc") 129 4705 : _velocity_interp_method = Moose::FV::InterpMethod::RhieChow; 130 4716 : } 131 : 132 : Real 133 17926 : RhieChowInterpolatorBase::getVolumetricFaceFlux(const Moose::FV::InterpMethod m, 134 : const FaceInfo & fi, 135 : const Moose::StateArg & time, 136 : const THREAD_ID tid, 137 : bool subtract_mesh_velocity) const 138 : { 139 17926 : return raw_value(this->getVelocity(m, fi, time, tid, subtract_mesh_velocity)) * fi.normal(); 140 : }