logFiles.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) 2012-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::functionObjects::logFiles
26 
27 Description
28  functionObject base class for creating, maintaining and writing log
29  files e.g. integrated of averaged field data vs time.
30 
31 See also
32  Foam::functionObject
33  Foam::functionObjects::writeFile
34 
35 SourceFiles
36  logFiles.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef functionObjects_logFiles_H
41 #define functionObjects_logFiles_H
42 
43 #include "writeFile.H"
44 #include "OFstream.H"
45 #include "PtrList.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 namespace functionObjects
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class logFiles Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class logFiles
59 :
60  public writeFile
61 {
62 
63 protected:
64 
65  // Protected data
66 
67  //- File names
69 
70  //- File pointer
72 
73 
74  // Protected Member Functions
75 
76  //- Create the output file
77  virtual void createFiles();
78 
79  //- Reset the list of names from a wordList
80  virtual void resetNames(const wordList& names);
81 
82  //- Reset the list of names to a single name entry
83  virtual void resetName(const word& name);
84 
85  //- File header information
86  virtual void writeFileHeader(const label i = 0) = 0;
87 
88 
89 public:
90 
91  // Constructors
92 
93  //- Construct from objectRegistry and prefix
94  logFiles
95  (
96  const objectRegistry& obr,
97  const word& prefix
98  );
99 
100  //- Disallow default bitwise copy construction
101  logFiles(const logFiles&) = delete;
102 
103 
104  //- Destructor
105  virtual ~logFiles();
106 
107 
108  // Member Functions
109 
110  //- Return const access to the names
111  const wordList& names() const;
112 
113  //- Return access to the files
115 
116  //- Return access to the file (if only 1)
117  OFstream& file();
118 
119  //- Return file 'i'
120  OFstream& file(const label i);
121 
122  //- Write function
123  virtual bool write();
124 
125 
126  // Member Operators
127 
128  //- Disallow default bitwise assignment
129  void operator=(const logFiles&) = delete;
130 };
131 
132 
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 
135 } // End namespace functionObjects
136 } // End namespace Foam
137 
138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 
140 #endif
141 
142 // ************************************************************************* //
logFiles(const objectRegistry &obr, const word &prefix)
Construct from objectRegistry and prefix.
Definition: logFiles.C:82
virtual bool write()
Write function.
Definition: logFiles.C:167
virtual void createFiles()
Create the output file.
Definition: logFiles.C:32
wordList names_
File names.
Definition: logFiles.H:67
Output to file stream.
Definition: OFstream.H:82
virtual void writeFileHeader(const label i=0)=0
File header information.
PtrList< OFstream > & files()
Return access to the files.
Definition: logFiles.C:134
A class for handling words, derived from string.
Definition: word.H:59
virtual void resetName(const word &name)
Reset the list of names to a single name entry.
Definition: logFiles.C:66
const wordList & names() const
Return const access to the names.
Definition: logFiles.C:101
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
void operator=(const logFiles &)=delete
Disallow default bitwise assignment.
OFstream & file()
Return access to the file (if only 1)
Definition: logFiles.C:107
Registry of regIOobjects.
functionObject base class for writing single files
Definition: writeFile.H:55
PtrList< OFstream > filePtrs_
File pointer.
Definition: logFiles.H:70
virtual void resetNames(const wordList &names)
Reset the list of names from a wordList.
Definition: logFiles.C:53
Namespace for OpenFOAM.
functionObject base class for creating, maintaining and writing log files e.g. integrated of averaged...
Definition: logFiles.H:57
virtual ~logFiles()
Destructor.
Definition: logFiles.C:95