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 | Copyright (C) 2011-2012 OpenFOAM Foundation
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 
27 #include "globalIndex.H"
28 #include "syncTools.H"
29 #include "SortableList.H"
30 
31 /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
32 
33 namespace Foam
34 {
35 defineTypeNameAndDebug(extendedCellToFaceStencil, 0);
36 }
37 
38 
39 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
40 
42 (
43  Ostream& os,
44  const labelListList& stencil,
45  const mapDistribute& map
46 )
47 {
48  label sumSize = 0;
49  label nSum = 0;
50  label minSize = labelMax;
51  label maxSize = labelMin;
52 
53  forAll(stencil, i)
54  {
55  const labelList& sCells = stencil[i];
56 
57  if (sCells.size() > 0)
58  {
59  sumSize += sCells.size();
60  nSum++;
61  minSize = min(minSize, sCells.size());
62  maxSize = max(maxSize, sCells.size());
63  }
64  }
65  reduce(sumSize, sumOp<label>());
66  reduce(nSum, sumOp<label>());
67 
68  reduce(minSize, minOp<label>());
69  reduce(maxSize, maxOp<label>());
70 
71  os << "Stencil size :" << nl
72  << " average : " << scalar(sumSize)/nSum << nl
73  << " min : " << minSize << nl
74  << " max : " << maxSize << nl
75  << endl;
76 
77  // Sum all sent data
78  label nSent = 0;
79  label nLocal = 0;
80  forAll(map.subMap(), procI)
81  {
82  if (procI != Pstream::myProcNo())
83  {
84  nSent += map.subMap()[procI].size();
85  }
86  else
87  {
88  nLocal += map.subMap()[procI].size();
89  }
90  }
91 
92  os << "Local data size : " << returnReduce(nLocal, sumOp<label>()) << nl
93  << "Sent data size : " << returnReduce(nSent, sumOp<label>()) << nl
94  << endl;
95 }
96 
97 
98 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
99 
101 :
102  mesh_(mesh)
103 {
104  // Check for transformation - not supported.
105  const polyBoundaryMesh& patches = mesh.boundaryMesh();
106 
107  forAll(patches, patchI)
108  {
109  if (patches[patchI].coupled())
110  {
111  const coupledPolyPatch& cpp =
112  refCast<const coupledPolyPatch>(patches[patchI]);
113 
114  if (!cpp.parallel() || cpp.separated())
115  {
117  (
118  "extendedCellToFaceStencil::extendedCellToFaceStencil"
119  "(const polyMesh&)"
120  ) << "Coupled patches with transformations not supported."
121  << endl
122  << "Problematic patch " << cpp.name() << exit(FatalError);
123  }
124  }
125  }
126 }
127 
128 
129 // ************************************************************************* //
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
const labelListList & subMap() const
From subsetted data back to original data.
virtual bool separated() const
Are the planes separated.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
const word & name() const
Return name.
Class containing processor-to-processor mapping information.
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
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
dynamicFvMesh & mesh
Namespace for OpenFOAM.
patches[0]
static const char nl
Definition: Ostream.H:260
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
virtual bool parallel() const
Are the cyclic planes parallel.
Foam::polyBoundaryMesh.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define forAll(list, i)
Definition: UList.H:421
static const label labelMin
Definition: label.H:61
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:404
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:421
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
error FatalError
extendedCellToFaceStencil(const polyMesh &)
Construct from mesh.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
static void writeStencilStats(Ostream &os, const labelListList &stencil, const mapDistribute &map)
Write some statistics about stencil.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
defineTypeNameAndDebug(combustionModel, 0)
static const label labelMax
Definition: label.H:62