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-2015 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  << "Coupled patches with transformations not supported."
118  << endl
119  << "Problematic patch " << cpp.name() << exit(FatalError);
120  }
121  }
122  }
123 }
124 
125 
126 // ************************************************************************* //
Foam::mapDistributeBase::subMap
const labelListList & subMap() const
From subsetted data back to original data.
Definition: mapDistributeBase.H:256
extendedCellToFaceStencil.H
Foam::maxOp
Definition: ops.H:172
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:86
Foam::polyBoundaryMesh
Foam::polyBoundaryMesh.
Definition: polyBoundaryMesh.H:60
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::extendedCellToFaceStencil::extendedCellToFaceStencil
extendedCellToFaceStencil(const polyMesh &)
Construct from mesh.
Definition: extendedCellToFaceStencil.C:100
globalIndex.H
Foam::labelMax
static const label labelMax
Definition: label.H:62
Foam::minOp
Definition: ops.H:173
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::coupledPolyPatch
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
Definition: coupledPolyPatch.H:51
syncTools.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::coupledPolyPatch::parallel
virtual bool parallel() const
Are the cyclic planes parallel.
Definition: coupledPolyPatch.H:288
SortableList.H
Foam::coupledPolyPatch::separated
virtual bool separated() const
Are the planes separated.
Definition: coupledPolyPatch.H:276
Foam::reduce
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Definition: PstreamReduceOps.H:43
Foam::labelMin
static const label labelMin
Definition: label.H:61
Foam::label
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
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::mapDistribute
Class containing processor-to-processor mapping information.
Definition: mapDistribute.H:152
Foam::FatalError
error FatalError
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::sumOp
Definition: ops.H:162
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::extendedCellToFaceStencil::writeStencilStats
static void writeStencilStats(Ostream &os, const labelListList &stencil, const mapDistribute &map)
Write some statistics about stencil.
Definition: extendedCellToFaceStencil.C:42
patches
patches[0]
Definition: createSingleCellMesh.H:36
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::min
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::patchIdentifier::name
const word & name() const
Return name.
Definition: patchIdentifier.H:109