https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NSFVPumpFunctorMaterial.C
Go to the documentation of this file.
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
11#include "NS.h"
12#include "Function.h"
13
16 NSFVPumpMaterial,
17 "08/01/2024 00:00",
19
22{
24 params.addClassDescription("Computes the effective pump body force.");
25 params.addParam<MooseFunctorName>(
26 "pump_force_name", "pump_volume_force", "Name of the pump force functor.");
27 params.addParam<FunctionName>("pressure_head_function", "Pressure Head Function.");
28 params.addParam<MooseFunctorName>("area_rated", 1.0, "Rated area of the pump.");
29 params.addParam<MooseFunctorName>("volume_rated", 1.0, "Rated volume of the pump.");
30 params.addRequiredParam<MooseFunctorName>(NS::density, "Density.");
31 params.addRequiredParam<MooseFunctorName>(NS::speed, "Flow speed.");
32 params.addParam<Real>("flow_rate_rated", 1.0, "Rated flow rate.");
33 params.addParam<PostprocessorName>("flow_rate", 1.0, "Flow rate.");
34 params.addParam<RealVectorValue>(
35 "gravity", RealVectorValue(0, -9.81, 0), "The gravitational acceleration vector.");
36 params.addParam<Real>("rotation_speed_rated", 1.0, "The rated rotation speed of the pump.");
37 params.addParam<Real>("rotation_speed", 1.0, "The rotation speed of the pump.");
38 params.addParam<bool>(
39 "enable_negative_rotation", false, "Flag to allow negative rotation speeds.");
40 params.addParam<bool>("symmetric_negative_pressure_head",
41 true,
42 "Flag to use the pressure head function in the negative direction than the "
43 "one in the positive direction.");
44 params.addParam<FunctionName>("pressure_head_function_negative_rotation",
45 "Pressure head function for negative rotation.");
46 params.declareControllable("rotation_speed");
47 return params;
48}
49
51 : FunctorMaterial(parameters),
52 _pressure_head_function(
53 isParamValid("pressure_head_function") ? &getFunction("pressure_head_function") : nullptr),
54 _area_rated(getFunctor<Real>("area_rated")),
55 _volume_rated(getFunctor<Real>("volume_rated")),
56 _rho(getFunctor<ADReal>(NS::density)),
57 _speed(getFunctor<ADReal>(NS::speed)),
58 _flow_rate_rated(getParam<Real>("flow_rate_rated")),
59 _flow_rate(getPostprocessorValue("flow_rate")),
60 _gravity(getParam<RealVectorValue>("gravity")),
61 _rotation_speed_rated(getParam<Real>("rotation_speed_rated")),
62 _rotation_speed(getParam<Real>("rotation_speed")),
63 _flow_rate_scaling_bool(isParamSetByUser("flow_rate_rated")),
64 _bool_negative_rotation_speed(getParam<bool>("enable_negative_rotation")),
65 _bool_symmetric_negative_pressure_head(getParam<bool>("symmetric_negative_pressure_head")),
66 _pressure_head_function_negative_rotation(
67 isParamValid("pressure_head_function_negative_rotation")
68 ? &getFunction("pressure_head_function_negative_rotation")
69 : nullptr)
70{
71 // Error checks
73 paramError("pressure_head_function",
74 "Pressure head function should be provided. If negative rotation is used "
75 "'pressure_head_function_negative_rotation' should be provided.");
76
78 paramError("rotation_speed",
79 "The rotation speed must be positive if 'enable_negative_rotation' is not true.");
80
83 "pressure_head_function_negative_rotation",
84 "The negative pressure head won't be used if 'enable_negative_rotation' is not true.");
85
87 paramError("pressure_head_function_negative_rotation",
88 "Negative pressure head function should be provided if "
89 "'symmetric_negative_pressure_head' is false.");
90
91 addFunctorProperty<Real>(
92 getParam<MooseFunctorName>("pump_force_name"),
93 [this](const auto & r, const auto & t) -> Real
94 {
95 // Getting rated pressure head
96 const Point ref_pressure_point(0.0, 0.0, 0.0);
97 Real rated_pressure_head;
99 rated_pressure_head =
100 (*_pressure_head_function).value(std::abs(_flow_rate), ref_pressure_point);
101 else
102 rated_pressure_head = -(*_pressure_head_function_negative_rotation)
103 .value(std::abs(_flow_rate), ref_pressure_point);
104
105 // Scaling pressure head
106 const auto flow_rate_scaling =
107 _flow_rate_scaling_bool ? std::sqrt(std::abs(_flow_rate) / _flow_rate_rated) : 1.0;
108 const auto rotation_speed_scaling = std::abs(_rotation_speed) / _rotation_speed_rated;
109 const auto pressure_head =
110 rated_pressure_head * std::pow(flow_rate_scaling * rotation_speed_scaling, 4.0 / 3.0);
111
112 // Computing effective volume force
113 mooseAssert(_rho.isConstant(),
114 "The density must be a constant in order for the pump force to not contain "
115 "derivative information.");
116 const auto rho = raw_value(_rho(r, t));
117 const Real gravity = _gravity.norm();
118 const auto area = _area_rated(r, t);
119 const auto volume = _volume_rated(r, t);
120 return -rho * gravity * pressure_head * area / volume;
121 });
122
123 const auto & mesh_blocks = _subproblem.mesh().meshSubdomains();
124 const auto & pump_blocks = blockIDs();
125 std::set<SubdomainID> missing_blocks;
126
127 std::set_difference(mesh_blocks.begin(),
128 mesh_blocks.end(),
129 pump_blocks.begin(),
130 pump_blocks.end(),
131 std::inserter(missing_blocks, missing_blocks.begin()));
132
133 if (missing_blocks.size() >= 1 && *(pump_blocks.begin()) != Moose::ANY_BLOCK_ID)
134 {
136 getParam<MooseFunctorName>("pump_force_name"),
137 [](const auto &, const auto &) -> Real { return 0.0; },
138 std::set<ExecFlagType>({EXEC_ALWAYS}),
140 missing_blocks,
141 _tid);
142 }
143}
DualNumber< Real, DNDerivativeType, true > ADReal
const double rho
const ExecFlagType EXEC_ALWAYS
registerMooseObjectRenamed("NavierStokesApp", NSFVPumpMaterial, "08/01/2024 00:00", NSFVPumpFunctorMaterial)
registerMooseObject("NavierStokesApp", NSFVPumpFunctorMaterial)
virtual const std::set< SubdomainID > & blockIDs() const
static InputParameters validParams()
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
THREAD_ID _tid
SubProblem & _subproblem
void paramError(const std::string &param, Args... args) const
const std::set< SubdomainID > & meshSubdomains() const
Computes the effective pump body force as a functor.
const bool _bool_symmetric_negative_pressure_head
Symmetric pressure head function in the negative direction.
const Function *const _pressure_head_function
Function providing the pressure head The pressure head should be provided as head (in meters) vs.
const Real & _flow_rate_rated
Rated flow rate.
const Moose::Functor< ADReal > & _rho
Density.
const Real & _rotation_speed
Actual Rotation Speed.
static InputParameters validParams()
NSFVPumpFunctorMaterial(const InputParameters &parameters)
const bool _flow_rate_scaling_bool
Boolean to determine if flow rate scaling is necessary.
const Function *const _pressure_head_function_negative_rotation
Homologous pressure head function in the negative direction (in meters) vs. flow rate (in m3/s)
const RealVectorValue & _gravity
Gravity.
const Moose::Functor< Real > & _volume_rated
Rated volume of the pump.
const Moose::Functor< Real > & _area_rated
Rated transversal area of the pump.
const Real & _rotation_speed_rated
Rated Rotation Speed.
const PostprocessorValue & _flow_rate
Actual flow rate.
const bool _bool_negative_rotation_speed
Allow negative rotation speed.
virtual MooseMesh & mesh()=0
const Moose::FunctorBase< T > & addPiecewiseByBlockLambdaFunctor(const std::string &name, PolymorphicLambda my_lammy, const std::set< ExecFlagType > &clearance_schedule, const MooseMesh &mesh, const std::set< SubdomainID > &block_ids, const THREAD_ID tid)
const SubdomainID ANY_BLOCK_ID
static const std::string density
Definition NS.h:34
static const std::string speed
Definition NS.h:147