sampledIsoSurfaceSurfaceTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation
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 \*---------------------------------------------------------------------------*/
25 
28 
29 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
30 
31 template<class Type>
33 Foam::sampledSurfaces::sampledIsoSurfaceSurface::sampleField
34 (
35  const VolField<Type>& vField
36 ) const
37 {
38  update();
39 
40  return isoSurfPtr_->sample(vField.primitiveField());
41 }
42 
43 
44 template<class Type>
46 Foam::sampledSurfaces::sampledIsoSurfaceSurface::interpolateField
47 (
48  const interpolation<Type>& interpolator
49 ) const
50 {
51  update();
52 
54  {
55  const PointField<Type>& pField =
56  refCast<const interpolationVolPointInterpolation<Type>>
57  (interpolator).psip();
58 
59  return isoSurfPtr_().interpolate(pField.primitiveField());
60  }
61  else
62  {
63  const pointField& points = isoSurfPtr_->points();
64  const faceList& faces = isoSurfPtr_->faces();
65  const labelList& faceCells = isoSurfPtr_->faceCells();
66 
67  labelList pointCells(points.size());
68  forAll(faces, facei)
69  {
70  forAll(faces[facei], facePointi)
71  {
72  pointCells[faces[facei][facePointi]] = faceCells[facei];
73  }
74  }
75 
76  return interpolator.interpolate(points, pointCells);
77  }
78 }
79 
80 
81 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Generic GeometricField class.
const Internal::FieldType & primitiveField() const
Return a const-reference to the primitive field.
Base class for interpolations that require a vol-point interpolated field.
Abstract base class for interpolation.
Definition: interpolation.H:55
virtual Type interpolate(const vector &position, const label celli, const label facei=-1) const =0
Interpolate field to the given point in the given cell.
virtual bool update()
Update the surface as required.
A class for managing temporary objects.
Definition: tmp.H:55
const pointField & points
bool isA(const Type &t)
Check if a dynamic_cast to typeid is possible.
Definition: typeInfo.H:166