mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: use globalIndex gather in patch merging
This commit is contained in:
@ -3,7 +3,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) 2012-2017 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -49,25 +49,11 @@ void Foam::PatchTools::gatherAndMerge
|
|||||||
// Collect points from all processors
|
// Collect points from all processors
|
||||||
labelList pointSizes;
|
labelList pointSizes;
|
||||||
{
|
{
|
||||||
List<Field<PointType>> gatheredPoints(Pstream::nProcs());
|
const globalIndex gi(p.points().size());
|
||||||
gatheredPoints[Pstream::myProcNo()] = p.points();
|
|
||||||
|
|
||||||
Pstream::gatherList(gatheredPoints);
|
gi.gather(p.points(), mergedPoints);
|
||||||
|
|
||||||
if (Pstream::master())
|
pointSizes = gi.sizes();
|
||||||
{
|
|
||||||
pointSizes = ListListOps::subSizes
|
|
||||||
(
|
|
||||||
gatheredPoints,
|
|
||||||
accessOp<Field<PointType>>()
|
|
||||||
);
|
|
||||||
|
|
||||||
mergedPoints = ListListOps::combine<Field<PointType>>
|
|
||||||
(
|
|
||||||
gatheredPoints,
|
|
||||||
accessOp<Field<PointType>>()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect faces from all processors and renumber using sizes of
|
// Collect faces from all processors and renumber using sizes of
|
||||||
|
|||||||
@ -3,7 +3,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) 2011-2017 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -29,6 +29,7 @@ License
|
|||||||
#include "meshSearch.H"
|
#include "meshSearch.H"
|
||||||
#include "writer.H"
|
#include "writer.H"
|
||||||
#include "particle.H"
|
#include "particle.H"
|
||||||
|
#include "globalIndex.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -427,40 +428,13 @@ Foam::autoPtr<Foam::coordSet> Foam::sampledSet::gather
|
|||||||
// ordering in indexSet.
|
// ordering in indexSet.
|
||||||
// Note: only master results are valid
|
// Note: only master results are valid
|
||||||
|
|
||||||
// Collect data from all processors
|
List<point> allPts;
|
||||||
List<List<point>> gatheredPts(Pstream::nProcs());
|
globalIndex::gatherOp(*this, allPts);
|
||||||
gatheredPts[Pstream::myProcNo()] = *this;
|
|
||||||
Pstream::gatherList(gatheredPts);
|
|
||||||
|
|
||||||
List<labelList> gatheredSegments(Pstream::nProcs());
|
globalIndex::gatherOp(segments(), allSegments);
|
||||||
gatheredSegments[Pstream::myProcNo()] = segments();
|
|
||||||
Pstream::gatherList(gatheredSegments);
|
|
||||||
|
|
||||||
List<scalarList> gatheredDist(Pstream::nProcs());
|
scalarList allCurveDist;
|
||||||
gatheredDist[Pstream::myProcNo()] = curveDist();
|
globalIndex::gatherOp(curveDist(), allCurveDist);
|
||||||
Pstream::gatherList(gatheredDist);
|
|
||||||
|
|
||||||
|
|
||||||
// Combine processor lists into one big list.
|
|
||||||
List<point> allPts
|
|
||||||
(
|
|
||||||
ListListOps::combine<List<point>>
|
|
||||||
(
|
|
||||||
gatheredPts, accessOp<List<point>>()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
allSegments =
|
|
||||||
ListListOps::combine<labelList>
|
|
||||||
(
|
|
||||||
gatheredSegments, accessOp<labelList>()
|
|
||||||
);
|
|
||||||
scalarList allCurveDist
|
|
||||||
(
|
|
||||||
ListListOps::combine<scalarList>
|
|
||||||
(
|
|
||||||
gatheredDist, accessOp<scalarList>()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
if (Pstream::master() && allCurveDist.empty())
|
if (Pstream::master() && allCurveDist.empty())
|
||||||
|
|||||||
@ -27,7 +27,6 @@ License
|
|||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
#include "ListListOps.H"
|
|
||||||
#include "volPointInterpolation.H"
|
#include "volPointInterpolation.H"
|
||||||
#include "mapPolyMesh.H"
|
#include "mapPolyMesh.H"
|
||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|||||||
@ -3,7 +3,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) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2015-2019 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -25,7 +25,7 @@ License
|
|||||||
|
|
||||||
#include "sampledSets.H"
|
#include "sampledSets.H"
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
#include "ListListOps.H"
|
#include "globalIndex.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -182,21 +182,12 @@ void Foam::sampledSets::combineSampledValues
|
|||||||
forAll(indexSets, setI)
|
forAll(indexSets, setI)
|
||||||
{
|
{
|
||||||
// Collect data from all processors
|
// Collect data from all processors
|
||||||
List<Field<T>> gatheredData(Pstream::nProcs());
|
|
||||||
gatheredData[Pstream::myProcNo()] = sampledFields[fieldi][setI];
|
Field<T> allData;
|
||||||
Pstream::gatherList(gatheredData);
|
globalIndex::gatherOp(sampledFields[fieldi][setI], allData);
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
Field<T> allData
|
|
||||||
(
|
|
||||||
ListListOps::combine<Field<T>>
|
|
||||||
(
|
|
||||||
gatheredData,
|
|
||||||
Foam::accessOp<Field<T>>()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
masterValues[setI] = UIndirectList<T>
|
masterValues[setI] = UIndirectList<T>
|
||||||
(
|
(
|
||||||
allData,
|
allData,
|
||||||
|
|||||||
@ -3,7 +3,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) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2015-2019 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -26,7 +26,7 @@ License
|
|||||||
#include "sampledSurfaces.H"
|
#include "sampledSurfaces.H"
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
#include "surfaceFields.H"
|
#include "surfaceFields.H"
|
||||||
#include "ListListOps.H"
|
#include "globalIndex.H"
|
||||||
#include "stringListOps.H"
|
#include "stringListOps.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
@ -51,29 +51,19 @@ void Foam::sampledSurfaces::writeSurface
|
|||||||
|
|
||||||
if (Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
{
|
{
|
||||||
// Collect values from all processors
|
// Gather all values into single field
|
||||||
List<Field<Type>> gatheredValues(Pstream::nProcs());
|
Field<Type> allValues;
|
||||||
gatheredValues[Pstream::myProcNo()] = values;
|
|
||||||
Pstream::gatherList(gatheredValues);
|
globalIndex::gatherOp(values, allValues);
|
||||||
|
|
||||||
fileName sampleFile;
|
fileName sampleFile;
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
// Combine values into single field
|
|
||||||
Field<Type> allValues
|
|
||||||
(
|
|
||||||
ListListOps::combine<Field<Type>>
|
|
||||||
(
|
|
||||||
gatheredValues,
|
|
||||||
accessOp<Field<Type>>()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Renumber (point data) to correspond to merged points
|
// Renumber (point data) to correspond to merged points
|
||||||
if (mergedList_[surfi].pointsMap().size() == allValues.size())
|
if (mergedList_[surfi].pointsMap().size() == allValues.size())
|
||||||
{
|
{
|
||||||
inplaceReorder(mergedList_[surfi].pointsMap(), allValues);
|
inplaceReorder(mergedList_[surfi].pointsMap(), allValues);
|
||||||
allValues.setSize(mergedList_[surfi].points().size());
|
allValues.resize(mergedList_[surfi].points().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write to time directory under outputPath_
|
// Write to time directory under outputPath_
|
||||||
|
|||||||
@ -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) 2016-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,7 +25,7 @@ License
|
|||||||
|
|
||||||
#include "mergedSurf.H"
|
#include "mergedSurf.H"
|
||||||
#include "PatchTools.H"
|
#include "PatchTools.H"
|
||||||
#include "ListListOps.H"
|
#include "globalIndex.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -140,20 +140,10 @@ bool Foam::mergedSurf::merge
|
|||||||
pointsMap_
|
pointsMap_
|
||||||
);
|
);
|
||||||
|
|
||||||
// Now handle zone/region information
|
|
||||||
List<labelList> allZones(Pstream::nProcs());
|
|
||||||
allZones[Pstream::myProcNo()] = originalIds;
|
|
||||||
Pstream::gatherList(allZones);
|
|
||||||
|
|
||||||
if (Pstream::master())
|
// Now handle zone/region information
|
||||||
{
|
|
||||||
zones_ = ListListOps::combine<labelList>
|
globalIndex::gatherOp(originalIds, zones_);
|
||||||
(
|
|
||||||
allZones,
|
|
||||||
accessOp<labelList>()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
allZones.clear();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user