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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::functionObjects::timeActivatedFileUpdate
29
30Group
31 grpUtilitiesFunctionObjects
32
33Description
34 Performs a file copy/replacement once a specified time has been reached.
35
36Usage
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
67SourceFiles
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
81namespace Foam
82{
83
84// Forward Declarations
85class Time;
86
87namespace functionObjects
88{
89
90/*---------------------------------------------------------------------------*\
91 Class timeActivatedFileUpdate Declaration
92\*---------------------------------------------------------------------------*/
93
94class 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
125public:
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
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// ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A class for handling file names.
Definition: fileName.H:76
const word & name() const noexcept
Return the name of this functionObject.
Performs a file copy/replacement once a specified time has been reached.
virtual bool filesModified() const
Did any file get changed during execution?
virtual ~timeActivatedFileUpdate()=default
Destructor.
TypeName("timeActivatedFileUpdate")
Runtime type information.
virtual bool read(const dictionary &)
Read the timeActivatedFileUpdate data.
Virtual base class for function objects with a reference to Time.
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
Namespace for OpenFOAM.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73