fvCellZone.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) 2011-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 \*---------------------------------------------------------------------------*/
25 
26 #include "fvCellZone.H"
27 #include "volFields.H"
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 void Foam::fvCellZone::update()
32 {
33  const labelList& cells(this->zone());
34 
35  nGlobalCells_ = cells.size();
36  reduce(nGlobalCells_, sumOp<label>());
37 
38  V_ = 0;
39  forAll(cells, i)
40  {
41  V_ += mesh_.V()[cells[i]];
42  }
43  reduce(V_, sumOp<scalar>());
44 }
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
50 :
52  mesh_(mesh),
53  nGlobalCells_(returnReduce(mesh.nCells(), sumOp<label>())),
54  V_(gSum(mesh_.V()))
55 {}
56 
57 
59 :
61  mesh_(mesh),
62  nGlobalCells_(-1),
63  V_(NaN)
64 {
65  update();
66 }
67 
68 
69 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
70 
72 {}
73 
74 
75 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
76 
78 (
80  Ostream& file
81 )
82 {
83  wf.writeCommented(file, "Selection");
84  file<< setw(1) << ':' << setw(1) << ' ' << name() << endl;
85  wf.writeHeaderValue(file, "Cells", nGlobalCells());
86  wf.writeHeaderValue(file, "Volume", V());
87 }
88 
89 
91 {
93  update();
94 }
95 
96 
98 {
100  update();
101 }
102 
103 
105 {
107  update();
108 }
109 
110 
112 {
114  update();
115 }
116 
117 
119 {
121  update();
122 
123  return true;
124 }
125 
126 
127 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
functionObject base class for writing single files
Definition: writeFile.H:56
void writeHeaderValue(Ostream &os, const string &property, const Type &value) const
Write a (commented) header property and value pair.
void writeCommented(Ostream &os, const string &str) const
Write a commented string to stream.
Definition: writeFile.C:110
void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: fvCellZone.C:97
void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: fvCellZone.C:111
void movePoints()
Update for mesh motion.
Definition: fvCellZone.C:90
bool read(const dictionary &dict)
Read coefficients dictionary.
Definition: fvCellZone.C:118
void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: fvCellZone.C:104
~fvCellZone()
Destructor.
Definition: fvCellZone.C:71
void writeFileHeader(const functionObjects::writeFile &wf, Ostream &file)
Output file header information.
Definition: fvCellZone.C:78
fvCellZone(const fvMesh &mesh)
Construct from mesh selecting all cells.
Definition: fvCellZone.C:49
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:96
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.
cellZone selection or generation class
const cellZone & zone() const
Return const access to the cell set.
void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
void movePoints()
Update for mesh motion.
bool read(const dictionary &dict)
Read coefficients dictionary.
void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
const cellShapeList & cells
Type gSum(const FieldField< Field, Type > &f)
List< label > labelList
A List of labels.
Definition: labelList.H:56
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:258
Omanip< int > setw(const int i)
Definition: IOmanip.H:199
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
dictionary dict