edgeMesh.H
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-2014 OpenFOAM Foundation
9 Copyright (C) 2017-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
27Class
28 Foam::edgeMesh
29
30Description
31 Points connected by edges.
32
33 Can be read from fileName based on extension. Uses ::New factory method
34 to select the reader and transfer the result.
35
36SourceFiles
37 edgeMeshI.H
38 edgeMesh.C
39 edgeMeshIO.C
40 edgeMeshNew.C
41
42\*---------------------------------------------------------------------------*/
43
44#ifndef edgeMesh_H
45#define edgeMesh_H
46
47#include "pointField.H"
48#include "edgeList.H"
49#include "dictionary.H"
50#include "edgeMeshFormatsCore.H"
53#include "HashSet.H"
54
55// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56
57namespace Foam
58{
59
60// Forward Declarations
61class edgeMesh;
62
63Istream& operator>>(Istream& is, edgeMesh& em);
64Ostream& operator<<(Ostream& os, const edgeMesh& em);
65
66/*---------------------------------------------------------------------------*\
67 Class edgeMesh Declaration
68\*---------------------------------------------------------------------------*/
69
70class edgeMesh
71:
72 public fileFormats::edgeMeshFormatsCore
73{
74 // Private Data
75
76 //- Vertices of the edges
77 pointField points_;
78
79 //- The edges defining the boundary
80 edgeList edges_;
81
82 //- From point to edges
83 mutable unique_ptr<labelListList> pointEdgesPtr_;
84
85
86 // Private Member Functions
87
88 //- Calculate point-edge addressing (inverse of edges)
89 void calcPointEdges() const;
90
91
92protected:
93
94 // Protected Member Functions
95
96 //- Non-const access to global points
98
99 //- Non-const access to the edges
100 inline edgeList& storedEdges() noexcept;
101
102
103public:
104
105 //- Runtime type information
107
108
109 // Static Member Functions
110
111 //- Summary of supported read file types.
112 static wordHashSet readTypes();
113
114 //- Summary of supported write file types.
115 static wordHashSet writeTypes();
116
117 //- Can we read this file format?
118 static bool canReadType(const word& fileType, bool verbose=false);
119
120 //- Can we write this file format type?
121 static bool canWriteType(const word& fileType, bool verbose=false);
122
123 //- Can we read this file format?
124 static bool canRead(const fileName& name, bool verbose=false);
125
126
127 // Constructors
128
129 //- Default construct
130 inline edgeMesh();
131
132 //- Copy construct
133 inline edgeMesh(const edgeMesh& em);
134
135 //- Move construct
136 inline edgeMesh(edgeMesh&& em);
137
138 //- Copy construct from components
139 inline edgeMesh(const pointField& points, const edgeList& edges);
140
141 //- Move construct from components
142 inline edgeMesh(pointField&& pointLst, edgeList&& edgeLst);
143
144 //- Construct from file name (uses extension to determine type)
145 explicit edgeMesh(const fileName& name);
146
147 //- Construct from file name with specified type
148 edgeMesh(const fileName& name, const word& fileType);
149
150
151 // Declare run-time constructor selection table
154 (
155 autoPtr,
156 edgeMesh,
157 fileExtension,
158 (
159 const fileName& name
160 ),
161 (name)
162 );
163
164
165 // Selectors
166
167 //- Read construct from filename with given format
168 static autoPtr<edgeMesh> New
169 (
170 const fileName& name,
171 const word& fileType
172 );
173
174 //- Select constructed from filename (implicit extension)
175 static autoPtr<edgeMesh> New(const fileName& name);
176
177
178 //- Destructor
179 virtual ~edgeMesh() = default;
180
181
182 // Member Function Selectors
185 (
186 void,
187 edgeMesh,
188 write,
189 fileExtension,
190 (
191 const fileName& name,
192 const edgeMesh& mesh,
193 IOstreamOption streamOpt,
194 const dictionary& options
195 ),
196 (name, mesh, streamOpt, options)
197 );
198
199 //- Write to file (format implicit in the extension)
200 static void write
201 (
202 const fileName& name,
203 const edgeMesh& mesh,
204 IOstreamOption streamOpt = IOstreamOption(),
205 const dictionary& options = dictionary::null
206 );
207
208 //- Write to file, with given format
209 static void write
210 (
211 const fileName& name,
212 const word& fileType,
213 const edgeMesh& mesh,
214 IOstreamOption streamOpt = IOstreamOption(),
215 const dictionary& options = dictionary::null
216 );
217
218
219 // Member Functions
220
221 //- Transfer the contents of the argument and annul the argument
222 void transfer(edgeMesh& mesh);
223
224
225 // Read
226
227 //- Read from file. Chooses reader based on explicit extension
228 bool read(const fileName& name, const word& fileType);
229
230 //- Read from file. Chooses reader based on detected extension
231 virtual bool read(const fileName& name);
232
233
234 // Access
235
236 //- Return points
237 inline const pointField& points() const noexcept;
238
239 //- Return edges
240 inline const edgeList& edges() const noexcept;
241
242 //- Return edges
243 inline const labelListList& pointEdges() const;
244
245 //- Find connected regions. Set region number per edge.
246 // Returns number of regions.
247 label regions(labelList& edgeRegion) const;
248
249
250 // Edit
251
252 //- Clear all storage
253 virtual void clear();
254
255 //- Scale points. A non-positive factor is ignored
256 virtual void scalePoints(const scalar scaleFactor);
257
258 //- Geometric merge points (points within mergeDist) prior to
259 // automatically calling mergeEdges().
260 virtual void mergePoints(const scalar mergeDist);
261
262 //- Merge duplicate edges and eliminate unused points.
263 virtual void mergeEdges();
264
265
266 // Write
267
268 virtual void writeStats(Ostream&) const;
269
270 //- Write to file, choosing writer based on the file extension.
271 virtual void write
272 (
273 const fileName& name,
274 IOstreamOption streamOpt = IOstreamOption(),
275 const dictionary& options = dictionary::null
276 ) const
277 {
278 write(name, *this, streamOpt, options);
279 }
280
281 //- Write to file with given format type.
282 // If the format type is "", uses the file extension.
283 virtual void write
284 (
285 const fileName& name,
286 const word& fileType,
287 IOstreamOption streamOpt = IOstreamOption(),
288 const dictionary& options = dictionary::null
289 ) const
290 {
291 write(name, fileType, *this, streamOpt, options);
292 }
293
294
295 // Member Operators
296
297 //- Copy assignment
298 inline void operator=(const edgeMesh& rhs);
299
300 //- Move assignment
301 inline void operator=(edgeMesh&& rhs);
302
303
304 // Ostream Operator
306 friend Ostream& operator<<(Ostream& os, const edgeMesh& em);
307 friend Istream& operator>>(Istream& is, edgeMesh& em);
308};
309
310
311// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
312
313} // End namespace Foam
314
315// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
316
317#include "edgeMeshI.H"
318
319// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
320
321#endif
322
323// ************************************************************************* //
The IOstreamOption is a simple container for options an IOstream can normally have.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Mesh data needed to do the Finite Area discretisation.
Definition: edgeFaMesh.H:56
pointField & storedPoints() noexcept
Non-const access to global points.
Definition: edgeMeshI.H:31
virtual void mergeEdges()
Merge duplicate edges and eliminate unused points.
Definition: edgeMesh.C:240
const labelListList & pointEdges() const
Return edges.
Definition: edgeMeshI.H:111
static bool canWriteType(const word &fileType, bool verbose=false)
Can we write this file format type?
Definition: edgeMesh.C:73
static wordHashSet writeTypes()
Summary of supported write file types.
Definition: edgeMesh.C:55
virtual void mergePoints(const scalar mergeDist)
Geometric merge points (points within mergeDist) prior to.
Definition: edgeMesh.C:213
edgeMesh()
Default construct.
Definition: edgeMeshI.H:45
const pointField & points() const noexcept
Return points.
Definition: edgeMeshI.H:99
const edgeList & edges() const noexcept
Return edges.
Definition: edgeMeshI.H:105
static bool canReadType(const word &fileType, bool verbose=false)
Can we read this file format?
Definition: edgeMesh.C:61
bool read(const fileName &name, const word &fileType)
Read from file. Chooses reader based on explicit extension.
Definition: edgeMeshIO.C:75
void transfer(edgeMesh &mesh)
Transfer the contents of the argument and annul the argument.
Definition: edgeMesh.C:124
friend Istream & operator>>(Istream &is, edgeMesh &em)
friend Ostream & operator<<(Ostream &os, const edgeMesh &em)
label regions(labelList &edgeRegion) const
Find connected regions. Set region number per edge.
Definition: edgeMesh.C:137
static bool canRead(const fileName &name, bool verbose=false)
Can we read this file format?
Definition: edgeMesh.C:85
virtual void writeStats(Ostream &) const
Definition: edgeMeshIO.C:125
edgeList & storedEdges() noexcept
Non-const access to the edges.
Definition: edgeMeshI.H:37
virtual void clear()
Clear all storage.
Definition: edgeMesh.C:116
void operator=(const edgeMesh &rhs)
Copy assignment.
Definition: edgeMeshI.H:123
static autoPtr< edgeMesh > New(const fileName &name, const word &fileType)
Read construct from filename with given format.
Definition: edgeMeshNew.C:34
virtual void scalePoints(const scalar scaleFactor)
Scale points. A non-positive factor is ignored.
Definition: edgeMesh.C:203
static wordHashSet readTypes()
Summary of supported read file types.
Definition: edgeMesh.C:49
A class for handling file names.
Definition: fileName.H:76
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
OBJstream os(runTime.globalPath()/outputName)
Macros to ease declaration of member function selection tables.
#define declareMemberFunctionSelectionTable(returnType, baseType, funcName, argNames, argList, parListUnused)
Declare a run-time member-function selection (variables and adder classes)
Namespace for OpenFOAM.
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Istream & operator>>(Istream &, directionInfo &)
const direction noexcept
Definition: Scalar.H:223
List< edge > edgeList
A List of edges.
Definition: edgeList.H:63
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
runTime write()
Macros to ease declaration of run-time selection tables.
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes)
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73