cpuLoad.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-2024 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 "cpuLoad.H"
27 #include "polyDistributionMap.H"
28 #include "polyTopoChangeMap.H"
29 #include "polyMeshMap.H"
30 #include "cellMapper.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
37  optionalCpuLoad optionalCpuLoad::optionalCpuLoad_;
38 }
39 
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 :
46  (
47  name,
48  mesh
49  ),
50  scalarField(mesh.nCells(), 0.0)
51 {}
52 
53 
54 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
55 
57 {}
58 
59 
60 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
61 
63 (
64  const word& name,
65  const polyMesh& mesh,
66  const bool loadBalancing
67 )
68 {
69  if (loadBalancing)
70  {
72  <
73  polyMesh,
75  cpuLoad
76  >::New(name, mesh);
77  }
78  else
79  {
80  return optionalCpuLoad::optionalCpuLoad_;
81  }
82 }
83 
84 
85 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
86 
88 {
89  cpuTime_.cpuTimeIncrement();
90 }
91 
92 
94 {
95  operator[](celli) += cpuTime_.cpuTimeIncrement();
96 }
97 
98 
100 {
102 }
103 
104 
106 {
107  return true;
108 }
109 
110 
112 {
113  const cellMapper cellMap(map);
114  cellMap(*this, *this);
115 }
116 
117 
119 {
120  setSize(map.mesh().nCells());
121  reset();
122 }
123 
124 
126 {
127  setSize(map.mesh().nCells());
128  reset();
129 }
130 
131 
132 // ************************************************************************* //
Templated abstract base-class for demand-driven mesh objects used to automate their allocation to the...
void operator=(const Field< scalar > &)
Definition: Field.C:550
This object provides mapping and fill-in information for cell data between the two meshes after the t...
Definition: cellMapper.H:57
Class to maintain a field of the CPU load per cell.
Definition: cpuLoad.H:129
virtual bool movePoints()
Update for mesh motion.
Definition: cpuLoad.C:105
virtual void resetCpuTime()
Reset the CPU time.
Definition: cpuLoad.C:87
cpuLoad(const word &name, const polyMesh &mesh)
Construct from mesh, name and switch.
Definition: cpuLoad.C:43
virtual void cpuTimeIncrement(const label celli)
Cache the CPU time increment for celli.
Definition: cpuLoad.C:93
virtual ~cpuLoad()
Destructor.
Definition: cpuLoad.C:56
virtual void mapMesh(const polyMeshMap &map)
Update from another mesh using the given map.
Definition: cpuLoad.C:118
virtual void distribute(const polyDistributionMap &map)
Redistribute or update using the given distribution map.
Definition: cpuLoad.C:125
virtual void reset()
Reset the CPU load field.
Definition: cpuLoad.C:99
virtual void topoChange(const polyTopoChangeMap &map)
Update topology using the given map.
Definition: cpuLoad.C:111
static optionalCpuLoad & New(const word &name, const polyMesh &mesh, const bool loadBalancing)
Construct from polyMesh if loadBalancing is true.
Definition: cpuLoad.C:63
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
const polyMesh & mesh() const
Return polyMesh.
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
const polyMesh & mesh() const
Return polyMesh.
Definition: polyMeshMap.H:75
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
label nCells() const
A class for handling words, derived from string.
Definition: word.H:62
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 bool)
Return a word representation of a bool.
Definition: boolIO.C:39
defineTypeNameAndDebug(combustionModel, 0)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
points setSize(newPointi)