functionObjects: Added fields() function to provide list of required fields to postProcess

With this change each functionObject provides the list of fields required so
that the postProcess utility can pre-load them before executing the list of
functionObjects.  This provides a more convenient interface than using the
-field or -fields command-line options to postProcess which are now redundant.
This commit is contained in:
Henry Weller
2021-10-21 09:23:34 +01:00
parent 777e5aeece
commit c01118589f
110 changed files with 809 additions and 746 deletions

View File

@ -44,21 +44,21 @@ using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define ReadFields(GeoFieldType) \
readFields<GeoFieldType>(mesh, objects, selectedFields, storedObjects);
readFields<GeoFieldType>(mesh, objects, requiredFields, storedObjects);
#define ReadPointFields(GeoFieldType) \
readFields<GeoFieldType>(pMesh, objects, selectedFields, storedObjects);
readFields<GeoFieldType>(pMesh, objects, requiredFields, storedObjects);
#define ReadUniformFields(FieldType) \
readUniformFields<FieldType> \
(constantObjects, selectedFields, storedObjects);
(constantObjects, requiredFields, storedObjects);
void executeFunctionObjects
(
const argList& args,
const Time& runTime,
fvMesh& mesh,
const HashSet<word>& selectedFields,
const HashSet<word>& requiredFields0,
functionObjectList& functions,
bool lastTime
)
@ -72,6 +72,12 @@ void executeFunctionObjects
// Read objects in time directory
IOobjectList objects(mesh, runTime.timeName());
HashSet<word> requiredFields(requiredFields0);
forAll(functions, i)
{
requiredFields.insert(functions[i].fields());
}
// Read volFields
ReadFields(volScalarField);
ReadFields(volVectorField);
@ -151,14 +157,14 @@ int main(int argc, char *argv[])
#include "createNamedMesh.H"
// Initialise the set of selected fields from the command-line options
HashSet<word> selectedFields;
HashSet<word> requiredFields;
if (args.optionFound("fields"))
{
args.optionLookup("fields")() >> selectedFields;
args.optionLookup("fields")() >> requiredFields;
}
if (args.optionFound("field"))
{
selectedFields.insert(args.optionLookup("field")());
requiredFields.insert(args.optionLookup("field")());
}
// Externally stored dictionary for functionObjectList
@ -172,8 +178,7 @@ int main(int argc, char *argv[])
(
args,
runTime,
functionsControlDict,
selectedFields
functionsControlDict
)
);
@ -190,8 +195,7 @@ int main(int argc, char *argv[])
(
args,
runTime,
functionsControlDict,
selectedFields
functionsControlDict
);
}
@ -204,7 +208,7 @@ int main(int argc, char *argv[])
args,
runTime,
mesh,
selectedFields,
requiredFields,
functionsPtr(),
timei == timeDirs.size()-1
);