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 #include "Switch.H"
78 
79 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
80 
81 namespace Foam
82 {
83 
84 // Forward Declarations
85 class Time;
86 
87 namespace functionObjects
88 {
89 
90 /*---------------------------------------------------------------------------*\
91  Class timeActivatedFileUpdate Declaration
92 \*---------------------------------------------------------------------------*/
93 
94 class timeActivatedFileUpdate
95 :
96  public functionObjects::timeFunctionObject
97 {
98  // Private Member Data
99 
100  //- Name of file to update
101  fileName fileToUpdate_;
102 
103  //- List of times vs filenames
104  List<Tuple2<scalar, fileName>> timeVsFile_;
105 
106  //- Index of last file copied
107  label lastIndex_;
108 
109  //- Has anything been copied?
110  bool modified_;
111 
112 
113  // Private Member Functions
114 
115  //- Update file
116  void updateFile();
117 
118  //- No copy construct
120 
121  //- No copy assignment
122  void operator=(const timeActivatedFileUpdate&) = delete;
123 
124 
125 public:
126 
127  //- Runtime type information
128  TypeName("timeActivatedFileUpdate");
129 
130 
131  // Constructors
132 
133  //- Construct from Time and dictionary
135  (
136  const word& name,
137  const Time& runTime,
138  const dictionary& dict
139  );
140 
141 
142  //- Destructor
143  virtual ~timeActivatedFileUpdate() = default;
144 
145 
146  // Member Functions
147 
148  //- Read the timeActivatedFileUpdate data
149  virtual bool read(const dictionary&);
150 
151  //- Execute file updates
152  virtual bool execute();
153 
154  //- Do nothing
155  virtual bool write();
156 
157  //- Did any file get changed during execution?
158  virtual bool filesModified() const;
159 };
160 
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 } // End namespace functionObjects
165 } // End namespace Foam
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 #endif
170 
171 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Tuple2.H
Foam::functionObjects::timeActivatedFileUpdate::execute
virtual bool execute()
Execute file updates.
Definition: timeActivatedFileUpdate.C:144
Foam::functionObjects::timeFunctionObject
Virtual base class for function objects with a reference to Time.
Definition: timeFunctionObject.H:56
Foam::functionObjects::timeActivatedFileUpdate::read
virtual bool read(const dictionary &)
Read the timeActivatedFileUpdate data.
Definition: timeActivatedFileUpdate.C:108
timeFunctionObject.H
Foam::functionObjects::timeActivatedFileUpdate::write
virtual bool write()
Do nothing.
Definition: timeActivatedFileUpdate.C:152
Switch.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::timeActivatedFileUpdate
Performs a file copy/replacement once a specified time has been reached.
Definition: timeActivatedFileUpdate.H:113
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::timeActivatedFileUpdate::~timeActivatedFileUpdate
virtual ~timeActivatedFileUpdate()=default
Destructor.
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::functionObjects::timeActivatedFileUpdate::filesModified
virtual bool filesModified() const
Did any file get changed during execution?
Definition: timeActivatedFileUpdate.C:158
Foam::functionObjects::timeActivatedFileUpdate::TypeName
TypeName("timeActivatedFileUpdate")
Runtime type information.