pointToPointPlanarInterpolationTemplates.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) 2012-2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
29
30// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
31
32template<class Type>
34(
35 const Field<Type>& sourceFld
36) const
37{
38 if (nPoints_ != sourceFld.size())
39 {
41 << "Number of source points = " << nPoints_
42 << " number of values = " << sourceFld.size()
43 << exit(FatalError);
44 }
45
46 tmp<Field<Type>> tfld(new Field<Type>(nearestVertex_.size()));
47 Field<Type>& fld = tfld.ref();
48
49 forAll(fld, i)
50 {
51 const FixedList<label, 3>& verts = nearestVertex_[i];
52 const FixedList<scalar, 3>& w = nearestVertexWeight_[i];
53
54 if (verts[2] == -1)
55 {
56 if (verts[1] == -1)
57 {
58 // Use vertex0 only
59 fld[i] = sourceFld[verts[0]];
60 }
61 else
62 {
63 // Use vertex 0,1
64 fld[i] =
65 w[0]*sourceFld[verts[0]]
66 + w[1]*sourceFld[verts[1]];
67 }
68 }
69 else
70 {
71 fld[i] =
72 w[0]*sourceFld[verts[0]]
73 + w[1]*sourceFld[verts[1]]
74 + w[2]*sourceFld[verts[2]];
75 }
76 }
77 return tfld;
78}
79
80
81// ************************************************************************* //
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Generic templated field type.
Definition: Field.H:82
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: FixedList.H:81
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
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 FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333