32 template<
class GeoField,
class Mesh>
42 IOobjectList fieldObjects(
objects.lookupClass(GeoField::typeName));
44 wordList masterNames(fieldObjects.names());
46 if (syncPar && Pstream::parRun())
49 const wordList localNames(masterNames);
50 Pstream::scatter(masterNames);
52 HashSet<word> localNamesSet(localNames);
56 const word& masterFld = masterNames[i];
58 HashSet<word>::iterator iter = localNamesSet.find(masterFld);
60 if (iter == localNamesSet.end())
63 <<
"Fields not synchronised across processors." <<
endl
64 <<
"Master has fields " << masterNames
65 <<
" processor " << Pstream::myProcNo()
70 localNamesSet.erase(iter);
77 <<
"Fields not synchronised across processors." <<
endl
78 <<
"Master has fields " << masterNames
79 <<
" processor " << Pstream::myProcNo()
85 fields.setSize(masterNames.size());
91 Info<<
"Reading " << GeoField::typeName <<
' ' << masterNames[i]
94 const IOobject& io = *fieldObjects[masterNames[i]];
108 IOobject::AUTO_WRITE,
119 template<
class GeoField>
122 const word& fieldName,
123 const typename GeoField::Mesh& mesh,
125 objectRegistry& fieldsCache
130 HashSet<word> usedTimes(timeNames);
132 DynamicList<word> unusedTimes(fieldsCache.size());
134 forAllIter(objectRegistry, fieldsCache, timeIter)
136 const word& tm = timeIter.key();
137 if (!usedTimes.found(tm))
139 unusedTimes.append(tm);
145 objectRegistry& timeCache =
const_cast<objectRegistry&
>
147 fieldsCache.lookupObject<objectRegistry>(unusedTimes[i])
149 fieldsCache.checkOut(timeCache);
157 const word& tm = timeNames[i];
160 if (!fieldsCache.found(tm))
163 objectRegistry* timeCachePtr =
new objectRegistry
174 timeCachePtr->store();
178 const objectRegistry& timeCache =
179 fieldsCache.lookupObject<objectRegistry>
185 if (!timeCache.found(fieldName))
202 GeoField* fldPtr =
new GeoField
220 template<
class GeoField>
223 const word& fieldName,
224 const typename GeoField::Mesh& mesh,
226 const word& registryName
234 const_cast<objectRegistry&
>
236 mesh.thisDb().subRegistry(registryName,
true)
242 template<
class GeoFieldType>
245 const typename GeoFieldType::Mesh& mesh,
252 if (!
fields.size())
return;
254 bool firstField =
true;
261 if (selectedFields.
found(fieldName))
265 Info<<
" " << GeoFieldType::typeName <<
"s:";
269 Info<<
" " << fieldName;
271 GeoFieldType* fieldPtr =
new GeoFieldType
285 storedObjects.
push(fieldPtr);
296 template<
class UniformFieldType>
307 if (!
fields.size())
return;
311 if (syncPar && Pstream::parRun())
314 const wordList localNames(masterNames);
315 Pstream::scatter(masterNames);
321 const word& masterFld = masterNames[i];
325 if (iter == localNamesSet.
end())
328 <<
"Fields not synchronised across processors." <<
endl
329 <<
"Master has fields " << masterNames
330 <<
" processor " << Pstream::myProcNo()
335 localNamesSet.
erase(iter);
342 <<
"Fields not synchronised across processors." <<
endl
343 <<
"Master has fields " << masterNames
344 <<
" processor " << Pstream::myProcNo()
349 bool firstField =
true;
356 if (selectedFields.
found(fieldName))
360 Info<<
" " << UniformFieldType::typeName <<
"s:";
364 Info<<
" " << fieldName;
366 UniformFieldType* fieldPtr =
new UniformFieldType
379 storedObjects.
push(fieldPtr);
Field reading functions for post-processing utilities.
#define forAll(list, i)
Loop across all elements in list.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
A HashTable with keys but without contents.
An STL-conforming iterator.
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
bool found(const Key &) const
Return true if hashedEntry is found in table.
List of IOobjects with searching and retrieving facilities.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
const fileName & local() const
fileName & instance() const
Return the instance directory, constant, system, <time> etc.
const objectRegistry & db() const
Return the local objectRegistry.
const word & name() const
Return name.
A LIFO stack based on a singly-linked list.
void push(const T &a)
Push an element onto the stack.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< word > wordList
A List of words.
wordList ReadFields(const Mesh &mesh, const IOobjectList &objects, PtrList< GeoField > &fields, const bool syncPar=true)
Read all fields of the specified type.
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
void readUniformFields(const IOobjectList &objects, const HashSet< word > &selectedFields, LIFOStack< regIOobject * > &storedObjects, const bool syncPar=true)
Read the selected UniformDimensionedFields of the specified type.
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable