meshReader.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) 2019-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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 "meshReader.H"
30#include "Time.H"
31#include "polyMesh.H"
32#include "faceSet.H"
33#include "emptyPolyPatch.H"
34
35// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
36
37void Foam::meshReader::addCellZones(polyMesh& mesh) const
38{
40 warnDuplicates("cellZones", mesh.cellZones().names());
41}
42
43
44void Foam::meshReader::addFaceZones(polyMesh& mesh) const
45{
46 label nZone = monitoringSets_.size();
47 mesh.faceZones().setSize(nZone);
48
49 if (!nZone)
50 {
51 return;
52 }
53
54 nZone = 0;
55 forAllConstIters(monitoringSets_, iter)
56 {
57 Info<< "faceZone " << nZone
58 << " (size: " << iter().size() << ") name: "
59 << iter.key() << endl;
60
62 (
63 nZone,
64 new faceZone
65 (
66 iter.key(),
67 iter(),
68 false, // none are flipped
69 nZone,
71 )
72 );
73
74 nZone++;
75 }
77 warnDuplicates("faceZones", mesh.faceZones().names());
78}
79
80
82(
83 const objectRegistry& registry
84)
85{
86 readGeometry();
87
88 Info<< "Creating a polyMesh" << endl;
89 createPolyCells();
90
91 Info<< "Number of internal faces: " << nInternalFaces_ << endl;
92
93 createPolyBoundary();
94 clearExtraStorage();
95
97 (
99 (
101 registry.time().constant(),
102 registry,
105 ),
106 std::move(points_),
107 std::move(meshFaces_),
108 std::move(cellPolys_)
109 );
111
112 // Adding patches also checks the mesh
113 mesh.addPatches(polyBoundaryPatches(mesh));
114
115 warnDuplicates("boundaries", mesh.boundaryMesh().names());
116
117 addCellZones(mesh);
118 addFaceZones(mesh);
119
120 return meshPtr;
121}
122
123
125(
126 const polyMesh& mesh,
127 IOstreamOption streamOpt
128) const
129{
131
132 Info<< "Writing polyMesh" << endl;
133 mesh.writeObject(streamOpt, true);
134 writeAux(mesh);
135}
136
137
138void Foam::meshReader::clearExtraStorage()
139{
140 cellFaces_.clear();
141 baffleFaces_.clear();
142 boundaryIds_.clear();
143 baffleIds_.clear();
144
145 pointCellsPtr_.reset(nullptr);
146}
147
148
149// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
150
152(
153 const fileName& fileOrPrefix,
154 const scalar scaleFactor
155)
156:
157 pointCellsPtr_(nullptr),
158 interfaces_(0),
159 baffleIds_(0),
160 cellPolys_(0),
161 monitoringSets_(),
162 // protected
163 geometryFile_(fileOrPrefix),
164 scaleFactor_(scaleFactor),
165 points_(0),
166 origCellId_(0),
167 boundaryIds_(0),
168 patchTypes_(0),
169 patchNames_(0),
170 patchPhysicalTypes_(0),
171 patchStarts_(0),
172 patchSizes_(0),
173 nInternalFaces_(0),
174 meshFaces_(0),
175 cellFaces_(0),
176 baffleFaces_(0),
177 cellTableId_(0),
178 cellTable_()
179{
180 // Sanity
181 if (scaleFactor_ <= VSMALL)
182 {
183 scaleFactor_ = 1;
184 }
185}
186
187
188// ************************************************************************* //
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
writeOption writeOpt() const noexcept
The write option.
Definition: IOobjectI.H:179
The IOstreamOption is a simple container for options an IOstream can normally have.
const T * set(const label i) const
Definition: PtrList.H:138
void setSize(const label newLen)
Same as resize()
Definition: PtrList.H:151
const word & constant() const
Return constant name.
Definition: TimePathsI.H:96
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
wordList names() const
A list of the zone names.
Definition: ZoneMesh.C:304
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
void addCellZones(polyMesh &, const labelList &tableIds) const
Classify tableIds into cellZones according to the cellTable.
Definition: cellTable.C:440
void writeMesh() const
Write equivalent mesh information at the polyMesh faceInstances time.
A class for handling file names.
Definition: fileName.H:76
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write the underlying polyMesh and other data.
Definition: fvMesh.C:1056
This class supports creating polyMeshes with baffles.
Definition: meshReader.H:69
scalar scaleFactor_
Geometry scaling.
Definition: meshReader.H:213
static void warnDuplicates(const word &context, const wordList &)
Warn about repeated names.
Definition: meshReaderAux.C:37
cellTable cellTable_
Cell table persistent data saved as a dictionary.
Definition: meshReader.H:254
labelList cellTableId_
Cell table id for each cell.
Definition: meshReader.H:251
Registry of regIOobjects.
const Time & time() const noexcept
Return time registry.
wordList names() const
Return a list of patch names.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
Definition: polyMesh.H:498
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:321
void addPatches(polyPatchList &plist, const bool validBoundary=true)
Add boundary patches.
Definition: polyMesh.C:975
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:456
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
Definition: polyMesh.H:504
void removeFiles(const fileName &instanceDir) const
Remove all files from mesh instance.
Definition: polyMesh.C:1340
dynamicFvMesh & mesh
Foam::autoPtr< Foam::dynamicFvMesh > meshPtr
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Definition: stdFoam.H:278