FreeFOAM The Cross-Platform CFD Toolkit
distanceSurface.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::distanceSurface
26 
27 Description
28  A sampledSurface defined by a distance to a surface.
29 
30 SourceFiles
31  distanceSurface.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef distanceSurface_H
36 #define distanceSurface_H
37 
40 //#include "isoSurfaceCell.H"
41 #include <sampling/isoSurface.H>
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class distanceSurface Declaration
50 \*---------------------------------------------------------------------------*/
51 
53 :
54  public sampledSurface
55 {
56  // Private data
57 
58  //- Surface
59  const autoPtr<searchableSurface> surfPtr_;
60 
61  //- distance value
62  const scalar distance_;
63 
64  //- signed distance
65  const bool signed_;
66 
67  //- Whether to coarsen
68  const Switch regularise_;
69 
70  //- zone name (if restricted to zones)
71  word zoneName_;
72 
73  //- Track if the surface needs an update
74  mutable bool needsUpdate_;
75 
76 
77  //- Distance to cell centres
78  autoPtr<volScalarField> cellDistancePtr_;
79 
80  //- Distance to points
81  scalarField pointDistance_;
82 
83  //- Constructed iso surface
84  autoPtr<isoSurface> isoSurfPtr_;
85 
86  //- triangles converted to faceList
87  mutable autoPtr<faceList> facesPtr_;
88 
89 
90  // Private Member Functions
91 
92  //- Create iso surface
93  void createGeometry();
94 
95  //- sample field on faces
96  template <class Type>
97  tmp<Field<Type> > sampleField
98  (
100  ) const;
101 
102 
103  template <class Type>
105  interpolateField(const interpolation<Type>&) const;
106 
107 
108 public:
109 
110  //- Runtime type information
111  TypeName("distanceSurface");
112 
113 
114  // Constructors
115 
116  //- Construct from dictionary
118  (
119  const word& name,
120  const polyMesh& mesh,
121  const dictionary& dict
122  );
123 
124 
125  // Destructor
126 
127  virtual ~distanceSurface();
128 
129 
130  // Member Functions
131 
132  //- Does the surface need an update?
133  virtual bool needsUpdate() const;
134 
135  //- Mark the surface as needing an update.
136  // May also free up unneeded data.
137  // Return false if surface was already marked as expired.
138  virtual bool expire();
139 
140  //- Update the surface as required.
141  // Do nothing (and return false) if no update was needed
142  virtual bool update();
143 
144  //- Points of surface
145  virtual const pointField& points() const
146  {
147  return surface().points();
148  }
149 
150  //- Faces of surface
151  virtual const faceList& faces() const
152  {
153  if (facesPtr_.empty())
154  {
155  const triSurface& s = surface();
156 
157  facesPtr_.reset(new faceList(s.size()));
158 
159  forAll(s, i)
160  {
161  facesPtr_()[i] = s[i].triFaceFace();
162  }
163  }
164  return facesPtr_;
165  }
166 
167 
168  const isoSurface& surface() const
169  {
170  return isoSurfPtr_();
171  }
172 
173  //- sample field on surface
174  virtual tmp<scalarField> sample
175  (
176  const volScalarField&
177  ) const;
178 
179  //- sample field on surface
180  virtual tmp<vectorField> sample
181  (
182  const volVectorField&
183  ) const;
184 
185  //- sample field on surface
187  (
189  ) const;
190 
191  //- sample field on surface
193  (
194  const volSymmTensorField&
195  ) const;
196 
197  //- sample field on surface
198  virtual tmp<tensorField> sample
199  (
200  const volTensorField&
201  ) const;
202 
203 
204  //- interpolate field on surface
206  (
207  const interpolation<scalar>&
208  ) const;
209 
210  //- interpolate field on surface
212  (
213  const interpolation<vector>&
214  ) const;
215 
216  //- interpolate field on surface
218  (
220  ) const;
221 
222  //- interpolate field on surface
224  (
226  ) const;
227 
228  //- interpolate field on surface
230  (
231  const interpolation<tensor>&
232  ) const;
233 
234  //- Write
235  virtual void print(Ostream&) const;
236 };
237 
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 } // End namespace Foam
242 
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 
245 #ifdef NoRepository
246 # include "distanceSurfaceTemplates.C"
247 #endif
248 
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 
251 #endif
252 
253 // ************************ vim: set sw=4 sts=4 et: ************************ //