mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: for-range, forAllIters() ... in parallel/
- reduced clutter when iterating over containers
This commit is contained in:
committed by
Andrew Heather
parent
45590671ac
commit
655f7d1997
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2015-2016 OpenFOAM Foundation
|
| Copyright (C) 2015-2016 OpenFOAM Foundation
|
||||||
@ -159,9 +159,9 @@ void Foam::decompositionConstraints::singleProcessorFaceSets::add
|
|||||||
|
|
||||||
// Check that it does not overlap with existing specifiedProcessorFaces
|
// Check that it does not overlap with existing specifiedProcessorFaces
|
||||||
labelList nMatch(specifiedProcessorFaces.size(), Zero);
|
labelList nMatch(specifiedProcessorFaces.size(), Zero);
|
||||||
forAllConstIter(faceSet, fz, iter)
|
for (const label facei : fz)
|
||||||
{
|
{
|
||||||
label seti = faceToSet[iter.key()];
|
const label seti = faceToSet[facei];
|
||||||
if (seti != -1)
|
if (seti != -1)
|
||||||
{
|
{
|
||||||
++nMatch[seti];
|
++nMatch[seti];
|
||||||
@ -191,7 +191,6 @@ void Foam::decompositionConstraints::singleProcessorFaceSets::add
|
|||||||
|
|
||||||
reduce(store, andOp<bool>());
|
reduce(store, andOp<bool>());
|
||||||
|
|
||||||
|
|
||||||
if (store)
|
if (store)
|
||||||
{
|
{
|
||||||
specifiedProcessorFaces.append(new labelList(fz.sortedToc()));
|
specifiedProcessorFaces.append(new labelList(fz.sortedToc()));
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2013 OpenFOAM Foundation
|
| Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
@ -39,8 +39,7 @@ License
|
|||||||
// List<Type>& values
|
// List<Type>& values
|
||||||
//) const
|
//) const
|
||||||
//{
|
//{
|
||||||
// typedef DimensionedField<Type, triSurfaceGeoMesh> DimensionedSurfField;
|
// typedef DimensionedField<Type, triSurfaceGeoMesh> fieldType;
|
||||||
//
|
|
||||||
//
|
//
|
||||||
// // Get query data (= local index of triangle)
|
// // Get query data (= local index of triangle)
|
||||||
// // ~~~~~~~~~~~~~~
|
// // ~~~~~~~~~~~~~~
|
||||||
@ -60,10 +59,8 @@ License
|
|||||||
// // Do my tests
|
// // Do my tests
|
||||||
// // ~~~~~~~~~~~
|
// // ~~~~~~~~~~~
|
||||||
//
|
//
|
||||||
// const DimensionedSurfField& fld = lookupObject<DimensionedSurfField>
|
// const auto& fld = lookupObject<fieldType>(fieldName);
|
||||||
// (
|
//
|
||||||
// fieldName
|
|
||||||
// );
|
|
||||||
// const triSurface& s = static_cast<const triSurface&>(*this);
|
// const triSurface& s = static_cast<const triSurface&>(*this);
|
||||||
//
|
//
|
||||||
// values.setSize(triangleIndex.size());
|
// values.setSize(triangleIndex.size());
|
||||||
@ -88,33 +85,24 @@ void Foam::distributedTriSurfaceMesh::distributeFields
|
|||||||
const mapDistribute& map
|
const mapDistribute& map
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
typedef DimensionedField<Type, triSurfaceGeoMesh> DimensionedSurfField;
|
typedef DimensionedField<Type, triSurfaceGeoMesh> fieldType;
|
||||||
|
|
||||||
HashTable<DimensionedSurfField*> fields
|
HashTable<fieldType*> fields
|
||||||
(
|
(
|
||||||
objectRegistry::lookupClass<DimensionedSurfField>()
|
objectRegistry::lookupClass<fieldType>()
|
||||||
);
|
);
|
||||||
|
|
||||||
for
|
forAllIters(fields, fieldIter)
|
||||||
(
|
|
||||||
typename HashTable<DimensionedSurfField*>::iterator fieldIter =
|
|
||||||
fields.begin();
|
|
||||||
fieldIter != fields.end();
|
|
||||||
++fieldIter
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
DimensionedSurfField& field = *fieldIter();
|
fieldType& field = *fieldIter();
|
||||||
|
|
||||||
label oldSize = field.size();
|
const label oldSize = field.size();
|
||||||
|
|
||||||
map.distribute(field);
|
map.distribute(field);
|
||||||
|
|
||||||
if (debug)
|
DebugInfo
|
||||||
{
|
<< "Mapped " << field.typeName << ' ' << field.name()
|
||||||
Info<< "Mapped " << field.typeName << ' ' << field.name()
|
<< " from size " << oldSize << " to size " << field.size() << endl;
|
||||||
<< " from size " << oldSize << " to size " << field.size()
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user