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