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