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-2018 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  END,
81  };
82 
84 
85 
86 private:
87 
88  // Private data
89 
90  //- List of conditions to satisfy
91  PtrList<runTimeCondition> conditions_;
92 
93  //- Map to define group IDs
94  Map<label> groupMap_;
95 
96  //- Number of write steps before exiting
97  label nWriteStep_;
98 
99  //- Current number of steps written
100  label writeStepI_;
101 
102  //- Action to take when conditions are satisfied
103  satisfiedAction satisfiedAction_;
104 
105  //- Trigger index if satisfiedAction is setTrigger
106  label triggerIndex_;
107 
108  //- Active flag
109  // Used in the trigger case to bypass any evaluations after the
110  // trigger has been set
111  bool active_;
112 
113 
114  // Private Member Functions
115 
116  //- No copy construct
117  runTimeControl(const runTimeControl&) = delete;
118 
119  //- No copy assignment
120  void operator=(const runTimeControl&) = delete;
121 
122 
123 public:
124 
125  //- Runtime type information
126  TypeName("runTimeControl");
127 
128 
129  // Constructors
130 
131  //- Construct for given objectRegistry and dictionary
133  (
134  const word& name,
135  const Time& runTime,
136  const dictionary& dict
137  );
138 
139 
140  //- Destructor
141  virtual ~runTimeControl() = default;
142 
143 
144  // Member Functions
145 
146  //- Read the runTimeControl data
147  virtual bool read(const dictionary&);
148 
149  //- Execute, currently does nothing
150  virtual bool execute();
151 
152  //- Calculate the runTimeControl and write
153  virtual bool write();
154 };
155 
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 } // End namespace runTimeControls
160 } // End namespace functionObjects
161 } // End namespace Foam
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 #endif
166 
167 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::Enum< satisfiedAction >
Foam::functionObjects::runTimeControls::runTimeControl::satisfiedAction::END
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:62
Foam::functionObjects::runTimeControls::runTimeControl::satisfiedAction::SET_TRIGGER
fvMeshFunctionObject.H
Foam::functionObjects::runTimeControls::runTimeControl::satisfiedActionNames
static Enum< satisfiedAction > satisfiedActionNames
Definition: runTimeControl.H:82
Foam::functionObjects::runTimeControls::runTimeControl::read
virtual bool read(const dictionary &)
Read the runTimeControl data.
Definition: runTimeControl.C:85
Foam::Map< label >
Foam::functionObjects::runTimeControls::runTimeControl::write
virtual bool write()
Calculate the runTimeControl and write.
Definition: runTimeControl.C:313
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:62
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:121
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
Return the name of this functionObject.
Definition: functionObject.C:131
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:177
Foam::functionObjects::runTimeControls::runTimeControl
Definition: runTimeControl.H:68
Enum.H