faFieldDecomposerReadFields.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) 2021 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 "faFieldDecomposer.H"
30 #include "GeometricField.H"
31 #include "IOobjectList.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 template<class Type, template<class> class PatchField, class GeoMesh>
37 (
38  const typename GeoMesh::Mesh& mesh,
39  const IOobjectList& objects,
41  const bool readOldTime
42 )
43 {
45 
46  // Search list of objects for fields of type GeoField
47  IOobjectList fieldObjects(objects.lookupClass<GeoField>());
48 
49  // Use sorted set of names
50  // (different processors might read objects in different order)
51  const wordList masterNames(fieldObjects.sortedNames());
52 
53  // Construct the fields
54  fields.resize(masterNames.size());
55 
56  forAll(masterNames, i)
57  {
58  const IOobject& io = *fieldObjects[masterNames[i]];
59 
60  fields.set(i, new GeoField(io, mesh, readOldTime));
61  }
62 }
63 
64 
65 template<class Mesh, class GeoField>
67 (
68  const Mesh& mesh,
69  const IOobjectList& objects,
71 )
72 {
73  // Search list of objects for fields of type GeomField
74  IOobjectList fieldObjects(objects.lookupClass<GeoField>());
75 
76  // Use sorted set of names
77  // (different processors might read objects in different order)
78  const wordList masterNames(fieldObjects.sortedNames());
79 
80  // Construct the fields
81  fields.resize(masterNames.size());
82 
83  forAll(masterNames, i)
84  {
85  const IOobject& io = *fieldObjects[masterNames[i]];
86 
87  fields.set(i, new GeoField(io, mesh));
88  }
89 }
90 
91 
92 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::IOobjectList::sortedNames
wordList sortedNames() const
The sorted names of the IOobjects.
Definition: IOobjectList.C:345
IOobjectList.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::IOobjectList
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:55
GeometricField.H
Foam::faFieldDecomposer::readFields
static void readFields(const typename GeoMesh::Mesh &mesh, const IOobjectList &objects, PtrList< GeometricField< Type, PatchField, GeoMesh >> &fields, const bool readOldTime)
Read the fields and hold on the pointer list.
Definition: faFieldDecomposerReadFields.C:37
Foam::List< word >
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::IOobjectList::lookupClass
IOobjectList lookupClass(const char *clsName) const
The list of IOobjects with the given headerClassName.
Definition: IOobjectList.C:290
Foam::GeoMesh::Mesh
MESH Mesh
Definition: GeoMesh.H:62
fields
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:97
faFieldDecomposer.H