stopAtFile.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-2020 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::stopAtFile
26 
27 Description
28  Stops the run when the specified file is created in the case directory
29  and optionally write results before stopping.
30 
31  The default name of the trigger file is \c $FOAM_CASE/<name> where \c
32  <name> is the name of the functionObject entry.
33 
34  Currently the following action types are supported:
35  - noWriteNow
36  - writeNow
37  - nextWrite (default)
38 
39  Examples of function object specification:
40  \verbatim
41  stop
42  {
43  type stopAtFile;
44  libs ("libutilityFunctionObjects.so");
45  }
46  \endverbatim
47  will stop the run at the next write after the file "stop" is created in the
48  case directory.
49 
50  \verbatim
51  stop
52  {
53  type stopAtFile;
54  libs ("libutilityFunctionObjects.so");
55  file "$FOAM_CASE/stop";
56  action writeNow;
57  }
58  \endverbatim
59  will write the fields and stop the run when the file "stop" is created in
60  the case directory.
61 
62 Usage
63  \table
64  Property | Description | Required | Default value
65  type | type name: stopAtFile | yes |
66  file | Trigger file path name | no | $FOAM_CASE/<name>
67  action | Action executed | no | nextWrite
68  \endtable
69 
70 SourceFiles
71  stopAtFile.C
72 
73 \*---------------------------------------------------------------------------*/
74 
75 #ifndef functionObjects_stopAtFile_H
76 #define functionObjects_stopAtFile_H
77 
78 #include "stopAt.H"
79 
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81 
82 namespace Foam
83 {
84 namespace functionObjects
85 {
86 
87 /*---------------------------------------------------------------------------*\
88  Class stopAtFile Declaration
89 \*---------------------------------------------------------------------------*/
90 
91 class stopAtFile
92 :
93  public stopAt
94 {
95  // Private Data
96 
97  //- The fully-qualified name of the stopAtFile file
98  fileName stopAtFileFile_;
99 
100 
101  // Private Member Functions
102 
103  //- Remove stopAtFile file.
104  void removeFile() const;
105 
106  //- Return true when the stop condition is achieved
107  virtual bool condition() const;
108 
109 
110 public:
111 
112  //- Runtime type information
113  TypeName("stopAtFile");
114 
115 
116  // Constructors
117 
118  //- Construct from Time and dictionary
119  stopAtFile
120  (
121  const word& name,
122  const Time& runTime,
123  const dictionary&
124  );
125 
126  //- Disallow default bitwise copy construction
127  stopAtFile(const stopAtFile&) = delete;
128 
129 
130  //- Destructor
131  virtual ~stopAtFile();
132 
133 
134  // Member Functions
135 
136  //- Read the dictionary settings
137  virtual bool read(const dictionary&);
138 
139  //- Execute at the final time-loop, used for cleanup
140  virtual bool end();
141 
142 
143  // Member Operators
144 
145  //- Disallow default bitwise assignment
146  void operator=(const stopAtFile&) = delete;
147 };
148 
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 } // End namespace functionObjects
153 } // End namespace Foam
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 #endif
158 
159 // ************************************************************************* //
virtual bool end()
Execute at the final time-loop, used for cleanup.
Definition: stopAtFile.C:112
stopAtFile(const word &name, const Time &runTime, const dictionary &)
Construct from Time and dictionary.
Definition: stopAtFile.C:74
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:158
engineTime & runTime
virtual ~stopAtFile()
Destructor.
Definition: stopAtFile.C:93
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
A class for handling words, derived from string.
Definition: word.H:59
virtual bool read(const dictionary &)
Read the dictionary settings.
Definition: stopAtFile.C:99
void operator=(const stopAtFile &)=delete
Disallow default bitwise assignment.
Stops the run when the specified file is created in the case directory and optionally write results b...
Definition: stopAtFile.H:110
TypeName("stopAtFile")
Runtime type information.
Namespace for OpenFOAM.