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 | Copyright (C) 2015 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "surfaceFields.H"
27 #include "syncTools.H"
28 
29 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
30 
31 template <class Type>
32 void Foam::pressurePIDControlInletVelocityFvPatchVectorField::faceZoneAverage
33 (
34  const word& name,
35  const GeometricField<Type, fvsPatchField, surfaceMesh>& field,
36  scalar& area,
37  Type& average
38 ) const
39 {
40  const fvMesh& mesh(patch().boundaryMesh().mesh());
41 
42  PackedBoolList isMasterFace(syncTools::getInternalOrMasterFaces(mesh));
43 
44  const faceZone& zone = mesh.faceZones()[name];
45 
46  area = 0;
47  average = pTraits<Type>::zero;
48 
49  forAll(zone, faceI)
50  {
51  const label f(zone[faceI]);
52 
53  if (mesh.isInternalFace(f))
54  {
55  const scalar da(mesh.magSf()[f]);
56 
57  area += da;
58  average += da*field[f];
59  }
60  else if (isMasterFace[f])
61  {
62  const label bf(f-mesh.nInternalFaces());
63  const label patchID = mesh.boundaryMesh().patchID()[bf];
64  const label lf(mesh.boundaryMesh()[patchID].whichFace(f));
65  const scalar da(mesh.magSf().boundaryField()[patchID][lf]);
66 
67  area += da;
68  average += da*field.boundaryField()[patchID][lf];
69  }
70  }
71 
72  reduce(area, sumOp<scalar>());
73  reduce(average, sumOp<Type>());
74 
75  average /= area;
76 }
77 
78 
79 // ************************************************************************* //
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
surfaceFields.H
Foam::surfaceFields.
Foam::fvc::average
tmp< GeometricField< Type, fvPatchField, volMesh > > average(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Area-weighted average a surfaceField creating a volField.
Definition: fvcAverage.C:46
syncTools.H
Foam::reduce
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Definition: PstreamReduceOps.H:43
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
f
labelList f(nPoints)
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47