sigStopAtWriteNow.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2019 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::sigStopAtWriteNow
29 
30 Description
31  Signal handler to write and stop the job.
32  The interrupt is defined by OptimisationSwitches::stopAtWriteNowSignal
33 
34 SourceFiles
35  sigStopAtWriteNow.C
36 
37 See also
38  Foam::JobInfo
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef Foam_sigStopAtWriteNow_H
43 #define Foam_sigStopAtWriteNow_H
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward Declarations
51 class Time;
52 
53 /*---------------------------------------------------------------------------*\
54  Class sigStopAtWriteNow Declaration
55 \*---------------------------------------------------------------------------*/
56 
58 {
59  // Private Data
60 
61  //- Signal number to use
62  static int signal_;
63 
64 
65  // Private Member Functions
66 
67  //- Handler for caught signals
68  static void sigHandler(int);
69 
70 
71 public:
72 
73  //- Allow setter access to signal_
74  friend class addstopAtWriteNowSignalToOpt;
75 
76 
77  // Constructors
78 
79  //- Default construct
80  sigStopAtWriteNow() noexcept = default;
81 
82  //- Construct with Time reference
83  explicit sigStopAtWriteNow(const Time& runTime, bool verbose=false);
84 
85 
86  //- Destructor
88 
89 
90  // Member Functions
91 
92  //- Is active?
93  static bool active() noexcept { return (signal_ > 0); }
94 
95  //- Signal number being used
96  static int signalNumber() noexcept { return signal_; }
97 
98  //- Set/reset signal handler
99  static void set(bool verbose=false);
100 };
101 
103 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
104 
105 } // End namespace Foam
106 
107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
108 
109 #endif
110 
111 // ************************************************************************* //
static bool active() noexcept
Is active?
engineTime & runTime
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
static int signalNumber() noexcept
Signal number being used.
const direction noexcept
Definition: Scalar.H:258
sigStopAtWriteNow() noexcept=default
Default construct.
Signal handler to write and stop the job. The interrupt is defined by OptimisationSwitches::stopAtWri...
Namespace for OpenFOAM.