printMeshSummary.H
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) 2021-2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12
13Description
14 Summary of faMesh information
15
16\*---------------------------------------------------------------------------*/
17
18{
19 const faBoundaryMesh& patches = aMesh.boundary();
20 const label nNonProcessor = patches.nNonProcessor();
21 const label nPatches = patches.size();
22
23 label nLocalProcEdges = 0;
24 if (Pstream::parRun())
25 {
26 for (const faPatch& fap : patches)
27 {
28 const auto* cpp = isA<processorFaPatch>(fap);
30 if (cpp)
31 {
32 nLocalProcEdges += fap.nEdges();
33 }
34 }
35 }
36
37 const labelList nFaces
38 (
39 UPstream::listGatherValues<label>(aMesh.nFaces())
40 );
41 const labelList nPoints
42 (
43 UPstream::listGatherValues<label>(aMesh.nPoints())
44 );
45 const labelList nEdges
46 (
47 UPstream::listGatherValues<label>(aMesh.nEdges())
48 );
49 const labelList nIntEdges
50 (
51 UPstream::listGatherValues<label>(aMesh.nInternalEdges())
52 );
53
54 // The "real" (non-processor) boundary edges
55 const labelList nBndEdges
56 (
57 UPstream::listGatherValues<label>
58 (
59 aMesh.nBoundaryEdges() - nLocalProcEdges
60 )
61 );
62 const labelList nProcEdges
63 (
64 UPstream::listGatherValues<label>(nLocalProcEdges)
65 );
66
67
68 // Format output as
69 // Number of faces: ...
70 // per-proc: (...)
72 const auto reporter =
73 [&](const char* tag, const labelList& list)
74 {
75 Info<< " Number of " << tag << ": " << sum(list) << nl;
76 if (Pstream::parRun())
77 {
78 int padding = static_cast<int>
79 (
80 // strlen(" Number of ") - strlen("per-proc")
81 (12 - 8)
82 + strlen(tag)
83 );
84
85 do { Info<< ' '; } while (--padding > 0);
86
87 Info<< "per-proc: " << flatOutput(list) << nl;
88 }
89 };
90
91
92 Info<< "----------------" << nl
93 << "Mesh Information" << nl
94 << "----------------" << nl
95 << " " << "boundingBox: " << boundBox(aMesh.points()) << nl;
96
97 if (Pstream::master())
98 {
99 reporter("faces", nFaces);
100 reporter("points", nPoints);
101 reporter("edges", nEdges);
102 reporter("internal edges", nIntEdges);
103 reporter("boundary edges", nBndEdges);
104
105 if (Pstream::parRun())
106 {
107 reporter("processor edges", nProcEdges);
108 }
109 }
110
111 Info<< "----------------" << nl
112 << "Patches" << nl
113 << "----------------" << nl;
114
115 for (label patchi = 0; patchi < nNonProcessor; ++patchi)
116 {
117 const faPatch& p = patches[patchi];
118
119 Info<< " " << "patch " << p.index()
120 << " (size: " << returnReduce(p.size(), sumOp<label>())
121 << ") name: " << p.name()
122 << nl;
123 }
124
125
126 // Geometry information
127 Info<< nl;
128 {
129 scalarMinMax limit(gMinMax(aMesh.S().field()));
130 Info<< "Face area:" << nl
131 << " min = " << limit.min() << " max = " << limit.max() << nl;
132 }
133
134 {
135 scalarMinMax limit(minMax(aMesh.magLe().primitiveField()));
136
137 // Include processor boundaries into 'internal' edges
138 if (Pstream::parRun())
139 {
140 for (label patchi = nNonProcessor; patchi < nPatches; ++patchi)
141 {
142 limit.add(minMax(aMesh.magLe().boundaryField()[patchi]));
143 }
144
145 reduce(limit, minMaxOp<scalar>());
146 }
147
148 Info<< "Edge length (internal):" << nl
149 << " min = " << limit.min() << " max = " << limit.max() << nl;
150
151
152 // Include (non-processor) boundaries
153 for (label patchi = 0; patchi < nNonProcessor; ++patchi)
154 {
155 limit.add(minMax(aMesh.magLe().boundaryField()[patchi]));
156 }
157
158 if (Pstream::parRun())
159 {
160 reduce(limit, minMaxOp<scalar>());
161 }
162
163 Info<< "Edge length:" << nl
164 << " min = " << limit.min() << " max = " << limit.max() << nl;
165 }
166
167 // Not particularly meaningful
168 #if 0
169 {
170 MinMax<vector> limit(gMinMax(aMesh.faceAreaNormals().field()));
171
172 Info<< "Face area normals:" << nl
173 << " min = " << limit.min() << " max = " << limit.max() << nl;
174 }
175 #endif
176}
177
178
179// ************************************************************************* //
reduce(hasMovingMesh, orOp< bool >())
volScalarField & p
pressureControl limit(p)
const polyBoundaryMesh & patches
const labelList nBndEdges(UPstream::listGatherValues< label >(aMesh.nBoundaryEdges() - nLocalProcEdges))
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
const label nNonProcessor
const labelList nIntEdges(UPstream::listGatherValues< label >(aMesh.nInternalEdges()))
const labelList nProcEdges(UPstream::listGatherValues< label >(nLocalProcEdges))
const label nPatches
const labelList nEdges(UPstream::listGatherValues< label >(aMesh.nEdges()))
const auto reporter
label nLocalProcEdges
label nPoints
List< label > labelList
A List of labels.
Definition: List.H:66
messageStream Info
Information stream (stdout output on master, null elsewhere)
MinMax< scalar > scalarMinMax
A scalar min/max range.
Definition: MinMax.H:117
MinMax< label > minMax(const labelHashSet &set)
Find the min/max values of labelHashSet.
Definition: hashSets.C:61
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Definition: FlatOutput.H:215
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
faMesh aMesh(mesh)