ensightAsciiStream.H
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-2020 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 public:
60 
61  // Constructors
62 
63  //- Construct from components
64  ensightAsciiStream(const fileName& f, const Time& runTime)
65  :
67  str_
68  (
69  f,
70  runTime.writeFormat(),
71  runTime.writeVersion(),
72  IOstream::UNCOMPRESSED
73  )
74  {
75 
76  str_.setf(ios_base::scientific, ios_base::floatfield);
77  str_.precision(5);
78  }
79 
80  //- Disallow default bitwise copy construction
81  ensightAsciiStream(const ensightAsciiStream&) = delete;
82 
83 
84  //- Destructor
85  virtual ~ensightAsciiStream()
86  {}
87 
88 
89  // Member Functions
90 
91  virtual bool ascii() const
92  {
93  return true;
94  }
95 
96  virtual void write(const char* c)
97  {
98  str_ << c << nl;
99  }
100 
101  virtual void write(const int v)
102  {
103  str_ << setw(10) << v << nl;
104  }
105 
106  virtual void write(const scalarField& sf)
107  {
108  forAll(sf, i)
109  {
110  if (mag(sf[i]) >= scalar(floatScalarVSmall))
111  {
112  str_ << setw(12) << sf[i] << nl;
113  }
114  else
115  {
116  str_ << setw(12) << scalar(0) << nl;
117  }
118  }
119  }
120 
121  virtual void write(const List<int>& sf)
122  {
123  forAll(sf, i)
124  {
125  str_ << setw(10) << sf[i];
126  }
127  str_<< nl;
128  }
129 
130  virtual void writePartHeader(const label partI)
131  {
132  str_<< "part" << nl
133  << setw(10) << partI << nl;
134  }
135 
136 
137  // Member Operators
138 
139  //- Disallow default bitwise assignment
140  void operator=(const ensightAsciiStream&) = delete;
141 };
142 
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 } // End namespace Foam
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 #endif
151 
152 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
An IOstream is an abstract base class for all input/output systems; be they streams,...
Definition: IOstream.H:72
ios_base::fmtflags setf(const ios_base::fmtflags f)
Set flags of stream.
Definition: IOstream.H:493
Output to file stream.
Definition: OFstream.H:86
virtual int precision() const
Get precision of output field.
Definition: OSstream.C:246
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
ensightAsciiStream(const fileName &f, const Time &runTime)
Construct from components.
virtual bool ascii() const
void operator=(const ensightAsciiStream &)=delete
Disallow default bitwise assignment.
virtual void write(const char *c)
virtual ~ensightAsciiStream()
Destructor.
virtual void writePartHeader(const label partI)
Abstract base class for writing Ensight data.
Definition: ensightStream.H:51
A class for handling file names.
Definition: fileName.H:82
volScalarField sf(fieldObject, mesh)
const dimensionedScalar c
Speed of light in a vacuum.
Namespace for OpenFOAM.
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
Omanip< int > setw(const int i)
Definition: IOmanip.H:199
IOstream & scientific(IOstream &io)
Definition: IOstream.H:579
dimensioned< scalar > mag(const dimensioned< Type > &)
static const floatScalar floatScalarVSmall
Definition: floatScalar.H:58
static const char nl
Definition: Ostream.H:260
labelList f(nPoints)