vtkSetWriter.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "vtkSetWriter.H"
27 #include "coordSet.H"
28 #include "faceList.H"
29 #include "OFstream.H"
30 #include "OSspecific.H"
31 #include "vtkWritePolyData.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
41 }
42 
43 
44 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
45 
47 {}
48 
49 
50 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
51 
53 (
54  const fileName& outputDir,
55  const fileName& setName,
56  const coordSet& set,
57  const wordList& valueSetNames
58  #define TypeValueSetsConstArg(Type, nullArg) \
59  , const UPtrList<const Field<Type>>& Type##ValueSets
62 ) const
63 {
64  if (!set.hasPointAxis())
65  {
67  << "Cannot write " << setName << " in " << typeName
68  << " format as it does not have a point axis"
69  << exit(FatalError);
70  }
71 
72  if (!isDir(outputDir))
73  {
74  mkDir(outputDir);
75  }
76 
77  // Write
79  (
80  outputDir/setName + ".vtk",
81  setName,
82  writeFormat_ == IOstream::BINARY,
83  set.pointCoords()(),
84  set.vertices(),
85  set.lines(),
86  faceList(),
87  valueSetNames,
88  boolList(valueSetNames.size(), true),
89  UPtrList<const Field<label>>(valueSetNames.size())
90  #define TypeValueSetsParameter(Type, nullArg) , Type##ValueSets
93  );
94 }
95 
96 
97 // ************************************************************************* //
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Macros for easy insertion into run-time selection tables.
Pre-declare SubField and related Field type.
Definition: Field.H:83
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:66
Holds list of sampling positions.
Definition: coordSet.H:51
bool hasPointAxis() const
Is the coordinate axis a point?
Definition: coordSet.C:152
labelListList lines() const
Return a list of lines. These are lists of points which are in the.
Definition: coordSet.C:378
labelList vertices() const
Return a list of isolated vertices. These are the points that are.
Definition: coordSet.C:335
tmp< pointField > pointCoords() const
Get vector coordinate (axis is xyz)
Definition: coordSet.C:281
A class for handling file names.
Definition: fileName.H:82
Base class for writing coordinate sets with data.
Definition: setWriter.H:64
virtual void write(const fileName &outputDir, const fileName &setName, const coordSet &set, const wordList &valueSetNames #define TypeValueSetsConstArg(Type, nullArg)) const
Write a coordSet and associated data.
Definition: vtkSetWriter.C:53
virtual ~vtkSetWriter()
Destructor.
Definition: vtkSetWriter.C:46
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
void write(const fileName &file, const word &title, const bool binary, const PointField &points, const VertexList &vertices, const LineList &lines, const FaceList &faces, const wordList &fieldNames, const boolList &fieldIsPointValues, const UPtrList< const Field< label >> &fieldLabelValues #define FieldTypeValuesConstArg(Type, nullArg))
Write VTK polygonal data to a file. Takes a PtrList of fields of labels and.
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
Definition: POSIX.C:290
List< bool > boolList
Bool container classes.
Definition: boolList.H:50
defineTypeNameAndDebug(combustionModel, 0)
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
Definition: POSIX.C:539
error FatalError
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
dictionary dict
#define TypeValueSetsParameter(Type, nullArg)
#define TypeValueSetsConstArg(Type, nullArg)