BUG: cloudSet.C: force early construction of tetBasePtIs to avoid demand-driven comms
[OpenFOAM-2.0.x.git] / src / sampling / sampledSurface / isoSurface / sampledIsoSurfaceTemplates.C
blobc58a665416389e8cd157d424b7b569c1504cae77
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 "sampledIsoSurface.H"
27 #include "volFieldsFwd.H"
28 #include "pointFields.H"
29 #include "volPointInterpolation.H"
31 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
33 template <class Type>
34 Foam::tmp<Foam::Field<Type> >
35 Foam::sampledIsoSurface::sampleField
37     const GeometricField<Type, fvPatchField, volMesh>& vField
38 ) const
40     // Recreate geometry if time has changed
41     updateGeometry();
43     return tmp<Field<Type> >(new Field<Type>(vField, surface().meshCells()));
47 template <class Type>
48 Foam::tmp<Foam::Field<Type> >
49 Foam::sampledIsoSurface::interpolateField
51     const interpolation<Type>& interpolator
52 ) const
54     // Get fields to sample. Assume volPointInterpolation!
55     const GeometricField<Type, fvPatchField, volMesh>& volFld =
56         interpolator.psi();
58     // Recreate geometry if time has changed
59     updateGeometry();
61     if (subMeshPtr_.valid())
62     {
63         tmp<GeometricField<Type, fvPatchField, volMesh> > tvolSubFld =
64             subMeshPtr_().interpolate(volFld);
66         const GeometricField<Type, fvPatchField, volMesh>& volSubFld =
67             tvolSubFld();
69         tmp<GeometricField<Type, pointPatchField, pointMesh> > tpointSubFld =
70             volPointInterpolation::New(volSubFld.mesh()).interpolate(volSubFld);
72         // Sample.
73         return surface().interpolate
74         (
75             (
76                 average_
77               ? pointAverage(tpointSubFld())()
78               : volSubFld
79             ),
80             tpointSubFld()
81         );
82     }
83     else
84     {
85         tmp<GeometricField<Type, pointPatchField, pointMesh> > tpointFld =
86             volPointInterpolation::New(volFld.mesh()).interpolate(volFld);
88         // Sample.
89         return surface().interpolate
90         (
91             (
92                 average_
93               ? pointAverage(tpointFld())()
94               : volFld
95             ),
96             tpointFld()
97         );
98     }
102 // ************************************************************************* //