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  beginGeometry();
38 }
39 
40 
41 void Foam::ensightGeoFile::beginGeometry()
42 {
43  // Description line 1
44  writeString("Ensight Geometry File");
45  newline();
46 
47  // Description line 2
48  writeString("Written by OpenFOAM " + std::to_string(foamVersion::api));
49  newline();
50 
51  writeString("node id assign");
52  newline();
53 
54  writeString("element id assign");
55  newline();
56 }
57 
58 
59 void Foam::ensightGeoFile::endGeometry()
60 {}
61 
62 
63 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
64 
65 Foam::ensightGeoFile::ensightGeoFile
66 (
67  const fileName& pathname,
69 )
70 :
71  ensightFile(pathname, fmt)
72 {
73  init();
74 }
75 
76 
77 Foam::ensightGeoFile::ensightGeoFile
78 (
79  const fileName& path,
80  const fileName& name,
82 )
83 :
84  ensightFile(path, name, fmt)
85 {
86  init();
87 }
88 
89 
90 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
91 
93 {
94  writeString(key);
95  newline();
96 
97  return *this;
98 }
99 
100 
101 //
102 // Convenience Output Methods
103 //
104 
106 (
107  const label index,
108  const std::string& description
109 )
110 {
111  beginPart(index);
112  writeString(description);
113  newline();
114 }
115 
116 
117 void Foam::ensightGeoFile::beginCoordinates(const label npoints)
118 {
119  writeString(ensightFile::coordinates);
120  newline();
121 
122  write(npoints);
123  newline();
124 }
125 
126 
127 // ************************************************************************* //
Ensight output with specialized write() for strings, integers and floats. Correctly handles binary wr...
Definition: ensightFile.H:46
void writeBinaryHeader()
Write "C Binary" string for binary files (eg, geometry/measured)
Definition: ensightFile.C:331
A class for handling keywords in dictionaries.
Definition: keyType.H:66
A class for handling file names.
Definition: fileName.H:72
void beginPart(const label index, const std::string &description)
Begin a "part" (0-based index), with a description.
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 expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
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:56
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
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)