pressurePIDControlInletVelocityFvPatchVectorFieldTemplates.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) 2015 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "surfaceFields.H"
29#include "syncTools.H"
30
31// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
32
33template <class Type>
34void Foam::pressurePIDControlInletVelocityFvPatchVectorField::faceZoneAverage
35(
36 const word& name,
37 const GeometricField<Type, fvsPatchField, surfaceMesh>& field,
38 scalar& area,
39 Type& average
40) const
41{
42 const fvMesh& mesh(patch().boundaryMesh().mesh());
43
44 bitSet isMasterFace(syncTools::getInternalOrMasterFaces(mesh));
45
46 const faceZone& zone = mesh.faceZones()[name];
47
48 area = 0;
49 average = Type(Zero);
50
51 forAll(zone, faceI)
52 {
53 const label f(zone[faceI]);
54
56 {
57 const scalar da(mesh.magSf()[f]);
58
59 area += da;
60 average += da*field[f];
61 }
62 else if (isMasterFace[f])
63 {
64 const label bf(f-mesh.nInternalFaces());
65 const label patchID = mesh.boundaryMesh().patchID()[bf];
66 const label lf(mesh.boundaryMesh()[patchID].whichFace(f));
67 const scalar da(mesh.magSf().boundaryField()[patchID][lf]);
68
69 area += da;
70 average += da*field.boundaryField()[patchID][lf];
71 }
72 }
73
74 reduce(area, sumOp<scalar>());
75 reduce(average, sumOp<Type>());
76
77 average /= area;
78}
79
80
81// ************************************************************************* //
const Boundary & boundaryField() const
Return const-reference to the boundary field.
const surfaceScalarField & magSf() const
Return cell face area magnitudes.
const labelList & patchID() const
Per boundary face label the patch index.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
Definition: polyMesh.H:498
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:456
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
label nInternalFaces() const noexcept
Number of internal faces.
static bitSet getInternalOrMasterFaces(const polyMesh &mesh)
Definition: syncTools.C:148
rDeltaTY field()
dynamicFvMesh & mesh
const wordList area
Standard area field types (scalar, vector, tensor, etc)
const std::string patch
OpenFOAM patch number as a std::string.
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
labelList f(nPoints)
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
Foam::surfaceFields.