Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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
34namespace Foam
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 =
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// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
Definition UPstream.H:1706
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
virtual bool separated() const
Are the planes separated.
virtual bool parallel() const
Are the cyclic planes parallel.
Calculates/constains the extended cell-to-face stencil.
extendedCellToFaceStencil(const polyMesh &)
Construct from mesh.
static void writeStencilStats(Ostream &os, const labelListList &stencil, const mapDistribute &map)
Write some statistics about stencil.
const labelListList & subMap() const noexcept
From subsetted data back to original data.
Class containing processor-to-processor mapping information.
const word & name() const noexcept
The patch name.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
const polyBoundaryMesh & patches
bool coupled
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Definition typeInfo.H:172
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:40
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
constexpr label labelMin
Definition label.H:54
constexpr label labelMax
Definition label.H:55
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:26
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299