All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 {
38  defineTypeNameAndDebug(vtkSetWriter, 0);
39  addToRunTimeSelectionTable(setWriter, vtkSetWriter, word);
40  addToRunTimeSelectionTable(setWriter, vtkSetWriter, dict);
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
60  FOR_ALL_FIELD_TYPES(TypeValueSetsConstArg)
61  #undef TypeValueSetsConstArg
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
92  #undef TypeValueSetsParameter
93  );
94 }
95 
96 
97 // ************************************************************************* //
dictionary dict
A class for handling file names.
Definition: fileName.H:79
virtual ~vtkSetWriter()
Destructor.
Definition: vtkSetWriter.C:46
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
List< face > faceList
Definition: faceListFwd.H:43
#define TypeValueSetsParameter(Type, nullArg)
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
Macros for easy insertion into run-time selection tables.
List< bool > boolList
Bool container classes.
Definition: boolList.H:50
#define TypeValueSetsConstArg(Type, nullArg)
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
pointField vertices(const blockVertexList &bvl)
Holds list of sampling positions.
Definition: coordSet.H:50
Pre-declare SubField and related Field type.
Definition: Field.H:56
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
Definition: POSIX.C:539
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:54
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
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.
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
Definition: POSIX.C:290
FOR_ALL_FIELD_TYPES(DefineFvWallInfoType)
Namespace for OpenFOAM.