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-2024 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 the list of log file names
111  const wordList& toc() const;
112 
113  //- Return the list of log file names
114  const wordList& names() const;
115 
116  //- Return access to the files
118 
119  //- Return access to the file (if only 1)
120  OFstream& file();
121 
122  //- Return file 'i'
123  OFstream& file(const label i);
124 
125  //- Write function
126  virtual bool write();
127 
128 
129  // Member Operators
130 
131  //- Disallow default bitwise assignment
132  void operator=(const logFiles&) = delete;
133 };
134 
135 
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 
138 } // End namespace functionObjects
139 } // End namespace Foam
140 
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 
143 #endif
144 
145 // ************************************************************************* //
Output to file stream.
Definition: OFstream.H:86
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
functionObject base class for creating, maintaining and writing log files e.g. integrated of averaged...
Definition: logFiles.H:60
const wordList & toc() const
Return the list of log file names.
Definition: logFiles.C:101
virtual void resetNames(const wordList &names)
Reset the list of names from a wordList.
Definition: logFiles.C:53
virtual void createFiles()
Create the output file.
Definition: logFiles.C:32
PtrList< OFstream > filePtrs_
File pointer.
Definition: logFiles.H:70
PtrList< OFstream > & files()
Return access to the files.
Definition: logFiles.C:140
virtual void resetName(const word &name)
Reset the list of names to a single name entry.
Definition: logFiles.C:66
wordList names_
File names.
Definition: logFiles.H:67
OFstream & file()
Return access to the file (if only 1)
Definition: logFiles.C:113
const wordList & names() const
Return the list of log file names.
Definition: logFiles.C:107
virtual void writeFileHeader(const label i=0)=0
File header information.
virtual ~logFiles()
Destructor.
Definition: logFiles.C:95
logFiles(const objectRegistry &obr, const word &prefix)
Construct from objectRegistry and prefix.
Definition: logFiles.C:82
void operator=(const logFiles &)=delete
Disallow default bitwise assignment.
virtual bool write()
Write function.
Definition: logFiles.C:173
functionObject base class for writing single files
Definition: writeFile.H:56
Registry of regIOobjects.
A class for handling words, derived from string.
Definition: word.H:62
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
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39