abortCalculation.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 | Copyright (C) 2011-2013 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::abortCalculation
26 
27 Group
28  grpJobControlFunctionObjects
29 
30 Description
31  Watches for presence of the named file in the $FOAM_CASE directory
32  and aborts the calculation if it is present.
33 
34  Currently the following action types are supported:
35  - noWriteNow
36  - writeNow
37  - nextWrite
38 
39 SourceFiles
40  abortCalculation.C
41  IOabortCalculation.H
42 
43 \*---------------------------------------------------------------------------*/
44 
45 #ifndef abortCalculation_H
46 #define abortCalculation_H
47 
48 #include "NamedEnum.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward declaration of classes
56 class objectRegistry;
57 class dictionary;
58 class polyMesh;
59 class mapPolyMesh;
60 
61 /*---------------------------------------------------------------------------*\
62  Class abortCalculation Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class abortCalculation
66 {
67 public:
68 
69  // Public data
70 
71  //- Enumeration defining the type of action
72  enum actionType
73  {
76  nextWrite
77  };
78 
79 private:
80 
81  // Private data
82 
83  //- Name of the abort file unless otherwise specified
84  word name_;
85 
86  const objectRegistry& obr_;
87 
88  //- The fully-qualified name of the abort file
90 
91  //- Action type names
93 
94  //- The type of action
96 
97 
98  // Private Member Functions
99 
100  //- Remove abort file.
101  void removeFile() const;
102 
103  //- Disallow default bitwise copy construct
105 
106  //- Disallow default bitwise assignment
107  void operator=(const abortCalculation&);
108 
109 
110 public:
111 
112  //- Runtime type information
113  TypeName("abort");
114 
115 
116  // Constructors
117 
118  //- Construct for given objectRegistry and dictionary.
120  (
121  const word& name,
122  const objectRegistry&,
123  const dictionary&,
124  const bool loadFromFilesUnused = false
125  );
126 
127 
128  //- Destructor
129  virtual ~abortCalculation();
130 
131 
132  // Member Functions
133 
134  //- Return name of the abort file
135  virtual const word& name() const
136  {
137  return name_;
138  }
139 
140  //- Read the dictionary settings
141  virtual void read(const dictionary&);
142 
143  //- Execute, check existence of abort file and take action
144  virtual void execute();
145 
146  //- Execute at the final time-loop, used for cleanup
147  virtual void end();
148 
149  //- Called when time was set at the end of the Time::operator++
150  virtual void timeSet();
151 
152  //- Execute, check existence of abort file and take action
153  virtual void write();
154 
155  //- Update for changes of mesh - does nothing
156  virtual void updateMesh(const mapPolyMesh&)
157  {}
158 
159  //- Update for changes of mesh - does nothing
160  virtual void movePoints(const polyMesh&)
161  {}
162 };
163 
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 } // End namespace Foam
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 #endif
172 
173 // ************************************************************************* //
Foam::abortCalculation::nextWrite
@ nextWrite
Definition: abortCalculation.H:75
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::abortCalculation::read
virtual void read(const dictionary &)
Read the dictionary settings.
Definition: abortCalculation.C:109
Foam::abortCalculation::name
virtual const word & name() const
Return name of the abort file.
Definition: abortCalculation.H:134
NamedEnum.H
Foam::abortCalculation::operator=
void operator=(const abortCalculation &)
Disallow default bitwise assignment.
Foam::abortCalculation::abortCalculation
abortCalculation(const abortCalculation &)
Disallow default bitwise copy construct.
Foam::abortCalculation::~abortCalculation
virtual ~abortCalculation()
Destructor.
Definition: abortCalculation.C:103
Foam::abortCalculation::TypeName
TypeName("abort")
Runtime type information.
Foam::abortCalculation::writeNow
@ writeNow
Definition: abortCalculation.H:74
Foam::abortCalculation::execute
virtual void execute()
Execute, check existence of abort file and take action.
Definition: abortCalculation.C:127
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::abortCalculation::action_
actionType action_
The type of action.
Definition: abortCalculation.H:94
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::abortCalculation
Watches for presence of the named file in the $FOAM_CASE directory and aborts the calculation if it i...
Definition: abortCalculation.H:64
Foam::abortCalculation::noWriteNow
@ noWriteNow
Definition: abortCalculation.H:73
Foam::abortCalculation::movePoints
virtual void movePoints(const polyMesh &)
Update for changes of mesh - does nothing.
Definition: abortCalculation.H:159
Foam::abortCalculation::write
virtual void write()
Execute, check existence of abort file and take action.
Definition: abortCalculation.C:188
Foam::abortCalculation::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh - does nothing.
Definition: abortCalculation.H:155
Foam::abortCalculation::obr_
const objectRegistry & obr_
Definition: abortCalculation.H:85
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::abortCalculation::actionTypeNames_
static const NamedEnum< actionType, 3 > actionTypeNames_
Action type names.
Definition: abortCalculation.H:91
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abortCalculation::name_
word name_
Name of the abort file unless otherwise specified.
Definition: abortCalculation.H:83
Foam::abortCalculation::removeFile
void removeFile() const
Remove abort file.
Definition: abortCalculation.C:65
Foam::abortCalculation::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: abortCalculation.C:182
Foam::abortCalculation::end
virtual void end()
Execute at the final time-loop, used for cleanup.
Definition: abortCalculation.C:176
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::abortCalculation::actionType
actionType
Enumeration defining the type of action.
Definition: abortCalculation.H:71
Foam::abortCalculation::abortFile_
fileName abortFile_
The fully-qualified name of the abort file.
Definition: abortCalculation.H:88
Foam::NamedEnum< actionType, 3 >