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 {
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 // ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
virtual bool separated() const
Are the planes separated.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
Calculates/constains the extended cell-to-face stencil.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
constexpr label labelMin
Definition: label.H:54
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
Definition: UPstream.H:1074
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
virtual bool parallel() const
Are the cyclic planes parallel.
dynamicFvMesh & mesh
extendedCellToFaceStencil(const polyMesh &)
Construct from mesh.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:26
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
const word & name() const noexcept
The patch name.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
Class containing processor-to-processor mapping information.
const polyBoundaryMesh & patches
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
constexpr label labelMax
Definition: label.H:55
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
static void writeStencilStats(Ostream &os, const labelListList &stencil, const mapDistribute &map)
Write some statistics about stencil.
bool coupled
const labelListList & subMap() const noexcept
From subsetted data back to original data.
Namespace for OpenFOAM.