parProfiling.C
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) 2019-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "parProfiling.H"
29 #include "profilingPstream.H"
30 #include "Pstream.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace functionObjects
38 {
39  defineTypeNameAndDebug(parProfiling, 0);
40 
42  (
43  functionObject,
44  parProfiling,
45  dictionary
46  );
47 
48 } // End namespace functionObject
49 } // End namespace Foam
50 
51 
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 
55 (
56  const word& name,
57  const Time& runTime,
58  const dictionary& dict
59 )
60 :
62  reportLevel_(0)
63 {
64  dict.readIfPresent("detail", reportLevel_);
66 }
67 
68 
69 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
70 
72 {
74 }
75 
76 
77 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
78 
80 {
81  if (UPstream::parRun() && UPstream::nProcs() > 1)
82  {
83  Info<< nl;
84  profilingPstream::report(reportLevel_);
85  }
86 }
87 
88 
90 {
91  report();
92  return true;
93 }
94 
95 
97 {
98  return true;
99 }
100 
101 
103 {
105  return true;
106 }
107 
108 
109 // ************************************************************************* //
virtual bool end()
Disables profilingPstream.
Definition: parProfiling.C:95
dictionary dict
defineTypeNameAndDebug(ObukhovLength, 0)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
engineTime & runTime
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:1049
Abstract base-class for Time/database function objects.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
Macros for easy insertion into run-time selection tables.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
Definition: UPstream.H:1065
virtual bool execute()
Report.
Definition: parProfiling.C:82
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
virtual ~parProfiling()
Destructor. Disables profilingPstream.
Definition: parProfiling.C:64
A class for handling words, derived from Foam::string.
Definition: word.H:63
addToRunTimeSelectionTable(functionObject, ObukhovLength, dictionary)
parProfiling(const parProfiling &)=delete
No copy construct.
static void disable() noexcept
Remove timer for measuring communication activity. Does not affect times/counts.
messageStream Info
Information stream (stdout output on master, null elsewhere)
static void report(const int reportLevel=0)
Report current information. Uses parallel communication!
void report()
Report the current profiling information.
Definition: parProfiling.C:72
static void enable()
Create timer for measuring communication or un-suspend existing.
Namespace for OpenFOAM.
virtual bool write()
Do nothing.
Definition: parProfiling.C:89