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 -------------------------------------------------------------------------------
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 "foamVtkWriteTopoSet.H"
29 #include "foamVtkIndPatchWriter.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 
59  indirectPatchWriter writer(pp, opts);
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 // ************************************************************************* //
Foam::vtk::outputOptions
Encapsulated combinations of output format options. This is primarily useful when defining the output...
Definition: foamVtkOutputOptions.H:59
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::BitOps::set
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
Definition: BitOps.C:37
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::vtk::GenericPatchWriter
Write concrete PrimitivePatch faces/points (optionally with fields) as a vtp file or a legacy vtk fil...
Definition: foamVtkGenericPatchWriter.H:65
foamVtkIndPatchWriter.H
globalIndex.H
Foam::writer::write
virtual void write(const coordSet &, const wordList &, const List< const Field< Type > * > &, Ostream &) const =0
General entry point for writing.
Foam::faceSet
A list of face labels.
Definition: faceSet.H:51
polyMesh.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::Field< label >
faceSet.H
Foam::IndirectList
A List with indirect addressing.
Definition: IndirectList.H:56
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::writer
Base class for graphics format writing. Entry points are.
Definition: writer.H:81
Foam::globalIndex
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:68
Foam::vtk::writeFaceSet
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.
Definition: foamVtkWriteFaceSet.C:37
foamVtkWriteTopoSet.H
Write topoSet in VTK format.
writer
vtk::internalMeshWriter writer(topoMesh, topoCells, vtk::formatType::INLINE_ASCII, runTime.path()/"blockTopology")
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:79