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 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 
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().size(); // 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(nPoints);
92  ListOps::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 // ************************************************************************* //
Foam::ensightFaces::faceIds
const labelList & faceIds() const noexcept
Processor-local face ids of all elements.
Definition: ensightFacesI.H:79
Foam::ensightFaces::flipMap
const boolList & flipMap() const
Processor-local flip-map of all elements.
Definition: ensightFacesI.H:92
Foam::ensightPart::index
label index() const noexcept
The index in a list (0-based)
Definition: ensightPart.H:124
Foam::List::resize
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
uindirectPrimitivePatch.H
ensightFaces.H
globalMeshData.H
globalIndex.H
Foam::ensightFaces::usesFlipMap
bool usesFlipMap() const
True for non-zero flip-map that spans the addresses.
Definition: ensightFacesI.H:98
polyMesh.H
Foam::ensightFaces
Sorting/classification of faces (2D) into corresponding ensight types.
Definition: ensightFaces.H:71
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::ensightFaces::write
virtual void write(ensightGeoFile &os, const polyMesh &mesh, bool parallel) const
Write geometry, using a mesh reference.
Definition: ensightFacesIO.C:39
nPoints
label nPoints
Definition: gmvOutputHeader.H:2
Foam::ensightOutput::writeFaceConnectivityPresorted
void writeFaceConnectivityPresorted(ensightGeoFile &os, const ensightFaces &part, const faceUList &faces, bool parallel)
Write the presorted face connectivity for the part.
Definition: ensightOutput.C:486
Foam::ensightGeoFile
Specialized Ensight output with extra geometry file header.
Definition: ensightGeoFile.H:48
ensightOutput.H
Foam::Field< vector >
Foam::ListListOps::inplaceRenumber
void inplaceRenumber(const labelUList &oldToNew, IntListType &lists)
Inplace renumber the values (not the indices) of a list of lists.
Definition: ensightOutput.H:89
os
OBJstream os(runTime.globalPath()/outputName)
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::PrimitivePatch::localFaces
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
Definition: PrimitivePatch.C:317
Foam::ensightPart::name
const string & name() const noexcept
The part name or description.
Definition: ensightPart.H:160
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
f
labelList f(nPoints)
Foam::List< label >
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::identity
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
Definition: labelList.C:38
Foam::UIndirectList
A List with indirect addressing.
Definition: faMatrix.H:60
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
Foam::PrimitivePatch::meshPointMap
const Map< label > & meshPointMap() const
Mesh point map.
Definition: PrimitivePatch.C:343
Foam::PrimitivePatch::meshPoints
const labelList & meshPoints() const
Return labelList of mesh points in patch.
Definition: PrimitivePatch.C:330
Foam::ensightOutput::Detail::writeCoordinates
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.
Definition: ensightOutputTemplates.C:136
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:79