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 -------------------------------------------------------------------------------
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 \*---------------------------------------------------------------------------*/
28 
29 #include "pointVolInterpolation.H"
30 #include "volFields.H"
31 #include "pointFields.H"
32 #include "primitiveMesh.H"
33 #include "emptyFvPatch.H"
34 #include "globalMeshData.H"
35 
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 
38 template<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 
93 template<class Type>
96 (
98 ) const
99 {
100  // Construct tmp<pointField>
102  (
104  (
105  IOobject
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 
123 template<class Type>
126 (
128 ) const
129 {
130  // Construct tmp<volField>
132  interpolate(tpf());
133  tpf.clear();
134  return tvf;
135 }
136 
137 
138 // ************************************************************************* //
volFields.H
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::FieldField
A field of fields is a PtrList of fields with reference counting.
Definition: FieldField.H:53
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
globalMeshData.H
pointVolInterpolation.H
primitiveMesh.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::fvBoundaryMesh
Foam::fvBoundaryMesh.
Definition: fvBoundaryMesh.H:57
Foam::pointVolInterpolation::interpolate
void interpolate(const GeometricField< Type, pointPatchField, pointMesh > &, GeometricField< Type, fvPatchField, volMesh > &) const
Interpolate from pointField to volField.
Definition: pointVolInterpolate.C:40
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
DebugInFunction
#define DebugInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:388
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
emptyFvPatch.H
Foam::GeometricField::correctBoundaryConditions
void correctBoundaryConditions()
Correct boundary field.
Definition: GeometricField.C:940
Foam::constant::mathematical::pi
constexpr scalar pi(M_PI)
Foam::GeometricField::boundaryFieldRef
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
Definition: GeometricField.C:783
Foam::List< labelList >
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition: pTraits.H:56
Foam::roots::type
type
Types of root.
Definition: Roots.H:54
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
pointFields.H
Foam::fac::interpolate
static tmp< GeometricField< Type, faePatchField, edgeMesh > > interpolate(const GeometricField< Type, faPatchField, areaMesh > &tvf, const edgeScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62