ensightParts.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "ensightParts.H"
30 #include "bitSet.H"
31 #include "emptyPolyPatch.H"
32 #include "processorPolyPatch.H"
33 
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 
36 Foam::ensightParts::ensightParts(const polyMesh& mesh)
37 :
38  StorageType()
39 {
41 }
42 
43 
44 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
45 
47 {
49 
50  label nPart = 0;
51 
52  // Track which cells are in a zone or not
53  bitSet selection(mesh.nCells());
54 
55  // Do all cell zones
56  for (const cellZone& zn : mesh.cellZones())
57  {
58  if (returnReduce(!zn.empty(), orOp<bool>()))
59  {
60  selection.set(zn);
61  this->append(new ensightPartCells(nPart++, mesh, zn));
62  }
63  }
64 
65  if (!nPart)
66  {
67  // No zones at all? - do entire mesh. Name as per ensightMesh
68  this->append(new ensightPartCells(nPart++, mesh, "internalMesh"));
69  }
70  else
71  {
72  // Flip from zoned to unzoned
73  selection.flip();
74 
75  if (returnReduce(selection.any(), orOp<bool>()))
76  {
77  this->append
78  (
79  new ensightPartCells(nPart++, mesh, selection, "__internal__")
80  );
81  }
82  }
83 
84 
85  // Do boundaries, skipping empty and processor patches
86  for (const polyPatch& p : mesh.boundaryMesh())
87  {
88  if (isA<processorPolyPatch>(p))
89  {
90  // No processor patches
91  break;
92  }
93 
94  if (returnReduce(!p.empty(), orOp<bool>()))
95  {
96  this->append(new ensightPartFaces(nPart++, mesh, p));
97  }
98  }
99 }
100 
101 
103 {
104  // Some feedback
105  Info<< "Write geometry part (" << flush;
106 
107  for (const ensightPart& part : *this)
108  {
109  Info<< ' ' << part.index() << flush;
110  part.write(os);
111  }
112  Info<< " )" << endl;
113 }
114 
115 
117 {
118  for (const ensightPart& part : *this)
119  {
120  part.writeSummary(os);
121  }
122 }
123 
124 
126 {
127  for (const ensightPart& part : *this)
128  {
129  part.dumpInfo(os);
130  }
131 }
132 
133 
134 // ************************************************************************* //
Foam::ensightPart::write
virtual void write(ensightGeoFile &os) const =0
Write geometry.
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:94
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:64
Foam::ensightParts::writeSummary
void writeSummary(Ostream &os) const
Write summary information about the objects.
Definition: ensightParts.C:116
Foam::bitSet::set
void set(const bitSet &bitset)
Set specified bits from another bitset.
Definition: bitSetI.H:563
Foam::polyMesh::cellZones
const cellZoneMesh & cellZones() const
Return cell zone mesh.
Definition: polyMesh.H:483
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:435
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::ensightPartCells
An implementation of ensightPart to hold volume mesh cells.
Definition: ensightPartCells.H:53
bitSet.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::LPtrList
Template class for non-intrusive linked PtrLists.
Definition: LPtrList.H:50
Foam::cellZone
A subset of mesh cells.
Definition: cellZone.H:62
Foam::flush
Ostream & flush(Ostream &os)
Flush stream.
Definition: Ostream.H:329
Foam::ensightGeoFile
Specialized Ensight output with extra geometry file header.
Definition: ensightGeoFile.H:48
Foam::primitiveMesh::nCells
label nCells() const
Number of mesh cells.
Definition: primitiveMeshI.H:96
Foam::label
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:62
Foam::ensightParts::write
void write(autoPtr< ensightGeoFile > &os) const
Write the geometry to file.
Definition: ensightParts.H:101
Foam::ensightPart::index
virtual label index() const =0
Part index (0-based)
Foam::ensightParts::dumpInfo
void dumpInfo(Ostream &os) const
Print various types of debugging information.
Definition: ensightParts.C:125
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
ensightParts.H
processorPolyPatch.H
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
emptyPolyPatch.H
Foam::ensightParts::recalculate
void recalculate(const polyMesh &mesh)
Clear old information and construct anew from polyMesh.
Definition: ensightParts.C:46
clear
patchWriters clear()
Foam::ensightPart
Base class for ensightPartCells and ensightPartFaces.
Definition: ensightPart.H:56
Foam::ensightPart::dumpInfo
virtual void dumpInfo(Ostream &os) const =0
Print various types of debugging information.
Foam::ensightPartFaces
An implementation of ensightPart to hold mesh faces.
Definition: ensightPartFaces.H:53
append
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::orOp
Definition: ops.H:234
Foam::ensightPart::writeSummary
virtual void writeSummary(Ostream &os) const =0
Write summary information about the object.