mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: execFlowFunctionObjects: load dimensionedFields and uniformDimensionedFields
This commit is contained in:
@ -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<class GeoField>
|
||||
wordList ReadUniformFields
|
||||
(
|
||||
const IOobjectList& objects,
|
||||
PtrList<GeoField>& 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<word> localNamesSet(localNames);
|
||||
|
||||
forAll(masterNames, i)
|
||||
{
|
||||
const word& masterFld = masterNames[i];
|
||||
|
||||
HashSet<word>::iterator iter = localNamesSet.find(masterFld);
|
||||
|
||||
if (iter == localNamesSet.end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"ReadFields<class GeoField>"
|
||||
"(const IOobjectList&, PtrList<GeoField>&"
|
||||
", 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<word>, localNamesSet, iter)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"ReadFields<class GeoField>"
|
||||
"(const IOobjectList&, PtrList<GeoField>&"
|
||||
", 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<volTensorField> vtFlds;
|
||||
ReadFields(mesh, objects, vtFlds);
|
||||
|
||||
// Read vol-internal fields.
|
||||
|
||||
PtrList<volScalarField::DimensionedInternalField> vsiFlds;
|
||||
ReadFields(mesh, objects, vsiFlds);
|
||||
|
||||
PtrList<volVectorField::DimensionedInternalField> vviFlds;
|
||||
ReadFields(mesh, objects, vviFlds);
|
||||
|
||||
PtrList<volSphericalTensorField::DimensionedInternalField> vstiFlds;
|
||||
ReadFields(mesh, objects, vstiFlds);
|
||||
|
||||
PtrList<volSymmTensorField::DimensionedInternalField> vsymtiFlds;
|
||||
ReadFields(mesh, objects, vsymtiFlds);
|
||||
|
||||
PtrList<volTensorField::DimensionedInternalField> vtiFlds;
|
||||
ReadFields(mesh, objects, vtiFlds);
|
||||
|
||||
// Read surface fields.
|
||||
|
||||
PtrList<surfaceScalarField> ssFlds;
|
||||
@ -125,6 +238,24 @@ void calc
|
||||
PtrList<pointTensorField> ptFlds;
|
||||
ReadFields(pMesh, objects, ptFlds);
|
||||
|
||||
// Read uniform dimensioned fields
|
||||
IOobjectList constantObjects(mesh, runTime.constant());
|
||||
|
||||
PtrList<uniformDimensionedScalarField> usFlds;
|
||||
ReadUniformFields(constantObjects, usFlds, true);
|
||||
|
||||
PtrList<uniformDimensionedVectorField> uvFlds;
|
||||
ReadUniformFields(constantObjects, uvFlds, true);
|
||||
|
||||
PtrList<uniformDimensionedSphericalTensorField> ustFlds;
|
||||
ReadUniformFields(constantObjects, ustFlds, true);
|
||||
|
||||
PtrList<uniformDimensionedSymmTensorField> usymmtFlds;
|
||||
ReadUniformFields(constantObjects, usymmtFlds, true);
|
||||
|
||||
PtrList<uniformDimensionedTensorField> utFlds;
|
||||
ReadUniformFields(constantObjects, utFlds, true);
|
||||
|
||||
fol.execute(true);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user