1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "sampledPatch.H"
27 #include "dictionary.H"
29 #include "polyPatch.H"
30 #include "volFields.H"
32 #include "addToRunTimeSelectionTable.H"
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 defineTypeNameAndDebug(sampledPatch, 0);
39 addNamedToRunTimeSelectionTable(sampledSurface, sampledPatch, word, patch);
43 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 Foam::sampledPatch::sampledPatch
49 const word& patchName,
50 const bool triangulate
53 sampledSurface(name, mesh),
54 patchName_(patchName),
55 triangulate_(triangulate),
61 Foam::sampledPatch::sampledPatch
65 const dictionary& dict
68 sampledSurface(name, mesh, dict),
69 patchName_(dict.lookup("patchName")),
70 triangulate_(dict.lookupOrDefault("triangulate", false)),
76 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
78 Foam::sampledPatch::~sampledPatch()
82 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
84 bool Foam::sampledPatch::needsUpdate() const
90 bool Foam::sampledPatch::expire()
92 // already marked as expired
98 sampledSurface::clearGeom();
100 patchFaceLabels_.clear();
107 bool Foam::sampledPatch::update()
114 label patchI = mesh().boundaryMesh().findPatchID(patchName_);
118 const polyPatch& p = mesh().boundaryMesh()[patchI];
119 this->storedPoints() = p.localPoints();
120 this->storedFaces() = p.localFaces();
123 patchFaceLabels_.setSize(faces().size());
124 forAll(patchFaceLabels_, i)
126 patchFaceLabels_[i] = i;
129 // triangulate uses remapFaces()
130 // - this is somewhat less efficient since it recopies the faces
131 // that we just created, but we probably don't want to do this
135 MeshStorage::triangulate();
145 needsUpdate_ = false;
150 // remap action on triangulation
151 void Foam::sampledPatch::remapFaces
153 const UList<label>& faceMap
156 // recalculate the cells cut
157 if (&faceMap && faceMap.size())
159 MeshStorage::remapFaces(faceMap);
165 Foam::tmp<Foam::scalarField>
166 Foam::sampledPatch::sample
168 const volScalarField& vField
171 return sampleField(vField);
175 Foam::tmp<Foam::vectorField>
176 Foam::sampledPatch::sample
178 const volVectorField& vField
181 return sampleField(vField);
184 Foam::tmp<Foam::sphericalTensorField>
185 Foam::sampledPatch::sample
187 const volSphericalTensorField& vField
190 return sampleField(vField);
194 Foam::tmp<Foam::symmTensorField>
195 Foam::sampledPatch::sample
197 const volSymmTensorField& vField
200 return sampleField(vField);
204 Foam::tmp<Foam::tensorField>
205 Foam::sampledPatch::sample
207 const volTensorField& vField
210 return sampleField(vField);
214 Foam::tmp<Foam::scalarField>
215 Foam::sampledPatch::interpolate
217 const interpolation<scalar>& interpolator
220 return interpolateField(interpolator);
224 Foam::tmp<Foam::vectorField>
225 Foam::sampledPatch::interpolate
227 const interpolation<vector>& interpolator
230 return interpolateField(interpolator);
233 Foam::tmp<Foam::sphericalTensorField>
234 Foam::sampledPatch::interpolate
236 const interpolation<sphericalTensor>& interpolator
239 return interpolateField(interpolator);
243 Foam::tmp<Foam::symmTensorField>
244 Foam::sampledPatch::interpolate
246 const interpolation<symmTensor>& interpolator
249 return interpolateField(interpolator);
253 Foam::tmp<Foam::tensorField>
254 Foam::sampledPatch::interpolate
256 const interpolation<tensor>& interpolator
259 return interpolateField(interpolator);
263 void Foam::sampledPatch::print(Ostream& os) const
265 os << "sampledPatch: " << name() << " :"
266 << " patch:" << patchName()
267 << " faces:" << faces().size()
268 << " points:" << points().size();
272 // ************************************************************************* //