readFields.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) 2011-2022 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 "readFields.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 template<class Type, template<class> class PatchField, class GeoMesh>
32 (
33  const typename GeoMesh::Mesh& mesh,
34  const IOobjectList& objects,
35  PtrList<GeometricField<Type, PatchField, GeoMesh>>& fields,
36  const bool readOldTime
37 )
38 {
39  // Search list of objects for fields
40  IOobjectList fieldObjects(objects.lookupClass
41  (
42  GeometricField<Type, PatchField, GeoMesh>::typeName)
43  );
44 
45  // Remove the cellProc field
46  IOobjectList::iterator cellProcIter = fieldObjects.find("cellProc");
47  if (cellProcIter != fieldObjects.end())
48  {
49  fieldObjects.erase(cellProcIter);
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
64  (
65  i,
66  new GeometricField<Type, PatchField, GeoMesh>
67  (
68  io,
69  mesh,
70  readOldTime
71  )
72  );
73  }
74 }
75 
76 
77 template<class Mesh, class GeoField>
79 (
80  const Mesh& mesh,
81  const IOobjectList& objects,
82  PtrList<GeoField>& fields
83 )
84 {
85  // Search list of objects for fields of type GeomField
86  IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
87 
88  // Construct the fields
89  fields.setSize(fieldObjects.size());
90 
91  // Get sorted set of names (different processors might read objects in
92  // different order)
93  const wordList masterNames(fieldObjects.sortedNames());
94 
95  // Construct the fields
96  fields.setSize(masterNames.size());
97 
98  forAll(masterNames, i)
99  {
100  const IOobject& io = *fieldObjects[masterNames[i]];
101 
102  fields.set(i, new GeoField(io, mesh));
103  }
104 }
105 
106 
107 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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:230
List< word > wordList
A List of words.
Definition: fileName.H:54
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const HashSet< word > &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the specified type.
Definition: ReadFields.C:244
objects