Loading...
Searching...
No Matches
ensightFacesIO.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) 2020-2023 OpenCFD Ltd.
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
28#include "ensightFaces.H"
29#include "ensightOutput.H"
30#include "InfoProxy.H"
31#include "polyMesh.H"
32#include "globalIndex.H"
33#include "globalMeshData.H"
35
36// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
37
39(
41 const polyMesh& mesh,
42 bool parallel
43) const
44{
45 const ensightFaces& part = *this;
46
47 parallel = parallel && Pstream::parRun();
48
49 // Renumber the patch points/faces into unique points
50 label nPoints = 0; // Total number of points
51 labelList pointToGlobal; // local point to unique global index
52 labelList uniqueMeshPointLabels; // unique global points
53
54
55 const pointField& points = mesh.points();
56 const faceList& faces = mesh.faces();
57
58
59 // Use the properly sorted faceIds (ensightFaces) and do NOT use
60 // the faceZone or anything else directly, otherwise the
61 // point-maps will not correspond.
62 // - perform face-flipping later
63
65 (
66 UIndirectList<face>(faces, part.faceIds()),
67 points
68 );
69
70 if (parallel)
71 {
72 autoPtr<globalIndex> globalPointsPtr =
73 mesh.globalData().mergePoints
74 (
75 pp.meshPoints(),
76 pp.meshPointMap(),
77 pointToGlobal,
78 uniqueMeshPointLabels
79 );
80
81 nPoints = globalPointsPtr().totalSize(); // nPoints (global)
82 }
83 else
84 {
85 // Non-parallel
86 // - all information already available from PrimitivePatch
87
88 nPoints = pp.meshPoints().size();
89 uniqueMeshPointLabels = pp.meshPoints();
90
91 pointToGlobal.resize_nocopy(nPoints);
92 Foam::identity(pointToGlobal);
93 }
94
96 (
97 os,
98 part.index(),
99 part.name(),
100 nPoints, // nPoints (global)
101 UIndirectList<point>(points, uniqueMeshPointLabels),
102 parallel
103 );
104
105
106 // Renumber the faces belonging to the faceZone,
107 // from local numbering to unique global index.
108
109 faceList patchFaces(pp.localFaces());
110 ListListOps::inplaceRenumber(pointToGlobal, patchFaces);
111
112 // Also a good place to perform face flipping
113 if (part.usesFlipMap())
114 {
115 const boolList& flip = part.flipMap();
116
117 forAll(patchFaces, facei)
118 {
119 face& f = patchFaces[facei];
120
121 if (flip[facei])
122 {
123 f.flip();
124 }
125 }
126 }
127
129 (
130 os,
131 part,
132 patchFaces,
133 parallel
134 );
135}
136
137
138// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
139
140template<>
141Foam::Ostream& Foam::operator<<
142(
143 Ostream& os,
144 const InfoProxy<ensightFaces>& iproxy
145)
146{
147 const auto& part = *iproxy;
148
149 os << part.name().c_str();
150
151 for (label typei=0; typei < ensightFaces::nTypes; ++typei)
152 {
153 const auto etype = ensightFaces::elemType(typei);
154
155 os << ' ' << ensightFaces::elemNames[etype]
156 << ':' << part.total(etype);
157 }
158 os << nl;
159
160 return os;
161}
162
163
164// ************************************************************************* //
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
A helper class for outputting values to Ostream.
Definition InfoProxy.H:49
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
Definition ListI.H:171
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A List with indirect addressing. Like IndirectList but does not store addressing.
static bool & parRun() noexcept
Test if this a parallel run.
Definition UPstream.H:1681
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
bool usesFlipMap() const
True for non-zero flip-map that spans the addresses.
const labelList & faceIds() const noexcept
Processor-local face ids of all elements.
static constexpr int nTypes
Number of 'Face' element types (3).
virtual void write(ensightGeoFile &os, const polyMesh &mesh, bool parallel) const
Write geometry, using a mesh reference No beginGeometry() marker.
static const char * elemNames[nTypes]
The ensight 'Face' element type names.
elemType
Supported ensight 'Face' element types.
ensightFaces()
Default construct, with part index 0.
const boolList & flipMap() const
Processor-local flip-map of all elements.
A variant of ensightFile (Ensight writing) that includes the extra geometry file header information.
label index() const noexcept
The index in a list (0-based).
const string & name() const noexcept
The part name or description.
A face is a list of labels corresponding to mesh vertices.
Definition face.H:71
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
dynamicFvMesh & mesh
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
label nPoints
void inplaceRenumber(const labelUList &oldToNew, IntListType &lists)
Inplace renumber the values (not the indices) of a list of lists.
bool writeCoordinates(ensightGeoFile &os, const label partId, const word &partName, const label nPoints, const FieldContainer< Foam::point > &fld, bool parallel)
Write coordinates (component-wise) for the given part.
void writeFaceConnectivityPresorted(ensightGeoFile &os, const ensightFaces &part, const faceUList &faces, bool parallel)
Write the presorted face connectivity for the part.
List< label > labelList
A List of labels.
Definition List.H:62
List< face > faceList
List of faces.
Definition faceListFwd.H:41
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
List< bool > boolList
A List of bools.
Definition List.H:60
PrimitivePatch< UIndirectList< face >, const pointField & > uindirectPrimitivePatch
A PrimitivePatch with UIndirectList for the faces, const reference for the point field.
vectorField pointField
pointField is a vectorField.
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
labelList f(nPoints)
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299