ensightAsciiStream.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011 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 Class
25  Foam::ensightAsciiStream
26 
27 Description
28 
29 SourceFiles
30  ensightAsciiStream.C
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #ifndef ensightAsciiStream_H
35 #define ensightAsciiStream_H
36 
37 #include "ensightStream.H"
38 #include "OFstream.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 /*---------------------------------------------------------------------------*\
46  Class ensightAsciiStream Declaration
47 \*---------------------------------------------------------------------------*/
48 
50 :
51  public ensightStream
52 {
53  // Private data
54 
55  //- Description of data_
56  OFstream str_;
57 
58 
59  // Private Member Functions
60 
61  //- Disallow default bitwise copy construct
63 
64  //- Disallow default bitwise assignment
65  void operator=(const ensightAsciiStream&);
66 
67 
68 public:
69 
70  // Constructors
71 
72  //- Construct from components
73  ensightAsciiStream(const fileName& f, const Time& runTime)
74  :
75  ensightStream(f),
76  str_
77  (
78  f,
79  runTime.writeFormat(),
80  runTime.writeVersion(),
81  IOstream::UNCOMPRESSED
82  )
83  {
84 
85  str_.setf(ios_base::scientific, ios_base::floatfield);
86  str_.precision(5);
87  }
88 
89 
90  //- Destructor
91  virtual ~ensightAsciiStream()
92  {}
93 
94 
95  // Member Functions
96 
97  virtual bool ascii() const
98  {
99  return true;
100  }
102  virtual void write(const char* c)
103  {
104  str_ << c << nl;
105  }
107  virtual void write(const int v)
108  {
109  str_ << setw(10) << v << nl;
110  }
112  virtual void write(const scalarField& sf)
113  {
114  forAll(sf, i)
115  {
116  if (mag(sf[i]) >= scalar(floatScalarVSMALL))
117  {
118  str_ << setw(12) << sf[i] << nl;
119  }
120  else
121  {
122  str_ << setw(12) << scalar(0) << nl;
123  }
124  }
125  }
127  virtual void write(const List<int>& sf)
128  {
129  forAll(sf, i)
130  {
131  str_ << setw(10) << sf[i];
132  }
133  str_<< nl;
134  }
136  virtual void writePartHeader(const label partI)
137  {
138  str_<< "part" << nl
139  << setw(10) << partI << nl;
140  }
141 
142  // Member Operators
143 
144  // Friend Functions
145 
146  // Friend Operators
147 
148  // IOstream Operators
149 
150 };
151 
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 } // End namespace Foam
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 #endif
160 
161 // ************************************************************************* //
Output to file stream.
Definition: OFstream.H:81
virtual bool ascii() const
dimensioned< scalar > mag(const dimensioned< Type > &)
labelList f(nPoints)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
virtual void write(const char *c)
volScalarField sf(fieldObject, mesh)
Namespace for OpenFOAM.
virtual void writePartHeader(const label partI)
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
static const char nl
Definition: Ostream.H:260
virtual int precision() const
Get precision of output field.
Definition: OSstream.C:290
static const floatScalar floatScalarVSMALL
Definition: floatScalar.H:59
#define forAll(list, i)
Definition: UList.H:421
Omanip< int > setw(const int i)
Definition: IOmanip.H:199
Abstract base class for writing Ensight data.
Definition: ensightStream.H:50
A class for handling file names.
Definition: fileName.H:69
ios_base::fmtflags setf(const ios_base::fmtflags f)
Set flags of stream.
Definition: IOstream.H:496
const dimensionedScalar c
Speed of light in a vacuum.
IOstream & scientific(IOstream &io)
Definition: IOstream.H:582
virtual ~ensightAsciiStream()
Destructor.
An IOstream is an abstract base class for all input/output systems; be they streams, files, token lists etc.
Definition: IOstream.H:71