All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sigStopAtWriteNow.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2023 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::sigStopAtWriteNow
26 
27 Description
28  Signal handler to write and exit when the stopAtWriteNowSignal is sent.
29 
30  stopAtWriteNowSignal is set in etc/controlDict::OptimisationSwitches, e.g.
31  \verbatim
32  OptimisationSwitches
33  {
34  .
35  .
36  // Force dumping and exit (at next timestep) upon signal (-1 to disable)
37  stopAtWriteNowSignal 12; // SIGUSR2
38  .
39  .
40  }
41  \endverbatim
42 
43 SourceFiles
44  sigStopAtWriteNow.C
45 
46 \*---------------------------------------------------------------------------*/
47 
48 #ifndef sigStopAtWriteNow_H
49 #define sigStopAtWriteNow_H
50 
51 #include <signal.h>
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 class Time;
59 
60 /*---------------------------------------------------------------------------*\
61  Class sigStopAtWriteNow Declaration
62 \*---------------------------------------------------------------------------*/
63 
65 {
66  // Private Data
67 
68  //- Number of signal to use
69  static int signal_;
70 
71  //- Pointer to Time
72  static Time const* runTimePtr_;
73 
74  //- Saved old signal trapping setting
75  static struct sigaction oldAction_;
76 
77 
78  // Private Member Functions
79 
80  static void sigHandler(int);
81 
82 
83 public:
84 
85  //- wip. Have setter have access to signal_
86  friend class addstopAtWriteNowSignalToOpt;
87 
88 
89  // Constructors
90 
91  //- Construct null
93 
94  //- Construct from components
95  sigStopAtWriteNow(const bool verbose, const Time& runTime);
96 
97 
98  //- Destructor
100 
101 
102  // Member Functions
103 
104  //- (re)set signal catcher
105  static void set(const bool verbose);
106 
107  //- Is active?
108  bool active() const;
109 };
110 
111 
112 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
113 
114 } // End namespace Foam
115 
116 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
117 
118 #endif
119 
120 // ************************************************************************* //
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
Signal handler to write and exit when the stopAtWriteNowSignal is sent.
sigStopAtWriteNow()
Construct null.
friend class addstopAtWriteNowSignalToOpt
wip. Have setter have access to signal_
bool active() const
Is active?
static void set(const bool verbose)
(re)set signal catcher
Namespace for OpenFOAM.