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