stopAt.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) 2020-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::stopAt
26 
27 Description
28  Abstract base class for stop conditions.
29 
30  Currently the following actions are supported:
31  - noWriteNow
32  - writeNow
33  - nextWrite
34 
35 SourceFiles
36  stopAt.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef functionObjects_stopAt_H
41 #define functionObjects_stopAt_H
42 
43 #include "functionObject.H"
44 #include "NamedEnum.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 namespace functionObjects
51 {
52 
53 /*---------------------------------------------------------------------------*\
54  Class stopAt Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 class stopAt
58 :
59  public functionObject
60 {
61 public:
62 
63  //- Enumeration defining the type of action
64  enum class actionType
65  {
66  noWriteNow,
67  writeNow,
68  nextWrite
69  };
70 
71 
72 protected:
73 
74  // Protected data
75 
76  //- Action type names
78 
79  //- The type of action
81 
82  //- Set true when the stop action has executed
83  bool stopped_;
84 
85 
86  // Protected Member Functions
87 
88  //- Return true when the stop condition is achieved
89  virtual bool condition() const = 0;
90 
91 
92 public:
93 
94  //- Runtime type information
95  TypeName("stopAt");
96 
97 
98  // Constructors
99 
100  //- Construct from Time and dictionary
101  stopAt
102  (
103  const word& name,
104  const Time& runTime,
105  const dictionary&
106  );
107 
108  //- Disallow default bitwise copy construction
109  stopAt(const stopAt&) = delete;
110 
111 
112  //- Destructor
113  virtual ~stopAt();
114 
115 
116  // Member Functions
117 
118  //- Read the dictionary settings
119  virtual bool read(const dictionary&);
120 
121  //- Return the list of fields required
122  virtual wordList fields() const
123  {
124  return wordList::null();
125  }
126 
127  //- Execute, check existence of stopAt file and take action
128  virtual bool execute();
129 
130  //- Execute, check existence of stopAt file and take action
131  virtual bool write();
132 
133  //- Execute at the final time-loop, used for cleanup
134  virtual bool end();
135 
136 
137  // Member Operators
138 
139  //- Disallow default bitwise assignment
140  void operator=(const stopAt&) = delete;
141 };
142 
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 } // End namespace functionObjects
147 } // End namespace Foam
148 
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 
151 #endif
152 
153 // ************************************************************************* //
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
Abstract base-class for Time/database functionObjects.
const word & name() const
Return the name of this functionObject.
Abstract base class for stop conditions.
Definition: stopAt.H:59
TypeName("stopAt")
Runtime type information.
virtual wordList fields() const
Return the list of fields required.
Definition: stopAt.H:121
bool stopped_
Set true when the stop action has executed.
Definition: stopAt.H:82
virtual ~stopAt()
Destructor.
Definition: stopAt.C:76
virtual bool condition() const =0
Return true when the stop condition is achieved.
actionType
Enumeration defining the type of action.
Definition: stopAt.H:64
@ nextWrite
stop the next time data are written
@ writeNow
write data and stop immediately
@ noWriteNow
stop immediately without writing data
static const NamedEnum< actionType, 3 > actionTypeNames_
Action type names.
Definition: stopAt.H:76
void operator=(const stopAt &)=delete
Disallow default bitwise assignment.
stopAt(const word &name, const Time &runTime, const dictionary &)
Construct from Time and dictionary.
Definition: stopAt.C:62
virtual bool execute()
Execute, check existence of stopAt file and take action.
Definition: stopAt.C:93
virtual bool write()
Execute, check existence of stopAt file and take action.
Definition: stopAt.C:149
actionType action_
The type of action.
Definition: stopAt.H:79
virtual bool end()
Execute at the final time-loop, used for cleanup.
Definition: stopAt.C:155
virtual bool read(const dictionary &)
Read the dictionary settings.
Definition: stopAt.C:82
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.