volPointInterpolation.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::volPointInterpolation
29 
30 Description
31  Interpolate from cell centres to points (vertices) using inverse distance
32  weighting
33 
34 SourceFiles
35  volPointInterpolation.C
36  volPointInterpolate.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef volPointInterpolation_H
41 #define volPointInterpolation_H
42 
43 #include "MeshObject.H"
44 #include "scalarList.H"
45 #include "volFields.H"
46 #include "pointFields.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 class fvMesh;
54 class pointMesh;
55 
56 /*---------------------------------------------------------------------------*\
57  Class volPointInterpolation Declaration
58 \*---------------------------------------------------------------------------*/
59 
61 :
62  public MeshObject<fvMesh, UpdateableMeshObject, volPointInterpolation>
63 {
64  // Private data
65 
66  //- Interpolation scheme weighting factor array.
67  scalarListList pointWeights_;
68 
69 
70  // Boundary handling
71 
72  //- Boundary addressing
73  autoPtr<primitivePatch> boundaryPtr_;
74 
75  //- Per boundary face whether is on non-coupled, non-empty patch
76  bitSet boundaryIsPatchFace_;
77 
78  //- Per mesh(!) point whether is on non-coupled, non-empty patch (on
79  // any processor)
80  bitSet isPatchPoint_;
81 
82  //- Per boundary point the weights per pointFaces.
83  scalarListList boundaryPointWeights_;
84 
85  //- Whether mesh has any non-processor coupled patches
86  bool hasSeparated_;
87 
88  //- Optional scaling for coupled point patch fields using the
89  // swapAddSeparated to add additional contributions (e.g. cyclicAMI).
90  // (note: one-to-one matching (processor) uses a different mechanism)
91  tmp<scalarField> normalisationPtr_;
92 
93 
94  // Private Member Functions
95 
96  //- Constructor helper: check if any non-processor coupled patches
97  static bool hasSeparated(const pointMesh& pMesh);
98 
99  //- Construct addressing over all boundary faces
100  void calcBoundaryAddressing();
101 
102  //- Make weights for internal and coupled-only boundarypoints
103  void makeInternalWeights(scalarField& sumWeights);
104 
105  //- Make weights for points on uncoupled patches
106  void makeBoundaryWeights(scalarField& sumWeights);
107 
108  //- Construct all point weighting factors
109  void makeWeights();
110 
111  //- Helper: interpolate oneField onto boundary points only. Used to
112  // correct normalisation
113  void interpolateOne
114  (
115  const tmp<scalarField>& tnormalisation,
116  pointScalarField& pf
117  ) const;
118 
119  //- Helper: push master point data to collocated points
120  template<class Type>
121  void pushUntransformedData(List<Type>&) const;
122 
123  //- Get boundary field in same order as boundary faces. Field is
124  // zero on all coupled and empty patches
125  template<class Type>
126  tmp<Field<Type>> flatBoundaryField
127  (
129  ) const;
130 
131  //- Add separated contributions
132  template<class Type>
133  void addSeparated
134  (
136  ) const;
137 
138  //- No copy construct
140 
141  //- No copy assignment
142  void operator=(const volPointInterpolation&) = delete;
143 
144 
145 public:
146 
147  // Declare name of the class and its debug switch
148  ClassName("volPointInterpolation");
149 
150 
151  // Constructors
152 
153  //- Constructor given fvMesh and pointMesh.
154  explicit volPointInterpolation(const fvMesh&);
155 
156 
157  //- Destructor
159 
160 
161  // Member functions
162 
163  // Edit
164 
165  //- Update mesh topology using the morph engine
166  void updateMesh(const mapPolyMesh&);
167 
168  //- Correct weighting factors for moving mesh.
169  bool movePoints();
170 
171 
172  // Interpolation Functions
173 
174  //- Interpolate volField using inverse distance weighting
175  // \return pointField
176  template<class Type>
178  (
180  ) const;
181 
182  //- Interpolate tmp<volField> using inverse distance weighting
183  // \return pointField
184  template<class Type>
186  (
188  ) const;
189 
190  //- Interpolate volField using inverse distance weighting
191  // returning pointField with the same patchField types. Assigns
192  // to any fixedValue boundary conditions to make them consistent
193  // with internal field
194  template<class Type>
196  (
198  const wordList& patchFieldTypes
199  ) const;
200 
201  //- Interpolate tmp<volField> using inverse distance weighting
202  // returning pointField with the same patchField types. Assigns
203  // to any fixedValue boundary conditions to make them consistent
204  // with internal field
205  template<class Type>
207  (
209  const wordList& patchFieldTypes
210  ) const;
211 
212  //- Interpolate dimensionedField using inverse distance weighting
213  // \return pointField
214  template<class Type>
216  (
218  ) const;
219 
220  //- Interpolate tmp<dimensionedField> using inverse distance
221  // weighting returning pointField
222  template<class Type>
224  (
226  ) const;
227 
228 
229  // Low level
230 
231  //- Interpolate internal field from volField to pointField
232  // using inverse distance weighting
233  template<class Type>
235  (
238  ) const;
239 
240  //- Interpolate boundary field without applying constraints/boundary
241  // conditions
242  template<class Type>
244  (
246 
248  ) const;
249 
250  //- Interpolate boundary with constraints/boundary conditions
251  template<class Type>
253  (
256  const bool overrideFixedValue
257  ) const;
258 
259  //- Interpolate from volField to pointField
260  // using inverse distance weighting
261  template<class Type>
262  void interpolate
263  (
266  ) const;
267 
268  //- Interpolate volField using inverse distance weighting
269  // returning pointField with name. Optionally caches
270  template<class Type>
272  (
274  const word& name,
275  const bool cache
276  ) const;
277 
278  //- Interpolate dimensioned internal field from cells to points
279  // using inverse distance weighting
280  template<class Type>
282  (
285  ) const;
286 
287  //- Interpolate dimensionedField using inverse distance weighting
288  // returning pointField with name. Optionally caches
289  template<class Type>
291  (
293  const word& name,
294  const bool cache
295  ) const;
296 
297  // Interpolation for displacement (applies 2D correction)
298 
299  //- Interpolate from volField to pointField
300  // using inverse distance weighting
302  (
303  const volVectorField&,
305  ) const;
306 };
307 
308 
309 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
310 
311 } // End namespace Foam
312 
313 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
314 
315 #ifdef NoRepository
316  #include "volPointInterpolate.C"
317 #endif
318 
319 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
320 
321 #endif
322 
323 // ************************************************************************* //
volFields.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:63
Foam::volPointInterpolation::ClassName
ClassName("volPointInterpolation")
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::volPointInterpolation::interpolate
tmp< GeometricField< Type, pointPatchField, pointMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &) const
Interpolate volField using inverse distance weighting.
Foam::volPointInterpolation::updateMesh
void updateMesh(const mapPolyMesh &)
Update mesh topology using the morph engine.
Definition: volPointInterpolation.C:492
scalarList.H
Foam::Field< scalar >
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::pointMesh
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:51
Foam::volPointInterpolation::~volPointInterpolation
~volPointInterpolation()
Destructor.
Definition: volPointInterpolation.C:486
Foam::IOobject::name
const word & name() const noexcept
Return name.
Definition: IOobjectI.H:65
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
volPointInterpolate.C
Foam::List< scalarList >
Foam::volPointInterpolation::movePoints
bool movePoints()
Correct weighting factors for moving mesh.
Definition: volPointInterpolation.C:501
Foam::volPointInterpolation::interpolateInternalField
void interpolateInternalField(const GeometricField< Type, fvPatchField, volMesh > &, GeometricField< Type, pointPatchField, pointMesh > &) const
Interpolate internal field from volField to pointField.
Definition: volPointInterpolate.C:133
Foam::volPointInterpolation::interpolateDisplacement
void interpolateDisplacement(const volVectorField &, pointVectorField &) const
Interpolate from volField to pointField.
Definition: volPointInterpolation.C:510
MeshObject.H
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
Foam::MeshObject
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:88
Foam::GeometricField< scalar, pointPatchField, pointMesh >
Foam::volPointInterpolation::interpolateDimensionedInternalField
void interpolateDimensionedInternalField(const DimensionedField< Type, volMesh > &vf, DimensionedField< Type, pointMesh > &pf) const
Interpolate dimensioned internal field from cells to points.
Definition: volPointInterpolate.C:170
Foam::volPointInterpolation::interpolateBoundaryField
void interpolateBoundaryField(const GeometricField< Type, fvPatchField, volMesh > &vf, GeometricField< Type, pointPatchField, pointMesh > &pf) const
Interpolate boundary field without applying constraints/boundary.
Definition: volPointInterpolate.C:277
Foam::volPointInterpolation
Interpolate from cell centres to points (vertices) using inverse distance weighting.
Definition: volPointInterpolation.H:59
pointFields.H
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54