Loading...
Searching...
No Matches
MeshedSurfaceProxy.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-2016 OpenFOAM Foundation
9 Copyright (C) 2016-2020 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::MeshedSurfaceProxy
29
30Description
31 A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh
32 to various file formats.
33
34 The constructor interface is fat and ugly, but is largely encapsulated
35 by conversion operators in other classes.
36
37SourceFiles
38 MeshedSurfaceProxy.C
39 MeshedSurfaceProxys.C
40
41\*---------------------------------------------------------------------------*/
42
43#ifndef Foam_MeshedSurfaceProxy_H
44#define Foam_MeshedSurfaceProxy_H
45
46#include "pointField.H"
47#include "surfZoneList.H"
48#include "surfaceFormatsCore.H"
51
52// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53
54namespace Foam
55{
56
57// Forward Declarations
58template<class Face> class MeshedSurface;
59
60/*---------------------------------------------------------------------------*\
61 Class MeshedSurfaceProxy Declaration
62\*---------------------------------------------------------------------------*/
63
64template<class Face>
66:
68{
69 // Private Data
70
71 const pointField& points_;
72
73 const UList<Face>& faces_;
74
75 const UList<surfZone>& zones_;
76
77 const UList<label>& faceMap_;
78
79 const UList<label>& faceIds_;
80
81
82public:
83
84 // Public Typedefs
85
86 //- The face type
87 typedef Face face_type;
88
89 //- The point type
90 typedef point point_type;
91
92
93 //- Declare type-name (with debug switch)
94 ClassName("MeshedSurfaceProxy");
96
97 // Static Functions
98
99 //- The file format types that can be written via MeshedSurfaceProxy
100 static wordHashSet writeTypes();
101
102 //- Can this file format type be written via MeshedSurfaceProxy?
103 static bool canWriteType(const word& fileType, bool verbose=false);
104
105
106 // Constructors
107
108 //- Construct from component references
110 (
111 const pointField& pointLst,
112 const UList<Face>& faceLst,
113 const UList<surfZone>& zoneLst = UList<surfZone>::null(),
115 const labelUList& faceIdLst = labelUList::null()
116 );
117
118
119 //- Destructor
120 virtual ~MeshedSurfaceProxy() = default;
121
122
123 // Member Function Selectors
124
126 (
127 void,
130 fileExtension,
131 (
132 const fileName& name,
133 const MeshedSurfaceProxy<Face>& surf,
134 IOstreamOption streamOpt,
135 const dictionary& options
136 ),
137 (name, surf, streamOpt, options)
138 );
139
140 //- Write to file, select based on its extension
141 static void write
142 (
143 const fileName& name,
144 const MeshedSurfaceProxy& surf,
145 IOstreamOption streamOpt = IOstreamOption(),
146 const dictionary& options = dictionary::null
147 );
148
149 //- Write to file with given format type.
150 // If the format type is "", uses the file extension.
151 static void write
152 (
153 const fileName& name,
154 const word& fileType,
155 const MeshedSurfaceProxy& surf,
156 IOstreamOption streamOpt = IOstreamOption(),
157 const dictionary& options = dictionary::null
158 );
159
160
161 // Member Functions
162
163 // Access
164
165 //- The surface size is the number of faces
166 label size() const noexcept { return faces_.size(); }
167
168 //- Return const access to the points
169 const pointField& points() const noexcept { return points_; }
170
171 //- Return const access to the faces
172 const UList<Face>& surfFaces() const noexcept { return faces_; }
173
174 //- Const access to the surface zones.
175 // If zones are defined, they must be contiguous and cover the
176 // entire surface
177 const UList<surfZone>& surfZones() const noexcept { return zones_; }
178
179 //- Const access to the faceMap, zero-sized when unused
180 const labelUList& faceMap() const noexcept { return faceMap_; }
181
182 //- Const access to the faceIds, zero-sized when unused
183 const labelUList& faceIds() const noexcept { return faceIds_; }
184
185 //- Can/should use faceMap?
186 bool useFaceMap() const noexcept
188 return faceMap_.size() == faces_.size();
189 }
190
191 //- Possible to use faceIds?
192 bool useFaceIds() const noexcept
193 {
194 return faceIds_.size() == faces_.size();
195 }
196
197 //- Count number of triangles.
198 inline label nTriangles() const;
199
201 // Write
202
203 //- Write to file, choosing writer based on the file extension.
204 virtual void write
206 const fileName& name,
207 IOstreamOption streamOpt = IOstreamOption(),
208 const dictionary& options = dictionary::null
209 ) const
211 write(name, *this, streamOpt, options);
212 }
213
214 //- Write to file with given format type.
215 // If the format type is "", uses the file extension.
216 virtual void write
217 (
218 const fileName& name,
219 const word& fileType,
220 IOstreamOption streamOpt = IOstreamOption(),
221 const dictionary& options = dictionary::null
222 ) const
224 write(name, fileType, *this, streamOpt, options);
225 }
226
227 //- Write to database
228 virtual void write
229 (
230 const Time& t,
231 const word& surfName = word::null
232 ) const;
233};
234
235
236// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237
238} // End namespace Foam
240// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241
242#ifdef NoRepository
243 #include "MeshedSurfaceProxy.C"
244#endif
245
246// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247
248#endif
249
250// ************************************************************************* //
A simple container for options an IOstream can normally have.
Face face_type
The face type.
virtual void write(const fileName &name, IOstreamOption streamOpt=IOstreamOption(), const dictionary &options=dictionary::null) const
Write to file, choosing writer based on the file extension.
const UList< surfZone > & surfZones() const noexcept
Const access to the surface zones.
static bool canWriteType(const word &fileType, bool verbose=false)
Can this file format type be written via MeshedSurfaceProxy?
ClassName("MeshedSurfaceProxy")
Declare type-name (with debug switch).
static wordHashSet writeTypes()
The file format types that can be written via MeshedSurfaceProxy.
const UList< Face > & surfFaces() const noexcept
Return const access to the faces.
declareMemberFunctionSelectionTable(void, MeshedSurfaceProxy, write, fileExtension,(const fileName &name, const MeshedSurfaceProxy< Face > &surf, IOstreamOption streamOpt, const dictionary &options),(name, surf, streamOpt, options))
virtual void write(const fileName &name, const word &fileType, IOstreamOption streamOpt=IOstreamOption(), const dictionary &options=dictionary::null) const
Write to file with given format type.
const labelUList & faceIds() const noexcept
Const access to the faceIds, zero-sized when unused.
virtual ~MeshedSurfaceProxy()=default
Destructor.
const labelUList & faceMap() const noexcept
Const access to the faceMap, zero-sized when unused.
const pointField & points() const noexcept
Return const access to the points.
MeshedSurfaceProxy(const pointField &pointLst, const UList< Face > &faceLst, const UList< surfZone > &zoneLst=UList< surfZone >::null(), const labelUList &faceMap=labelUList::null(), const labelUList &faceIdLst=labelUList::null())
Construct from component references.
label nTriangles() const
Count number of triangles.
label size() const noexcept
The surface size is the number of faces.
bool useFaceIds() const noexcept
Possible to use faceIds?
static void write(const fileName &name, const MeshedSurfaceProxy &surf, IOstreamOption streamOpt=IOstreamOption(), const dictionary &options=dictionary::null)
Write to file, select based on its extension.
point point_type
The point type.
bool useFaceMap() const noexcept
Can/should use faceMap?
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
static const UList< T > & null() noexcept
Return a null UList (reference to a nullObject). Behaves like an empty UList.
Definition UList.H:225
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Definition dictionary.H:487
A collection of helper functions for reading/writing surface formats.
A class for handling file names.
Definition fileName.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
static const word null
An empty word.
Definition word.H:84
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition className.H:74
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.
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
Definition HashSet.H:80
vector point
Point is a vector.
Definition point.H:37
const direction noexcept
Definition scalarImpl.H:265
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
Definition UList.H:75
runTime write()
Macros to ease declaration of run-time selection tables.