32 template<
class GeoField,
class Mesh>
36 const IOobjectList& objects,
37 PtrList<GeoField>& fields,
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;
309 wordList masterNames(fields.names());
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;
353 const IOobject& io = *fields[masterNames[i]];
356 if (selectedFields.
found(fieldName))
360 Info<<
" " << UniformFieldType::typeName <<
"s:";
364 Info<<
" " << fieldName;
366 UniformFieldType* fieldPtr =
new UniformFieldType
379 storedObjects.
push(fieldPtr);
A LIFO stack based on a singly-linked list.
A HashTable with keys but without contents.
wordList ReadFields(const Mesh &mesh, const IOobjectList &objects, PtrList< GeoField > &fields, const bool syncPar=true)
Read all fields of the specified type.
#define forAll(list, i)
Loop across all elements in list.
const word & name() const
Return name.
List of IOobjects with searching and retrieving facilities.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
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.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Field reading functions for post-processing utilities.
void push(const T &a)
Push an element onto the stack.
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
An STL-conforming iterator.
bool found(const Key &) const
Return true if hashedEntry is found in table.
A class for handling words, derived from string.
const fileName & local() const
List< word > wordList
A List of words.
IOobjectList lookupClass(const word &className) const
Return the list for all IOobjects of a given class.
Info<< "Reading field p_rgh\"<< endl;volScalarField p_rgh(IOobject("p_rgh", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);pressureReference pressureReference(p, p_rgh, pimple.dict(), thermo.incompressible());mesh.schemes().setFluxRequired(p_rgh.name());hydrostaticInitialisation(p_rgh, p, rho, U, gh, ghf, pRef, thermo, pimple.dict());Info<< "Creating field dpdt\"<< endl;volScalarField dpdt(IOobject("dpdt", runTime.timeName(), mesh), mesh, dimensionedScalar(p.dimensions()/dimTime, 0));Info<< "Creating field kinetic energy K\"<< endl;volScalarField K("K", 0.5 *magSqr(U));dimensionedScalar initialMass=fvc::domainIntegrate(rho);multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
fileName & instance() const
Return the instance directory, constant, system, <time> etc.
const objectRegistry & db() const
Return the local objectRegistry.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
void readUniformFields(const IOobjectList &objects, const HashSet< word > &selectedFields, LIFOStack< regIOobject *> &storedObjects, const bool syncPar=true)
Read the selected UniformDimensionedFields of the specified type.