1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "sampledTriSurfaceMesh.H"
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 Foam::tmp<Foam::Field<Type> >
32 Foam::sampledTriSurfaceMesh::sampleField
34 const GeometricField<Type, fvPatchField, volMesh>& vField
38 tmp<Field<Type> > tvalues(new Field<Type>(sampleElements_.size()));
39 Field<Type>& values = tvalues();
41 if (sampleSource_ == cells)
45 forAll(sampleElements_, triI)
47 values[triI] = vField[sampleElements_[triI]];
52 // Sample boundary faces
54 const polyBoundaryMesh& pbm = mesh().boundaryMesh();
55 label nBnd = mesh().nFaces()-mesh().nInternalFaces();
57 // Create flat boundary field
59 Field<Type> bVals(nBnd, pTraits<Type>::zero);
61 forAll(vField.boundaryField(), patchI)
63 label bFaceI = pbm[patchI].start() - mesh().nInternalFaces();
68 vField.boundaryField()[patchI].size(),
70 ).assign(vField.boundaryField()[patchI]);
73 // Sample in flat boundary field
75 forAll(sampleElements_, triI)
77 label faceI = sampleElements_[triI];
78 values[triI] = bVals[faceI-mesh().nInternalFaces()];
87 Foam::tmp<Foam::Field<Type> >
88 Foam::sampledTriSurfaceMesh::interpolateField
90 const interpolation<Type>& interpolator
93 // One value per vertex
94 tmp<Field<Type> > tvalues(new Field<Type>(sampleElements_.size()));
95 Field<Type>& values = tvalues();
97 if (sampleSource_ == cells)
101 forAll(sampleElements_, pointI)
103 values[pointI] = interpolator.interpolate
105 samplePoints_[pointI],
106 sampleElements_[pointI]
112 // Sample boundary faces.
114 forAll(samplePoints_, pointI)
116 label faceI = sampleElements_[pointI];
118 values[pointI] = interpolator.interpolate
120 samplePoints_[pointI],
121 mesh().faceOwner()[faceI],
131 // ************************************************************************* //