cellPoint_interpolation.H
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-2025 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 Class
25  Foam::interpolations::cellPoint
26 
27 Description
28  Piecewise-linear interpolation method. Uses volPointInterpolation to create
29  values on the points. Then uses a face-diagonal tetrahedral decomposition
30  to linearly interpolate between the values at the points and at the
31  cell-centres.
32 
33 SourceFiles
34  cellPoint_interpolationI.H
35  cellPoint_interpolation.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef cellPoint_interpolation_H
40 #define cellPoint_interpolation_H
41 
42 #include "interpolation.H"
43 #include "barycentricTensor.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 namespace interpolations
51 {
52 
53 // Forward declaration of classes
54 template<class Type>
55 class cellPoint;
56 
57 /*---------------------------------------------------------------------------*\
58  Class cellPointBase Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 template<class Type>
62 class cellPointBase
63 :
64  public fieldInterpolation<Type, cellPoint<Type>>,
65  public volPointInterpolation<Type>
66 {
67 protected:
68 
69  // Protected Member Functions
70 
71  //- Return the transform associated with the given tetrahedron
72  inline void tetTransform
73  (
74  const tetIndices& tetIs,
75  vector& x0,
76  scalar& detA,
78  ) const;
79 
80  //- Return the transform associated with the face-triangle of the given
81  // tetrahedron
82  inline void tetFaceTriTransform
83  (
84  const tetIndices& tetIs,
85  vector& x0,
86  scalar& detA,
88  ) const;
89 
90  //- Return the barycentric origin for the above transforms
91  inline barycentric y0() const;
92 
93  //- Find the tetrahedron (or triangle) containing the given point, and
94  // also generate and return the associated transformation
95  inline tetIndices findTet
96  (
97  const point& x,
98  const label celli,
99  const label facei,
100  vector& x0,
101  scalar& detA,
103  ) const;
104 
105 
106 public:
107 
108  // Constructors
109 
110  //- Construct from components
112 
113  //- Copy construct
115 
116  //- Construct from components
118 
119 
120  // Member Functions
121 
122  //- Inherit interpolate from interpolation
124 
125  //- Interpolate to the given point in the given cell
126  inline Type interpolate
127  (
128  const vector& position,
129  const label celli,
130  const label facei = -1
131  ) const;
132 
133  //- Interpolate to the coordinates in the given tetrahedron
134  inline Type interpolate
135  (
136  const barycentric& coordinates,
137  const tetIndices& tetIs,
138  const label facei = -1
139  ) const;
140 };
141 
142 
143 /*---------------------------------------------------------------------------*\
144  Class cellPointGradBase Declaration
145 \*---------------------------------------------------------------------------*/
146 
147 template<class Type>
148 class cellPointGradBase
149 :
150  public cellPointBase<Type>
151 {
152 public:
153 
154  // Constructors
155 
156  //- Inherit base class constructors
158 
159 
160  // Member Functions
161 
162  //- Inherit interpolate from interpolation
164 
165  //- Interpolate the gradient to the given point in the given cell
167  (
168  const tetIndices& tetIs,
169  const scalar detA,
170  const barycentricTensor T
171  ) const;
172 
173  //- Interpolate the gradient to the given point in the given cell
175  (
176  const vector& position,
177  const label celli,
178  const label facei = -1
179  ) const;
180 
181  //- Interpolate the gradient to the coordinates in the given tetrahedron
183  (
184  const barycentric& coordinates,
185  const tetIndices& tetIs,
186  const label facei = -1
187  ) const;
188 };
189 
190 
191 /*---------------------------------------------------------------------------*\
192  Typedef cellPointBaseOrGradBase Declaration
193 \*---------------------------------------------------------------------------*/
194 
195 template<class Type>
197  typename std::conditional
198  <
199  (pTraits<Type>::rank > 1),
202  >::type;
203 
204 
205 /*---------------------------------------------------------------------------*\
206  Class cellPoint Declaration
207 \*---------------------------------------------------------------------------*/
208 
209 template<class Type>
210 class cellPoint
211 :
212  public cellPointBaseOrGradBase<Type>
213 {
214  // Private Type Definitions
215 
216  //- The base class
217  typedef cellPointBaseOrGradBase<Type> Base;
218 
219 
220 public:
221 
222  //- Runtime type information
223  TypeName("cellPoint");
224 
225 
226  // Constructors
227 
228  //- Inherit base class constructors
229  using Base::Base;
230 
231  //- Clone
232  virtual autoPtr<interpolation<Type>> clone() const
233  {
235  (
236  new cellPoint<Type>(*this)
237  );
238  }
239 };
240 
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 } // End namespace interpolations
245 } // End namespace Foam
246 
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 
250 
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 
253 #ifdef NoRepository
254  #include "cellPoint_interpolation.C"
255 #endif
256 
257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
258 
259 #endif
260 
261 // ************************************************************************* //
Templated 4x3 tensor derived from VectorSpace. Has 12 components. Can represent a barycentric transfo...
Generic GeometricField class.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Abstract base class for interpolation.
barycentric y0() const
Return the barycentric origin for the above transforms.
cellPointBase(const VolField< Type > &psi)
Construct from components.
void tetFaceTriTransform(const tetIndices &tetIs, vector &x0, scalar &detA, barycentricTensor &T) const
Return the transform associated with the face-triangle of the given.
tetIndices findTet(const point &x, const label celli, const label facei, vector &x0, scalar &detA, barycentricTensor &T) const
Find the tetrahedron (or triangle) containing the given point, and.
Type interpolate(const vector &position, const label celli, const label facei=-1) const
Interpolate to the given point in the given cell.
void tetTransform(const tetIndices &tetIs, vector &x0, scalar &detA, barycentricTensor &T) const
Return the transform associated with the given tetrahedron.
interpolationGradType< Type > interpolateGrad(const tetIndices &tetIs, const scalar detA, const barycentricTensor T) const
Interpolate the gradient to the given point in the given cell.
Piecewise-linear interpolation method. Uses volPointInterpolation to create values on the points....
virtual autoPtr< interpolation< Type > > clone() const
Clone.
TypeName("cellPoint")
Runtime type information.
Base class for interpolations that require a vol-point interpolated field.
const PointField< Type > & psip() const
Access the point field.
Traits class for primitives.
Definition: pTraits.H:53
Storage and named access for the indices of a tet which is part of the decomposition of a cell.
Definition: tetIndices.H:82
A class for managing temporary objects.
Definition: tmp.H:55
const volScalarField & psi
typename std::conditional<(pTraits< Type >::rank > 1), cellPointBase< Type >, cellPointGradBase< Type > >::type cellPointBaseOrGradBase
barycentric coordinates(const polyMesh &mesh, const point &position, const label celli, const label facei, const label faceTrii, const scalar stepFraction)
Return the coordinates given the position and tet topology.
Definition: tracking.C:1258
point position(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label facei, const label faceTrii, const scalar stepFraction)
Return the position given the coordinates and tet topology.
Definition: trackingI.H:224
Namespace for OpenFOAM.
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
typename outerProduct< Type, vector >::type interpolationGradType
Definition: interpolation.H:52
void T(GeometricField< Type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf1)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488