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-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::timeActivatedFileUpdate
26 
27 Group
28  grpUtilitiesFunctionObjects
29 
30 Description
31  Performs a file copy/replacement once a specified time has been reached.
32 
33  Example usage to update the fvSolution dictionary at various times
34  throughout the calculation:
35 
36  \verbatim
37  fileUpdate1
38  {
39  type timeActivatedFileUpdate;
40  libs ("libutilityFunctionObjects.so");
41  writeControl timeStep;
42  writeInterval 1;
43  fileToUpdate "$FOAM_CASE/system/fvSolution";
44  timeVsFile
45  (
46  (-1 "$FOAM_CASE/system/fvSolution.0")
47  (0.10 "$FOAM_CASE/system/fvSolution.10")
48  (0.20 "$FOAM_CASE/system/fvSolution.20")
49  (0.35 "$FOAM_CASE/system/fvSolution.35")
50  );
51  }
52  \endverbatim
53 
54 SourceFiles
55  timeActivatedFileUpdate.C
56 
57 \*---------------------------------------------------------------------------*/
58 
59 #ifndef functionObjects_timeActivatedFileUpdate_H
60 #define functionObjects_timeActivatedFileUpdate_H
61 
62 #include "functionObject.H"
63 #include "Tuple2.H"
64 
65 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66 
67 namespace Foam
68 {
69 
70 // Forward declaration of classes
71 class Time;
72 
73 namespace functionObjects
74 {
75 
76 /*---------------------------------------------------------------------------*\
77  Class timeActivatedFileUpdate Declaration
78 \*---------------------------------------------------------------------------*/
79 
81 :
82  public functionObject
83 {
84  // Private data
85 
86  //- Reference to Time
87  const Time& time_;
88 
89  //- Name of file to update
90  fileName fileToUpdate_;
91 
92  //- List of times vs filenames
93  List<Tuple2<scalar, fileName>> timeVsFile_;
94 
95  //- Index of last file copied
96  label lastIndex_;
97 
98 
99  // Private Member Functions
100 
101  //- Update file
102  void updateFile();
103 
104  //- Disallow default bitwise copy construct
106 
107  //- Disallow default bitwise assignment
108  void operator=(const timeActivatedFileUpdate&);
109 
110 
111 public:
112 
113  //- Runtime type information
114  TypeName("timeActivatedFileUpdate");
115 
116 
117  // Constructors
118 
119  //- Construct from Time and dictionary
121  (
122  const word& name,
123  const Time& runTime,
124  const dictionary& dict
125  );
126 
127 
128  //- Destructor
129  virtual ~timeActivatedFileUpdate();
130 
131 
132  // Member Functions
133 
134  //- Read the timeActivatedFileUpdate data
135  virtual bool read(const dictionary&);
136 
137  //- Execute file updates
138  virtual bool execute();
139 
140  //- Do nothing
141  virtual bool write();
142 };
143 
144 
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 
147 } // End namespace functionObjects
148 } // End namespace Foam
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 #endif
153 
154 // ************************************************************************* //
dictionary dict
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 class for handling file names.
Definition: fileName.H:69
virtual bool execute()
Execute file updates.
const word & name() const
Return the name of this functionObject.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:60
Abstract base-class for Time/database function objects.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Performs a file copy/replacement once a specified time has been reached.
A class for handling words, derived from string.
Definition: word.H:59
virtual bool read(const dictionary &)
Read the timeActivatedFileUpdate data.
TypeName("timeActivatedFileUpdate")
Runtime type information.
Namespace for OpenFOAM.