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-2020 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::initialize()
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");
50  newline();
51 }
52 
53 
54 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
55 
56 Foam::ensightGeoFile::ensightGeoFile
57 (
58  const fileName& pathname,
60 )
61 :
62  ensightFile(pathname, format)
63 {
64  initialize();
65 }
66 
67 
68 Foam::ensightGeoFile::ensightGeoFile
69 (
70  const fileName& path,
71  const fileName& name,
73 )
74 :
76 {
77  initialize();
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 // ************************************************************************* //
Foam::ensightGeoFile::beginPart
void beginPart(const label index, const string &description)
Begin a "part" (0-based index), with a description.
Definition: ensightGeoFile.C:97
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::glTF::key
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:108
Foam::ensightFile::writeBinaryHeader
Ostream & writeBinaryHeader()
Write "C Binary" string for binary files (eg, geometry/measured)
Definition: ensightFile.C:339
Foam::ensightGeoFile::beginCoordinates
void beginCoordinates(const label npoints)
Begin a "coordinates" block.
Definition: ensightGeoFile.C:108
Foam::keyType
A class for handling keywords in dictionaries.
Definition: keyType.H:68
format
word format(conversionProperties.get< word >("format"))
Foam::foamVersion::api
const int api
Foam::ensightFile::newline
void newline()
Add carriage return to ascii stream.
Definition: ensightFile.C:304
Foam::ensightFile::coordinates
static const char *const coordinates
The keyword "coordinates".
Definition: ensightFile.H:88
Foam::IOstreamOption::streamFormat
streamFormat
Data format (ascii | binary)
Definition: IOstreamOption.H:70
Foam::ensightFile::write
virtual bool write(const token &)
Writing token does not make sense.
Definition: ensightFile.H:176
Foam::ensightFile
Ensight output with specialized write() for strings, integers and floats. Correctly handles binary wr...
Definition: ensightFile.H:52
ensightGeoFile.H
Foam::ensightGeoFile::writeKeyword
virtual Ostream & writeKeyword(const keyType &key)
Write keyword with trailing newline.
Definition: ensightGeoFile.C:83
path
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Definition: foamVtkOutputTemplates.C:36
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
foamVersion.H