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-2022 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  Example usage to update the fvSolution dictionary at various times
31  throughout the calculation:
32 
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  timeVsFile
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  //- Reference to Time
86  const Time& time_;
87 
88  //- Name of file to update
89  fileName fileToUpdate_;
90 
91  //- List of times vs filenames
92  List<Tuple2<scalar, fileName>> timeVsFile_;
93 
94  //- Index of last file copied
95  label lastIndex_;
96 
97 
98  // Private Member Functions
99 
100  //- Update file
101  void updateFile();
102 
103  //- Disallow default bitwise copy construction
105 
106  //- Disallow default bitwise assignment
107  void operator=(const timeActivatedFileUpdate&) = delete;
108 
109 
110 public:
111 
112  //- Runtime type information
113  TypeName("timeActivatedFileUpdate");
114 
115 
116  // Constructors
117 
118  //- Construct from Time and dictionary
120  (
121  const word& name,
122  const Time& runTime,
123  const dictionary& dict
124  );
125 
126 
127  //- Destructor
128  virtual ~timeActivatedFileUpdate();
129 
130 
131  // Member Functions
132 
133  //- Read the timeActivatedFileUpdate data
134  virtual bool read(const dictionary&);
135 
136  //- Return the list of fields required
137  virtual wordList fields() const
138  {
139  return wordList::null();
140  }
141 
142  //- Execute file updates
143  virtual bool execute();
144 
145  //- Do nothing
146  virtual bool write();
147 };
148 
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 } // End namespace functionObjects
153 } // End namespace Foam
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 #endif
158 
159 // ************************************************************************* //
dictionary dict
A class for handling file names.
Definition: fileName.H:79
virtual wordList fields() const
Return the list of fields required.
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:156
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
static const List< T > & null()
Return a null List.
Definition: ListI.H:118
Abstract base-class for Time/database functionObjects.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
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.