From 78eaf506ebe26d0bb3aaf1775c44e85e8421335d Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 29 Apr 2014 10:02:22 +0100 Subject: [PATCH] ENH: execFlowFunctionObjects: load dimensionedFields and uniformDimensionedFields --- .../execFlowFunctionObjects.C | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C b/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C index 18e04a4e6b..d20f94d851 100644 --- a/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C +++ b/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C @@ -41,6 +41,7 @@ Description #include "volFields.H" #include "surfaceFields.H" #include "pointFields.H" +#include "uniformDimensionedFields.H" #include "ReadFields.H" #include "fvIOoptionList.H" @@ -57,6 +58,101 @@ using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Read all fields of type. Returns names of fields read. Guarantees all +// processors to read fields in same order. +template +wordList ReadUniformFields +( + const IOobjectList& objects, + PtrList& fields, + const bool syncPar +) +{ + // Search list of objects for wanted type + IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName)); + + wordList masterNames(fieldObjects.names()); + + if (syncPar && Pstream::parRun()) + { + // Check that I have the same fields as the master + const wordList localNames(masterNames); + Pstream::scatter(masterNames); + + HashSet localNamesSet(localNames); + + forAll(masterNames, i) + { + const word& masterFld = masterNames[i]; + + HashSet::iterator iter = localNamesSet.find(masterFld); + + if (iter == localNamesSet.end()) + { + FatalErrorIn + ( + "ReadFields" + "(const IOobjectList&, PtrList&" + ", const bool)" + ) << "Fields not synchronised across processors." << endl + << "Master has fields " << masterNames + << " processor " << Pstream::myProcNo() + << " has fields " << localNames << exit(FatalError); + } + else + { + localNamesSet.erase(iter); + } + } + + forAllConstIter(HashSet, localNamesSet, iter) + { + FatalErrorIn + ( + "ReadFields" + "(const IOobjectList&, PtrList&" + ", const bool)" + ) << "Fields not synchronised across processors." << endl + << "Master has fields " << masterNames + << " processor " << Pstream::myProcNo() + << " has fields " << localNames << exit(FatalError); + } + } + + + fields.setSize(masterNames.size()); + + // Make sure to read in masterNames order. + + forAll(masterNames, i) + { + Info<< "Reading " << GeoField::typeName << ' ' << masterNames[i] + << endl; + + const IOobject& io = *fieldObjects[masterNames[i]]; + + fields.set + ( + i, + new GeoField + ( + IOobject + ( + io.name(), + io.instance(), + io.local(), + io.db(), + IOobject::MUST_READ, + IOobject::AUTO_WRITE, + io.registerObject() + ) + ) + ); + } + return masterNames; +} + + void calc ( const argList& args, @@ -90,6 +186,23 @@ void calc PtrList vtFlds; ReadFields(mesh, objects, vtFlds); + // Read vol-internal fields. + + PtrList vsiFlds; + ReadFields(mesh, objects, vsiFlds); + + PtrList vviFlds; + ReadFields(mesh, objects, vviFlds); + + PtrList vstiFlds; + ReadFields(mesh, objects, vstiFlds); + + PtrList vsymtiFlds; + ReadFields(mesh, objects, vsymtiFlds); + + PtrList vtiFlds; + ReadFields(mesh, objects, vtiFlds); + // Read surface fields. PtrList ssFlds; @@ -125,6 +238,24 @@ void calc PtrList ptFlds; ReadFields(pMesh, objects, ptFlds); + // Read uniform dimensioned fields + IOobjectList constantObjects(mesh, runTime.constant()); + + PtrList usFlds; + ReadUniformFields(constantObjects, usFlds, true); + + PtrList uvFlds; + ReadUniformFields(constantObjects, uvFlds, true); + + PtrList ustFlds; + ReadUniformFields(constantObjects, ustFlds, true); + + PtrList usymmtFlds; + ReadUniformFields(constantObjects, usymmtFlds, true); + + PtrList utFlds; + ReadUniformFields(constantObjects, utFlds, true); + fol.execute(true); } else