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 // Forward Declarations
54 class fvMesh;
55 class pointMesh;
56 
57 /*---------------------------------------------------------------------------*\
58  Class volPointInterpolation Declaration
59 \*---------------------------------------------------------------------------*/
60 
62 :
63  public MeshObject<fvMesh, UpdateableMeshObject, volPointInterpolation>
64 {
65  // Private Typedefs
66 
67  typedef MeshObject
68  <
69  fvMesh,
73 
74 
75  // Private Data
76 
77  //- Interpolation scheme weighting factor array.
78  scalarListList pointWeights_;
79 
80 
81  // Boundary handling
82 
83  //- Boundary addressing
84  autoPtr<primitivePatch> boundaryPtr_;
85 
86  //- Per boundary face whether is on non-coupled, non-empty patch
87  bitSet boundaryIsPatchFace_;
88 
89  //- Per mesh(!) point whether is on non-coupled, non-empty patch (on
90  // any processor)
91  bitSet isPatchPoint_;
92 
93  //- Per boundary point the weights per pointFaces.
94  scalarListList boundaryPointWeights_;
95 
96  //- Whether mesh has any non-processor coupled patches
97  bool hasSeparated_;
98 
99  //- Optional scaling for coupled point patch fields using the
100  // swapAddSeparated to add additional contributions (e.g. cyclicAMI).
101  // (note: one-to-one matching (processor) uses a different mechanism)
102  tmp<scalarField> normalisationPtr_;
103 
104 
105  // Private Member Functions
106 
107  //- Constructor helper: check if any non-processor coupled patches
108  static bool hasSeparated(const pointMesh& pMesh);
109 
110  //- Construct addressing over all boundary faces
111  void calcBoundaryAddressing();
112 
113  //- Make weights for internal and coupled-only boundarypoints
114  void makeInternalWeights(scalarField& sumWeights);
115 
116  //- Make weights for points on uncoupled patches
117  void makeBoundaryWeights(scalarField& sumWeights);
118 
119  //- Construct all point weighting factors
120  void makeWeights();
121 
122  //- Helper: interpolate oneField onto boundary points only. Used to
123  // correct normalisation
124  void interpolateOne
125  (
126  const tmp<scalarField>& tnormalisation,
127  pointScalarField& pf
128  ) const;
129 
130  //- Helper: push master point data to collocated points
131  template<class Type>
132  void pushUntransformedData(List<Type>&) const;
133 
134  //- Get boundary field in same order as boundary faces.
135  //- Field is zero on all coupled and empty patches
136  template<class Type>
137  void flatBoundaryField
138  (
139  UList<Type>& result,
141  ) const;
142 
143  //- Get boundary field in same order as boundary faces.
144  //- Field is zero on all coupled and empty patches
145  template<class Type>
146  tmp<Field<Type>> flatBoundaryField
147  (
149  ) const;
150 
151  //- Add separated contributions
152  template<class Type>
153  void addSeparated
154  (
156  ) const;
157 
158  //- No copy construct
160 
161  //- No copy assignment
162  void operator=(const volPointInterpolation&) = delete;
163 
164 
165 public:
166 
167  // Declare name of the class and its debug switch
168  ClassName("volPointInterpolation");
169 
170 
171  // Constructors
172 
173  //- Construct given fvMesh
174  explicit volPointInterpolation(const fvMesh&);
175 
176 
177  //- Destructor
179 
180 
181  // Member functions
182 
183  // Edit
184 
185  //- Update mesh topology using the morph engine
186  void updateMesh(const mapPolyMesh&);
187 
188  //- Correct weighting factors for moving mesh.
189  bool movePoints();
190 
191 
192  // Interpolation Functions
193 
194  //- Interpolate volField using inverse distance weighting
195  // \return pointField
196  template<class Type>
198  (
200  ) const;
201 
202  //- Interpolate tmp<volField> using inverse distance weighting
203  // \return pointField
204  template<class Type>
206  (
208  ) const;
209 
210  //- Interpolate volField using inverse distance weighting
211  // returning pointField with the same patchField types. Assigns
212  // to any fixedValue boundary conditions to make them consistent
213  // with internal field
214  template<class Type>
216  (
218  const wordList& patchFieldTypes
219  ) const;
220 
221  //- Interpolate tmp<volField> using inverse distance weighting
222  // returning pointField with the same patchField types. Assigns
223  // to any fixedValue boundary conditions to make them consistent
224  // with internal field
225  template<class Type>
227  (
229  const wordList& patchFieldTypes
230  ) const;
231 
232  //- Interpolate dimensionedField using inverse distance weighting
233  // \return pointField
234  template<class Type>
236  (
238  ) const;
239 
240  //- Interpolate tmp<dimensionedField> using inverse distance
241  // weighting returning pointField
242  template<class Type>
244  (
246  ) const;
247 
248 
249  // Low level
250 
251  //- Interpolate internal field from volField to pointField
252  // using inverse distance weighting
253  template<class Type>
255  (
258  ) const;
259 
260  //- Interpolate boundary field without applying constraints/boundary
261  // conditions
262  template<class Type>
264  (
266 
268  ) const;
269 
270  //- Interpolate boundary with constraints/boundary conditions
271  template<class Type>
273  (
276  const bool overrideFixedValue
277  ) const;
278 
279  //- Interpolate from volField to pointField
280  // using inverse distance weighting
281  template<class Type>
282  void interpolate
283  (
286  ) const;
287 
288  //- Interpolate volField using inverse distance weighting
289  // returning pointField with name. Optionally caches
290  template<class Type>
292  (
294  const word& name,
295  const bool cache
296  ) const;
297 
298  //- Interpolate dimensioned internal field from cells to points
299  // using inverse distance weighting
300  template<class Type>
302  (
305  ) const;
306 
307  //- Interpolate dimensionedField using inverse distance weighting
308  // returning pointField with name. Optionally caches
309  template<class Type>
311  (
313  const word& name,
314  const bool cache
315  ) const;
316 
317  // Interpolation for displacement (applies 2D correction)
318 
319  //- Interpolate from volField to pointField
320  // using inverse distance weighting
322  (
323  const volVectorField&,
325  ) const;
326 };
327 
328 
329 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
330 
331 } // End namespace Foam
332 
333 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
334 
335 #ifdef NoRepository
336  #include "volPointInterpolate.C"
337 #endif
338 
339 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
340 
341 #endif
342 
343 // ************************************************************************* //
tmp< GeometricField< Type, pointPatchField, pointMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &) const
Interpolate volField using inverse distance weighting.
void updateMesh(const mapPolyMesh &)
Update mesh topology using the morph engine.
void interpolateBoundaryField(const GeometricField< Type, fvPatchField, volMesh > &vf, GeometricField< Type, pointPatchField, pointMesh > &pf) const
Interpolate boundary field without applying constraints/boundary.
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:205
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:45
ClassName("volPointInterpolation")
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:152
A class for handling words, derived from Foam::string.
Definition: word.H:63
void interpolateInternalField(const GeometricField< Type, fvPatchField, volMesh > &, GeometricField< Type, pointPatchField, pointMesh > &) const
Interpolate internal field from volField to pointField.
Interpolate from cell centres to points (vertices) using inverse distance weighting.
void interpolateDimensionedInternalField(const DimensionedField< Type, volMesh > &vf, DimensionedField< Type, pointMesh > &pf) const
Interpolate dimensioned internal field from cells to points.
void interpolateDisplacement(const volVectorField &, pointVectorField &) const
Interpolate from volField to pointField.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:58
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
A class for managing temporary objects.
Definition: HashPtrTable.H:50
bool movePoints()
Correct weighting factors for moving mesh.
Namespace for OpenFOAM.
UpdateableMeshObject(const word &objName, const objectRegistry &obr)
Construct from name and instance on registry.
Definition: MeshObject.H:354