mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: use objectRegistry/IOobjectList sorted instead of lookupClass
- in most cases a parallel-consistent order is required. Even when the order is not important, it will generally require fewer allocations to create a UPtrList of entries instead of a HashTable or even a wordList.
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -186,26 +186,17 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
|
||||
{
|
||||
// Read sets
|
||||
IOobjectList objects(*this, facesInstance(), "polyMesh/sets");
|
||||
for (const IOobject& io : objects.csorted<cellSet>())
|
||||
{
|
||||
IOobjectList sets(objects.lookupClass<cellSet>());
|
||||
forAllConstIters(sets, iter)
|
||||
{
|
||||
cellSets.append(new cellSet(*(iter.val())));
|
||||
}
|
||||
cellSets.emplace_back(io);
|
||||
}
|
||||
for (const IOobject& io : objects.csorted<faceSet>())
|
||||
{
|
||||
IOobjectList sets(objects.lookupClass<faceSet>());
|
||||
forAllConstIters(sets, iter)
|
||||
{
|
||||
faceSets.append(new faceSet(*(iter.val())));
|
||||
}
|
||||
faceSets.emplace_back(io);
|
||||
}
|
||||
for (const IOobject& io : objects.csorted<pointSet>())
|
||||
{
|
||||
IOobjectList sets(objects.lookupClass<pointSet>());
|
||||
forAllConstIters(sets, iter)
|
||||
{
|
||||
pointSets.append(new pointSet(*(iter.val())));
|
||||
}
|
||||
pointSets.emplace_back(io);
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,9 +210,9 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
|
||||
facesInstance(),
|
||||
polyMesh::meshSubDir,
|
||||
*this,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
IOobjectOption::READ_IF_PRESENT,
|
||||
IOobjectOption::NO_WRITE,
|
||||
IOobjectOption::NO_REGISTER
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -597,19 +597,19 @@ int main(int argc, char *argv[])
|
||||
polyMesh::meshSubDir/"sets"
|
||||
);
|
||||
|
||||
for (const word& setName : objects.sortedNames<cellSet>())
|
||||
for (const IOobject& io : objects.csorted<cellSet>())
|
||||
{
|
||||
cSetNames.insert(setName, cSetNames.size());
|
||||
cSetNames.insert(io.name(), cSetNames.size());
|
||||
}
|
||||
|
||||
for (const word& setName : objects.sortedNames<faceSet>())
|
||||
for (const IOobject& io : objects.csorted<faceSet>())
|
||||
{
|
||||
fSetNames.insert(setName, fSetNames.size());
|
||||
fSetNames.insert(io.name(), fSetNames.size());
|
||||
}
|
||||
|
||||
for (const word& setName : objects.sortedNames<pointSet>())
|
||||
for (const IOobject& io : objects.csorted<pointSet>())
|
||||
{
|
||||
pSetNames.insert(setName, pSetNames.size());
|
||||
pSetNames.insert(io.name(), pSetNames.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -405,20 +405,20 @@ Foam::label Foam::parFvFieldDistributor::distributeInternalFields
|
||||
{
|
||||
typedef DimensionedField<Type, volMesh> fieldType;
|
||||
|
||||
// Available fields, sorted order
|
||||
const wordList fieldNames =
|
||||
(
|
||||
selectedFields.empty()
|
||||
? objects.sortedNames<fieldType>()
|
||||
: objects.sortedNames<fieldType>(selectedFields)
|
||||
);
|
||||
|
||||
label nFields = 0;
|
||||
for (const word& fieldName : fieldNames)
|
||||
for
|
||||
(
|
||||
const IOobject& io :
|
||||
(
|
||||
selectedFields.empty()
|
||||
? objects.csorted<fieldType>()
|
||||
: objects.csorted<fieldType>(selectedFields)
|
||||
)
|
||||
)
|
||||
{
|
||||
if ("cellDist" == fieldName)
|
||||
if ("cellDist" == io.name())
|
||||
{
|
||||
// There is an odd chance this is an internal field
|
||||
// Ignore cellDist (internal or volume) field
|
||||
continue;
|
||||
}
|
||||
if (verbose_)
|
||||
@ -428,13 +428,13 @@ Foam::label Foam::parFvFieldDistributor::distributeInternalFields
|
||||
Info<< " Reconstructing "
|
||||
<< fieldType::typeName << "s\n" << nl;
|
||||
}
|
||||
Info<< " " << fieldName << nl;
|
||||
Info<< " " << io.name() << nl;
|
||||
}
|
||||
++nFields;
|
||||
|
||||
tmp<fieldType> tfld
|
||||
(
|
||||
distributeInternalField<Type>(*(objects[fieldName]))
|
||||
distributeInternalField<Type>(io)
|
||||
);
|
||||
|
||||
if (isWriteProc_.good())
|
||||
@ -470,19 +470,20 @@ Foam::label Foam::parFvFieldDistributor::distributeVolumeFields
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
// Available fields, sorted order
|
||||
const wordList fieldNames =
|
||||
(
|
||||
selectedFields.empty()
|
||||
? objects.sortedNames<fieldType>()
|
||||
: objects.sortedNames<fieldType>(selectedFields)
|
||||
);
|
||||
|
||||
label nFields = 0;
|
||||
for (const word& fieldName : fieldNames)
|
||||
for
|
||||
(
|
||||
const IOobject& io :
|
||||
(
|
||||
selectedFields.empty()
|
||||
? objects.csorted<fieldType>()
|
||||
: objects.csorted<fieldType>(selectedFields)
|
||||
)
|
||||
)
|
||||
{
|
||||
if ("cellDist" == fieldName)
|
||||
if ("cellDist" == io.name())
|
||||
{
|
||||
// Ignore cellDist (internal or volume) field
|
||||
continue;
|
||||
}
|
||||
if (verbose_)
|
||||
@ -492,13 +493,13 @@ Foam::label Foam::parFvFieldDistributor::distributeVolumeFields
|
||||
Info<< " Reconstructing "
|
||||
<< fieldType::typeName << "s\n" << nl;
|
||||
}
|
||||
Info<< " " << fieldName << nl;
|
||||
Info<< " " << io.name() << nl;
|
||||
}
|
||||
++nFields;
|
||||
|
||||
tmp<fieldType> tfld
|
||||
(
|
||||
distributeVolumeField<Type>(*(objects[fieldName]))
|
||||
distributeVolumeField<Type>(io)
|
||||
);
|
||||
|
||||
if (isWriteProc_.good())
|
||||
@ -534,16 +535,16 @@ Foam::label Foam::parFvFieldDistributor::distributeSurfaceFields
|
||||
{
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> fieldType;
|
||||
|
||||
// Available fields, sorted order
|
||||
const wordList fieldNames =
|
||||
(
|
||||
selectedFields.empty()
|
||||
? objects.sortedNames<fieldType>()
|
||||
: objects.sortedNames<fieldType>(selectedFields)
|
||||
);
|
||||
|
||||
label nFields = 0;
|
||||
for (const word& fieldName : fieldNames)
|
||||
for
|
||||
(
|
||||
const IOobject& io :
|
||||
(
|
||||
selectedFields.empty()
|
||||
? objects.csorted<fieldType>()
|
||||
: objects.csorted<fieldType>(selectedFields)
|
||||
)
|
||||
)
|
||||
{
|
||||
if (verbose_)
|
||||
{
|
||||
@ -552,13 +553,13 @@ Foam::label Foam::parFvFieldDistributor::distributeSurfaceFields
|
||||
Info<< " Reconstructing "
|
||||
<< fieldType::typeName << "s\n" << nl;
|
||||
}
|
||||
Info<< " " << fieldName << nl;
|
||||
Info<< " " << io.name() << nl;
|
||||
}
|
||||
++nFields;
|
||||
|
||||
tmp<fieldType> tfld
|
||||
(
|
||||
distributeSurfaceField<Type>(*(objects[fieldName]))
|
||||
distributeSurfaceField<Type>(io)
|
||||
);
|
||||
|
||||
if (isWriteProc_.good())
|
||||
|
||||
@ -82,7 +82,7 @@ void Foam::parLagrangianDistributor::findClouds
|
||||
)
|
||||
);
|
||||
|
||||
cloudNames.setSize(localCloudDirs.size());
|
||||
cloudNames.resize_nocopy(localCloudDirs.size());
|
||||
forAll(localCloudDirs, i)
|
||||
{
|
||||
cloudNames[i] = localCloudDirs[i];
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -324,18 +324,11 @@ Foam::label Foam::parLagrangianDistributor::distributeStoredFields
|
||||
passivePositionParticleCloud& cloud
|
||||
) const
|
||||
{
|
||||
HashTable<Container*> fields
|
||||
(
|
||||
cloud.lookupClass<Container>()
|
||||
);
|
||||
|
||||
bool reconstruct = false;
|
||||
|
||||
label nFields = 0;
|
||||
forAllIters(fields, iter)
|
||||
{
|
||||
Container& field = *(iter.val());
|
||||
|
||||
for (Container& field : cloud.sorted<Container>())
|
||||
{
|
||||
if (!nFields)
|
||||
{
|
||||
// Performing an all-to-one (reconstruct)?
|
||||
|
||||
Reference in New Issue
Block a user