FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/pointField.H>
41 #include <OpenFOAM/face.H>
42 #include <OpenFOAM/triFace.H>
43 
44 #include <surfMesh/surfZoneList.H>
48 #include <OpenFOAM/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>
65 :
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  // Static
82 
83  //- Runtime type information
84  ClassName("MeshedSurfaceProxy");
85 
86  //- The file format types that can be written via MeshedSurfaceProxy
87  static wordHashSet writeTypes();
88 
89  //- Can this file format type be written via MeshedSurfaceProxy?
90  static bool canWriteType(const word& ext, const bool verbose=false);
91 
92 
93  // Constructors
94 
95  //- Construct from component references
97  (
98  const pointField&,
99  const List<Face>&,
100  const List<surfZone>& = List<surfZone>(),
101  const List<label>& faceMap = List<label>()
102  );
103 
104 
105  // Destructor
106 
107  virtual ~MeshedSurfaceProxy();
108 
109 
110  // Member Function Selectors
111 
113  (
114  void,
116  write,
117  fileExtension,
118  (
119  const fileName& name,
120  const MeshedSurfaceProxy<Face>& surf
121  ),
122  (name, surf)
123  );
124 
125  //- Write to file
126  static void write(const fileName&, const MeshedSurfaceProxy<Face>&);
127 
128 
129  // Member Functions
130 
131  // Access
132 
133  //- Return const access to the points
134  inline const pointField& points() const
135  {
136  return points_;
137  }
138 
139  //- Return const access to the faces
140  inline const List<Face>& faces() const
141  {
142  return faces_;
143  }
144 
145  //- Const access to the surface zones.
146  // If zones are defined, they must be contiguous and cover the
147  // entire surface
148  inline const List<surfZone>& surfZones() const
149  {
150  return zones_;
151  }
152 
153  //- Const access to the faceMap, zero-sized when unused
154  inline const List<label>& faceMap() const
155  {
156  return faceMap_;
157  }
158 
159  //- Use faceMap?
160  inline bool useFaceMap() const
161  {
162  return faceMap_.size() == faces_.size();
163  }
164 
165  // Write
166 
167  //- Generic write routine. Chooses writer based on extension.
168  virtual void write(const fileName& name) const
169  {
170  write(name, *this);
171  }
172 
173  //- Write to database
174  virtual void write(const Time&, const word& surfName = "") const;
175 };
176 
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 } // End namespace Foam
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 #ifdef NoRepository
185 # include "MeshedSurfaceProxy.C"
186 #endif
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
190 #endif
191 
192 // ************************ vim: set sw=4 sts=4 et: ************************ //