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