Commit c44814c1 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: use globalIndex gather in patch merging

parent f498d09d
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -49,25 +49,11 @@ void Foam::PatchTools::gatherAndMerge
// Collect points from all processors
labelList pointSizes;
{
List<Field<PointType>> gatheredPoints(Pstream::nProcs());
gatheredPoints[Pstream::myProcNo()] = p.points();
const globalIndex gi(p.points().size());
Pstream::gatherList(gatheredPoints);
gi.gather(p.points(), mergedPoints);
if (Pstream::master())
{
pointSizes = ListListOps::subSizes
(
gatheredPoints,
accessOp<Field<PointType>>()
);
mergedPoints = ListListOps::combine<Field<PointType>>
(
gatheredPoints,
accessOp<Field<PointType>>()
);
}
pointSizes = gi.sizes();
}
// Collect faces from all processors and renumber using sizes of
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2018-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -29,6 +29,7 @@ License
#include "meshSearch.H"
#include "writer.H"
#include "particle.H"
#include "globalIndex.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -427,40 +428,13 @@ Foam::autoPtr<Foam::coordSet> Foam::sampledSet::gather
// ordering in indexSet.
// Note: only master results are valid
// Collect data from all processors
List<List<point>> gatheredPts(Pstream::nProcs());
gatheredPts[Pstream::myProcNo()] = *this;
Pstream::gatherList(gatheredPts);
List<point> allPts;
globalIndex::gatherOp(*this, allPts);
List<labelList> gatheredSegments(Pstream::nProcs());
gatheredSegments[Pstream::myProcNo()] = segments();
Pstream::gatherList(gatheredSegments);
globalIndex::gatherOp(segments(), allSegments);
List<scalarList> gatheredDist(Pstream::nProcs());
gatheredDist[Pstream::myProcNo()] = curveDist();
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>()
)
);
scalarList allCurveDist;
globalIndex::gatherOp(curveDist(), allCurveDist);
if (Pstream::master() && allCurveDist.empty())
......
......@@ -27,7 +27,6 @@ License
#include "dictionary.H"
#include "Time.H"
#include "volFields.H"
#include "ListListOps.H"
#include "volPointInterpolation.H"
#include "mapPolyMesh.H"
#include "addToRunTimeSelectionTable.H"
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / 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
This file is part of OpenFOAM.
......@@ -25,7 +25,7 @@ License
#include "sampledSets.H"
#include "volFields.H"
#include "ListListOps.H"
#include "globalIndex.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......@@ -182,21 +182,12 @@ void Foam::sampledSets::combineSampledValues
forAll(indexSets, setI)
{
// Collect data from all processors
List<Field<T>> gatheredData(Pstream::nProcs());
gatheredData[Pstream::myProcNo()] = sampledFields[fieldi][setI];
Pstream::gatherList(gatheredData);
Field<T> allData;
globalIndex::gatherOp(sampledFields[fieldi][setI], allData);
if (Pstream::master())
{
Field<T> allData
(
ListListOps::combine<Field<T>>
(
gatheredData,
Foam::accessOp<Field<T>>()
)
);
masterValues[setI] = UIndirectList<T>
(
allData,
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / 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
This file is part of OpenFOAM.
......@@ -26,7 +26,7 @@ License
#include "sampledSurfaces.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "ListListOps.H"
#include "globalIndex.H"
#include "stringListOps.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......@@ -51,29 +51,19 @@ void Foam::sampledSurfaces::writeSurface
if (Pstream::parRun())
{
// Collect values from all processors
List<Field<Type>> gatheredValues(Pstream::nProcs());
gatheredValues[Pstream::myProcNo()] = values;
Pstream::gatherList(gatheredValues);
// Gather all values into single field
Field<Type> allValues;
globalIndex::gatherOp(values, allValues);
fileName sampleFile;
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
if (mergedList_[surfi].pointsMap().size() == allValues.size())
{
inplaceReorder(mergedList_[surfi].pointsMap(), allValues);
allValues.setSize(mergedList_[surfi].points().size());
allValues.resize(mergedList_[surfi].points().size());
}
// Write to time directory under outputPath_
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -25,7 +25,7 @@ License
#include "mergedSurf.H"
#include "PatchTools.H"
#include "ListListOps.H"
#include "globalIndex.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......@@ -140,20 +140,10 @@ bool Foam::mergedSurf::merge
pointsMap_
);
// Now handle zone/region information
List<labelList> allZones(Pstream::nProcs());
allZones[Pstream::myProcNo()] = originalIds;
Pstream::gatherList(allZones);
if (Pstream::master())
{
zones_ = ListListOps::combine<labelList>
(
allZones,
accessOp<labelList>()
);
}
allZones.clear();
globalIndex::gatherOp(originalIds, zones_);
return true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment