extendedCellToFaceStencil.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-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 
29 #include "globalIndex.H"
30 #include "syncTools.H"
31 
32 /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(extendedCellToFaceStencil, 0);
37 }
38 
39 
40 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
41 
43 (
44  Ostream& os,
45  const labelListList& stencil,
46  const mapDistribute& map
47 )
48 {
49  label sumSize = 0;
50  label nSum = 0;
51  label minSize = labelMax;
52  label maxSize = labelMin;
53 
54  forAll(stencil, i)
55  {
56  const labelList& sCells = stencil[i];
57 
58  if (sCells.size() > 0)
59  {
60  sumSize += sCells.size();
61  nSum++;
62  minSize = min(minSize, sCells.size());
63  maxSize = max(maxSize, sCells.size());
64  }
65  }
66  reduce(sumSize, sumOp<label>());
67  reduce(nSum, sumOp<label>());
68 
69  reduce(minSize, minOp<label>());
70  reduce(maxSize, maxOp<label>());
71 
72  os << "Stencil size :" << nl
73  << " average : " << scalar(sumSize)/nSum << nl
74  << " min : " << minSize << nl
75  << " max : " << maxSize << nl
76  << endl;
77 
78  // Sum all sent data
79  label nSent = 0;
80  label nLocal = 0;
81  forAll(map.subMap(), proci)
82  {
83  if (proci != Pstream::myProcNo())
84  {
85  nSent += map.subMap()[proci].size();
86  }
87  else
88  {
89  nLocal += map.subMap()[proci].size();
90  }
91  }
92 
93  os << "Local data size : " << returnReduce(nLocal, sumOp<label>()) << nl
94  << "Sent data size : " << returnReduce(nSent, sumOp<label>()) << nl
95  << endl;
96 }
97 
98 
99 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
100 
102 :
103  mesh_(mesh)
104 {
105  // Check for transformation - not supported.
106  const polyBoundaryMesh& patches = mesh.boundaryMesh();
107 
108  forAll(patches, patchi)
109  {
110  if (patches[patchi].coupled())
111  {
112  const coupledPolyPatch& cpp =
113  refCast<const coupledPolyPatch>(patches[patchi]);
114 
115  if (!cpp.parallel() || cpp.separated())
116  {
118  << "Coupled patches with transformations not supported."
119  << endl
120  << "Problematic patch " << cpp.name() << exit(FatalError);
121  }
122  }
123  }
124 }
125 
126 
127 // ************************************************************************* //
Foam::mapDistributeBase::subMap
const labelListList & subMap() const
From subsetted data back to original data.
Definition: mapDistributeBase.H:289
extendedCellToFaceStencil.H
Foam::maxOp
Definition: ops.H:223
Foam::labelMax
constexpr label labelMax
Definition: label.H:61
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:94
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:63
Foam::extendedCellToFaceStencil::extendedCellToFaceStencil
extendedCellToFaceStencil(const polyMesh &)
Construct from mesh.
Definition: extendedCellToFaceStencil.C:101
Foam::minOp
Definition: ops.H:224
globalIndex.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::coupledPolyPatch
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
Definition: coupledPolyPatch.H:54
syncTools.H
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::sumOp
Definition: ops.H:213
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::coupledPolyPatch::parallel
virtual bool parallel() const
Are the cyclic planes parallel.
Definition: coupledPolyPatch.H:295
Foam::coupledPolyPatch::separated
virtual bool separated() const
Are the planes separated.
Definition: coupledPolyPatch.H:283
Foam::mapDistribute
Class containing processor-to-processor mapping information.
Definition: mapDistribute.H:163
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::FatalError
error FatalError
reduce
reduce(hasMovingMesh, orOp< bool >())
os
OBJstream os(runTime.globalPath()/outputName)
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::List< labelList >
Foam::extendedCellToFaceStencil::writeStencilStats
static void writeStencilStats(Ostream &os, const labelListList &stencil, const mapDistribute &map)
Write some statistics about stencil.
Definition: extendedCellToFaceStencil.C:43
patches
const polyBoundaryMesh & patches
Definition: convertProcessorPatches.H:65
Foam::labelMin
constexpr label labelMin
Definition: label.H:60
Foam::patchIdentifier::name
const word & name() const noexcept
The patch name.
Definition: patchIdentifier.H:135
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
coupled
bool coupled(solutionDict.getOrDefault("coupledEnergyField", false))
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)