ensightGeoFile.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) 2011 OpenFOAM Foundation
9  Copyright (C) 2016-2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "ensightGeoFile.H"
30 #include "foamVersion.H"
31 
32 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 
34 void Foam::ensightGeoFile::init()
35 {
37 
38  // Description line 1
39  write("Ensight Geometry File");
40  newline();
41 
42  // Description line 2
43  write(string("Written by OpenFOAM " + std::to_string(foamVersion::api)));
44  newline();
45 
46  write("node id assign");
47  newline();
48 
49  write("element id assign");
51 }
52 
53 
54 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
55 
56 Foam::ensightGeoFile::ensightGeoFile
57 (
58  const fileName& pathname,
60 )
61 :
62  ensightFile(pathname, fmt)
63 {
64  init();
65 }
66 
67 
68 Foam::ensightGeoFile::ensightGeoFile
69 (
70  const fileName& path,
71  const fileName& name,
73 )
74 :
75  ensightFile(path, name, fmt)
76 {
77  init();
78 }
79 
80 
81 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
82 
84 {
85  writeString(key);
86  newline();
87 
88  return *this;
89 }
90 
91 
92 //
93 // Convenience Output Methods
94 //
95 
97 (
98  const label index,
99  const string& description
100 )
101 {
102  beginPart(index);
103  writeString(description);
104  newline();
105 }
106 
107 
108 void Foam::ensightGeoFile::beginCoordinates(const label npoints)
109 {
110  writeString(ensightFile::coordinates);
111  newline();
112 
113  write(npoints);
114  newline();
115 }
116 
117 
118 // ************************************************************************* //
Ensight output with specialized write() for strings, integers and floats. Correctly handles binary wr...
Definition: ensightFile.H:46
A class for handling keywords in dictionaries.
Definition: keyType.H:66
A class for handling file names.
Definition: fileName.H:71
static const char *const coordinates
The keyword "coordinates".
Definition: ensightFile.H:96
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:52
virtual Ostream & writeKeyword(const keyType &key)
Write keyword with trailing newline.
void beginCoordinates(const label npoints)
Begin a "coordinates" block.
const int api
OpenFOAM api number (integer) corresponding to the value of OPENFOAM at the time of compilation...
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:55
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
Ostream & writeBinaryHeader()
Write "C Binary" string for binary files (eg, geometry/measured)
Definition: ensightFile.C:317
void newline()
Add carriage return to ascii stream.
Definition: ensightFile.C:281
void beginPart(const label index, const string &description)
Begin a "part" (0-based index), with a description.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:103
streamFormat
Data format (ascii | binary)
virtual bool write(const token &)
Writing token does not make sense.
Definition: ensightFile.H:202