ensightFacesAddr.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"
34 #include "indirectPrimitivePatch.H"
35 
36 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
37 
39 (
40  const polyMesh& mesh,
41  labelList& uniqueMeshPointLabels,
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 
53  const pointField& points = mesh.points();
54  const faceList& faces = mesh.faces();
55 
56 
57  // Use the properly sorted faceIds (ensightFaces) and do NOT use
58  // the faceZone or anything else directly, otherwise the
59  // point-maps will not correspond.
60  // - perform face-flipping later
61 
63  (
64  UIndirectList<face>(faces, part.faceIds()),
65  points
66  );
67 
68  if (parallel)
69  {
70  autoPtr<globalIndex> globalPointsPtr =
71  mesh.globalData().mergePoints
72  (
73  pp.meshPoints(),
74  pp.meshPointMap(),
75  pointToGlobal,
76  uniqueMeshPointLabels
77  );
78 
79  nPoints = globalPointsPtr().totalSize(); // nPoints (global)
80  }
81  else
82  {
83  // Non-parallel
84  // - all information already available from PrimitivePatch
85 
86  nPoints = pp.meshPoints().size();
87  uniqueMeshPointLabels = pp.meshPoints();
88 
89  // Not needed: pointToGlobal
90  }
91 
92  return nPoints;
93 }
94 
95 
96 // ************************************************************************* //
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:1049
Sorting/classification of faces (2D) into corresponding ensight types.
Definition: ensightFaces.H:66
A list of faces which address into the list of points.
dynamicFvMesh & mesh
const pointField & points
label nPoints
label uniqueMeshPoints(const polyMesh &mesh, labelList &uniqueMeshPointLabels, bool parallel) const
Globally unique mesh points. Required when writing point fields.
const labelList & faceIds() const noexcept
Processor-local face ids of all elements.
Definition: ensightFacesI.H:72
A List with indirect addressing. Like IndirectList but does not store addressing. ...
Definition: faMatrix.H:56
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())