FreeFOAM The Cross-Platform CFD Toolkit
sampledPatch.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::sampledPatch
26 
27 Description
28  A sampledSurface on a patch. Non-triangulated by default.
29 
30 SourceFiles
31  sampledPatch.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef sampledPatch_H
36 #define sampledPatch_H
37 
39 #include <surfMesh/MeshedSurface.H>
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class sampledPatch Declaration
48 \*---------------------------------------------------------------------------*/
49 
51 :
52  public MeshedSurface<face>,
53  public sampledSurface
54 {
55  //- Private typedefs for convenience
57 
58  // Private data
59 
60  //- Name of patch
61  const word patchName_;
62 
63  //- Triangulated faces or keep faces as is
64  bool triangulate_;
65 
66  //- Track if the surface needs an update
67  mutable bool needsUpdate_;
68 
69  //- Local patch face labels
70  labelList patchFaceLabels_;
71 
72  // Private Member Functions
73 
74 
75  //- sample field on faces
76  template <class Type>
77  tmp<Field<Type> > sampleField
78  (
80  ) const;
81 
82 
83  template <class Type>
85  interpolateField(const interpolation<Type>&) const;
86 
87 
88  //- remap action on triangulation or cleanup
89  virtual void remapFaces(const UList<label>& faceMap);
90 
91 public:
92 
93  //- Runtime type information
94  TypeName("sampledPatch");
95 
96 
97  // Constructors
98 
99  //- Construct from components
101  (
102  const word& name,
103  const polyMesh& mesh,
104  const word& patchName,
105  const bool triangulate = false
106  );
107 
108  //- Construct from dictionary
110  (
111  const word& name,
112  const polyMesh& mesh,
113  const dictionary& dict
114  );
115 
116 
117  // Destructor
118 
119  virtual ~sampledPatch();
120 
121 
122  // Member Functions
123 
124  //- Does the surface need an update?
125  virtual bool needsUpdate() const;
126 
127  //- Mark the surface as needing an update.
128  // May also free up unneeded data.
129  // Return false if surface was already marked as expired.
130  virtual bool expire();
131 
132  //- Update the surface as required.
133  // Do nothing (and return false) if no update was needed
134  virtual bool update();
135 
136 
137  const word patchName() const
138  {
139  return patchName_;
140  }
141 
142  label patchIndex() const
143  {
144  return mesh().boundaryMesh().findPatchID(patchName_);
145  }
146 
147  const labelList& patchFaceLabels() const
148  {
149  return patchFaceLabels_;
150  }
151 
152  //- Points of surface
153  virtual const pointField& points() const
154  {
155  return MeshStorage::points();
156  }
157 
158  //- Faces of surface
159  virtual const faceList& faces() const
160  {
161  return MeshStorage::faces();
162  }
163 
164 
165  //- sample field on surface
166  virtual tmp<scalarField> sample
167  (
168  const volScalarField&
169  ) const;
170 
171  //- sample field on surface
172  virtual tmp<vectorField> sample
173  (
174  const volVectorField&
175  ) const;
176 
177  //- sample field on surface
179  (
181  ) const;
182 
183  //- sample field on surface
185  (
186  const volSymmTensorField&
187  ) const;
188 
189  //- sample field on surface
190  virtual tmp<tensorField> sample
191  (
192  const volTensorField&
193  ) const;
194 
195 
196  //- interpolate field on surface
198  (
199  const interpolation<scalar>&
200  ) const;
201 
202 
203  //- interpolate field on surface
205  (
206  const interpolation<vector>&
207  ) const;
208 
209  //- interpolate field on surface
211  (
213  ) const;
214 
215  //- interpolate field on surface
217  (
219  ) const;
220 
221  //- interpolate field on surface
223  (
224  const interpolation<tensor>&
225  ) const;
226 
227  //- Write
228  virtual void print(Ostream&) const;
229 };
230 
231 
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 
234 } // End namespace Foam
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 #ifdef NoRepository
240 #endif
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 #endif
245 
246 // ************************ vim: set sw=4 sts=4 et: ************************ //