Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / mesh / cfMesh / utilities / workflowControls / workflowControls.H
blobc719bf29e6a6c5961c4c9f1fbc97df501ab437dc
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.
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.
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.
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/>.
24 Class
25     workflowControls
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.
32 SourceFiles
33     workflowControls.C
35 \*---------------------------------------------------------------------------*/
37 #ifndef workflowControls_H
38 #define workflowControls_H
40 #include "objectRegistry.H"
41 #include "foamTime.H"
42 #include "IOdictionary.H"
43 #include "DynList.H"
45 #include <map>
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 namespace Foam
52 class polyMeshGen;
54 /*---------------------------------------------------------------------------*\
55                     Class workflowControls Declaration
56 \*---------------------------------------------------------------------------*/
58 class workflowControls
60     // Private data
61         //- reference to the mesh
62         polyMeshGen& mesh_;
64         //- current step in the workflow
65         word currentStep_;
67         //- step for restarting the workflow
68         word restartAfterStep_;
70         //- completed step before restart
71         DynList<word> completedStepsBeforeRestart_;
73         //- holds information whether the workflow has been restarted
74         mutable bool isRestarted_;
76     // static private data
77         static const std::map<word, label> workflowSteps_;
79     // Private member functions
80         //- check if restart is requested
81         bool restartRequested() const;
83         //- sets the current step to completed
84         void setStepCompleted() const;
86         //- is the current step already completed
87         bool isStepCompleted() const;
89         //- shall the procedure stop after the current step
90         bool exitAfterCurrentStep() const;
92         //- return the latest completed step
93         word lastCompletedStep() const;
95         //- return the names of completed steps
96         DynList<word> completedSteps() const;
98         //- remove completedStep from the dictionary
99         void clearCompletedSteps();
101         //- shall the workflow stop after the current step
102         bool stopAfterCurrentStep() const;
104         //- shall the workflow run after the current step
105         bool runAfterCurrentStep() const;
107     // Static private member functions
108         //- populate workflowSteps with values
109         static std::map<word, label> populateWorkflowSteps();
111 public:
113     // Constructors
115         //- Construct from IOdictionary
116         workflowControls(polyMeshGen& mesh);
118     // Destructor
119         ~workflowControls();
121     // Public member functions
123         //- shall the process run the current step
124         bool runCurrentStep(const word&);
126         //- set the workflow completed flag
127         void workflowCompleted();
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133 } // End namespace Foam
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 #endif
139 // ************************************************************************* //