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