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 | Copyright (C) 2011-2015 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 #include "GeometricField.H"
27 #include "readFields.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 template<class Type, template<class> class PatchField, class GeoMesh>
33 (
34  const typename GeoMesh::Mesh& mesh,
35  const IOobjectList& objects,
37  const bool readOldTime
38 )
39 {
41 
42  // Search list of objects for fields of type GeomField
43  IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
44 
45  // Remove the cellDist field
46  IOobjectList::iterator celDistIter = fieldObjects.find("cellDist");
47  if (celDistIter != fieldObjects.end())
48  {
49  fieldObjects.erase(celDistIter);
50  }
51 
52  // Get sorted set of names (different processors might read objects in
53  // different order)
54  const wordList masterNames(fieldObjects.sortedNames());
55 
56  // Construct the fields
57  fields.setSize(masterNames.size());
58 
59  forAll(masterNames, i)
60  {
61  const IOobject& io = *fieldObjects[masterNames[i]];
62 
63  fields.set(i, new GeoField(io, mesh, readOldTime));
64  }
65 }
66 
67 
68 template<class Mesh, class GeoField>
70 (
71  const Mesh& mesh,
72  const IOobjectList& objects,
74 )
75 {
76  // Search list of objects for fields of type GeomField
77  IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
78 
79  // Construct the fields
80  fields.setSize(fieldObjects.size());
81 
82  // Get sorted set of names (different processors might read objects in
83  // different order)
84  const wordList masterNames(fieldObjects.sortedNames());
85 
86  // Construct the fields
87  fields.setSize(masterNames.size());
88 
89  forAll(masterNames, i)
90  {
91  const IOobject& io = *fieldObjects[masterNames[i]];
92 
93  fields.set(i, new GeoField(io, mesh));
94  }
95 }
96 
97 
98 // ************************************************************************* //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::HashTable::iterator
An STL-conforming iterator.
Definition: HashTable.H:415
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
fields
Info<< "Creating field dpdt\n"<< endl;volScalarField dpdt(IOobject("dpdt", runTime.timeName(), mesh), mesh, dimensionedScalar("dpdt", p.dimensions()/dimTime, 0));Info<< "Creating field kinetic energy K\n"<< endl;volScalarField K("K", 0.5 *magSqr(U));volScalarField p_rgh(IOobject("p_rgh", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);p_rgh=p - rho *gh;mesh.setFluxRequired(p_rgh.name());multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:127
Foam::IOobjectList::sortedNames
wordList sortedNames() const
Return the sorted list of names of the IOobjects.
Definition: IOobjectList.C:227
readFields.H
Foam::PtrList
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::IOobjectList::lookupClass
IOobjectList lookupClass(const word &className) const
Return the list for all IOobjects of a given class.
Definition: IOobjectList.C:199
Foam::IOobjectList
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:50
GeometricField.H
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::HashPtrTable::erase
bool erase(iterator &)
Erase an hashedEntry specified by given iterator.
Definition: HashPtrTable.C:76
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::GeoMesh::Mesh
MESH Mesh
Definition: GeoMesh.H:61
Foam::readFields
void readFields(const typename GeoMesh::Mesh &mesh, const IOobjectList &objects, PtrList< GeometricField< Type, PatchField, GeoMesh > > &fields, const bool readOldTime)
Definition: readFields.C:33