readFields.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 -------------------------------------------------------------------------------
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 
28 #include "GeometricField.H"
29 #include "readFields.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 template<class Type, template<class> class PatchField, class GeoMesh>
35 (
36  const typename GeoMesh::Mesh& mesh,
37  const IOobjectList& objects,
38  PtrList<GeometricField<Type, PatchField, GeoMesh>>& fields,
39  const bool readOldTime
40 )
41 {
42  typedef GeometricField<Type, PatchField, GeoMesh> GeoField;
43 
44  // Search list of objects for fields of type GeoField
45  IOobjectList fieldObjects(objects.lookupClass<GeoField>());
46 
47  // Use sorted set of names
48  // (different processors might read objects in different order)
49  const wordList masterNames(fieldObjects.sortedNames());
50 
51  // Construct the fields
52  fields.resize(masterNames.size());
53 
54  forAll(masterNames, i)
55  {
56  const IOobject& io = *fieldObjects[masterNames[i]];
57 
58  fields.set(i, new GeoField(io, mesh, readOldTime));
59  }
60 }
61 
62 
63 template<class Mesh, class GeoField>
65 (
66  const Mesh& mesh,
67  const IOobjectList& objects,
68  PtrList<GeoField>& fields
69 )
70 {
71  // Search list of objects for fields of type GeomField
72  IOobjectList fieldObjects(objects.lookupClass<GeoField>());
73 
74  // Use sorted set of names
75  // (different processors might read objects in different order)
76  const wordList masterNames(fieldObjects.sortedNames());
77 
78  // Construct the fields
79  fields.resize(masterNames.size());
80 
81  forAll(masterNames, i)
82  {
83  const IOobject& io = *fieldObjects[masterNames[i]];
84 
85  fields.set(i, new GeoField(io, mesh));
86  }
87 }
88 
89 
90 // ************************************************************************* //
forAll
#define forAll(list, i)
Definition: stdFoam.H:349
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:58
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::readFields
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Definition: ReadFieldsTemplates.C:305
GeometricField.H
fields
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:97