FreeFOAM The Cross-Platform CFD Toolkit
surfMesh.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::surfMesh
26 
27 Description
28  A surface mesh consisting of general polygon faces.
29 
30 SourceFiles
31  surfMesh.C
32  surfMeshClear.C
33  surfMeshIO.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef surfMesh_H
38 #define surfMesh_H
39 
43 #include <OpenFOAM/SubField.H>
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 template<class Face> class MeshedSurface;
51 
52 /*---------------------------------------------------------------------------*\
53  Class surfMesh Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class surfMesh
57 :
58  public surfaceRegistry,
60  public PrimitivePatch<face, ::Foam::UList, ::Foam::SubField<point>, point>
61 {
62  // friends
63  template<class Face> friend class MeshedSurface;
64  template<class Face> friend class UnsortedMeshedSurface;
65 
66 public:
67 
68  // Public data types
69 
70  //- Enumeration defining the state of the mesh after a read update.
71  // Used for post-processing applications, where the mesh
72  // needs to update based on the files written in time directores
74  {
79  };
80 
81 
82 private:
83 
84  // Private typedefs
85 
86  typedef MeshedSurfaceIOAllocator Allocator;
87 
88  typedef PrimitivePatch
89  <
90  face,
93  point
94  >
95  MeshReference;
96 
97 
98  // Private member functions
99 
100  //- Disallow construct as copy
101  surfMesh(const surfMesh&);
102 
103  //- Disallow default bitwise assignment
104  void operator=(const surfMesh&);
105 
106 
107 protected:
108 
109  // Protected Member Functions
110 
111  //- Non-const access to global points
113  {
114  return Allocator::storedIOPoints();
115  }
116 
117  //- Non-const access to the faces
119  {
120  return Allocator::storedIOFaces();
121  }
122 
123  //- Non-const access to the zones
125  {
126  return Allocator::storedIOZones();
127  }
128 
129  //- Update references to storedFaces
130  virtual void updateFacesRef();
131 
132  //- Update references to storedPoints
133  virtual void updatePointsRef();
134 
135  //- Update references to storedPoints/storedFaces
136  virtual void updateRefs();
137 
138 
139 public:
140 
141  // Public typedefs
142 
143  typedef surfMesh Mesh;
144 
145  //- Placeholder only, but do not remove - it is needed for GeoMesh
146  typedef bool BoundaryMesh;
147 
148 
149  //- Runtime type information
150  TypeName("surfMesh");
151 
152  //- Return the mesh sub-directory name (normally "surfMesh")
153  static word meshSubDir;
154 
155  // Constructors
156 
157  //- Construct from IOobject, with alternative surface name
158  explicit surfMesh(const IOobject&, const word& surfName="");
159 
160  //- Construct by transferring components (points, faces) without zones.
161  // surfZones are added using addZones() member function
162  surfMesh
163  (
164  const IOobject&,
165  const Xfer<pointField>&,
166  const Xfer<faceList>&,
167  const word& surfName=""
168  );
169 
170  //- Construct copy/move from MeshedSurface
171  surfMesh
172  (
173  const IOobject&,
174  const Xfer< MeshedSurface<face> >& surf,
175  const word& surfName=""
176  );
177 
178 
179  // Destructor
180 
181  virtual ~surfMesh();
182 
183 
184  // Member Functions
185 
186  // Database
187 
188  //- Return the local mesh directory (dbDir()/meshSubDir)
189  fileName meshDir() const;
190 
191  //- Return the current instance directory for points
192  // Used in the consruction of geometric mesh data dependent
193  // on points
194  const fileName& pointsInstance() const;
195 
196  //- Return the current instance directory for faces
197  const fileName& facesInstance() const;
198 
199  //- Set the instance for mesh files
200  void setInstance(const fileName&);
201 
202 
203  // Access
204 
205  //- Return the number of raw points
206  virtual label nPoints() const;
207 
208  //- Return the number of raw faces
209  virtual label nFaces() const;
210 
211  //- Return number of faces
212  virtual label size() const
213  {
214  return nFaces();
215  }
216 
217 
218  //- Return points
219  virtual const pointField& points() const;
220 
221  //- Return faces
222  virtual const faceList& faces() const;
223 
224  //- Return surface zones
225  virtual const surfZoneList& surfZones() const
226  {
227  return Allocator::storedIOZones();
228  }
229 
230  //- Check the surface zone definitions
231  void checkZones();
232 
233  //- Add surface zones
234  void addZones
235  (
236  const List<surfZone>&,
237  const bool validate = true
238  );
239 
240  //- Update the mesh based on the mesh files saved in
241  // time directories
242  virtual readUpdateState readUpdate();
243 
244  //- Update the mesh corresponding to given map
245 
246  //- Remove surface zones
247  void removeZones();
248 
249  //- Reset mesh primitive data.
250  void resetPrimitives
251  (
252  const Xfer< pointField >& points,
253  const Xfer< faceList >& faces,
254  const Xfer< surfZoneList >& zones,
255  const bool validate = true
256  );
257 
258 
259  //- Transfer the contents of the argument and annull the argument
261 
262 
263  //- Avoid masking the normal objectRegistry write
265 
266  //- Write to file
267  static void write(const fileName&, const surfMesh&);
268 
269  //- Write to file
270  void write(const fileName&);
271 
272  // Storage management
273 
274  //- Transfer contents to the Xfer container as a MeshedSurface
276 
277  //- Clear geometry
278  void clearGeom();
279 
280  //- Clear addressing
281  void clearAddressing();
282 
283  //- Clear all geometry and addressing unnecessary for CFD
284  void clearOut();
285 
286  //- Clear primitive data (points, faces and cells)
287  void clearPrimitives();
288 
289  //- Remove all files from mesh instance
290  void removeFiles(const fileName& instanceDir) const;
291 
292  //- Remove all files from mesh instance()
293  void removeFiles() const;
294 };
295 
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
297 
298 } // End namespace Foam
299 
300 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
301 
302 #endif
303 
304 // ************************ vim: set sw=4 sts=4 et: ************************ //