runTimeControl.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2015-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::functionObjects::runTimeControl
29 
30 Group
31  grpUtilitiesFunctionObjects
32 
33 Description
34  Controls when the calculation is terminated based on satisfying
35  user-specified conditions.
36 
37  Optionally specify a number of write steps before the calculation is
38  terminated. Here, a write is performed each time that all conditions are
39  satisfied.
40 
41 SourceFiles
42  runTimeControl.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef functionObjects_runTimeControl_H
47 #define functionObjects_runTimeControl_H
48 
49 #include "fvMeshFunctionObject.H"
50 #include "Map.H"
51 #include "Enum.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 namespace functionObjects
58 {
59 namespace runTimeControls
60 {
61 
62 // Forward declaration of classes
63 class runTimeCondition;
64 
65 /*---------------------------------------------------------------------------*\
66  Class runTimeControl Declaration
67 \*---------------------------------------------------------------------------*/
68 
69 class runTimeControl
70 :
72 {
73 public:
74 
75  // Public enumerations
76 
77  enum class satisfiedAction
78  {
79  ABORT,
80  END,
82  };
83 
85 
86 
87 private:
88 
89  // Private data
90 
91  //- List of conditions to satisfy
92  PtrList<runTimeCondition> conditions_;
93 
94  //- Map to define group IDs
95  Map<label> groupMap_;
96 
97  //- Number of write steps before exiting
98  label nWriteStep_;
99 
100  //- Current number of steps written
101  label writeStepI_;
102 
103  //- Action to take when conditions are satisfied
104  satisfiedAction satisfiedAction_;
105 
106  //- Trigger index if satisfiedAction is setTrigger
107  label triggerIndex_;
108 
109  //- Active flag
110  // Used in the trigger case to bypass any evaluations after the
111  // trigger has been set
112  bool active_;
113 
114 
115  // Private Member Functions
116 
117  //- No copy construct
118  runTimeControl(const runTimeControl&) = delete;
119 
120  //- No copy assignment
121  void operator=(const runTimeControl&) = delete;
122 
123 
124 public:
125 
126  //- Runtime type information
127  TypeName("runTimeControl");
128 
129 
130  // Constructors
131 
132  //- Construct for given objectRegistry and dictionary
134  (
135  const word& name,
136  const Time& runTime,
137  const dictionary& dict
138  );
139 
140 
141  //- Destructor
142  virtual ~runTimeControl() = default;
143 
144 
145  // Member Functions
146 
147  //- Read the runTimeControl data
148  virtual bool read(const dictionary&);
149 
150  //- Execute, currently does nothing
151  virtual bool execute();
152 
153  //- Calculate the runTimeControl and write
154  virtual bool write();
155 };
156 
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 } // End namespace runTimeControls
161 } // End namespace functionObjects
162 } // End namespace Foam
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 #endif
167 
168 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::Enum< satisfiedAction >
Foam::functionObjects::runTimeControls::runTimeControl::satisfiedAction::END
"end" - write and exit cleanly
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::functionObjects::runTimeControls::runTimeControl::satisfiedAction::SET_TRIGGER
"setTrigger" - trigger another condition
fvMeshFunctionObject.H
Foam::functionObjects::runTimeControls::runTimeControl::satisfiedActionNames
static Enum< satisfiedAction > satisfiedActionNames
Definition: runTimeControl.H:83
Foam::functionObjects::runTimeControls::runTimeControl::read
virtual bool read(const dictionary &)
Read the runTimeControl data.
Definition: runTimeControl.C:86
Foam::Map< label >
Foam::functionObjects::runTimeControls::runTimeControl::write
virtual bool write()
Calculate the runTimeControl and write.
Definition: runTimeControl.C:322
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Map.H
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
Foam::functionObjects::runTimeControls::runTimeControl::~runTimeControl
virtual ~runTimeControl()=default
Destructor.
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::runTimeControls::runTimeControl::TypeName
TypeName("runTimeControl")
Runtime type information.
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::runTimeControls::runTimeControl::satisfiedAction
satisfiedAction
Definition: runTimeControl.H:76
Foam::functionObjects::runTimeControls::runTimeControl::execute
virtual bool execute()
Execute, currently does nothing.
Definition: runTimeControl.C:178
Foam::functionObjects::runTimeControls::runTimeControl::satisfiedAction::ABORT
"abort" - write and emit a FatalError
Foam::functionObjects::runTimeControls::runTimeControl
Definition: runTimeControl.H:68
Enum.H