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 | Copyright (C) 2011 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::MeshedSurfaceProxy
26 
27 Description
28  A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh
29  to various file formats.
30 
31 SourceFiles
32  MeshedSurfaceProxy.C
33  MeshedSurfaceProxyCore.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef MeshedSurfaceProxy_H
38 #define MeshedSurfaceProxy_H
39 
40 #include "pointField.H"
41 #include "face.H"
42 #include "triFace.H"
43 
44 #include "surfZoneList.H"
45 #include "surfaceFormatsCore.H"
46 #include "runTimeSelectionTables.H"
48 #include "HashSet.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward declaration of friend functions and operators
56 
57 template<class Face> class MeshedSurface;
58 
59 /*---------------------------------------------------------------------------*\
60  Class MeshedSurfaceProxy Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 template<class Face>
64 class MeshedSurfaceProxy
65 :
66  public fileFormats::surfaceFormatsCore
67 {
68  //- Private data
69 
70  const pointField& points_;
71 
72  const List<Face>& faces_;
73 
74  const List<surfZone>& zones_;
75 
76  const List<label>& faceMap_;
77 
78 
79 public:
80 
81  // Public typedefs
82 
83  //- Face type used
84  typedef Face FaceType;
85 
86 
87  // Static
88 
89  //- Runtime type information
90  ClassName("MeshedSurfaceProxy");
91 
92  //- The file format types that can be written via MeshedSurfaceProxy
93  static wordHashSet writeTypes();
94 
95  //- Can this file format type be written via MeshedSurfaceProxy?
96  static bool canWriteType(const word& ext, const bool verbose=false);
97 
98 
99  // Constructors
100 
101  //- Construct from component references
103  (
104  const pointField&,
105  const List<Face>&,
106  const List<surfZone>& = List<surfZone>(),
107  const List<label>& faceMap = List<label>()
108  );
109 
110 
111  //- Destructor
112  virtual ~MeshedSurfaceProxy();
113 
114 
115  // Member Function Selectors
116 
118  (
119  void,
121  write,
122  fileExtension,
123  (
124  const fileName& name,
125  const MeshedSurfaceProxy<Face>& surf
126  ),
127  (name, surf)
128  );
129 
130  //- Write to file
131  static void write(const fileName&, const MeshedSurfaceProxy<Face>&);
132 
133 
134  // Member Functions
135 
136  // Access
137 
138  //- Return const access to the points
139  inline const pointField& points() const
140  {
141  return points_;
142  }
143 
144  //- Return const access to the faces
145  inline const List<Face>& faces() const
146  {
147  return faces_;
148  }
149 
150  //- Const access to the surface zones.
151  // If zones are defined, they must be contiguous and cover the
152  // entire surface
153  inline const List<surfZone>& surfZones() const
154  {
155  return zones_;
156  }
157 
158  //- Const access to the faceMap, zero-sized when unused
159  inline const List<label>& faceMap() const
160  {
161  return faceMap_;
162  }
163 
164  //- Use faceMap?
165  inline bool useFaceMap() const
166  {
167  return faceMap_.size() == faces_.size();
168  }
169 
170  // Write
171 
172  //- Generic write routine. Chooses writer based on extension.
173  virtual void write(const fileName& name) const
174  {
175  write(name, *this);
176  }
177 
178  //- Write to database
179  virtual void write(const Time&, const word& surfName = "") const;
180 };
181 
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 } // End namespace Foam
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 #ifdef NoRepository
190 # include "MeshedSurfaceProxy.C"
191 #endif
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 #endif
196 
197 // ************************************************************************* //
Face FaceType
Face type used.
bool useFaceMap() const
Use faceMap?
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
static void write(const fileName &, const MeshedSurfaceProxy< Face > &)
Write to file.
static wordHashSet writeTypes()
The file format types that can be written via MeshedSurfaceProxy.
Macros to ease declaration of run-time selection tables.
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats...
Definition: MeshedSurface.H:73
A class for handling words, derived from string.
Definition: word.H:59
const pointField & points() const
Return const access to the points.
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
Namespace for OpenFOAM.
const List< Face > & faces() const
Return const access to the faces.
ClassName("MeshedSurfaceProxy")
Runtime type information.
virtual ~MeshedSurfaceProxy()
Destructor.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
const List< surfZone > & surfZones() const
Const access to the surface zones.
static bool canWriteType(const word &ext, const bool verbose=false)
Can this file format type be written via MeshedSurfaceProxy?
declareMemberFunctionSelectionTable(void, MeshedSurfaceProxy, write, fileExtension,( const fileName &name, const MeshedSurfaceProxy< Face > &surf ),(name, surf))
A class for handling file names.
Definition: fileName.H:69
A HashTable with keys but without contents.
Definition: HashSet.H:59
const List< label > & faceMap() const
Const access to the faceMap, zero-sized when unused.
MeshedSurfaceProxy(const pointField &, const List< Face > &, const List< surfZone > &=List< surfZone >(), const List< label > &faceMap=List< label >())
Construct from component references.