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 MeshedSurfaceProxy_H
44#define 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");
95
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
126 (
127 void,
129 write,
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
167 {
168 return faces_.size();
169 }
170
171 //- Return const access to the points
172 const pointField& points() const
173 {
174 return points_;
175 }
176
177 //- Return const access to the faces
178 const UList<Face>& surfFaces() const
179 {
180 return faces_;
181 }
182
183 //- Const access to the surface zones.
184 // If zones are defined, they must be contiguous and cover the
185 // entire surface
186 const UList<surfZone>& surfZones() const
187 {
188 return zones_;
189 }
190
191 //- Const access to the faceMap, zero-sized when unused
192 const labelUList& faceMap() const
193 {
194 return faceMap_;
195 }
196
197 //- Const access to the faceIds, zero-sized when unused
198 const labelUList& faceIds() const
199 {
200 return faceIds_;
201 }
202
203 //- Can/should use faceMap?
204 bool useFaceMap() const
205 {
206 return faceMap_.size() == faces_.size();
207 }
208
209 //- Possible to use faceIds?
210 bool useFaceIds() const
211 {
212 return faceIds_.size() == faces_.size();
213 }
214
215 //- Count number of triangles.
216 inline label nTriangles() const;
217
218
219 // Write
220
221 //- Write to file, choosing writer based on the file extension.
222 virtual void write
223 (
224 const fileName& name,
225 IOstreamOption streamOpt = IOstreamOption(),
226 const dictionary& options = dictionary::null
227 ) const
228 {
229 write(name, *this, streamOpt, options);
230 }
231
232 //- Write to file with given format type.
233 // If the format type is "", uses the file extension.
234 virtual void write
235 (
236 const fileName& name,
237 const word& fileType,
238 IOstreamOption streamOpt = IOstreamOption(),
239 const dictionary& options = dictionary::null
240 ) const
241 {
242 write(name, fileType, *this, streamOpt, options);
243 }
244
245 //- Write to database
246 virtual void write
247 (
248 const Time& t,
249 const word& surfName = word::null
250 ) const;
251};
252
253
254// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255
256} // End namespace Foam
257
258// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259
260#ifdef NoRepository
261 #include "MeshedSurfaceProxy.C"
262#endif
263
264// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265
266#endif
267
268// ************************************************************************* //
The IOstreamOption is a simple container for options an IOstream can normally have.
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats.
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.
static bool canWriteType(const word &fileType, bool verbose=false)
Can this file format type be written via MeshedSurfaceProxy?
const UList< surfZone > & surfZones() const
Const access to the surface zones.
ClassName("MeshedSurfaceProxy")
Declare type-name (with debug switch)
static wordHashSet writeTypes()
The file format types that can be written via MeshedSurfaceProxy.
declareMemberFunctionSelectionTable(void, MeshedSurfaceProxy, write, fileExtension,(const fileName &name, const MeshedSurfaceProxy< Face > &surf, IOstreamOption streamOpt, const dictionary &options),(name, surf, streamOpt, options))
virtual ~MeshedSurfaceProxy()=default
Destructor.
bool useFaceIds() const
Possible to use faceIds?
const UList< Face > & surfFaces() const
Return const access to the faces.
label size() const
The surface size is the number of faces.
bool useFaceMap() const
Can/should use faceMap?
label nTriangles() const
Count number of triangles.
const labelUList & faceIds() const
Const access to the faceIds, zero-sized when unused.
point point_type
The point type.
const pointField & points() const
Return const access to the points.
const labelUList & faceMap() const
Const access to the faceMap, zero-sized when unused.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
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:94
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A collection of helper functions for reading/writing surface formats.
A class for handling file names.
Definition: fileName.H:76
A class for handling words, derived from Foam::string.
Definition: word.H:68
static const word null
An empty word.
Definition: word.H:80
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
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.
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.