workflowControls.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation; either version 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  workflowControls
26 
27 Description
28  A controller fo managing the mesh generation workflow. It allows the user
29  to stop the meshing process after selected steps in the workflow,
30  and restart from a selected point.
31 
32 SourceFiles
33  workflowControls.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef workflowControls_H
38 #define workflowControls_H
39 
40 #include "IOdictionary.H"
41 #include "DynList.H"
42 
43 #include <map>
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 class polyMeshGen;
51 
52 /*---------------------------------------------------------------------------*\
53  Class workflowControls Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class workflowControls
57 {
58  // Private data
59  //- reference to the mesh
61 
62  //- current step in the workflow
64 
65  //- step for restarting the workflow
67 
68  //- completed step before restart
70 
71  //- holds information whether the workflow has been restarted
72  mutable bool isRestarted_;
73 
74  // static private data
75  static const std::map<word, label> workflowSteps_;
76 
77  // Private member functions
78  //- check if restart is requested
79  bool restartRequested() const;
80 
81  //- sets the current step to completed
82  void setStepCompleted() const;
83 
84  //- is the current step already completed
85  bool isStepCompleted() const;
86 
87  //- shall the procedure stop after the current step
88  bool exitAfterCurrentStep() const;
89 
90  //- return the latest completed step
91  word lastCompletedStep() const;
92 
93  //- return the names of completed steps
95 
96  //- remove completedStep from the dictionary
97  void clearCompletedSteps();
98 
99  //- shall the workflow stop after the current step
100  bool stopAfterCurrentStep() const;
101 
102  //- shall the workflow run after the current step
103  bool runAfterCurrentStep() const;
104 
105  // Static private member functions
106  //- populate workflowSteps with values
107  static std::map<word, label> populateWorkflowSteps();
108 
109 public:
110 
111  // Constructors
112 
113  //- Construct from IOdictionary
115 
116  // Destructor
118 
119  // Public member functions
120 
121  //- shall the process run the current step
122  bool runCurrentStep(const word&);
123 
124  //- set the workflow completed flag
125  void workflowCompleted();
126 };
127 
128 
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 
131 } // End namespace Foam
132 
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 
135 #endif
136 
137 // ************************************************************************* //
Foam::workflowControls::runCurrentStep
bool runCurrentStep(const word &)
shall the process run the current step
Definition: workflowControls.C:276
Foam::workflowControls::lastCompletedStep
word lastCompletedStep() const
return the latest completed step
Definition: workflowControls.C:136
Foam::workflowControls::clearCompletedSteps
void clearCompletedSteps()
remove completedStep from the dictionary
Definition: workflowControls.C:158
Foam::workflowControls::restartRequested
bool restartRequested() const
check if restart is requested
Definition: workflowControls.C:41
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::workflowControls::populateWorkflowSteps
static std::map< word, label > populateWorkflowSteps()
populate workflowSteps with values
Definition: workflowControls.C:231
Foam::polyMeshGen
Definition: polyMeshGen.H:46
Foam::workflowControls::mesh_
polyMeshGen & mesh_
reference to the mesh
Definition: workflowControls.H:59
Foam::workflowControls::completedStepsBeforeRestart_
DynList< word > completedStepsBeforeRestart_
completed step before restart
Definition: workflowControls.H:68
polyMeshGen
Mesh with selections.
Foam::workflowControls::setStepCompleted
void setStepCompleted() const
sets the current step to completed
Definition: workflowControls.C:67
Foam::workflowControls::restartAfterStep_
word restartAfterStep_
step for restarting the workflow
Definition: workflowControls.H:65
Foam::workflowControls::completedSteps
DynList< word > completedSteps() const
return the names of completed steps
Definition: workflowControls.C:148
Foam::workflowControls::workflowCompleted
void workflowCompleted()
set the workflow completed flag
Definition: workflowControls.C:323
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::workflowControls::workflowControls
workflowControls(polyMeshGen &mesh)
Construct from IOdictionary.
Definition: workflowControls.C:249
Foam::DynList
Definition: DynList.H:53
IOdictionary.H
Foam::workflowControls::isRestarted_
bool isRestarted_
holds information whether the workflow has been restarted
Definition: workflowControls.H:71
Foam::workflowControls::isStepCompleted
bool isStepCompleted() const
is the current step already completed
Definition: workflowControls.C:94
Foam::workflowControls::~workflowControls
~workflowControls()
Definition: workflowControls.C:271
Foam::workflowControls::runAfterCurrentStep
bool runAfterCurrentStep() const
shall the workflow run after the current step
Definition: workflowControls.C:202
Foam::workflowControls::workflowSteps_
static const std::map< word, label > workflowSteps_
Definition: workflowControls.H:74
Foam::workflowControls::currentStep_
word currentStep_
current step in the workflow
Definition: workflowControls.H:62
Foam::workflowControls
Definition: workflowControls.H:55
Foam::workflowControls::stopAfterCurrentStep
bool stopAfterCurrentStep() const
shall the workflow stop after the current step
Definition: workflowControls.C:164
DynList.H
Foam::workflowControls::exitAfterCurrentStep
bool exitAfterCurrentStep() const
shall the procedure stop after the current step
Definition: workflowControls.C:110