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 | Copyright (C) 2012-2013 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 
28 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
29 
30 template<class Type>
32 (
33  const Field<Type>& sourceFld
34 ) const
35 {
36  if (nPoints_ != sourceFld.size())
37  {
39  (
40  "pointToPointPlanarInterpolation::interpolate"
41  "(const Field<Type>&) const"
42  ) << "Number of source points = " << nPoints_
43  << " number of values = " << sourceFld.size()
44  << exit(FatalError);
45  }
46 
47  tmp<Field<Type> > tfld(new Field<Type>(nearestVertex_.size()));
48  Field<Type>& fld = tfld();
49 
50  forAll(fld, i)
51  {
52  const FixedList<label, 3>& verts = nearestVertex_[i];
53  const FixedList<scalar, 3>& w = nearestVertexWeight_[i];
54 
55  if (verts[2] == -1)
56  {
57  if (verts[1] == -1)
58  {
59  // Use vertex0 only
60  fld[i] = sourceFld[verts[0]];
61  }
62  else
63  {
64  // Use vertex 0,1
65  fld[i] =
66  w[0]*sourceFld[verts[0]]
67  + w[1]*sourceFld[verts[1]];
68  }
69  }
70  else
71  {
72  fld[i] =
73  w[0]*sourceFld[verts[0]]
74  + w[1]*sourceFld[verts[1]]
75  + w[2]*sourceFld[verts[2]];
76  }
77  }
78  return tfld;
79 }
80 
81 
82 // ************************************************************************* //
void size(const label)
Override size to be inconsistent with allocated storage.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
#define forAll(list, i)
Definition: UList.H:421
Pre-declare SubField and related Field type.
Definition: Field.H:57
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject( name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE ))
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
error FatalError
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: PtrList.H:118