pointMVCWeight.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::pointMVCWeight
26 
27 Description
28  Container to calculate weights for interpolating directly from vertices
29  of cell using Mean Value Coordinates. Based on VTK's
30  vtkMeanValueCoordinatesInterpolator.
31 
32  Reference:
33  \verbatim
34  Langer, T., Belyaev, A., & Seidel, H. P. (2006, June).
35  Spherical barycentric coordinates.
36  In Symposium on Geometry Processing (pp. 81-88).
37  \endverbatim
38 
39 SourceFiles
40  pointMVCWeightI.H
41  pointMVCWeight.C
42 
43 \*---------------------------------------------------------------------------*/
44 
45 #ifndef pointMVCWeight_H
46 #define pointMVCWeight_H
47 
48 #include "point.H"
49 #include "volFieldsFwd.H"
50 #include "pointFieldsFwd.H"
51 #include "scalarField.H"
52 #include "vectorField.H"
53 #include "Map.H"
54 #include "DynamicList.H"
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace Foam
59 {
60 
61 class face;
62 class polyMesh;
63 class pointMesh;
64 
65 /*---------------------------------------------------------------------------*\
66  Class pointMVCWeight Declaration
67 \*---------------------------------------------------------------------------*/
68 
69 class pointMVCWeight
70 {
71 protected:
72 
73  // Protected data
74 
75  //- Cell index
76  const label cellIndex_;
77 
78  //- Weights applied to cell vertices
80 
81 
82  // Protected Member Functions
83 
84  //- Calculate weights from single face's vertices only
85  void calcWeights
86  (
87  const Map<label>& toLocal,
88  const face& f,
89  const DynamicList<point>& u,
90  const scalarField& dist,
92  ) const;
93 
94  //- Calculate weights from all cell's vertices
95  void calcWeights
96  (
97  const polyMesh& mesh,
98  const labelList& toGlobal,
99  const Map<label>& toLocal,
100  const vector& position,
101  const vectorField& uVec,
102  const scalarField& dist,
104  ) const;
105 
106 
107 public:
108 
109  //- Type information
110  ClassName("pointMVCWeight");
111 
112 
113  // Static Member Data
114 
115  //- Tolerance used in calculating barycentric co-ordinates
116  static scalar tol;
117 
118 
119  // Constructors
120 
121  //- Construct from components
123  (
124  const polyMesh& mesh,
125  const vector& position,
126  const label celli,
127  const label facei = -1
128  );
129 
130 
131  // Member Functions
132 
133  //- Cell index
134  inline label cell() const
135  {
136  return cellIndex_;
137  }
138 
139  //- Interpolation weights (in order of cellPoints)
140  inline const scalarField& weights() const
141  {
142  return weights_;
143  }
144 
145  //- Interpolate field
146  template<class Type>
147  inline Type interpolate
148  (
149  const PointField<Type>& psip
150  ) const;
151 };
152 
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 } // End namespace Foam
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 #include "pointMVCWeightI.H"
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 #endif
165 
166 // ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:78
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:76
Container to calculate weights for interpolating directly from vertices of cell using Mean Value Coor...
const label cellIndex_
Cell index.
static scalar tol
Tolerance used in calculating barycentric co-ordinates.
label cell() const
Cell index.
scalarField weights_
Weights applied to cell vertices.
const scalarField & weights() const
Interpolation weights (in order of cellPoints)
Type interpolate(const PointField< Type > &psip) const
Interpolate field.
pointMVCWeight(const polyMesh &mesh, const vector &position, const label celli, const label facei=-1)
Construct from components.
void calcWeights(const Map< label > &toLocal, const face &f, const DynamicList< point > &u, const scalarField &dist, scalarField &weights) const
Calculate weights from single face's vertices only.
ClassName("pointMVCWeight")
Type information.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
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
labelList f(nPoints)