timeActivatedFileUpdate.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-2014 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::timeActivatedFileUpdate
26 
27 Group
28  grpUtilitiesFunctionObjects
29 
30 Description
31  This function object performs a file copy/replacement once a specified
32  time has been reached.
33 
34  Example usage to update the fvSolution dictionary at various times
35  throughout the calculation:
36  \verbatim
37  fileUpdate1
38  {
39  type timeActivatedFileUpdate;
40  functionObjectLibs ("libutilityFunctionObjects.so");
41  fileToUpdate "$FOAM_CASE/system/fvSolution";
42  timeVsFile
43  (
44  (-1 "$FOAM_CASE/system/fvSolution.0")
45  (0.10 "$FOAM_CASE/system/fvSolution.10")
46  (0.20 "$FOAM_CASE/system/fvSolution.20")
47  (0.35 "$FOAM_CASE/system/fvSolution.35")
48  );
49  ...
50  }
51  \endverbatim
52 
53  \heading Function object usage
54  \table
55  Property | Description | Required | Default value
56  type | Type name: timeActivatedFileUpdate | yes |
57  fileToUpdate | Name of file to update | yes |
58  timeVsFile | List of time vs file | yes |
59  log | Log to standard output | no | yes
60  \endtable
61 
62 
63 SourceFiles
64  timeActivatedFileUpdate.C
65  IOtimeActivatedFileUpdate.H
66 
67 \*---------------------------------------------------------------------------*/
68 
69 #ifndef timeActivatedFileUpdate_H
70 #define timeActivatedFileUpdate_H
71 
72 #include "Tuple2.H"
73 #include "Switch.H"
74 
75 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
76 
77 namespace Foam
78 {
79 
80 // Forward declaration of classes
81 class objectRegistry;
82 class dictionary;
83 class polyMesh;
84 class mapPolyMesh;
85 
86 /*---------------------------------------------------------------------------*\
87  Class timeActivatedFileUpdate Declaration
88 \*---------------------------------------------------------------------------*/
89 
90 class timeActivatedFileUpdate
91 {
92  // Private data
93 
94  //- Name of this set of timeActivatedFileUpdate objects
95  word name_;
96 
97  //- Owner database
98  const objectRegistry& obr_;
99 
100  //- On/off switch
101  bool active_;
102 
103  //- Name of file to update
104  fileName fileToUpdate_;
105 
106  //- List of times vs filenames
108 
109  //- Index of last file copied
111 
112  //- Switch to send output to Info as well as to file
113  Switch log_;
114 
115 
116  // Private Member Functions
117 
118  //- Update file
119  void updateFile();
120 
121  //- Disallow default bitwise copy construct
123 
124  //- Disallow default bitwise assignment
126 
127 
128 public:
129 
130  //- Runtime type information
131  TypeName("timeActivatedFileUpdate");
132 
133 
134  // Constructors
135 
136  //- Construct for given objectRegistry and dictionary.
137  // Allow the possibility to load fields from files
139  (
140  const word& name,
141  const objectRegistry&,
142  const dictionary&,
143  const bool loadFromFiles = false
144  );
145 
146 
147  //- Destructor
148  virtual ~timeActivatedFileUpdate();
149 
150 
151  // Member Functions
152 
153  //- Return name of the set of timeActivatedFileUpdate
154  virtual const word& name() const
155  {
156  return name_;
157  }
158 
159  //- Read the timeActivatedFileUpdate data
160  virtual void read(const dictionary&);
161 
162  //- Execute, currently does nothing
163  virtual void execute();
164 
165  //- Execute at the final time-loop, currently does nothing
166  virtual void end();
167 
168  //- Called when time was set at the end of the Time::operator++
169  virtual void timeSet();
170 
171  //- Calculate the timeActivatedFileUpdate and write
172  virtual void write();
173 
174  //- Update for changes of mesh
175  virtual void updateMesh(const mapPolyMesh&)
176  {}
177 
178  //- Update for changes of mesh
179  virtual void movePoints(const polyMesh&)
180  {}
181 };
182 
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 } // End namespace Foam
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
190 #endif
191 
192 // ************************************************************************* //
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::timeActivatedFileUpdate::~timeActivatedFileUpdate
virtual ~timeActivatedFileUpdate()
Destructor.
Definition: timeActivatedFileUpdate.C:89
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::timeActivatedFileUpdate::timeActivatedFileUpdate
timeActivatedFileUpdate(const timeActivatedFileUpdate &)
Disallow default bitwise copy construct.
Foam::timeActivatedFileUpdate::execute
virtual void execute()
Execute, currently does nothing.
Definition: timeActivatedFileUpdate.C:132
Tuple2.H
Foam::timeActivatedFileUpdate::timeVsFile_
List< Tuple2< scalar, fileName > > timeVsFile_
List of times vs filenames.
Definition: timeActivatedFileUpdate.H:131
Foam::timeActivatedFileUpdate::fileToUpdate_
fileName fileToUpdate_
Name of file to update.
Definition: timeActivatedFileUpdate.H:128
Foam::timeActivatedFileUpdate::write
virtual void write()
Calculate the timeActivatedFileUpdate and write.
Definition: timeActivatedFileUpdate.C:153
Foam::timeActivatedFileUpdate::obr_
const objectRegistry & obr_
Owner database.
Definition: timeActivatedFileUpdate.H:122
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::timeActivatedFileUpdate::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
Definition: timeActivatedFileUpdate.H:199
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::timeActivatedFileUpdate::updateFile
void updateFile()
Update file.
Definition: timeActivatedFileUpdate.C:41
Foam::timeActivatedFileUpdate::operator=
void operator=(const timeActivatedFileUpdate &)
Disallow default bitwise assignment.
Foam::label
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
Foam::timeActivatedFileUpdate::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: timeActivatedFileUpdate.C:141
Foam::timeActivatedFileUpdate::log_
Switch log_
Switch to send output to Info as well as to file.
Definition: timeActivatedFileUpdate.H:137
Switch.H
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::timeActivatedFileUpdate::active_
bool active_
On/off switch.
Definition: timeActivatedFileUpdate.H:125
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::timeActivatedFileUpdate
This function object performs a file copy/replacement once a specified time has been reached.
Definition: timeActivatedFileUpdate.H:114
Foam::timeActivatedFileUpdate::movePoints
virtual void movePoints(const polyMesh &)
Update for changes of mesh.
Definition: timeActivatedFileUpdate.H:203
Foam::timeActivatedFileUpdate::TypeName
TypeName("timeActivatedFileUpdate")
Runtime type information.
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::timeActivatedFileUpdate::name
virtual const word & name() const
Return name of the set of timeActivatedFileUpdate.
Definition: timeActivatedFileUpdate.H:178
Foam::timeActivatedFileUpdate::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: timeActivatedFileUpdate.C:147
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
List
Definition: Test.C:19
Foam::timeActivatedFileUpdate::lastIndex_
label lastIndex_
Index of last file copied.
Definition: timeActivatedFileUpdate.H:134
Foam::timeActivatedFileUpdate::read
virtual void read(const dictionary &)
Read the timeActivatedFileUpdate data.
Definition: timeActivatedFileUpdate.C:95
Foam::timeActivatedFileUpdate::name_
word name_
Name of this set of timeActivatedFileUpdate objects.
Definition: timeActivatedFileUpdate.H:119