extendedCellToFaceStencil.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 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 // * * * * * * * * * * * * Protected 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.transform().transformsPosition())
115  {
117  << "Coupled patches with transformations not supported."
118  << endl
119  << "Problematic patch " << cpp.name() << exit(FatalError);
120  }
121  }
122  }
123 }
124 
125 
126 // ************************************************************************* //
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:434
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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
const word & name() const
Return name.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:323
const labelListList & subMap() const
From subsetted data back to original data.
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:429
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
patches[0]
virtual const transformer & transform() const =0
Return transformation between the coupled patches.
dynamicFvMesh & mesh
extendedCellToFaceStencil(const polyMesh &)
Construct from mesh.
static const label labelMax
Definition: label.H:62
Foam::polyBoundaryMesh.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
static const char nl
Definition: Ostream.H:260
defineTypeNameAndDebug(combustionModel, 0)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
bool transformsPosition() const
Return true if the transformer transforms a point.
Definition: transformerI.H:146
label patchi
Class containing processor-to-processor mapping information.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
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.
static const label labelMin
Definition: label.H:61
Namespace for OpenFOAM.