foamVtkWriteFaceSet.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) 2017-2019 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 "foamVtkWriteTopoSet.H"
30#include "polyMesh.H"
31#include "faceSet.H"
32#include "globalIndex.H"
33
34// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
35
37(
38 const polyMesh& mesh,
39 const faceSet& set,
40 const vtk::outputOptions opts,
41 const fileName& file,
42 bool parallel
43)
44{
45 typedef IndirectList<face> FaceListType;
46
48 (
49 FaceListType(mesh.faces(), labelList()),
50 mesh.points()
51 );
52 FaceListType& faces = pp;
53
54 // Use the faces from faceSet
55 faces.addressing() = set.sortedToc();
56
57 //-------------------------------------------------------------------------
58
60
61 writer.open(file, parallel);
62
63 writer.beginFile(set.name());
64 writer.writeGeometry();
65
66
67 // CellData - faceID only
68 {
69 writer.beginCellData(1);
70
71 labelField faceValues(faces.addressing());
72
73 // processor-local faceID offset
74 const label faceIdOffset =
75 (
76 writer.parallel() ? globalIndex(mesh.nFaces()).localStart() : 0
77 );
78
79 if (faceIdOffset)
80 {
81 faceValues += faceIdOffset;
82 }
83
84 writer.write("faceID", faceValues);
85
86 // End CellData/PointData is implicit
87 }
88
89 writer.close();
90
91 return true;
92}
93
94
95// ************************************************************************* //
vtk::internalMeshWriter writer(topoMesh, topoCells, vtk::formatType::INLINE_ASCII, runTime.path()/"blockTopology")
A List with indirect addressing.
Definition: IndirectList.H:119
A list of faces which address into the list of points.
A list of face labels.
Definition: faceSet.H:54
A class for handling file names.
Definition: fileName.H:76
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:68
label localStart() const
My local start.
Definition: globalIndexI.H:195
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
Write concrete PrimitivePatch faces/points (optionally with fields) as a vtp file or a legacy vtk fil...
Encapsulated combinations of output format options. This is primarily useful when defining the output...
dynamicFvMesh & mesh
Write topoSet in VTK format.
bool writeFaceSet(const polyMesh &mesh, const faceSet &set, const vtk::outputOptions opts, const fileName &file, bool parallel=Pstream::parRun())
Write faceSet as VTK polydata file.