fanFvPatchFields.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2017-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "fanFvPatchFields.H"
31 #include "volFields.H"
32 #include "surfaceFields.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38  makePatchFieldType(scalar, fan);
39 }
40 
41 
42 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
43 
44 template<>
46 {
47  if (this->cyclicPatch().owner())
48  {
49  const auto& phip =
50  patch().lookupPatchField<surfaceScalarField>(phiName_);
51 
52  scalarField Un(max(phip/patch().magSf(), scalar(0)));
53 
54  // The non-dimensional parameters
55 
56  scalar rpm(0);
57  scalar meanDiam(0);
58 
59  if (nonDimensional_)
60  {
61  rpm = rpm_->value(this->db().time().timeOutputValue());
62  meanDiam = dm_->value(this->db().time().timeOutputValue());
63  }
64 
65  if (uniformJump_)
66  {
67  const scalar area = gSum(patch().magSf());
68  Un = gSum(Un*patch().magSf())/area;
69 
70  if (nonDimensional_)
71  {
72  // Create an non-dimensional velocity
73  Un =
74  (
75  120.0*Un
76  / stabilise
77  (
78  pow3(constant::mathematical::pi) * meanDiam * rpm,
79  VSMALL
80  )
81  );
82  }
83  }
84 
85  if (phip.internalField().dimensions() == dimMass/dimTime)
86  {
87  Un /= patch().lookupPatchField<volScalarField>(rhoName_);
88  }
89 
90  if (nonDimensional_)
91  {
92  scalarField deltap(this->jumpTable_->value(Un));
93 
94  // Convert non-dimensional deltap from curve into deltaP
95  scalarField pdFan
96  (
98  * sqr(meanDiam*rpm)/1800.0
99  );
100 
101  this->setJump(pdFan);
102  }
103  else
104  {
105  this->setJump(jumpTable_->value(Un));
106  }
107 
108  this->relax();
109  }
110 }
111 
112 
113 // ************************************************************************* //
Foam::surfaceFields.
UEqn relax()
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedScalar stabilise(const dimensionedScalar &x, const dimensionedScalar &y)
Macros for easy insertion into run-time selection tables.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:81
This boundary condition provides a jump condition, using the cyclic condition as a base...
Type gSum(const FieldField< Field, Type > &f)
const wordList area
Standard area field types (scalar, vector, tensor, etc)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
constexpr scalar pi(M_PI)
dimensionedScalar pow3(const dimensionedScalar &ds)
dimensionedScalar pow4(const dimensionedScalar &ds)
const std::string patch
OpenFOAM patch number as a std::string.
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:49
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
makePatchFieldType(scalar, fan)
Namespace for OpenFOAM.