mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: allow wordHashSet filter for IOobjectList::names
- simplifies usage. Support syncPar check on names() to detect inconsistencies. - simplify readFields, ReadFields and other routines by using these new methods.
This commit is contained in:
@ -173,21 +173,21 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
|
||||
IOobjectList objects(*this, facesInstance(), "polyMesh/sets");
|
||||
{
|
||||
IOobjectList cSets(objects.lookupClass(cellSet::typeName));
|
||||
forAllConstIter(IOobjectList, cSets, iter)
|
||||
forAllConstIters(cSets, iter)
|
||||
{
|
||||
cellSets.append(new cellSet(*iter()));
|
||||
}
|
||||
}
|
||||
{
|
||||
IOobjectList fSets(objects.lookupClass(faceSet::typeName));
|
||||
forAllConstIter(IOobjectList, fSets, iter)
|
||||
forAllConstIters(fSets, iter)
|
||||
{
|
||||
faceSets.append(new faceSet(*iter()));
|
||||
}
|
||||
}
|
||||
{
|
||||
IOobjectList pSets(objects.lookupClass(pointSet::typeName));
|
||||
forAllConstIter(IOobjectList, pSets, iter)
|
||||
forAllConstIters(pSets, iter)
|
||||
{
|
||||
pointSets.append(new pointSet(*iter()));
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ void Foam::lagrangianFieldDecomposer::readFields
|
||||
);
|
||||
|
||||
label lagrangianFieldi = 0;
|
||||
forAllIter(IOobjectList, lagrangianTypeObjects, iter)
|
||||
forAllConstIters(lagrangianTypeObjects, iter)
|
||||
{
|
||||
lagrangianFields[cloudI].set
|
||||
(
|
||||
@ -97,7 +97,7 @@ void Foam::lagrangianFieldDecomposer::readFieldFields
|
||||
|
||||
label lagrangianFieldi = 0;
|
||||
|
||||
forAllIter(IOobjectList, lagrangianTypeObjectsA, iter)
|
||||
forAllConstIters(lagrangianTypeObjectsA, iter)
|
||||
{
|
||||
lagrangianFields[cloudI].set
|
||||
(
|
||||
@ -106,7 +106,7 @@ void Foam::lagrangianFieldDecomposer::readFieldFields
|
||||
);
|
||||
}
|
||||
|
||||
forAllIter(IOobjectList, lagrangianTypeObjectsB, iter)
|
||||
forAllConstIters(lagrangianTypeObjectsB, iter)
|
||||
{
|
||||
lagrangianFields[cloudI].set
|
||||
(
|
||||
@ -129,22 +129,19 @@ Foam::lagrangianFieldDecomposer::decomposeField
|
||||
Field<Type> procField(field, particleIndices_);
|
||||
|
||||
// Create the field for the processor
|
||||
return tmp<IOField<Type>>
|
||||
return tmp<IOField<Type>>::New
|
||||
(
|
||||
new IOField<Type>
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
field.name(),
|
||||
procMesh_.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
procMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
procField
|
||||
)
|
||||
field.name(),
|
||||
procMesh_.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
procMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
procField
|
||||
);
|
||||
}
|
||||
|
||||
@ -161,22 +158,19 @@ Foam::lagrangianFieldDecomposer::decomposeFieldField
|
||||
Field<Field<Type>> procField(field, particleIndices_);
|
||||
|
||||
// Create the field for the processor
|
||||
return tmp<CompactIOField<Field<Type>, Type>>
|
||||
return tmp<CompactIOField<Field<Type>, Type>>::New
|
||||
(
|
||||
new CompactIOField<Field<Type>, Type>
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
field.name(),
|
||||
procMesh_.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
procMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
procField
|
||||
)
|
||||
field.name(),
|
||||
procMesh_.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
procMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
procField
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -39,14 +39,14 @@ void Foam::readFields
|
||||
{
|
||||
typedef GeometricField<Type, PatchField, GeoMesh> GeoField;
|
||||
|
||||
// Search list of objects for fields of type GeomField
|
||||
// Search list of objects for fields of type GeoField
|
||||
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
|
||||
|
||||
// Remove the cellDist field
|
||||
IOobjectList::iterator celDistIter = fieldObjects.find("cellDist");
|
||||
if (celDistIter != fieldObjects.end())
|
||||
auto iter = fieldObjects.find("cellDist");
|
||||
if (iter.found())
|
||||
{
|
||||
fieldObjects.erase(celDistIter);
|
||||
fieldObjects.erase(iter);
|
||||
}
|
||||
|
||||
// Get sorted set of names (different processors might read objects in
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2016-2017 Wikki Ltd
|
||||
@ -273,23 +273,20 @@ Foam::faFieldReconstructor::reconstructFaAreaField
|
||||
|
||||
// Now construct and write the field
|
||||
// setting the internalField and patchFields
|
||||
return tmp<GeometricField<Type, faPatchField, areaMesh>>
|
||||
return tmp<GeometricField<Type, faPatchField, areaMesh>>::New
|
||||
(
|
||||
new GeometricField<Type, faPatchField, areaMesh>
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldIoObject.name(),
|
||||
mesh_.time().timeName(),
|
||||
mesh_(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
procFields[0].dimensions(),
|
||||
internalField,
|
||||
patchFields
|
||||
)
|
||||
fieldIoObject.name(),
|
||||
mesh_.time().timeName(),
|
||||
mesh_(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
procFields[0].dimensions(),
|
||||
internalField,
|
||||
patchFields
|
||||
);
|
||||
}
|
||||
|
||||
@ -553,23 +550,20 @@ Foam::faFieldReconstructor::reconstructFaEdgeField
|
||||
|
||||
// Now construct and write the field
|
||||
// setting the internalField and patchFields
|
||||
return tmp<GeometricField<Type, faePatchField, edgeMesh>>
|
||||
return tmp<GeometricField<Type, faePatchField, edgeMesh>>::New
|
||||
(
|
||||
new GeometricField<Type, faePatchField, edgeMesh>
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldIoObject.name(),
|
||||
mesh_.time().timeName(),
|
||||
mesh_(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
procFields[0].dimensions(),
|
||||
internalField,
|
||||
patchFields
|
||||
)
|
||||
fieldIoObject.name(),
|
||||
mesh_.time().timeName(),
|
||||
mesh_(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
procFields[0].dimensions(),
|
||||
internalField,
|
||||
patchFields
|
||||
);
|
||||
}
|
||||
|
||||
@ -581,31 +575,26 @@ void Foam::faFieldReconstructor::reconstructFaAreaFields
|
||||
const IOobjectList& objects
|
||||
)
|
||||
{
|
||||
const word& fieldClassName =
|
||||
const word& clsName =
|
||||
GeometricField<Type, faPatchField, areaMesh>::typeName;
|
||||
|
||||
IOobjectList fields = objects.lookupClass(fieldClassName);
|
||||
const wordList fieldNames = objects.sortedNames(clsName);
|
||||
|
||||
if (fields.size())
|
||||
if (fieldNames.size())
|
||||
{
|
||||
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
|
||||
|
||||
for
|
||||
(
|
||||
IOobjectList::const_iterator fieldIter = fields.begin();
|
||||
fieldIter != fields.end();
|
||||
++fieldIter
|
||||
)
|
||||
{
|
||||
Info << " " << fieldIter()->name() << endl;
|
||||
|
||||
reconstructFaAreaField<Type>(*fieldIter())().write();
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
Info<< " Reconstructing " << clsName << "s\n" << endl;
|
||||
}
|
||||
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
Info << " " << fieldName << endl;
|
||||
reconstructFaAreaField<Type>(*(objects[fieldName]))().write();
|
||||
}
|
||||
|
||||
if (fieldNames.size()) Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
// Reconstruct and write all edge fields
|
||||
template<class Type>
|
||||
void Foam::faFieldReconstructor::reconstructFaEdgeFields
|
||||
@ -613,29 +602,24 @@ void Foam::faFieldReconstructor::reconstructFaEdgeFields
|
||||
const IOobjectList& objects
|
||||
)
|
||||
{
|
||||
const word& fieldClassName =
|
||||
const word& clsName =
|
||||
GeometricField<Type, faePatchField, edgeMesh>::typeName;
|
||||
|
||||
IOobjectList fields = objects.lookupClass(fieldClassName);
|
||||
const wordList fieldNames = objects.sortedNames(clsName);
|
||||
|
||||
if (fields.size())
|
||||
if (fieldNames.size())
|
||||
{
|
||||
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
|
||||
|
||||
for
|
||||
(
|
||||
IOobjectList::const_iterator fieldIter = fields.begin();
|
||||
fieldIter != fields.end();
|
||||
++fieldIter
|
||||
)
|
||||
{
|
||||
Info<< " " << fieldIter()->name() << endl;
|
||||
|
||||
reconstructFaEdgeField<Type>(*fieldIter())().write();
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
Info<< " Reconstructing " << clsName << "s\n" << endl;
|
||||
}
|
||||
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
Info << " " << fieldName << endl;
|
||||
|
||||
reconstructFaEdgeField<Type>(*(objects[fieldName]))().write();
|
||||
}
|
||||
|
||||
if (fieldNames.size()) Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -780,18 +780,18 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
IOobjectList cSets(objects.lookupClass(cellSet::typeName));
|
||||
forAllConstIter(IOobjectList, cSets, iter)
|
||||
forAllConstIters(cSets, iter)
|
||||
{
|
||||
cSetNames.insert(iter.key(), cSetNames.size());
|
||||
}
|
||||
|
||||
IOobjectList fSets(objects.lookupClass(faceSet::typeName));
|
||||
forAllConstIter(IOobjectList, fSets, iter)
|
||||
forAllConstIters(fSets, iter)
|
||||
{
|
||||
fSetNames.insert(iter.key(), fSetNames.size());
|
||||
}
|
||||
IOobjectList pSets(objects.lookupClass(pointSet::typeName));
|
||||
forAllConstIter(IOobjectList, pSets, iter)
|
||||
forAllConstIters(pSets, iter)
|
||||
{
|
||||
pSetNames.insert(iter.key(), pSetNames.size());
|
||||
}
|
||||
@ -842,7 +842,7 @@ int main(int argc, char *argv[])
|
||||
objects.lookupClass(cellSet::typeName)
|
||||
);
|
||||
|
||||
forAllConstIter(IOobjectList, cSets, iter)
|
||||
forAllConstIters(cSets, iter)
|
||||
{
|
||||
// Load cellSet
|
||||
const cellSet procSet(*iter());
|
||||
@ -878,7 +878,7 @@ int main(int argc, char *argv[])
|
||||
objects.lookupClass(faceSet::typeName)
|
||||
);
|
||||
|
||||
forAllConstIter(IOobjectList, fSets, iter)
|
||||
forAllConstIters(fSets, iter)
|
||||
{
|
||||
// Load faceSet
|
||||
const faceSet procSet(*iter());
|
||||
@ -912,7 +912,7 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
objects.lookupClass(pointSet::typeName)
|
||||
);
|
||||
forAllConstIter(IOobjectList, pSets, iter)
|
||||
forAllConstIters(pSets, iter)
|
||||
{
|
||||
// Load pointSet
|
||||
const pointSet propSet(*iter());
|
||||
|
||||
@ -159,7 +159,7 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
|
||||
|
||||
if (!haveMesh)
|
||||
{
|
||||
bool oldParRun = Pstream::parRun();
|
||||
const bool oldParRun = Pstream::parRun();
|
||||
Pstream::parRun() = false;
|
||||
|
||||
|
||||
@ -383,17 +383,17 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
|
||||
|
||||
if (!haveMesh)
|
||||
{
|
||||
forAll(pointSetNames, i)
|
||||
for (const word& setName : pointSetNames)
|
||||
{
|
||||
pointSet(mesh, pointSetNames[i], 0).write();
|
||||
pointSet(mesh, setName, 0).write();
|
||||
}
|
||||
forAll(faceSetNames, i)
|
||||
for (const word& setName : faceSetNames)
|
||||
{
|
||||
faceSet(mesh, faceSetNames[i], 0).write();
|
||||
faceSet(mesh, setName, 0).write();
|
||||
}
|
||||
forAll(cellSetNames, i)
|
||||
for (const word& setName : cellSetNames)
|
||||
{
|
||||
cellSet(mesh, cellSetNames[i], 0).write();
|
||||
cellSet(mesh, setName, 0).write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -66,15 +66,12 @@ Foam::parFvFieldReconstructor::reconstructFvVolumeInternalField
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
tmp<DimensionedField<Type, volMesh>> tfield
|
||||
auto tfield = tmp<DimensionedField<Type, volMesh>>::New
|
||||
(
|
||||
new DimensionedField<Type, volMesh>
|
||||
(
|
||||
baseIO,
|
||||
baseMesh_,
|
||||
fld.dimensions(),
|
||||
internalField
|
||||
)
|
||||
baseIO,
|
||||
baseMesh_,
|
||||
fld.dimensions(),
|
||||
internalField
|
||||
);
|
||||
|
||||
tfield.ref().oriented() = fld.oriented();
|
||||
@ -213,16 +210,13 @@ Foam::parFvFieldReconstructor::reconstructFvVolumeField
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh>> tfield
|
||||
auto tfield = tmp<GeometricField<Type, fvPatchField, volMesh>>::New
|
||||
(
|
||||
new GeometricField<Type, fvPatchField, volMesh>
|
||||
(
|
||||
baseIO,
|
||||
baseMesh_,
|
||||
fld.dimensions(),
|
||||
internalField,
|
||||
basePatchFields
|
||||
)
|
||||
baseIO,
|
||||
baseMesh_,
|
||||
fld.dimensions(),
|
||||
internalField,
|
||||
basePatchFields
|
||||
);
|
||||
|
||||
tfield.ref().oriented()= fld.oriented();
|
||||
@ -380,16 +374,13 @@ Foam::parFvFieldReconstructor::reconstructFvSurfaceField
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tfield
|
||||
auto tfield = tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>::New
|
||||
(
|
||||
new GeometricField<Type, fvsPatchField, surfaceMesh>
|
||||
(
|
||||
baseIO,
|
||||
baseMesh_,
|
||||
fld.dimensions(),
|
||||
internalField,
|
||||
basePatchFields
|
||||
)
|
||||
baseIO,
|
||||
baseMesh_,
|
||||
fld.dimensions(),
|
||||
internalField,
|
||||
basePatchFields
|
||||
);
|
||||
|
||||
tfield.ref().oriented() = fld.oriented();
|
||||
@ -423,37 +414,37 @@ void Foam::parFvFieldReconstructor::reconstructFvVolumeInternalFields
|
||||
const wordHashSet& selectedFields
|
||||
) const
|
||||
{
|
||||
const word& fieldClassName = DimensionedField<Type, volMesh>::typeName;
|
||||
typedef DimensionedField<Type, volMesh> FieldType;
|
||||
const word& clsName = FieldType::typeName;
|
||||
|
||||
IOobjectList fields = objects.lookupClass(fieldClassName);
|
||||
// Available fields, sorted order
|
||||
const wordList fieldNames =
|
||||
(
|
||||
selectedFields.empty()
|
||||
? objects.sortedNames(clsName)
|
||||
: objects.sortedNames(clsName, selectedFields)
|
||||
);
|
||||
|
||||
if (fields.size())
|
||||
if (fieldNames.size())
|
||||
{
|
||||
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
|
||||
|
||||
forAllConstIter(IOobjectList, fields, fieldIter)
|
||||
{
|
||||
if
|
||||
(
|
||||
selectedFields.empty()
|
||||
|| selectedFields.found(fieldIter()->name())
|
||||
)
|
||||
{
|
||||
Info<< " " << fieldIter()->name() << endl;
|
||||
|
||||
tmp<DimensionedField<Type, volMesh>> tfld
|
||||
(
|
||||
reconstructFvVolumeInternalField<Type>(*fieldIter())
|
||||
);
|
||||
|
||||
if (isWriteProc_)
|
||||
{
|
||||
tfld().write();
|
||||
}
|
||||
}
|
||||
}
|
||||
Info<< endl;
|
||||
Info<< " Reconstructing " << clsName << "s\n" << endl;
|
||||
}
|
||||
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
Info<< " " << fieldName << endl;
|
||||
|
||||
tmp<FieldType> tfld
|
||||
(
|
||||
reconstructFvVolumeInternalField<Type>(*(objects[fieldName]))
|
||||
);
|
||||
if (isWriteProc_)
|
||||
{
|
||||
tfld().write();
|
||||
}
|
||||
}
|
||||
|
||||
if (fieldNames.size()) Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -464,39 +455,41 @@ void Foam::parFvFieldReconstructor::reconstructFvVolumeFields
|
||||
const wordHashSet& selectedFields
|
||||
) const
|
||||
{
|
||||
const word& fieldClassName =
|
||||
GeometricField<Type, fvPatchField, volMesh>::typeName;
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
|
||||
const word& clsName = FieldType::typeName;
|
||||
|
||||
IOobjectList fields = objects.lookupClass(fieldClassName);
|
||||
// Available fields, sorted order
|
||||
const wordList fieldNames =
|
||||
(
|
||||
selectedFields.empty()
|
||||
? objects.sortedNames(clsName)
|
||||
: objects.sortedNames(clsName, selectedFields)
|
||||
);
|
||||
|
||||
if (fields.size())
|
||||
if (fieldNames.size())
|
||||
{
|
||||
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
|
||||
|
||||
forAllConstIter(IOobjectList, fields, fieldIter)
|
||||
{
|
||||
const word& name = fieldIter()->name();
|
||||
|
||||
if
|
||||
(
|
||||
(selectedFields.empty() || selectedFields.found(name))
|
||||
&& name != "cellDist"
|
||||
)
|
||||
{
|
||||
Info<< " " << name << endl;
|
||||
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh>> tfld
|
||||
(
|
||||
reconstructFvVolumeField<Type>(*fieldIter())
|
||||
);
|
||||
if (isWriteProc_)
|
||||
{
|
||||
tfld().write();
|
||||
}
|
||||
}
|
||||
}
|
||||
Info<< endl;
|
||||
Info<< " Reconstructing " << clsName << "s\n" << endl;
|
||||
}
|
||||
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
if ("cellDist" == fieldName)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Info<< " " << fieldName << endl;
|
||||
|
||||
tmp<FieldType> tfld
|
||||
(
|
||||
reconstructFvVolumeField<Type>(*(objects[fieldName]))
|
||||
);
|
||||
if (isWriteProc_)
|
||||
{
|
||||
tfld().write();
|
||||
}
|
||||
}
|
||||
|
||||
if (fieldNames.size()) Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -507,37 +500,37 @@ void Foam::parFvFieldReconstructor::reconstructFvSurfaceFields
|
||||
const wordHashSet& selectedFields
|
||||
) const
|
||||
{
|
||||
const word& fieldClassName =
|
||||
GeometricField<Type, fvsPatchField, surfaceMesh>::typeName;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> FieldType;
|
||||
const word& clsName = FieldType::typeName;
|
||||
|
||||
IOobjectList fields = objects.lookupClass(fieldClassName);
|
||||
// Available fields, sorted order
|
||||
const wordList fieldNames =
|
||||
(
|
||||
selectedFields.empty()
|
||||
? objects.sortedNames(clsName)
|
||||
: objects.sortedNames(clsName, selectedFields)
|
||||
);
|
||||
|
||||
if (fields.size())
|
||||
if (fieldNames.size())
|
||||
{
|
||||
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
|
||||
|
||||
forAllConstIter(IOobjectList, fields, fieldIter)
|
||||
{
|
||||
if
|
||||
(
|
||||
selectedFields.empty()
|
||||
|| selectedFields.found(fieldIter()->name())
|
||||
)
|
||||
{
|
||||
Info<< " " << fieldIter()->name() << endl;
|
||||
|
||||
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tfld
|
||||
(
|
||||
reconstructFvSurfaceField<Type>(*fieldIter())
|
||||
);
|
||||
if (isWriteProc_)
|
||||
{
|
||||
tfld().write();
|
||||
}
|
||||
}
|
||||
}
|
||||
Info<< endl;
|
||||
Info<< " Reconstructing " << clsName << "s\n" << endl;
|
||||
}
|
||||
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
Info<< " " << fieldName << endl;
|
||||
|
||||
tmp<FieldType> tfld
|
||||
(
|
||||
reconstructFvSurfaceField<Type>(*(objects[fieldName]))
|
||||
);
|
||||
if (isWriteProc_)
|
||||
{
|
||||
tfld().write();
|
||||
}
|
||||
}
|
||||
|
||||
if (fieldNames.size()) Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -40,25 +40,20 @@ Foam::wordList Foam::parLagrangianRedistributor::filterObjects
|
||||
const wordHashSet& selectedFields
|
||||
)
|
||||
{
|
||||
const word fieldClassName(Container::typeName);
|
||||
|
||||
// Parallel synchronise
|
||||
wordList fieldNames(objects.names(fieldClassName));
|
||||
wordList fieldNames =
|
||||
(
|
||||
selectedFields.empty()
|
||||
? objects.names(Container::typeName)
|
||||
: objects.names(Container::typeName, selectedFields)
|
||||
);
|
||||
|
||||
Pstream::combineGather(fieldNames, ListOps::uniqueEqOp<word>());
|
||||
Pstream::combineScatter(fieldNames);
|
||||
|
||||
if (!selectedFields.empty())
|
||||
{
|
||||
DynamicList<word> selectedNames(fieldNames.size());
|
||||
forAll(fieldNames, i)
|
||||
{
|
||||
if (selectedFields.found(fieldNames[i]))
|
||||
{
|
||||
selectedNames.append(fieldNames[i]);
|
||||
}
|
||||
}
|
||||
fieldNames.transfer(selectedNames);
|
||||
}
|
||||
// Ensure order is consistent
|
||||
Foam::sort(fieldNames);
|
||||
|
||||
return fieldNames;
|
||||
}
|
||||
|
||||
@ -72,6 +67,8 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFields
|
||||
const wordHashSet& selectedFields
|
||||
) const
|
||||
{
|
||||
const word fieldClassName(IOField<Type>::typeName);
|
||||
|
||||
const wordList objectNames
|
||||
(
|
||||
filterObjects<IOField<Type>>
|
||||
@ -83,55 +80,53 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFields
|
||||
|
||||
if (objectNames.size())
|
||||
{
|
||||
const word fieldClassName(IOField<Type>::typeName);
|
||||
|
||||
Info<< " Redistributing lagrangian "
|
||||
<< fieldClassName << "s\n" << endl;
|
||||
}
|
||||
|
||||
forAll(objectNames, i)
|
||||
for (const word& objectName : objectNames)
|
||||
{
|
||||
Info<< " " << objectName << endl;
|
||||
|
||||
// Read if present
|
||||
IOField<Type> field
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
objectName,
|
||||
srcMesh_.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
srcMesh_,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
label(0)
|
||||
);
|
||||
|
||||
map.distribute(field);
|
||||
|
||||
|
||||
if (field.size())
|
||||
{
|
||||
Info<< " " << objectNames[i] << endl;
|
||||
|
||||
// Read if present
|
||||
IOField<Type> field
|
||||
IOField<Type>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
objectNames[i],
|
||||
srcMesh_.time().timeName(),
|
||||
objectName,
|
||||
tgtMesh_.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
srcMesh_,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
tgtMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
label(0)
|
||||
);
|
||||
|
||||
map.distribute(field);
|
||||
|
||||
|
||||
if (field.size())
|
||||
{
|
||||
IOField<Type>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
objectNames[i],
|
||||
tgtMesh_.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
tgtMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
std::move(field)
|
||||
).write();
|
||||
}
|
||||
std::move(field)
|
||||
).write();
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
if (objectNames.size()) Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -144,6 +139,8 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFieldFields
|
||||
const wordHashSet& selectedFields
|
||||
) const
|
||||
{
|
||||
const word fieldClassName(CompactIOField<Field<Type>, Type>::typeName);
|
||||
|
||||
wordList objectNames
|
||||
(
|
||||
filterObjects<CompactIOField<Field<Type>, Type>>
|
||||
@ -153,9 +150,9 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFieldFields
|
||||
)
|
||||
);
|
||||
|
||||
// Append IOField names
|
||||
// Append IOField Field names
|
||||
{
|
||||
const wordList ioFieldNames
|
||||
wordList ioFieldNames
|
||||
(
|
||||
filterObjects<IOField<Field<Type>>>
|
||||
(
|
||||
@ -169,52 +166,50 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFieldFields
|
||||
|
||||
if (objectNames.size())
|
||||
{
|
||||
const word fieldClassName(CompactIOField<Field<Type>, Type>::typeName);
|
||||
|
||||
Info<< " Redistributing lagrangian "
|
||||
<< fieldClassName << "s\n" << endl;
|
||||
}
|
||||
|
||||
forAll(objectNames, i)
|
||||
for (const word& objectName : objectNames)
|
||||
{
|
||||
Info<< " " << objectName << endl;
|
||||
|
||||
// Read if present
|
||||
CompactIOField<Field<Type>, Type> field
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
objectName,
|
||||
srcMesh_.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
srcMesh_,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
label(0)
|
||||
);
|
||||
|
||||
// Distribute
|
||||
map.distribute(field);
|
||||
|
||||
// Write
|
||||
if (field.size())
|
||||
{
|
||||
Info<< " " << objectNames[i] << endl;
|
||||
|
||||
// Read if present
|
||||
CompactIOField<Field<Type>, Type> field
|
||||
CompactIOField<Field<Type>, Type>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
objectNames[i],
|
||||
srcMesh_.time().timeName(),
|
||||
objectName,
|
||||
tgtMesh_.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
srcMesh_,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
tgtMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
label(0)
|
||||
);
|
||||
|
||||
// Distribute
|
||||
map.distribute(field);
|
||||
|
||||
// Write
|
||||
if (field.size())
|
||||
{
|
||||
CompactIOField<Field<Type>, Type>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
objectNames[i],
|
||||
tgtMesh_.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
tgtMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
std::move(field)
|
||||
).write();
|
||||
}
|
||||
std::move(field)
|
||||
).write();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -228,6 +223,8 @@ void Foam::parLagrangianRedistributor::readLagrangianFields
|
||||
const wordHashSet& selectedFields
|
||||
)
|
||||
{
|
||||
const word fieldClassName(Container::typeName);
|
||||
|
||||
const wordList objectNames
|
||||
(
|
||||
filterObjects<Container>
|
||||
@ -239,31 +236,29 @@ void Foam::parLagrangianRedistributor::readLagrangianFields
|
||||
|
||||
if (objectNames.size())
|
||||
{
|
||||
const word fieldClassName(Container::typeName);
|
||||
|
||||
Info<< " Reading lagrangian "
|
||||
<< fieldClassName << "s\n" << endl;
|
||||
}
|
||||
|
||||
forAll(objectNames, i)
|
||||
{
|
||||
Info<< " " << objectNames[i] << endl;
|
||||
for (const word& objectName : objectNames)
|
||||
{
|
||||
Info<< " " << objectName << endl;
|
||||
|
||||
// Read if present
|
||||
Container* fieldPtr = new Container
|
||||
// Read if present
|
||||
Container* fieldPtr = new Container
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
objectNames[i],
|
||||
cloud.time().timeName(),
|
||||
cloud,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
label(0)
|
||||
);
|
||||
objectName,
|
||||
cloud.time().timeName(),
|
||||
cloud,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
label(0)
|
||||
);
|
||||
|
||||
fieldPtr->store();
|
||||
}
|
||||
fieldPtr->store();
|
||||
}
|
||||
}
|
||||
|
||||
@ -275,6 +270,8 @@ void Foam::parLagrangianRedistributor::redistributeStoredLagrangianFields
|
||||
passivePositionParticleCloud& cloud
|
||||
) const
|
||||
{
|
||||
const word fieldClassName(Container::typeName);
|
||||
|
||||
HashTable<Container*> fields
|
||||
(
|
||||
cloud.lookupClass<Container>()
|
||||
@ -282,36 +279,34 @@ void Foam::parLagrangianRedistributor::redistributeStoredLagrangianFields
|
||||
|
||||
if (fields.size())
|
||||
{
|
||||
const word fieldClassName(Container::typeName);
|
||||
|
||||
Info<< " Redistributing lagrangian "
|
||||
<< fieldClassName << "s\n" << endl;
|
||||
}
|
||||
|
||||
forAllIter(typename HashTable<Container*>, fields, iter)
|
||||
forAllIters(fields, iter)
|
||||
{
|
||||
Container& field = *(*iter);
|
||||
|
||||
Info<< " " << field.name() << endl;
|
||||
|
||||
map.distribute(field);
|
||||
|
||||
if (field.size())
|
||||
{
|
||||
Container& field = *iter();
|
||||
|
||||
Info<< " " << field.name() << endl;
|
||||
|
||||
map.distribute(field);
|
||||
|
||||
if (field.size())
|
||||
{
|
||||
Container
|
||||
Container
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
field.name(),
|
||||
tgtMesh_.time().timeName(),
|
||||
cloud::prefix/cloud.name(),
|
||||
tgtMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
std::move(field)
|
||||
).write();
|
||||
}
|
||||
field.name(),
|
||||
tgtMesh_.time().timeName(),
|
||||
cloud::prefix/cloud.name(),
|
||||
tgtMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
std::move(field)
|
||||
).write();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -636,11 +636,11 @@ void readFields
|
||||
if (haveMesh[Pstream::myProcNo()] && objectNames != masterNames)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "differing fields of type " << GeoField::typeName
|
||||
<< " on processors." << nl
|
||||
<< "Master has:" << masterNames << endl
|
||||
<< Pstream::myProcNo() << " has:" << objectNames
|
||||
<< abort(FatalError);
|
||||
<< "Objects not synchronised across processors." << nl
|
||||
<< "Master has " << flatOutput(masterNames) << nl
|
||||
<< "Processor " << Pstream::myProcNo()
|
||||
<< " has " << flatOutput(objectNames)
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
fields.setSize(masterNames.size());
|
||||
|
||||
Reference in New Issue
Block a user