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 #include "SortableList.H"
32 
33 /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(extendedCellToFaceStencil, 0);
38 }
39 
40 
41 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
42 
44 (
45  Ostream& os,
46  const labelListList& stencil,
47  const mapDistribute& map
48 )
49 {
50  label sumSize = 0;
51  label nSum = 0;
52  label minSize = labelMax;
53  label maxSize = labelMin;
54 
55  forAll(stencil, i)
56  {
57  const labelList& sCells = stencil[i];
58 
59  if (sCells.size() > 0)
60  {
61  sumSize += sCells.size();
62  nSum++;
63  minSize = min(minSize, sCells.size());
64  maxSize = max(maxSize, sCells.size());
65  }
66  }
67  reduce(sumSize, sumOp<label>());
68  reduce(nSum, sumOp<label>());
69 
70  reduce(minSize, minOp<label>());
71  reduce(maxSize, maxOp<label>());
72 
73  os << "Stencil size :" << nl
74  << " average : " << scalar(sumSize)/nSum << nl
75  << " min : " << minSize << nl
76  << " max : " << maxSize << nl
77  << endl;
78 
79  // Sum all sent data
80  label nSent = 0;
81  label nLocal = 0;
82  forAll(map.subMap(), proci)
83  {
84  if (proci != Pstream::myProcNo())
85  {
86  nSent += map.subMap()[proci].size();
87  }
88  else
89  {
90  nLocal += map.subMap()[proci].size();
91  }
92  }
93 
94  os << "Local data size : " << returnReduce(nLocal, sumOp<label>()) << nl
95  << "Sent data size : " << returnReduce(nSent, sumOp<label>()) << nl
96  << endl;
97 }
98 
99 
100 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
101 
103 :
104  mesh_(mesh)
105 {
106  // Check for transformation - not supported.
107  const polyBoundaryMesh& patches = mesh.boundaryMesh();
108 
109  forAll(patches, patchi)
110  {
111  if (patches[patchi].coupled())
112  {
113  const coupledPolyPatch& cpp =
114  refCast<const coupledPolyPatch>(patches[patchi]);
115 
116  if (!cpp.parallel() || cpp.separated())
117  {
119  << "Coupled patches with transformations not supported."
120  << endl
121  << "Problematic patch " << cpp.name() << exit(FatalError);
122  }
123  }
124  }
125 }
126 
127 
128 // ************************************************************************* //
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:62
Foam::extendedCellToFaceStencil::extendedCellToFaceStencil
extendedCellToFaceStencil(const polyMesh &)
Construct from mesh.
Definition: extendedCellToFaceStencil.C:102
Foam::minOp
Definition: ops.H:224
globalIndex.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::coupledPolyPatch
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
Definition: coupledPolyPatch.H:53
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:290
SortableList.H
Foam::coupledPolyPatch::separated
virtual bool separated() const
Are the planes separated.
Definition: coupledPolyPatch.H:278
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 >())
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:381
Foam::nl
constexpr char nl
Definition: Ostream.H:385
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:44
patches
const polyBoundaryMesh & patches
Definition: convertProcessorPatches.H:65
Foam::labelMin
constexpr label labelMin
Definition: label.H:60
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::patchIdentifier::name
const word & name() const
The patch name.
Definition: patchIdentifier.H:134