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 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  //- Reference to the Time
77  const Time& time_;
78 
79  //- Action type names
81 
82  //- The type of action
84 
85  //- Set true when the stop action has executed
86  bool stopped_;
87 
88 
89  // Protected Member Functions
90 
91  //- Return true when the stop condition is achieved
92  virtual bool condition() const = 0;
93 
94 
95 public:
96 
97  //- Runtime type information
98  TypeName("stopAt");
99 
100 
101  // Constructors
102 
103  //- Construct from Time and dictionary
104  stopAt
105  (
106  const word& name,
107  const Time& runTime,
108  const dictionary&
109  );
110 
111  //- Disallow default bitwise copy construction
112  stopAt(const stopAt&) = delete;
113 
114 
115  //- Destructor
116  virtual ~stopAt();
117 
118 
119  // Member Functions
120 
121  //- Read the dictionary settings
122  virtual bool read(const dictionary&);
123 
124  //- Execute, check existence of stopAt file and take action
125  virtual bool execute();
126 
127  //- Execute, check existence of stopAt file and take action
128  virtual bool write();
129 
130  //- Execute at the final time-loop, used for cleanup
131  virtual bool end();
132 
133 
134  // Member Operators
135 
136  //- Disallow default bitwise assignment
137  void operator=(const stopAt&) = delete;
138 };
139 
140 
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 
143 } // End namespace functionObjects
144 } // End namespace Foam
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 #endif
149 
150 // ************************************************************************* //
actionType
Enumeration defining the type of action.
Definition: stopAt.H:63
virtual bool end()
Execute at the final time-loop, used for cleanup.
Definition: stopAt.C:160
virtual bool read(const dictionary &)
Read the dictionary settings.
Definition: stopAt.C:83
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
engineTime & runTime
virtual bool condition() const =0
Return true when the stop condition is achieved.
virtual ~stopAt()
Destructor.
Definition: stopAt.C:77
stop immediately without writing data
Abstract base-class for Time/database functionObjects.
stop the next time data are written
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
void operator=(const stopAt &)=delete
Disallow default bitwise assignment.
static const NamedEnum< actionType, 3 > actionTypeNames_
Action type names.
Definition: stopAt.H:79
A class for handling words, derived from string.
Definition: word.H:59
virtual bool write()
Execute, check existence of stopAt file and take action.
Definition: stopAt.C:154
TypeName("stopAt")
Runtime type information.
virtual bool execute()
Execute, check existence of stopAt file and take action.
Definition: stopAt.C:98
Abstract base class for stop conditions.
Definition: stopAt.H:56
bool stopped_
Set true when the stop action has executed.
Definition: stopAt.H:85
stopAt(const word &name, const Time &runTime, const dictionary &)
Construct from Time and dictionary.
Definition: stopAt.C:62
actionType action_
The type of action.
Definition: stopAt.H:82
const Time & time_
Reference to the Time.
Definition: stopAt.H:76
Namespace for OpenFOAM.