fvCellSet.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-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 "fvCellSet.H"
27 #include "volFields.H"
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 void Foam::fvCellSet::setV()
32 {
33  Info<< incrIndent;
34 
35  const labelUList cells(this->cells());
36 
37  V_ = 0;
38  forAll(cells, i)
39  {
40  V_ += mesh_.V()[cells[i]];
41  }
42  reduce(V_, sumOp<scalar>());
43 
44  Info<< indent
45  << "- selected " << returnReduce(cells.size(), sumOp<label>())
46  << " cell(s) with volume " << V_ << endl;
47 
48  Info<< decrIndent;
49 }
50 
51 
52 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
53 
55 (
57  Ostream& file
58 )
59 {
60  wf.writeCommented(file, "Selection");
61  file<< setw(1) << ':' << setw(1) << ' '
62  << selectionTypeNames[selectionType()] << " " << cellSetName() << endl;
63  wf.writeHeaderValue(file, "Volume", V());
64 }
65 
66 
67 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
68 
70 :
71  polyCellSet(mesh),
72  mesh_(mesh),
73  V_(gSum(mesh_.V()))
74 {}
75 
76 
78 :
79  polyCellSet(mesh, dict),
80  mesh_(mesh),
81  V_(NaN)
82 {
83  setV();
84 }
85 
86 
87 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
88 
90 {}
91 
92 
93 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
94 
96 {
98  setV();
99 }
100 
101 
103 {
105  setV();
106 }
107 
108 
110 {
112  setV();
113 }
114 
115 
117 {
119  setV();
120 }
121 
122 
124 {
126  setV();
127 
128  return true;
129 }
130 
131 
132 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
label size() const
Return the number of elements in the UList.
Definition: UListI.H:311
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
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
~fvCellSet()
Destructor.
Definition: fvCellSet.C:89
void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: fvCellSet.C:102
void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: fvCellSet.C:116
void movePoints()
Update for mesh motion.
Definition: fvCellSet.C:95
bool read(const dictionary &dict)
Read coefficients dictionary.
Definition: fvCellSet.C:123
fvCellSet(const fvMesh &mesh)
Construct from mesh. Will select all.
Definition: fvCellSet.C:69
void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: fvCellSet.C:109
void writeFileHeader(const functionObjects::writeFile &wf, Ostream &file)
Output file header information.
Definition: fvCellSet.C:55
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.
General run-time selected cell set selection class for polyMesh.
Definition: polyCellSet.H:82
void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: polyCellSet.C:183
void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: polyCellSet.C:195
void movePoints()
Update for mesh motion.
Definition: polyCellSet.C:174
bool read(const dictionary &dict)
Read coefficients dictionary.
Definition: polyCellSet.C:201
labelUList cells() const
Return const access to the cell set.
Definition: polyCellSetI.H:43
void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: polyCellSet.C:189
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.
static Type NaN()
Return a primitive with all components set to NaN.
Type gSum(const FieldField< Field, Type > &f)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:235
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Omanip< int > setw(const int i)
Definition: IOmanip.H:199
messageStream Info
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:228
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)
UList< label > labelUList
Definition: UList.H:65
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
dictionary dict