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 -------------------------------------------------------------------------------
10 License
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 
32 template<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 // ************************************************************************* //
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::pointToPointPlanarInterpolation::interpolate
tmp< Field< Type > > interpolate(const Field< Type > &sourceFld) const
Interpolate from field on source points to dest points.
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
Foam::Field
Generic templated field type.
Definition: Field.H:63
pointToPointPlanarInterpolation.H
fld
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))
Definition: gmvOutputLagrangian.H:23
Foam::FatalError
error FatalError
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::FixedList< label, 3 >