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 "PINSFVSpeedFunctorMaterial.h" 11 : #include "NS.h" 12 : #include "NavierStokesMethods.h" 13 : 14 : registerMooseObject("NavierStokesApp", PINSFVSpeedFunctorMaterial); 15 : 16 : InputParameters 17 3065 : PINSFVSpeedFunctorMaterial::validParams() 18 : { 19 3065 : InputParameters params = FunctorMaterial::validParams(); 20 3065 : params.addClassDescription("This is the material class used to compute the interstitial velocity" 21 : " norm for the incompressible and weakly compressible primitive " 22 : "superficial finite-volume implementation of porous media equations."); 23 : 24 3065 : params.addRequiredParam<MooseFunctorName>(NS::porosity, "porosity"); 25 3065 : params.addParam<MooseFunctorName>( 26 3065 : NS::superficial_velocity_x, 0, "The x component of the fluid superficial velocity variable."); 27 3065 : params.addParam<MooseFunctorName>( 28 3065 : NS::superficial_velocity_y, 0, "The y component of the fluid superficial velocity variable."); 29 3065 : params.addParam<MooseFunctorName>( 30 3065 : NS::superficial_velocity_z, 0, "The z component of the fluid superficial velocity variable."); 31 15325 : auto add_property = [¶ms](const auto & property_name) 32 : { 33 30650 : params.addParam<MooseFunctorName>(property_name, 34 : property_name, 35 : "The name to give the declared '" + property_name + 36 : "' functor property"); 37 15325 : }; 38 3065 : add_property(NS::velocity); 39 3065 : add_property(NS::speed); 40 3065 : add_property(NS::velocity_x); 41 3065 : add_property(NS::velocity_y); 42 3065 : add_property(NS::velocity_z); 43 6130 : params.addParam<bool>("define_interstitial_velocity_components", 44 6130 : true, 45 : "Whether to define the interstitial velocity functors"); 46 : 47 3065 : return params; 48 0 : } 49 : 50 1609 : PINSFVSpeedFunctorMaterial::PINSFVSpeedFunctorMaterial(const InputParameters & parameters) 51 : : FunctorMaterial(parameters), 52 1609 : _eps(getFunctor<ADReal>(NS::porosity)), 53 1609 : _superficial_vel_x(getFunctor<ADReal>(NS::superficial_velocity_x)), 54 1609 : _superficial_vel_y(getFunctor<ADReal>(NS::superficial_velocity_y)), 55 1609 : _superficial_vel_z(getFunctor<ADReal>(NS::superficial_velocity_z)) 56 : { 57 : // Check dimension of the mesh 58 : const unsigned int num_components_specified = 59 1609 : parameters.isParamSetByUser(NS::superficial_velocity_x) + 60 1609 : parameters.isParamSetByUser(NS::superficial_velocity_y) + 61 1609 : parameters.isParamSetByUser(NS::superficial_velocity_z); 62 1609 : if (num_components_specified != blocksMaxDimension()) 63 0 : mooseError("Only ", 64 : num_components_specified, 65 : " superficial velocity components were provided for a mesh of dimension ", 66 0 : blocksMaxDimension()); 67 : 68 : // Interstitial velocity is needed by certain correlations 69 4827 : const auto & interstitial_velocity = addFunctorProperty<ADRealVectorValue>( 70 : getParam<MooseFunctorName>(NS::velocity), 71 30111970 : [this](const auto & r, const auto & t) -> ADRealVectorValue 72 : { 73 120447880 : return ADRealVectorValue( 74 30111970 : _superficial_vel_x(r, t), _superficial_vel_y(r, t), _superficial_vel_z(r, t)) / 75 60223940 : _eps(r, t); 76 : }); 77 : 78 : // Speed is normal of regular interstitial velocity 79 : // This is needed to compute the Reynolds number 80 4827 : addFunctorProperty<ADReal>(getParam<MooseFunctorName>(NS::speed), 81 29593170 : [&interstitial_velocity](const auto & r, const auto & t) -> ADReal 82 29593170 : { return NS::computeSpeed<ADReal>(interstitial_velocity(r, t)); }); 83 : 84 : // This is not needed for non-porous media, but they can use the 'speed' functor for some friction 85 : // models 86 3218 : if (getParam<bool>("define_interstitial_velocity_components")) 87 : { 88 4695 : addFunctorProperty<ADReal>(getParam<MooseFunctorName>(NS::velocity_x), 89 254000 : [&interstitial_velocity](const auto & r, const auto & t) -> ADReal 90 254000 : { return interstitial_velocity(r, t)(0); }); 91 4695 : addFunctorProperty<ADReal>(getParam<MooseFunctorName>(NS::velocity_y), 92 254000 : [&interstitial_velocity](const auto & r, const auto & t) -> ADReal 93 254000 : { return interstitial_velocity(r, t)(1); }); 94 4695 : addFunctorProperty<ADReal>(getParam<MooseFunctorName>(NS::velocity_z), 95 0 : [&interstitial_velocity](const auto & r, const auto & t) -> ADReal 96 0 : { return interstitial_velocity(r, t)(2); }); 97 : } 98 9522 : }