processorRunTimes.C
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-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 \*---------------------------------------------------------------------------*/
25 
26 #include "processorRunTimes.H"
27 #include "decompositionMethod.H"
28 #include "timeSelector.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
33 (
34  const word& name,
35  const argList& args
36 )
37 :
38  completeRunTime_(name, args),
39  procRunTimes_
40  (
41  decompositionMethod::decomposeParDict(completeRunTime_)
42  .lookup<int>("numberOfSubdomains")
43  )
44 {
45  forAll(procRunTimes_, proci)
46  {
47  procRunTimes_.set
48  (
49  proci,
50  new Time
51  (
53  completeRunTime_.rootPath(),
54  completeRunTime_.caseName()
55  /fileName(word("processor") + Foam::name(proci))
56  )
57  );
58 
59  procRunTimes_[proci].setTime(completeRunTime_);
60  }
61 }
62 
63 
64 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
65 
67 {}
68 
69 
70 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
71 
73 (
74  const instant& inst,
75  const label newIndex
76 )
77 {
78  completeRunTime_.setTime(inst, newIndex);
79 
80  forAll(procRunTimes_, proci)
81  {
82  procRunTimes_[proci].setTime(inst, newIndex);
83  }
84 }
85 
86 
88 {
89  const instantList timeDirs =
90  timeSelector::selectIfPresent(completeRunTime_, args);
91 
92  forAll(procRunTimes_, proci)
93  {
94  procRunTimes_[proci].setTime(completeRunTime_);
95  }
96 
97  return timeDirs;
98 }
99 
100 
102 {
103  const instantList timeDirs =
104  timeSelector::select0(procRunTimes_[0], args);
105 
106  completeRunTime_.setTime(procRunTimes_[0]);
107 
108  for (label proci = 1; proci < nProcs(); proci ++)
109  {
110  procRunTimes_[proci].setTime(procRunTimes_[0]);
111  }
112 
113  return timeDirs;
114 }
115 
116 
117 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
static word controlDictName
The default control dictionary name (normally "controlDict")
Definition: Time.H:208
const fileName & caseName() const
Explicitly inherit caseName from TimePaths to disambiguate from.
Definition: TimePaths.H:106
const fileName & rootPath() const
Explicitly inherit rootPath from TimePaths to disambiguate from.
Definition: TimePaths.H:94
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:103
Abstract base class for decomposition.
A class for handling file names.
Definition: fileName.H:82
An instant of time. Contains the time value and name.
Definition: instant.H:67
instantList selectComplete(const argList &args)
Select the time.
instantList selectProc(const argList &args)
Select the time.
void setTime(const instant &inst, const label newIndex)
Set the time.
processorRunTimes(const word &name, const argList &args)
Construct from directory and arguments.
static instantList select0(Time &runTime, const argList &args)
Return the set of times selected based on the argList options.
Definition: timeSelector.C:252
static instantList selectIfPresent(Time &runTime, const argList &args)
If any time option provided return the set of times (as select0)
Definition: timeSelector.C:283
A class for handling words, derived from string.
Definition: word.H:62
static instantList timeDirs
Definition: globalFoam.H:44
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 bool)
Return a word representation of a bool.
Definition: boolIO.C:39
Foam::argList args(argc, argv)