Loading...
Searching...
No Matches
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 Copyright (C) 2022 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\*---------------------------------------------------------------------------*/
30
31// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32
33template<class Type>
36(
37 const Field<Type>& sourceFld
38) const
39{
40 if (nPoints_ != sourceFld.size())
41 {
43 << "Number of source points = " << nPoints_
44 << " number of values = " << sourceFld.size()
45 << exit(FatalError);
46 }
47
48 auto tfld = tmp<Field<Type>>::New(nearestVertex_.size());
49 auto& fld = tfld.ref();
50
51 forAll(fld, i)
52 {
53 const FixedList<label, 3>& verts = nearestVertex_[i];
54 const FixedList<scalar, 3>& w = nearestVertexWeight_[i];
55
56 if (verts[1] == -1)
57 {
58 // Use vertex (0) only
59 fld[i] = sourceFld[verts[0]];
60 }
61 else if (verts[2] == -1)
62 {
63 // Use vertex (0,1)
64 fld[i] =
65 (
66 w[0]*sourceFld[verts[0]]
67 + w[1]*sourceFld[verts[1]]
68 );
69 }
70 else
71 {
72 // Use vertex (0,1,2)
73 fld[i] =
74 (
75 w[0]*sourceFld[verts[0]]
76 + w[1]*sourceFld[verts[1]]
77 + w[2]*sourceFld[verts[2]]
78 );
79 }
80 }
81 return tfld;
82}
83
84
85template<class Type>
88(
89 const tmp<Field<Type>>& tsource
90) const
91{
92 tmp<Field<Type>> tresult = this->interpolate(tsource());
93 tsource.clear();
94
95 return tresult;
96}
97
98
99// ************************************************************************* //
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
A 1D vector of objects of type <T> with a fixed length <N>.
Definition FixedList.H:73
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
tmp< Field< Type > > interpolate(const Field< Type > &sourceFld) const
Interpolate from field on source points to dest points.
A class for managing temporary objects.
Definition tmp.H:75
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
Definition curveTools.C:75
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299