pointToPointPlanarInterpolationTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2012-2018 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  << "Number of source points = " << nPoints_
40  << " number of values = " << sourceFld.size()
41  << exit(FatalError);
42  }
43 
44  tmp<Field<Type>> tfld(new Field<Type>(nearestVertex_.size()));
45  Field<Type>& fld = tfld.ref();
46 
47  forAll(fld, i)
48  {
49  const FixedList<label, 3>& verts = nearestVertex_[i];
50  const FixedList<scalar, 3>& w = nearestVertexWeight_[i];
51 
52  if (verts[2] == -1)
53  {
54  if (verts[1] == -1)
55  {
56  // Use vertex0 only
57  fld[i] = sourceFld[verts[0]];
58  }
59  else
60  {
61  // Use vertex 0,1
62  fld[i] =
63  w[0]*sourceFld[verts[0]]
64  + w[1]*sourceFld[verts[1]];
65  }
66  }
67  else
68  {
69  fld[i] =
70  w[0]*sourceFld[verts[0]]
71  + w[1]*sourceFld[verts[1]]
72  + w[2]*sourceFld[verts[2]];
73  }
74  }
75  return tfld;
76 }
77 
78 
79 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Pre-declare SubField and related Field type.
Definition: Field.H:83
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
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:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
gmvFile<< "tracers "<< particles.size()<< nl;{ pointField positions(particles.size());label particlei=0;forAllConstIter(Cloud< passiveParticle >, particles, iter) { positions[particlei++]=iter().position(mesh);} for(i=0;i< pTraits< point >::nComponents;i++) { forAll(positions, particlei) { gmvFile<< component(positions[particlei], i)<< ' ';} gmvFile<< nl;}}forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError