surfaceInterpolateTemplates.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2015-2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 \*---------------------------------------------------------------------------*/
28 
29 #include "surfaceInterpolate.H"
30 #include "volFields.H"
31 #include "linear.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 template<class Type>
37 {
39 
40  // Convert field to map
41  HashTable<word> fieldMap(2*fieldSet_.size());
42  for (const auto& namePair : fieldSet_)
43  {
44  fieldMap.insert(namePair.first(), namePair.second());
45  }
46 
47 
48  HashTable<const VolFieldType*> flds(obr_.lookupClass<VolFieldType>());
49 
50  forAllConstIters(flds, iter)
51  {
52  const VolFieldType& fld = *iter();
53 
54  if (fieldMap.found(fld.name()))
55  {
56  // const word sName = "interpolate(" + fld.name() + ')';
57  word& sName = fieldMap[fld.name()];
58 
59  if (obr_.found(sName))
60  {
61  Log << " updating field " << sName << endl;
62  }
63  else
64  {
65  Log << " interpolating " << fld.name() << " to create "
66  << sName << endl;
67  }
68 
69  store(sName, linearInterpolate(fld));
70  }
71  }
72 }
73 
74 
75 // ************************************************************************* //
volFields.H
Foam::functionObjects::regionFunctionObject::obr_
const objectRegistry & obr_
Reference to the region objectRegistry.
Definition: regionFunctionObject.H:102
Log
#define Log
Definition: PDRblock.C:35
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::functionObjects::surfaceInterpolate::fieldSet_
List< Tuple2< word, word > > fieldSet_
Fields to process.
Definition: surfaceInterpolate.H:159
Foam::HashTable::insert
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
Definition: HashTableI.H:180
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::functionObjects::regionFunctionObject::store
bool store(word &fieldName, const tmp< ObjectType > &tfield, bool cacheable=false)
Store the field in the (sub) objectRegistry under the given name.
Definition: regionFunctionObjectTemplates.C:107
Foam::objectRegistry::lookupClass
HashTable< const Type * > lookupClass(const bool strict=false) const
Return all objects with a class satisfying isA<Type>
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::objectRegistry::found
bool found(const word &name, const bool recursive=false) const
Can the regIOobject object be found (by name).
Definition: objectRegistry.C:432
Foam::HashTable
A HashTable similar to std::unordered_map.
Definition: HashTable.H:105
Foam::functionObjects::surfaceInterpolate::interpolateFields
void interpolateFields()
Linearly interpolate volume fields to generate surface fields.
Definition: surfaceInterpolateTemplates.C:36
Foam::linearInterpolate
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > linearInterpolate(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: linear.H:112
forAllConstIters
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
surfaceInterpolate.H
Foam::GeometricField< Type, fvPatchField, volMesh >