sampledThresholdCellFacesTemplates.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) 2011-2019 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 
27 #include "thresholdCellFaces.H"
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 template<class Type>
33 Foam::sampledSurfaces::thresholdCellFaces::sampleField
34 (
36 ) const
37 {
38  // Recreate geometry if time has changed
39  updateGeometry();
40 
41  return tmp<Field<Type>>(new Field<Type>(vField, meshCells_));
42 }
43 
44 
45 template<class Type>
47 Foam::sampledSurfaces::thresholdCellFaces::interpolateField
48 (
49  const interpolation<Type>& interpolator
50 ) const
51 {
52  // Recreate geometry if time has changed
53  updateGeometry();
54 
55  // One value per point
56  tmp<Field<Type>> tvalues(new Field<Type>(points().size()));
57  Field<Type>& values = tvalues.ref();
58 
59  boolList pointDone(points().size(), false);
60 
61  forAll(faces(), cutFacei)
62  {
63  const face& f = faces()[cutFacei];
64 
65  forAll(f, faceVertI)
66  {
67  label pointi = f[faceVertI];
68 
69  if (!pointDone[pointi])
70  {
71  values[pointi] = interpolator.interpolate
72  (
73  points()[pointi],
74  meshCells_[cutFacei]
75  );
76  pointDone[pointi] = true;
77  }
78  }
79  }
80 
81  return tvalues;
82 }
83 
84 
85 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:174
Generic GeometricField class.
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.
const pointField & points
Pre-declare SubField and related Field type.
Definition: Field.H:56
labelList f(nPoints)
Abstract base class for interpolation.
A class for managing temporary objects.
Definition: PtrList.H:53