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 -------------------------------------------------------------------------------
10 License
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 
33 template <class Type>
34 void 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 
55  if (mesh.isInternalFace(f))
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 // ************************************************************************* //
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
surfaceFields.H
Foam::surfaceFields.
syncTools.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::reduce
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Definition: PstreamReduceOps.H:51
Foam::fac::average
tmp< GeometricField< Type, faPatchField, areaMesh > > average(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Area-weighted average a edgeField creating a areaField.
Definition: facAverage.C:47
patchID
label patchID
Definition: boundaryProcessorFaPatchPoints.H:5
field
rDeltaTY field()
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
f
labelList f(nPoints)
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::fieldTypes::area
const wordList area
Standard area field types (scalar, vector, tensor, etc)
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::average
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:328
Foam::syncTools::getInternalOrMasterFaces
static bitSet getInternalOrMasterFaces(const polyMesh &mesh)
Definition: syncTools.C:148