uniformInterpolate.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-2024 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 
26 
27 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
28 
29 template<class GeoField>
31 (
32  const HashPtrTable<GeoField, label, Hash<label>>& fields,
33  const labelList& indices,
34  const scalarField& weights
35 )
36 {
37  const GeoField& field0 = *(*fields.begin());
38 
39  // Interpolate
40  tmp<GeoField> tfld
41  (
43  (
44  "uniformInterpolate(" + field0.name() + ')',
45  weights[0]*(*fields[indices[0]])
46  )
47  );
48  GeoField& fld = tfld();
49 
50  for (label i = 1; i < indices.size(); ++i)
51  {
52  fld += weights[i]*(*fields[indices[i]]);
53  }
54 
55  return tfld;
56 }
57 
58 
59 template<class GeoField>
61 (
62  const IOobject& fieldIO,
63  const word& fieldName,
64  const wordList& times,
65  const scalarField& weights,
66  const objectRegistry& fieldsCache
67 )
68 {
69  // Look up the first field
70  const objectRegistry& time0Fields =
71  fieldsCache.lookupObject<const objectRegistry>(times[0]);
72 
73  const GeoField& field0 =
74  time0Fields.lookupObject<const GeoField>(fieldName);
75 
76  // Interpolate
77  tmp<GeoField> tfld(GeoField::New(fieldIO.name(), weights[0]*field0));
78  GeoField& fld = tfld.ref();
79 
80  for (label i = 1; i < times.size(); ++i)
81  {
82  const objectRegistry& timeIFields =
83  fieldsCache.lookupObject<const objectRegistry>(times[i]);
84 
85  const GeoField& fieldi =
86  timeIFields.lookupObject<const GeoField>(fieldName);
87 
88  fld += weights[i]*fieldi;
89  }
90 
91  return tfld;
92 }
93 
94 
95 template<class GeoField>
97 (
98  const IOobject& fieldIO,
99  const word& fieldName,
100  const wordList& times,
101  const scalarField& weights,
102  const word& registryName
103 )
104 {
105  return uniformInterpolate<GeoField>
106  (
107  fieldIO,
108  fieldName,
109  times,
110  weights,
111  fieldIO.db().subRegistry(registryName, true)
112  );
113 }
114 
115 
116 // ************************************************************************* //
A class for managing temporary objects.
Definition: tmp.H:55
volScalarField scalarField(fieldObject, mesh)
gmvFile<< "tracers "<< particles.size()<< nl;{ pointField positions(particles.size());label particlei=0;forAllConstIter(lagrangian::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(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Info<< "Calculating turbulent flame speed field St\n"<< endl;volScalarField St(IOobject("St", runTime.name(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), flameWrinkling->Xi() *Su);multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:234
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
List< word > wordList
A List of words.
Definition: fileName.H:54
List< label > labelList
A List of labels.
Definition: labelList.H:56
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
tmp< GeoField > uniformInterpolate(const HashPtrTable< GeoField, label, Hash< label >> &fields, const labelList &indices, const scalarField &weights)
Interpolate selected fields (given by indices and corresponding weights)