vtkSurfaceWriter.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 "vtkSurfaceWriter.H"
27 #include "vtkWritePolyData.H"
28 #include "OSspecific.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(vtkSurfaceWriter, 0);
36  addToRunTimeSelectionTable(surfaceWriter, vtkSurfaceWriter, word);
37  addToRunTimeSelectionTable(surfaceWriter, vtkSurfaceWriter, dict);
38 }
39 
40 
41 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
42 
44 {}
45 
46 
47 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
48 
50 (
51  const fileName& outputDir,
52  const fileName& surfaceName,
53  const pointField& points,
54  const faceList& faces,
55  const wordList& fieldNames,
56  const bool writePointValues
57  #define FieldTypeValuesConstArg(Type, nullArg) \
58  , const UPtrList<const Field<Type>>& field##Type##Values
59  FOR_ALL_FIELD_TYPES(FieldTypeValuesConstArg)
60  #undef FieldTypeValuesConstArg
61 ) const
62 {
63  if (!isDir(outputDir))
64  {
65  mkDir(outputDir);
66  }
67 
69  (
70  outputDir/surfaceName + ".vtk",
71  "sampleSurface",
72  writeFormat_ == IOstream::BINARY,
73  points,
74  labelList(),
75  edgeList(),
76  faces,
77  fieldNames,
78  boolList(fieldNames.size(), writePointValues),
79  UPtrList<const Field<label>>(fieldNames.size())
80  #define FieldTypeValuesParameter(Type, nullArg) , field##Type##Values
82  #undef FieldTypeValuesParameter
83  );
84 }
85 
86 
87 // ************************************************************************* //
dictionary dict
A class for handling file names.
Definition: fileName.H:79
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
virtual ~vtkSurfaceWriter()
Destructor.
virtual void write(const fileName &outputDir, const fileName &surfaceName, const pointField &points, const faceList &faces, const wordList &fieldNames, const bool writePointValues #define FieldTypeValuesConstArg(Type, nullArg)) const
Write fields for a single surface to file.
Macros for easy insertion into run-time selection tables.
List< bool > boolList
Bool container classes.
Definition: boolList.H:50
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
List< edge > edgeList
Definition: edgeList.H:38
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
Definition: POSIX.C:539
List< label > labelList
A List of labels.
Definition: labelList.H:56
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
#define FieldTypeValuesConstArg(Type, nullArg)
FOR_ALL_FIELD_TYPES(DefineFvWallInfoType)
#define FieldTypeValuesParameter(Type, nullArg)
rDeltaTY field()
Namespace for OpenFOAM.