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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2017-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::functionObjects::timeActivatedFileUpdate
29 
30 Group
31  grpUtilitiesFunctionObjects
32 
33 Description
34  Performs a file copy/replacement once a specified time has been reached.
35 
36 Usage
37  Example usage to update the fvSolution dictionary at various times
38  throughout the calculation:
39  \verbatim
40  fileUpdate1
41  {
42  type timeActivatedFileUpdate;
43  libs (utilityFunctionObjects);
44  writeControl timeStep;
45  writeInterval 1;
46  fileToUpdate "<system>/fvSolution";
47  timeVsFile
48  (
49  (-1 "<system>/fvSolution.0")
50  (0.10 "<system>/fvSolution.10")
51  (0.20 "<system>/fvSolution.20")
52  (0.35 "<system>/fvSolution.35")
53  );
54  ...
55  }
56  \endverbatim
57 
58  Where the entries comprise:
59  \table
60  Property | Description | Required | Default value
61  type | Type name: timeActivatedFileUpdate | yes |
62  fileToUpdate | Name of file to update | yes |
63  timeVsFile | List of time vs file | yes |
64  \endtable
65 
66 
67 SourceFiles
68  timeActivatedFileUpdate.C
69 
70 \*---------------------------------------------------------------------------*/
71 
72 #ifndef functionObjects_timeActivatedFileUpdate_H
73 #define functionObjects_timeActivatedFileUpdate_H
74 
75 #include "timeFunctionObject.H"
76 #include "Tuple2.H"
77 
78 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
79 
80 namespace Foam
81 {
82 
83 // Forward Declarations
84 class Time;
85 
86 namespace functionObjects
87 {
88 
89 /*---------------------------------------------------------------------------*\
90  Class timeActivatedFileUpdate Declaration
91 \*---------------------------------------------------------------------------*/
92 
93 class timeActivatedFileUpdate
94 :
95  public functionObjects::timeFunctionObject
96 {
97  // Private Member Data
98 
99  //- Name of file to update
100  fileName fileToUpdate_;
101 
102  //- List of times vs filenames
103  List<Tuple2<scalar, fileName>> timeVsFile_;
104 
105  //- Index of last file copied
106  label lastIndex_;
107 
108  //- Has anything been copied?
109  bool modified_;
110 
111 
112  // Private Member Functions
113 
114  //- Update file
115  void updateFile();
116 
117  //- No copy construct
119 
120  //- No copy assignment
121  void operator=(const timeActivatedFileUpdate&) = delete;
122 
123 
124 public:
125 
126  //- Runtime type information
127  TypeName("timeActivatedFileUpdate");
128 
129 
130  // Constructors
131 
132  //- Construct from Time and dictionary
134  (
135  const word& name,
136  const Time& runTime,
137  const dictionary& dict
138  );
139 
140 
141  //- Destructor
142  virtual ~timeActivatedFileUpdate() = default;
143 
144 
145  // Member Functions
146 
147  //- Read the timeActivatedFileUpdate data
148  virtual bool read(const dictionary&);
149 
150  //- Execute file updates
151  virtual bool execute();
152 
153  //- Do nothing
154  virtual bool write();
155 
156  //- Did any file get changed during execution?
157  virtual bool filesModified() const;
158 };
159 
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 } // End namespace functionObjects
164 } // End namespace Foam
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 #endif
169 
170 // ************************************************************************* //
dictionary dict
virtual bool execute()
Execute file updates.
virtual bool filesModified() const
Did any file get changed during execution?
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
engineTime & runTime
virtual ~timeActivatedFileUpdate()=default
Destructor.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
const word & name() const noexcept
Return the name of this functionObject.
Performs a file copy/replacement once a specified time has been reached.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual bool read(const dictionary &)
Read the timeActivatedFileUpdate data.
TypeName("timeActivatedFileUpdate")
Runtime type information.
Namespace for OpenFOAM.