All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2018 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  libs ("libutilityFunctionObjects.so");
38  writeControl timeStep;
39  writeInterval 1;
40  fileToUpdate "$FOAM_CASE/system/fvSolution";
41  timeVsFile
42  (
43  (-1 "$FOAM_CASE/system/fvSolution.0")
44  (0.10 "$FOAM_CASE/system/fvSolution.10")
45  (0.20 "$FOAM_CASE/system/fvSolution.20")
46  (0.35 "$FOAM_CASE/system/fvSolution.35")
47  );
48  }
49  \endverbatim
50 
51 SourceFiles
52  timeActivatedFileUpdate.C
53 
54 \*---------------------------------------------------------------------------*/
55 
56 #ifndef functionObjects_timeActivatedFileUpdate_H
57 #define functionObjects_timeActivatedFileUpdate_H
58 
59 #include "functionObject.H"
60 #include "Tuple2.H"
61 
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 
64 namespace Foam
65 {
66 
67 // Forward declaration of classes
68 class Time;
69 
70 namespace functionObjects
71 {
72 
73 /*---------------------------------------------------------------------------*\
74  Class timeActivatedFileUpdate Declaration
75 \*---------------------------------------------------------------------------*/
76 
78 :
79  public functionObject
80 {
81  // Private data
82 
83  //- Reference to Time
84  const Time& time_;
85 
86  //- Name of file to update
87  fileName fileToUpdate_;
88 
89  //- List of times vs filenames
90  List<Tuple2<scalar, fileName>> timeVsFile_;
91 
92  //- Index of last file copied
93  label lastIndex_;
94 
95 
96  // Private Member Functions
97 
98  //- Update file
99  void updateFile();
100 
101  //- Disallow default bitwise copy construct
103 
104  //- Disallow default bitwise assignment
105  void operator=(const timeActivatedFileUpdate&);
106 
107 
108 public:
109 
110  //- Runtime type information
111  TypeName("timeActivatedFileUpdate");
112 
113 
114  // Constructors
115 
116  //- Construct from Time and dictionary
118  (
119  const word& name,
120  const Time& runTime,
121  const dictionary& dict
122  );
123 
124 
125  //- Destructor
126  virtual ~timeActivatedFileUpdate();
127 
128 
129  // Member Functions
130 
131  //- Read the timeActivatedFileUpdate data
132  virtual bool read(const dictionary&);
133 
134  //- Execute file updates
135  virtual bool execute();
136 
137  //- Do nothing
138  virtual bool write();
139 };
140 
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 } // End namespace functionObjects
145 } // End namespace Foam
146 
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 
149 #endif
150 
151 // ************************************************************************* //
dictionary dict
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
A class for handling file names.
Definition: fileName.H:69
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:137
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:60
engineTime & runTime
Abstract base-class for Time/database function objects.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
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.