patchMeanVelocityForce.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-2016 OpenFOAM Foundation
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 "patchMeanVelocityForce.H"
31 
32 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace fv
37 {
38  defineTypeNameAndDebug(patchMeanVelocityForce, 0);
39  addToRunTimeSelectionTable(option, patchMeanVelocityForce, dictionary);
40 }
41 }
42 
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
46 Foam::fv::patchMeanVelocityForce::patchMeanVelocityForce
47 (
48  const word& sourceName,
49  const word& modelType,
50  const dictionary& dict,
51  const fvMesh& mesh
52 )
53 :
54  meanVelocityForce(sourceName, modelType, dict, mesh),
55  patch_(coeffs_.get<word>("patch")),
56  patchi_(mesh.boundaryMesh().findPatchID(patch_))
57 {
58  if (patchi_ < 0)
59  {
61  << "Cannot find patch " << patch_
62  << exit(FatalIOError);
63  }
64 }
65 
66 
67 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
68 
69 Foam::scalar Foam::fv::patchMeanVelocityForce::magUbarAve
70 (
71  const volVectorField& U
72 ) const
73 {
74  vector2D sumAmagUsumA
75  (
76  sum
77  (
78  (flowDir_ & U.boundaryField()[patchi_])
79  *mesh_.boundary()[patchi_].magSf()
80  ),
81  sum(mesh_.boundary()[patchi_].magSf())
82  );
83 
84 
85  // If the mean velocity force is applied to a cyclic patch
86  // for parallel runs include contributions from processorCyclic patches
87  // generated from the decomposition of the cyclic patch
88  const polyBoundaryMesh& patches = mesh_.boundaryMesh();
89 
90  if (Pstream::parRun() && isA<cyclicPolyPatch>(patches[patchi_]))
91  {
92  labelList processorCyclicPatches
93  (
95  );
96 
97  forAll(processorCyclicPatches, pcpi)
98  {
99  const label patchi = processorCyclicPatches[pcpi];
100 
101  sumAmagUsumA.x() +=
102  sum
103  (
104  (flowDir_ & U.boundaryField()[patchi])
105  *mesh_.boundary()[patchi].magSf()
106  );
107 
108  sumAmagUsumA.y() += sum(mesh_.boundary()[patchi].magSf());
109  }
110  }
111 
112  mesh_.reduce(sumAmagUsumA, sumOp<vector2D>());
113 
114  return sumAmagUsumA.x()/sumAmagUsumA.y();
115 }
116 
117 
118 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:63
patchMeanVelocityForce.H
Foam::FatalIOError
IOerror FatalIOError
processorCyclicPolyPatch.H
forAll
#define forAll(list, i)
Definition: stdFoam.H:349
dict
dictionary dict
Definition: searchingEngine.H:14
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Definition: atmBoundaryLayer.C:26
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
Foam::volVectorField
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:58
fv
labelList fv(nPoints)
U
U
Definition: pEqn.H:72
Foam::processorCyclicPolyPatch::patchIDs
static labelList patchIDs(const word &cyclicPolyPatchName, const polyBoundaryMesh &bm)
Definition: processorCyclicPolyPatch.C:170
Foam::vector2D
Vector2D< scalar > vector2D
A 2D vector of scalars obtained from the generic Vector2D.
Definition: vector2D.H:47
Foam::UPstream::parRun
static bool & parRun() noexcept
Definition: UPstream.H:429
Foam::sum
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:320
patches
const polyBoundaryMesh & patches
Definition: convertProcessorPatches.H:59
Foam::PtrListOps::get
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
Foam::fv::defineTypeNameAndDebug
defineTypeNameAndDebug(atmAmbientTurbSource, 0)
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Definition: error.H:494
Foam::fv::addToRunTimeSelectionTable
addToRunTimeSelectionTable(option, atmAmbientTurbSource, dictionary)