pointVolInterpolate.C
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) Wikki Ltd
9 Copyright (C) 2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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\*---------------------------------------------------------------------------*/
28
30#include "volFields.H"
31#include "pointFields.H"
32#include "primitiveMesh.H"
33#include "emptyFvPatch.H"
34#include "globalMeshData.H"
35
36// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37
38template<class Type>
40(
43) const
44{
46 << "interpolating field from points to cells"
47 << endl;
48
49 const FieldField<Field, scalar>& weights = volWeights();
50 const labelListList& cellPoints = vf.mesh().cellPoints();
51
52 // Multiply pointField by weighting factor matrix to create volField
53 forAll(cellPoints, cellI)
54 {
55 vf[cellI] = pTraits<Type>::zero;
56
57 const labelList& curCellPoints = cellPoints[cellI];
58
59 forAll(curCellPoints, cellPointI)
60 {
61 vf[cellI] +=
62 weights[cellI][cellPointI]*pf[curCellPoints[cellPointI]];
63 }
64 }
65
66
67 // Interpolate patch values: over-ride the internal values for the points
68 // on the patch with the interpolated point values from the faces
69 const fvBoundaryMesh& bm = vMesh().boundary();
70
71 const PtrList<primitivePatchInterpolation>& pi = patchInterpolators();
72 forAll(bm, patchI)
73 {
74 // If the patch is empty, skip it
75 if (bm[patchI].type() != emptyFvPatch::typeName)
76 {
77 vf.boundaryFieldRef()[patchI] =
78 pi[patchI].pointToFaceInterpolate
79 (
80 pf.boundaryField()[patchI].patchInternalField()
81 );
82 }
83 }
84
86
88 << "finished interpolating field from points to cells"
89 << endl;
90}
91
92
93template<class Type>
96(
98) const
99{
100 // Construct tmp<pointField>
102 (
104 (
106 (
107 "pointVolInterpolate(" + pf.name() + ')',
108 pf.instance(),
109 pf.db()
110 ),
111 vMesh(),
112 pf.dimensions()
113 )
114 );
115
116 // Perform interpolation
117 interpolate(pf, tvf.ref());
118
119 return tvf;
120}
121
122
123template<class Type>
126(
128) const
129{
130 // Construct tmp<volField>
132 interpolate(tpf());
133 tpf.clear();
134 return tvf;
135}
136
137
138// ************************************************************************* //
const dimensionSet & dimensions() const
Return dimensions.
const Mesh & mesh() const
Return mesh.
A field of fields is a PtrList of fields with reference counting.
Definition: FieldField.H:80
Generic GeometricField class.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
void correctBoundaryConditions()
Correct boundary field.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:65
const objectRegistry & db() const noexcept
Return the local objectRegistry.
Definition: IOobject.C:500
const fileName & instance() const noexcept
Read access to instance path component.
Definition: IOobjectI.H:196
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
Foam::fvBoundaryMesh.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:712
const FieldField< Field, scalar > & volWeights() const
Return reference to weights arrays.
const fvMesh & vMesh() const
bool interpolate() const noexcept
Same as isPointData()
A class for managing temporary objects.
Definition: tmp.H:65
T & ref() const
Definition: tmpI.H:227
#define DebugInFunction
Report an information message using Foam::Info.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
Definition: curveTools.C:75
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
static const char *const typeName
The type name used in ensight case files.
A non-counting (dummy) refCount.
Definition: refCount.H:59