Revert "Merge branch 'primitiveMeshOptimization' into 'develop'"
This reverts merge request !596
This commit is contained in:
parent
61d610574c
commit
c66993e288
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2018-2023 OpenCFD Ltd.
|
Copyright (C) 2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -29,7 +29,6 @@ License
|
|||||||
#include "primitiveMesh.H"
|
#include "primitiveMesh.H"
|
||||||
#include "cell.H"
|
#include "cell.H"
|
||||||
#include "bitSet.H"
|
#include "bitSet.H"
|
||||||
#include "DynamicList.H"
|
|
||||||
#include "ListOps.H"
|
#include "ListOps.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
@ -58,51 +57,12 @@ void Foam::primitiveMesh::calcCellPoints() const
|
|||||||
<< "cellPoints already calculated"
|
<< "cellPoints already calculated"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
else if (hasPointCells())
|
else
|
||||||
{
|
{
|
||||||
// Invert pointCells
|
// Invert pointCells
|
||||||
cpPtr_ = new labelListList(nCells());
|
cpPtr_ = new labelListList(nCells());
|
||||||
invertManyToMany(nCells(), pointCells(), *cpPtr_);
|
invertManyToMany(nCells(), pointCells(), *cpPtr_);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// Calculate cell-point topology
|
|
||||||
|
|
||||||
cpPtr_ = new labelListList(nCells());
|
|
||||||
auto& cellPointAddr = *cpPtr_;
|
|
||||||
|
|
||||||
const cellList& cellLst = cells();
|
|
||||||
const faceList& faceLst = faces();
|
|
||||||
|
|
||||||
// Tracking (only use each point id once)
|
|
||||||
bitSet usedPoints(nPoints());
|
|
||||||
|
|
||||||
// Vertex labels for the current cell
|
|
||||||
DynamicList<label> currPoints(256);
|
|
||||||
|
|
||||||
const label loopLen = nCells();
|
|
||||||
|
|
||||||
for (label celli = 0; celli < loopLen; ++celli)
|
|
||||||
{
|
|
||||||
// Clear any previous contents
|
|
||||||
usedPoints.unset(currPoints);
|
|
||||||
currPoints.clear();
|
|
||||||
|
|
||||||
for (const label facei : cellLst[celli])
|
|
||||||
{
|
|
||||||
for (const label pointi : faceLst[facei])
|
|
||||||
{
|
|
||||||
// Only once for each point id
|
|
||||||
if (usedPoints.set(pointi))
|
|
||||||
{
|
|
||||||
currPoints.push_back(pointi);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cellPointAddr[celli] = currPoints; // NB: unsorted
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2023 OpenCFD Ltd.
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -29,13 +28,14 @@ License
|
|||||||
#include "primitiveMesh.H"
|
#include "primitiveMesh.H"
|
||||||
#include "cell.H"
|
#include "cell.H"
|
||||||
#include "bitSet.H"
|
#include "bitSet.H"
|
||||||
#include "DynamicList.H"
|
|
||||||
#include "ListOps.H"
|
#include "ListOps.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::primitiveMesh::calcPointCells() const
|
void Foam::primitiveMesh::calcPointCells() const
|
||||||
{
|
{
|
||||||
|
// Loop through cells and mark up points
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< "primitiveMesh::calcPointCells() : "
|
Pout<< "primitiveMesh::calcPointCells() : "
|
||||||
@ -59,128 +59,48 @@ void Foam::primitiveMesh::calcPointCells() const
|
|||||||
<< "pointCells already calculated"
|
<< "pointCells already calculated"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
else if (hasCellPoints())
|
|
||||||
{
|
|
||||||
// Invert cellPoints
|
|
||||||
pcPtr_ = new labelListList(nPoints());
|
|
||||||
invertManyToMany(nPoints(), cellPoints(), *pcPtr_);
|
|
||||||
}
|
|
||||||
else if (hasPointFaces())
|
|
||||||
{
|
|
||||||
// Calculate point-cell from point-face information
|
|
||||||
|
|
||||||
const labelList& own = faceOwner();
|
|
||||||
const labelList& nei = faceNeighbour();
|
|
||||||
const labelListList& pFaces = pointFaces();
|
|
||||||
|
|
||||||
// Tracking (only use each cell id once)
|
|
||||||
bitSet usedCells(nCells());
|
|
||||||
|
|
||||||
// Cell ids for the point currently being processed
|
|
||||||
DynamicList<label> currCells(256);
|
|
||||||
|
|
||||||
const label loopLen = nPoints();
|
|
||||||
|
|
||||||
pcPtr_ = new labelListList(nPoints());
|
|
||||||
auto& pointCellAddr = *pcPtr_;
|
|
||||||
|
|
||||||
for (label pointi = 0; pointi < loopLen; ++pointi)
|
|
||||||
{
|
|
||||||
// Clear any previous contents
|
|
||||||
usedCells.unset(currCells);
|
|
||||||
currCells.clear();
|
|
||||||
|
|
||||||
for (const label facei : pFaces[pointi])
|
|
||||||
{
|
|
||||||
// Owner cell - only allow one occurance
|
|
||||||
if (usedCells.set(own[facei]))
|
|
||||||
{
|
|
||||||
currCells.push_back(own[facei]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Neighbour cell - only allow one occurance
|
|
||||||
if (facei < nInternalFaces())
|
|
||||||
{
|
|
||||||
if (usedCells.set(nei[facei]))
|
|
||||||
{
|
|
||||||
currCells.push_back(nei[facei]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pointCellAddr[pointi] = currCells; // NB: unsorted
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Calculate point-cell topology
|
const cellList& cf = cells();
|
||||||
|
|
||||||
const cellList& cellLst = cells();
|
// Count number of cells per point
|
||||||
const faceList& faceLst = faces();
|
|
||||||
|
|
||||||
// Tracking (only use each point id once)
|
labelList npc(nPoints(), Zero);
|
||||||
bitSet usedPoints(nPoints());
|
|
||||||
|
|
||||||
// Which of usedPoints needs to be unset [faster]
|
forAll(cf, celli)
|
||||||
DynamicList<label> currPoints(256);
|
|
||||||
|
|
||||||
const label loopLen = nCells();
|
|
||||||
|
|
||||||
// Step 1: count number of cells per point
|
|
||||||
|
|
||||||
labelList pointCount(nPoints(), Zero);
|
|
||||||
|
|
||||||
for (label celli = 0; celli < loopLen; ++celli)
|
|
||||||
{
|
{
|
||||||
// Clear any previous contents
|
const labelList curPoints = cf[celli].labels(faces());
|
||||||
usedPoints.unset(currPoints);
|
|
||||||
currPoints.clear();
|
|
||||||
|
|
||||||
for (const label facei : cellLst[celli])
|
forAll(curPoints, pointi)
|
||||||
{
|
{
|
||||||
for (const label pointi : faceLst[facei])
|
label ptI = curPoints[pointi];
|
||||||
{
|
|
||||||
// Only once for each point id
|
npc[ptI]++;
|
||||||
if (usedPoints.set(pointi))
|
|
||||||
{
|
|
||||||
currPoints.push_back(pointi); // Needed for cleanup
|
|
||||||
++pointCount[pointi];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Step 2: set sizing, reset counters
|
// Size and fill cells per point
|
||||||
|
|
||||||
pcPtr_ = new labelListList(nPoints());
|
pcPtr_ = new labelListList(npc.size());
|
||||||
auto& pointCellAddr = *pcPtr_;
|
labelListList& pointCellAddr = *pcPtr_;
|
||||||
|
|
||||||
forAll(pointCellAddr, pointi)
|
forAll(pointCellAddr, pointi)
|
||||||
{
|
{
|
||||||
pointCellAddr[pointi].resize_nocopy(pointCount[pointi]);
|
pointCellAddr[pointi].setSize(npc[pointi]);
|
||||||
pointCount[pointi] = 0;
|
|
||||||
}
|
}
|
||||||
|
npc = 0;
|
||||||
|
|
||||||
|
|
||||||
// Step 3: fill in values. Logic as per step 1
|
forAll(cf, celli)
|
||||||
for (label celli = 0; celli < loopLen; ++celli)
|
|
||||||
{
|
{
|
||||||
// Clear any previous contents
|
const labelList curPoints = cf[celli].labels(faces());
|
||||||
usedPoints.unset(currPoints);
|
|
||||||
currPoints.clear();
|
|
||||||
|
|
||||||
for (const label facei : cellLst[celli])
|
forAll(curPoints, pointi)
|
||||||
{
|
{
|
||||||
for (const label pointi : faceLst[facei])
|
label ptI = curPoints[pointi];
|
||||||
{
|
|
||||||
// Only once for each point id
|
pointCellAddr[ptI][npc[ptI]++] = celli;
|
||||||
if (usedPoints.set(pointi))
|
|
||||||
{
|
|
||||||
currPoints.push_back(pointi); // Needed for cleanup
|
|
||||||
pointCellAddr[pointi][pointCount[pointi]++] = celli;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,8 +154,12 @@ const Foam::labelList& Foam::primitiveMesh::pointCells
|
|||||||
if (storage.size() > 1)
|
if (storage.size() > 1)
|
||||||
{
|
{
|
||||||
std::sort(storage.begin(), storage.end());
|
std::sort(storage.begin(), storage.end());
|
||||||
|
|
||||||
auto last = std::unique(storage.begin(), storage.end());
|
auto last = std::unique(storage.begin(), storage.end());
|
||||||
storage.resize(label(last - storage.begin()));
|
|
||||||
|
const label newLen = label(last - storage.begin());
|
||||||
|
|
||||||
|
storage.resize(newLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
return storage;
|
return storage;
|
||||||
|
Loading…
Reference in New Issue
Block a user