processorRunTimes.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) 2022-2025 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::processorRunTimes
26 
27 Description
28 
29 SourceFiles
30  processorRunTimes.C
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #ifndef processorRunTimes_H
35 #define processorRunTimes_H
36 
37 #include "Time.H"
38 #include "PtrList.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 /*---------------------------------------------------------------------------*\
46  Class processorRunTimes Declaration
47 \*---------------------------------------------------------------------------*/
48 
50 {
51 public:
52 
53  // Public Enumerations
54 
55  //- Enumeration for how the number of processors is determined
56  enum class nProcsFrom
57  {
60  };
61 
62 
63 private:
64 
65  // Private Data
66 
67  //- The complete run time
68  Time completeRunTime_;
69 
70  //- Processor run times
71  PtrList<Time> procRunTimes_;
72 
73  //- Processor zero time that can be used/queried when there is no
74  // decomposition. Only allocated when procRunTimes_ is empty.
75  autoPtr<Time> proc0RunTime_;
76 
77 
78  // Private Member Functions
79 
80  //- Construct the processor run times
81  static PtrList<Time> procRunTimes
82  (
83  const Time& completeRunTime,
84  const nProcsFrom
85  );
86 
87  //- Construct the processor0 run time (if necessary)
88  static autoPtr<Time> proc0RunTime
89  (
90  const Time& completeRunTime,
91  const PtrList<Time>& procRunTimes
92  );
93 
94  //- Access the processor0 run time
95  inline Time& proc0TimeRef()
96  {
97  return proc0RunTime_.valid() ? proc0RunTime_() : procRunTimes_[0];
98  }
99 
100 
101 public:
102 
103  // Constructors
104 
105  //- Construct from name and arguments
107  (
108  const word& name,
109  const argList& args,
110  const bool enableFunctionObjects = true,
112  );
113 
114  //- Construct from name and directories
116  (
117  const word& name,
118  const fileName& rootPath,
119  const fileName& caseName,
120  const bool enableFunctionObjects = true,
122  );
123 
124 
125  //- Destructor
127 
128 
129  // Member Functions
130 
131  //- Access the complete run time
132  inline const Time& completeTime() const
133  {
134  return completeRunTime_;
135  }
136 
137  //- Access the processor run times
138  inline const PtrList<Time>& procTimes() const
139  {
140  return procRunTimes_;
141  }
142 
143  //- Return the number of processors
144  inline label nProcs() const
145  {
146  return procRunTimes_.size();
147  }
148 
149  //- Access the processor0 run time
150  inline const Time& proc0Time() const
151  {
152  return proc0RunTime_.valid() ? proc0RunTime_() : procRunTimes_[0];
153  }
154 
155  //- Set the time
156  void setTime(const instant& inst, const label newIndex);
157 
158  //- Select the time
160 
161  //- Select the time
163 };
164 
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 } // End namespace Foam
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 #endif
173 
174 // ************************************************************************* //
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:103
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
Definition: autoPtrI.H:83
An instant of time. Contains the time value and name.
Definition: instant.H:67
instantList selectComplete(const argList &args)
Select the time.
const Time & proc0Time() const
Access the processor0 run time.
nProcsFrom
Enumeration for how the number of processors is determined.
instantList selectProc(const argList &args)
Select the time.
label nProcs() const
Return the number of processors.
processorRunTimes(const word &name, const argList &args, const bool enableFunctionObjects=true, const nProcsFrom=nProcsFrom::decomposeParDict)
Construct from name and arguments.
const PtrList< Time > & procTimes() const
Access the processor run times.
void setTime(const instant &inst, const label newIndex)
Set the time.
const Time & completeTime() const
Access the complete run time.
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
Foam::argList args(argc, argv)