Compare commits
1 Commits
xxx-primit
...
update-pst
| Author | SHA1 | Date | |
|---|---|---|---|
| 5cf5af9d3b |
@ -143,7 +143,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
#include "setRootCase.H"
|
||||
|
||||
treeBoundBox bb(zero_one{});
|
||||
treeBoundBox bb(cube(0, 1));
|
||||
treeBoundBox sub(cube(0.1, 0.8));
|
||||
|
||||
Info<< nl
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
Test-polyMeshGeom-speed1.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-polyMeshGeom-speed1
|
||||
@ -1,5 +0,0 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/mesh/blockMesh/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lblockMesh
|
||||
@ -1,804 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Simple timing tests for some polyMesh primitives
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "clockTime.H"
|
||||
#include "Time.H"
|
||||
#include "PDRblock.H"
|
||||
#include "polyMesh.H"
|
||||
#include "ListOps.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
void printAlloc(const polyMesh& mesh)
|
||||
{
|
||||
Info<< "memory"
|
||||
<< " hasCellPoints:" << mesh.hasCellPoints()
|
||||
<< " hasPointCells:" << mesh.hasPointCells() << endl;
|
||||
}
|
||||
|
||||
|
||||
void printInfo(const polyMesh& mesh)
|
||||
{
|
||||
Info<< "polyMesh"
|
||||
<< " nPoints:" << mesh.nPoints()
|
||||
<< " nInternalFaces:" << mesh.nInternalFaces()
|
||||
<< " nFaces:" << mesh.nFaces()
|
||||
<< " nCells:" << mesh.nCells() << endl;
|
||||
}
|
||||
|
||||
|
||||
// How point cells are calculated in OpenFOAM-v2212 and earlier
|
||||
autoPtr<labelListList> pointCells_2212(const polyMesh& mesh)
|
||||
{
|
||||
const cellList& cf = mesh.cells();
|
||||
|
||||
// Count number of cells per point
|
||||
|
||||
labelList npc(mesh.nPoints(), Zero);
|
||||
|
||||
forAll(cf, celli)
|
||||
{
|
||||
const labelList curPoints = cf[celli].labels(mesh.faces());
|
||||
|
||||
for (const label pointi : curPoints)
|
||||
{
|
||||
++npc[pointi];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Size and fill cells per point
|
||||
|
||||
auto pcPtr_ = autoPtr<labelListList>::New(npc.size());
|
||||
labelListList& pointCellAddr = *pcPtr_;
|
||||
|
||||
forAll(pointCellAddr, pointi)
|
||||
{
|
||||
pointCellAddr[pointi].setSize(npc[pointi]);
|
||||
npc[pointi] = 0;
|
||||
}
|
||||
|
||||
|
||||
forAll(cf, celli)
|
||||
{
|
||||
const labelList curPoints = cf[celli].labels(mesh.faces());
|
||||
|
||||
for (const label pointi : curPoints)
|
||||
{
|
||||
pointCellAddr[pointi][npc[pointi]++] = celli;
|
||||
}
|
||||
}
|
||||
|
||||
return pcPtr_;
|
||||
}
|
||||
|
||||
|
||||
// Line cell::labels but with persistent storage
|
||||
void cell_labels
|
||||
(
|
||||
const cell& cFaces,
|
||||
const faceUList& meshFaces,
|
||||
DynamicList<label>& pointLabels
|
||||
)
|
||||
{
|
||||
// const labelList& cFaces = *this;
|
||||
|
||||
label nVerts = 0;
|
||||
for (const label facei : cFaces)
|
||||
{
|
||||
nVerts += meshFaces[facei].size();
|
||||
}
|
||||
|
||||
// pointLabels.clear();
|
||||
pointLabels.expandStorage();
|
||||
|
||||
// The first face has no duplicates, can copy in values
|
||||
const labelList& firstFace = meshFaces[cFaces[0]];
|
||||
|
||||
std::copy(firstFace.cbegin(), firstFace.cend(), pointLabels.begin());
|
||||
|
||||
// Now already contains some vertices
|
||||
nVerts = firstFace.size();
|
||||
|
||||
// For the rest of the faces. For each vertex, check if the point is
|
||||
// already inserted (up to nVerts, which now carries the number of real
|
||||
// points. If not, add it at the end of the list.
|
||||
|
||||
for (label facei = 1; facei < cFaces.size(); ++facei)
|
||||
{
|
||||
for (const label curPoint : meshFaces[cFaces[facei]])
|
||||
{
|
||||
bool pointFound = false;
|
||||
|
||||
for (label checki = 0; checki < nVerts; ++checki)
|
||||
{
|
||||
if (curPoint == pointLabels[checki])
|
||||
{
|
||||
pointFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pointFound)
|
||||
{
|
||||
pointLabels[nVerts] = curPoint;
|
||||
++nVerts;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pointLabels.resize(nVerts);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Like OpenFOAM-v2212, but with cell::labels unrolled to avoid allocations
|
||||
autoPtr<labelListList> pointCells_2212mod(const polyMesh& mesh)
|
||||
{
|
||||
const cellList& cf = mesh.cells();
|
||||
|
||||
// Vertex labels for the current cell
|
||||
DynamicList<label> vertices(256);
|
||||
|
||||
// Count number of cells per point
|
||||
|
||||
labelList npc(mesh.nPoints(), Zero);
|
||||
|
||||
for (const cell& c : cf)
|
||||
{
|
||||
cell_labels(c, mesh.faces(), vertices);
|
||||
|
||||
for (const label pointi : vertices)
|
||||
{
|
||||
++npc[pointi];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Size and fill cells per point
|
||||
|
||||
auto pcPtr_ = autoPtr<labelListList>::New(npc.size());
|
||||
labelListList& pointCellAddr = *pcPtr_;
|
||||
|
||||
forAll(pointCellAddr, pointi)
|
||||
{
|
||||
pointCellAddr[pointi].resize(npc[pointi]);
|
||||
npc[pointi] = 0;
|
||||
}
|
||||
|
||||
|
||||
forAll(cf, celli)
|
||||
{
|
||||
cell_labels(cf[celli], mesh.faces(), vertices);
|
||||
|
||||
for (const label pointi : vertices)
|
||||
{
|
||||
pointCellAddr[pointi][npc[pointi]++] = celli;
|
||||
}
|
||||
}
|
||||
|
||||
return pcPtr_;
|
||||
}
|
||||
|
||||
|
||||
// How cells points are calculated in OpenFOAM-v2212 and earlier
|
||||
autoPtr<labelListList> cellPoints_2212(const polyMesh& mesh)
|
||||
{
|
||||
autoPtr<labelListList> pointCells = pointCells_2212(mesh);
|
||||
|
||||
auto cpPtr_ = autoPtr<labelListList>::New(mesh.nCells());
|
||||
|
||||
invertManyToMany(mesh.nCells(), pointCells(), *cpPtr_);
|
||||
|
||||
return cpPtr_;
|
||||
}
|
||||
|
||||
|
||||
// Calculate with bitSet tracking and avoid cells::labels
|
||||
autoPtr<labelListList> pointCells_bitSet(const polyMesh& mesh)
|
||||
{
|
||||
// Calculate point-cell topology
|
||||
|
||||
const cellList& cellLst = mesh.cells();
|
||||
const faceList& faceLst = mesh.faces();
|
||||
|
||||
// For tracking (only use each point id once)
|
||||
bitSet usedPoints(mesh.nPoints());
|
||||
|
||||
// Vertex labels for the current cell
|
||||
DynamicList<label> vertices(256);
|
||||
|
||||
const label loopLen = mesh.nCells();
|
||||
|
||||
// Step 1: count number of cells per point
|
||||
|
||||
labelList pointCount(mesh.nPoints(), Zero);
|
||||
|
||||
for (label celli = 0; celli < loopLen; ++celli)
|
||||
{
|
||||
// Clear any previous contents
|
||||
usedPoints.unset(vertices);
|
||||
vertices.clear();
|
||||
|
||||
for (const label facei : cellLst[celli])
|
||||
{
|
||||
for (const label pointi : faceLst[facei])
|
||||
{
|
||||
// Only once for each point id
|
||||
if (usedPoints.set(pointi))
|
||||
{
|
||||
vertices.push_back(pointi);
|
||||
++pointCount[pointi];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Step 2: set sizing, reset counters
|
||||
|
||||
auto pcPtr_ = autoPtr<labelListList>::New(mesh.nPoints());
|
||||
auto& pointCellAddr = *pcPtr_;
|
||||
|
||||
forAll(pointCellAddr, pointi)
|
||||
{
|
||||
pointCellAddr[pointi].resize_nocopy(pointCount[pointi]);
|
||||
pointCount[pointi] = 0;
|
||||
}
|
||||
|
||||
|
||||
// Step 3: fill in values. Logic as per step 1
|
||||
for (label celli = 0; celli < loopLen; ++celli)
|
||||
{
|
||||
// Clear any previous contents
|
||||
usedPoints.unset(vertices);
|
||||
vertices.clear();
|
||||
|
||||
for (const label facei : cellLst[celli])
|
||||
{
|
||||
for (const label pointi : faceLst[facei])
|
||||
{
|
||||
// Only once for each point id
|
||||
if (usedPoints.set(pointi))
|
||||
{
|
||||
vertices.push_back(pointi);
|
||||
pointCellAddr[pointi][pointCount[pointi]++] = celli;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pcPtr_;
|
||||
}
|
||||
|
||||
|
||||
// Calculate with bitSet tracking and avoid cells::labels
|
||||
autoPtr<labelListList> cellPoints_bitSet(const polyMesh& mesh)
|
||||
{
|
||||
// Calculate cell-point topology
|
||||
|
||||
auto cpPtr_ = autoPtr<labelListList>::New(mesh.nCells());
|
||||
auto& cellPointAddr = *cpPtr_;
|
||||
|
||||
const cellList& cellLst = mesh.cells();
|
||||
const faceList& faceLst = mesh.faces();
|
||||
|
||||
// For tracking (only use each point id once)
|
||||
bitSet usedPoints(mesh.nPoints());
|
||||
|
||||
// Vertex labels for the current cell
|
||||
DynamicList<label> vertices(256);
|
||||
|
||||
const label loopLen = mesh.nCells();
|
||||
|
||||
for (label celli = 0; celli < loopLen; ++celli)
|
||||
{
|
||||
// Clear any previous contents
|
||||
usedPoints.unset(vertices);
|
||||
vertices.clear();
|
||||
|
||||
for (const label facei : cellLst[celli])
|
||||
{
|
||||
for (const label pointi : faceLst[facei])
|
||||
{
|
||||
// Only once for each point id
|
||||
if (usedPoints.set(pointi))
|
||||
{
|
||||
vertices.push_back(pointi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cellPointAddr[celli] = vertices; // unsorted
|
||||
}
|
||||
|
||||
return cpPtr_;
|
||||
}
|
||||
|
||||
|
||||
// Calculate with linear lookup and avoid cells::labels
|
||||
autoPtr<labelListList> pointCells_linear(const polyMesh& mesh)
|
||||
{
|
||||
// Calculate point-cell topology
|
||||
|
||||
const cellList& cellLst = mesh.cells();
|
||||
const faceList& faceLst = mesh.faces();
|
||||
|
||||
// Vertex labels for the current cell
|
||||
DynamicList<label> vertices(256);
|
||||
|
||||
const label loopLen = mesh.nCells();
|
||||
|
||||
// Step 1: count number of cells per point
|
||||
|
||||
labelList pointCount(mesh.nPoints(), Zero);
|
||||
|
||||
for (label celli = 0; celli < loopLen; ++celli)
|
||||
{
|
||||
// Clear any previous contents
|
||||
vertices.clear();
|
||||
|
||||
for (const label facei : cellLst[celli])
|
||||
{
|
||||
for (const label pointi : faceLst[facei])
|
||||
{
|
||||
// Only once for each point id
|
||||
if (!vertices.contains(pointi))
|
||||
{
|
||||
vertices.push_back(pointi);
|
||||
++pointCount[pointi];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Step 2: set sizing, reset counters
|
||||
|
||||
auto pcPtr_ = autoPtr<labelListList>::New(mesh.nPoints());
|
||||
auto& pointCellAddr = *pcPtr_;
|
||||
|
||||
forAll(pointCellAddr, pointi)
|
||||
{
|
||||
pointCellAddr[pointi].resize_nocopy(pointCount[pointi]);
|
||||
pointCount[pointi] = 0;
|
||||
}
|
||||
|
||||
|
||||
// Step 3: fill in values. Logic as per step 1
|
||||
for (label celli = 0; celli < loopLen; ++celli)
|
||||
{
|
||||
// Clear any previous contents
|
||||
vertices.clear();
|
||||
|
||||
for (const label facei : cellLst[celli])
|
||||
{
|
||||
for (const label pointi : faceLst[facei])
|
||||
{
|
||||
// Only once for each point id
|
||||
if (!vertices.contains(pointi))
|
||||
{
|
||||
vertices.push_back(pointi);
|
||||
pointCellAddr[pointi][pointCount[pointi]++] = celli;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pcPtr_;
|
||||
}
|
||||
|
||||
|
||||
// Calculate with linear lookup and avoid cells::labels
|
||||
autoPtr<labelListList> cellPoints_linear(const polyMesh& mesh)
|
||||
{
|
||||
// Calculate cell-point topology
|
||||
|
||||
auto cpPtr_ = autoPtr<labelListList>::New(mesh.nCells());
|
||||
auto& cellPointAddr = *cpPtr_;
|
||||
|
||||
const cellList& cellLst = mesh.cells();
|
||||
const faceList& faceLst = mesh.faces();
|
||||
|
||||
// Vertex labels for the current cell
|
||||
DynamicList<label> vertices(256);
|
||||
|
||||
const label loopLen = mesh.nCells();
|
||||
|
||||
for (label celli = 0; celli < loopLen; ++celli)
|
||||
{
|
||||
// Clear any previous contents
|
||||
vertices.clear();
|
||||
|
||||
for (const label facei : cellLst[celli])
|
||||
{
|
||||
for (const label pointi : faceLst[facei])
|
||||
{
|
||||
// Only once for each point id
|
||||
if (!vertices.contains(pointi))
|
||||
{
|
||||
vertices.push_back(pointi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cellPointAddr[celli] = vertices; // unsorted
|
||||
}
|
||||
|
||||
return cpPtr_;
|
||||
}
|
||||
|
||||
|
||||
// Calculate point-cell from point-face information
|
||||
autoPtr<labelListList> pointCells_faces(const polyMesh& mesh)
|
||||
{
|
||||
const labelList& own = mesh.faceOwner();
|
||||
const labelList& nei = mesh.faceNeighbour();
|
||||
const labelListList& pFaces = mesh.pointFaces();
|
||||
|
||||
const label loopLen = mesh.nPoints();
|
||||
|
||||
auto pcPtr_ = autoPtr<labelListList>::New(mesh.nPoints());
|
||||
auto& pointCellAddr = *pcPtr_;
|
||||
|
||||
DynamicList<label> storage(256);
|
||||
|
||||
for (label pointi = 0; pointi < loopLen; ++pointi)
|
||||
{
|
||||
// Clear any previous contents
|
||||
storage.clear();
|
||||
|
||||
for (const label facei : pFaces[pointi])
|
||||
{
|
||||
// Owner cell
|
||||
storage.push_back(own[facei]);
|
||||
|
||||
// Neighbour cell
|
||||
if (facei < mesh.nInternalFaces())
|
||||
{
|
||||
storage.push_back(nei[facei]);
|
||||
}
|
||||
}
|
||||
|
||||
// Sort + unique to eliminate duplicates
|
||||
std::sort(storage.begin(), storage.end());
|
||||
auto last = std::unique(storage.begin(), storage.end());
|
||||
storage.resize(label(last - storage.begin()));
|
||||
|
||||
pointCellAddr[pointi] = storage;
|
||||
}
|
||||
|
||||
return pcPtr_;
|
||||
}
|
||||
|
||||
// Calculate point-cell from point-face information
|
||||
autoPtr<labelListList> pointCells_bitSet_faces(const polyMesh& mesh)
|
||||
{
|
||||
const labelList& own = mesh.faceOwner();
|
||||
const labelList& nei = mesh.faceNeighbour();
|
||||
const labelListList& pFaces = mesh.pointFaces();
|
||||
|
||||
const label loopLen = mesh.nPoints();
|
||||
|
||||
auto pcPtr_ = autoPtr<labelListList>::New(mesh.nPoints());
|
||||
auto& pointCellAddr = *pcPtr_;
|
||||
|
||||
// For tracking (only use each cell id once)
|
||||
bitSet usedCells(mesh.nCells());
|
||||
|
||||
DynamicList<label> storage(256);
|
||||
|
||||
for (label pointi = 0; pointi < loopLen; ++pointi)
|
||||
{
|
||||
// Clear any previous contents
|
||||
usedCells.unset(storage);
|
||||
storage.clear();
|
||||
|
||||
for (const label facei : pFaces[pointi])
|
||||
{
|
||||
// Owner cell - only once
|
||||
if (usedCells.set(own[facei]))
|
||||
{
|
||||
storage.push_back(own[facei]);
|
||||
}
|
||||
|
||||
// Neighbour cell
|
||||
if (facei < mesh.nInternalFaces() && usedCells.set(nei[facei]))
|
||||
{
|
||||
storage.push_back(nei[facei]);
|
||||
}
|
||||
}
|
||||
|
||||
pointCellAddr[pointi] = storage;
|
||||
}
|
||||
|
||||
return pcPtr_;
|
||||
}
|
||||
|
||||
|
||||
// Calculate point-cell from cell-point information
|
||||
autoPtr<labelListList> pointCells_bitSet_alon(const polyMesh& mesh)
|
||||
{
|
||||
autoPtr<labelListList> cellPoints = cellPoints_bitSet(mesh);
|
||||
|
||||
auto pcPtr_ = autoPtr<labelListList>::New(mesh.nPoints());
|
||||
|
||||
invertManyToMany(mesh.nPoints(), cellPoints(), *pcPtr_);
|
||||
|
||||
return pcPtr_;
|
||||
}
|
||||
|
||||
|
||||
// Eliminate duplicates with sort+unique
|
||||
autoPtr<labelListList> cellPoints_sorted(const polyMesh& mesh)
|
||||
{
|
||||
// Calculate cell-point topology
|
||||
|
||||
auto cpPtr_ = autoPtr<labelListList>::New(mesh.nCells());
|
||||
auto& cellPointAddr = *cpPtr_;
|
||||
|
||||
const cellList& cellLst = mesh.cells();
|
||||
const faceList& faceLst = mesh.faces();
|
||||
|
||||
// Vertex labels for the current cell
|
||||
DynamicList<label> vertices(256);
|
||||
|
||||
const label loopLen = mesh.nCells();
|
||||
|
||||
for (label celli = 0; celli < loopLen; ++celli)
|
||||
{
|
||||
// Clear any previous contents
|
||||
vertices.clear();
|
||||
|
||||
for (const label facei : cellLst[celli])
|
||||
{
|
||||
for (const label pointi : faceLst[facei])
|
||||
{
|
||||
vertices.push_back(pointi);
|
||||
}
|
||||
}
|
||||
|
||||
// Sort + unique to eliminate duplicates
|
||||
std::sort(vertices.begin(), vertices.end());
|
||||
auto last = std::unique(vertices.begin(), vertices.end());
|
||||
vertices.resize(label(last - vertices.begin()));
|
||||
|
||||
cellPointAddr[celli] = vertices;
|
||||
}
|
||||
|
||||
return cpPtr_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noBanner();
|
||||
argList::noParallel();
|
||||
argList::noFunctionObjects();
|
||||
argList::addOption("nCells", "number", "The number of cells");
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
const scalar cellCount(args.getOrDefault<scalar>("nCells", 1000));
|
||||
|
||||
const label nDivs(::round(::cbrt(cellCount)));
|
||||
|
||||
PDRblock blkMesh(boundBox(zero_one{}), labelVector::uniform(nDivs));
|
||||
|
||||
autoPtr<Time> dummyTimePtr(Time::New());
|
||||
|
||||
Info<< "Requested " << cellCount
|
||||
<< " cells, blockMesh with " << blkMesh.nCells() << " cells" << nl;
|
||||
|
||||
autoPtr<polyMesh> meshPtr = blkMesh.innerMesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Testing",
|
||||
dummyTimePtr->system(),
|
||||
*dummyTimePtr,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
)
|
||||
);
|
||||
|
||||
auto& mesh = meshPtr();
|
||||
|
||||
printInfo(mesh);
|
||||
printAlloc(mesh);
|
||||
|
||||
clockTime timing;
|
||||
|
||||
// pointCells
|
||||
{
|
||||
mesh.clearOut();
|
||||
timing.resetTime();
|
||||
(void) mesh.pointCells();
|
||||
Info<< "pointCells (builtin): " << timing.elapsedTime() << " s" << nl;
|
||||
}
|
||||
|
||||
// cellPoints
|
||||
{
|
||||
mesh.clearOut();
|
||||
timing.resetTime();
|
||||
(void) mesh.cellPoints();
|
||||
Info<< "cellPoints (builtin): " << timing.elapsedTime() << " s" << nl;
|
||||
}
|
||||
Info<< nl;
|
||||
|
||||
|
||||
// pointCells
|
||||
{
|
||||
mesh.clearOut();
|
||||
timing.resetTime();
|
||||
(void) pointCells_2212(mesh);
|
||||
Info<< "pointCells (2212): " << timing.elapsedTime() << " s" << nl;
|
||||
}
|
||||
|
||||
{
|
||||
mesh.clearOut();
|
||||
timing.resetTime();
|
||||
(void) pointCells_2212mod(mesh);
|
||||
Info<< "pointCells (2212mod): " << timing.elapsedTime() << " s" << nl;
|
||||
}
|
||||
|
||||
{
|
||||
mesh.clearOut();
|
||||
timing.resetTime();
|
||||
(void) pointCells_bitSet(mesh);
|
||||
Info<< "pointCells (bitSet): " << timing.elapsedTime() << " s" << nl;
|
||||
}
|
||||
|
||||
{
|
||||
mesh.clearOut();
|
||||
timing.resetTime();
|
||||
(void) pointCells_linear(mesh);
|
||||
Info<< "pointCells (linear): " << timing.elapsedTime() << " s" << nl;
|
||||
}
|
||||
|
||||
{
|
||||
mesh.clearOut();
|
||||
timing.resetTime();
|
||||
(void) pointCells_faces(mesh);
|
||||
Info<< "pointCells (faces): " << timing.elapsedTime() << " s" << nl;
|
||||
}
|
||||
|
||||
{
|
||||
mesh.clearOut();
|
||||
timing.resetTime();
|
||||
(void) pointCells_bitSet_faces(mesh);
|
||||
Info<< "pointCells (bitSet faces): " << timing.elapsedTime() << " s" << nl;
|
||||
}
|
||||
|
||||
{
|
||||
mesh.clearOut();
|
||||
timing.resetTime();
|
||||
(void) pointCells_bitSet_alon(mesh);
|
||||
Info<< "pointCells (bitSet alon): " << timing.elapsedTime() << " s" << nl;
|
||||
}
|
||||
|
||||
// cellPoints
|
||||
{
|
||||
mesh.clearOut();
|
||||
timing.resetTime();
|
||||
(void) cellPoints_2212(mesh);
|
||||
Info<< "cellPoints (2212): " << timing.elapsedTime() << " s" << nl;
|
||||
}
|
||||
|
||||
{
|
||||
mesh.clearOut();
|
||||
timing.resetTime();
|
||||
(void) cellPoints_bitSet(mesh);
|
||||
Info<< "cellPoints (bitSet): " << timing.elapsedTime() << " s" << nl;
|
||||
}
|
||||
|
||||
{
|
||||
mesh.clearOut();
|
||||
timing.resetTime();
|
||||
(void) cellPoints_linear(mesh);
|
||||
Info<< "cellPoints (linear): " << timing.elapsedTime() << " s" << nl;
|
||||
}
|
||||
|
||||
{
|
||||
mesh.clearOut();
|
||||
timing.resetTime();
|
||||
(void) cellPoints_sorted(mesh);
|
||||
Info<< "cellPoints (sorted): " << timing.elapsedTime() << " s" << nl;
|
||||
}
|
||||
|
||||
|
||||
// With precalculated values
|
||||
{
|
||||
mesh.clearOut();
|
||||
const auto& cp = mesh.cellPoints();
|
||||
timing.resetTime();
|
||||
|
||||
auto pcPtr_ = autoPtr<labelListList>::New(mesh.nPoints());
|
||||
|
||||
invertManyToMany(mesh.nPoints(), cp, *pcPtr_);
|
||||
|
||||
Info<< "pointCells (from cached cellPoints): " << timing.elapsedTime() << " s" << nl;
|
||||
}
|
||||
|
||||
// With precalculated values
|
||||
{
|
||||
mesh.clearOut();
|
||||
(void)mesh.pointFaces();
|
||||
timing.resetTime();
|
||||
|
||||
(void) pointCells_bitSet_faces(mesh);
|
||||
|
||||
Info<< "pointCells (bitSet from cached pointFaces): " << timing.elapsedTime() << " s" << nl;
|
||||
}
|
||||
|
||||
|
||||
// With precalculated values
|
||||
{
|
||||
mesh.clearOut();
|
||||
const auto& pc = mesh.pointCells();
|
||||
timing.resetTime();
|
||||
|
||||
auto cpPtr_ = autoPtr<labelListList>::New(mesh.nCells());
|
||||
|
||||
invertManyToMany(mesh.nCells(), pc, *cpPtr_);
|
||||
|
||||
Info<< "cellPoints (from cached pointCells): " << timing.elapsedTime() << " s" << nl;
|
||||
}
|
||||
|
||||
|
||||
// Re-measure timings
|
||||
Info<< nl;
|
||||
{
|
||||
mesh.clearOut();
|
||||
timing.resetTime();
|
||||
(void) mesh.pointCells();
|
||||
Info<< "pointCells (builtin): " << timing.elapsedTime() << " s" << nl;
|
||||
}
|
||||
|
||||
{
|
||||
mesh.clearOut();
|
||||
timing.resetTime();
|
||||
(void) mesh.cellPoints();
|
||||
Info<< "cellPoints (builtin): " << timing.elapsedTime() << " s" << nl;
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << nl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -88,7 +88,8 @@ int main(int argc, char *argv[])
|
||||
// Info<<"tree-bb faces: " << treeBoundBox::faces << nl
|
||||
// <<"tree-bb edges: " << treeBoundBox::edges << endl;
|
||||
|
||||
treeBoundBox bb(zero_one{});
|
||||
treeBoundBox bb;
|
||||
bb = cube(0, 1);
|
||||
|
||||
triPoints tri;
|
||||
tri.a() = point(-0.1, 0.5, 0.5);
|
||||
|
||||
@ -130,7 +130,9 @@ OptimisationSwitches
|
||||
// Number processors to change to tree communication
|
||||
nProcsSimpleSum 0;
|
||||
// Min numProc to use non-blocking exchange algorithm (Hoeffler: NBX)
|
||||
nonBlockingExchange 0;
|
||||
nonBlockingExchange 1;
|
||||
// Use hybrid NBX/PEX for PstreamBuffers
|
||||
pbufs.algorithm 0;
|
||||
|
||||
// MPI buffer size (bytes)
|
||||
// Can override with the MPI_BUFFER_SIZE env variable.
|
||||
|
||||
@ -173,10 +173,6 @@ public:
|
||||
//- (discard old element at that location).
|
||||
//- Return reference to the new list element.
|
||||
template<class... Args>
|
||||
inline T& emplace_set(const label i, Args&&... args);
|
||||
|
||||
//- Same as emplace_set()
|
||||
template<class... Args>
|
||||
inline T& emplace(const label i, Args&&... args);
|
||||
|
||||
//- Set element to given pointer and return old element (can be null)
|
||||
|
||||
@ -172,17 +172,11 @@ inline void Foam::PtrList<T>::push_back(PtrList<T>&& other)
|
||||
|
||||
template<class T>
|
||||
template<class... Args>
|
||||
inline T& Foam::PtrList<T>::emplace_set(const label i, Args&&... args)
|
||||
{
|
||||
T* ptr = new T(std::forward<Args>(args)...);
|
||||
(void)this->set(i, ptr);
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
template<class... Args>
|
||||
inline T& Foam::PtrList<T>::emplace(const label i, Args&&... args)
|
||||
inline T& Foam::PtrList<T>::emplace
|
||||
(
|
||||
const label i,
|
||||
Args&&... args
|
||||
)
|
||||
{
|
||||
T* ptr = new T(std::forward<Args>(args)...);
|
||||
(void)this->set(i, ptr);
|
||||
|
||||
@ -27,7 +27,6 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "PstreamBuffers.H"
|
||||
#include "bitSet.H"
|
||||
#include "debug.H"
|
||||
#include "registerSwitch.H"
|
||||
|
||||
@ -36,7 +35,7 @@ License
|
||||
int Foam::PstreamBuffers::algorithm
|
||||
(
|
||||
// Not really the most creative name...
|
||||
Foam::debug::optimisationSwitch("pbufs.algorithm", -1)
|
||||
Foam::debug::optimisationSwitch("pbufs.algorithm", 0)
|
||||
);
|
||||
registerOptSwitch
|
||||
(
|
||||
@ -134,8 +133,7 @@ void Foam::PstreamBuffers::finalExchange
|
||||
|
||||
void Foam::PstreamBuffers::finalExchange
|
||||
(
|
||||
const labelUList& sendProcs,
|
||||
const labelUList& recvProcs,
|
||||
const labelUList& neighProcs,
|
||||
const bool wait,
|
||||
labelList& recvSizes
|
||||
)
|
||||
@ -155,7 +153,7 @@ void Foam::PstreamBuffers::finalExchange
|
||||
// Preserve self-send, even if not described by neighbourhood
|
||||
recvSizes[UPstream::myProcNo(comm_)] = 1;
|
||||
|
||||
for (const label proci : sendProcs)
|
||||
for (const label proci : neighProcs)
|
||||
{
|
||||
recvSizes[proci] = 1; // Connected
|
||||
}
|
||||
@ -172,8 +170,7 @@ void Foam::PstreamBuffers::finalExchange
|
||||
// PEX stage 1: exchange sizes (limited neighbourhood)
|
||||
Pstream::exchangeSizes
|
||||
(
|
||||
sendProcs,
|
||||
recvProcs,
|
||||
neighProcs,
|
||||
sendBuffers_,
|
||||
recvSizes,
|
||||
tag_,
|
||||
@ -626,7 +623,7 @@ void Foam::PstreamBuffers::finishedNeighbourSends
|
||||
const bool wait
|
||||
)
|
||||
{
|
||||
finalExchange(neighProcs, neighProcs, wait, recvSizes);
|
||||
finalExchange(neighProcs, wait, recvSizes);
|
||||
}
|
||||
|
||||
|
||||
@ -637,71 +634,7 @@ void Foam::PstreamBuffers::finishedNeighbourSends
|
||||
)
|
||||
{
|
||||
labelList recvSizes;
|
||||
finalExchange(neighProcs, neighProcs, wait, recvSizes);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::PstreamBuffers::finishedSends
|
||||
(
|
||||
bitSet& sendConnections,
|
||||
DynamicList<label>& sendProcs,
|
||||
DynamicList<label>& recvProcs,
|
||||
const bool wait
|
||||
)
|
||||
{
|
||||
bool changed = (sendConnections.size() != nProcs());
|
||||
|
||||
if (changed)
|
||||
{
|
||||
sendConnections.resize(nProcs());
|
||||
}
|
||||
|
||||
// Update send connections
|
||||
forAll(sendBuffers_, proci)
|
||||
{
|
||||
if (sendConnections.set(proci, !sendBuffers_[proci].empty()))
|
||||
{
|
||||
// The state changed
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
UPstream::reduceOr(changed, comm_);
|
||||
|
||||
if (changed)
|
||||
{
|
||||
// Update send/recv topology
|
||||
labelList recvSizes;
|
||||
finishedSends(recvSizes, wait); // eg, using all-to-all
|
||||
|
||||
// The send ranks
|
||||
sendProcs.clear();
|
||||
forAll(sendBuffers_, proci)
|
||||
{
|
||||
if (!sendBuffers_[proci].empty())
|
||||
{
|
||||
sendProcs.push_back(proci);
|
||||
}
|
||||
}
|
||||
|
||||
// The recv ranks
|
||||
recvProcs.clear();
|
||||
forAll(recvSizes, proci)
|
||||
{
|
||||
if (recvSizes[proci] > 0)
|
||||
{
|
||||
recvProcs.push_back(proci);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use existing send/recv ranks
|
||||
labelList recvSizes;
|
||||
finalExchange(sendProcs, recvProcs, wait, recvSizes);
|
||||
}
|
||||
|
||||
return changed;
|
||||
finalExchange(neighProcs, wait, recvSizes);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -108,9 +108,6 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward Declarations
|
||||
class bitSet;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class PstreamBuffers Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -168,8 +165,7 @@ class PstreamBuffers
|
||||
// (nonBlocking comms).
|
||||
void finalExchange
|
||||
(
|
||||
const labelUList& sendProcs,
|
||||
const labelUList& recvProcs,
|
||||
const labelUList& neighProcs,
|
||||
const bool wait,
|
||||
labelList& recvSizes
|
||||
);
|
||||
@ -435,25 +431,6 @@ public:
|
||||
const bool wait = true
|
||||
);
|
||||
|
||||
//- A caching version that uses a limited send/recv connectivity.
|
||||
//
|
||||
// Non-blocking mode: populates receive buffers.
|
||||
// \param sendConnections on/off for sending ranks
|
||||
// \param sendProcs ranks used for sends
|
||||
// \param recvProcs ranks used for recvs
|
||||
// \param wait wait for requests to complete (in nonBlocking mode)
|
||||
//
|
||||
// \return True if the send/recv connectivity changed
|
||||
//
|
||||
// \warning currently only valid for nonBlocking comms.
|
||||
bool finishedSends
|
||||
(
|
||||
bitSet& sendConnections,
|
||||
DynamicList<label>& sendProcs,
|
||||
DynamicList<label>& recvProcs,
|
||||
const bool wait = true
|
||||
);
|
||||
|
||||
|
||||
// Gather/scatter modes
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -163,9 +163,6 @@ public:
|
||||
//- Construct a bounding box containing a single initial point
|
||||
inline explicit boundBox(const point& p);
|
||||
|
||||
//- Construct a 0/1 unit bounding box
|
||||
inline explicit boundBox(const Foam::zero_one);
|
||||
|
||||
//- Construct from bound box min/max points
|
||||
inline boundBox(const point& min, const point& max);
|
||||
|
||||
@ -294,9 +291,6 @@ public:
|
||||
//- Reset to an inverted box
|
||||
inline void reset();
|
||||
|
||||
//- Reset to a 0/1 unit bounding box
|
||||
inline void reset(const Foam::zero_one);
|
||||
|
||||
//- Reset min/max to be identical to the specified point
|
||||
inline void reset(const point& pt);
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -112,13 +112,6 @@ inline Foam::boundBox::boundBox()
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::boundBox::boundBox(const Foam::zero_one)
|
||||
:
|
||||
min_(point::zero),
|
||||
max_(point::one)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::boundBox::boundBox(const point& p)
|
||||
:
|
||||
min_(p),
|
||||
@ -306,13 +299,6 @@ inline void Foam::boundBox::reset()
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::boundBox::reset(const Foam::zero_one)
|
||||
{
|
||||
min_ = point::zero;
|
||||
max_ = point::one;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::boundBox::reset(const point& pt)
|
||||
{
|
||||
min_ = pt;
|
||||
|
||||
@ -34,8 +34,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Foam_ijkAddressing_H
|
||||
#define Foam_ijkAddressing_H
|
||||
#ifndef ijkAddressing_H
|
||||
#define ijkAddressing_H
|
||||
|
||||
#include "labelVector.H"
|
||||
#include "vector.H"
|
||||
|
||||
@ -38,8 +38,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Foam_ijkMesh_H
|
||||
#define Foam_ijkMesh_H
|
||||
#ifndef ijkMesh_H
|
||||
#define ijkMesh_H
|
||||
|
||||
#include "ijkAddressing.H"
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -201,9 +201,6 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct a 0/1 unit bounding box
|
||||
inline explicit treeBoundBox(const Foam::zero_one);
|
||||
|
||||
//- Construct a bounding box containing a single initial point
|
||||
inline explicit treeBoundBox(const point& p);
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -31,12 +31,6 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::treeBoundBox::treeBoundBox(const Foam::zero_one)
|
||||
:
|
||||
boundBox(zero_one{})
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::treeBoundBox::treeBoundBox(const point& p)
|
||||
:
|
||||
boundBox(p)
|
||||
|
||||
@ -109,9 +109,7 @@ void Foam::zoneDistribute::setUpCommforZone
|
||||
}
|
||||
}
|
||||
|
||||
// Stream the send data into PstreamBuffers,
|
||||
// which we also use to track the current topology.
|
||||
|
||||
// Stream the send data into PstreamBuffers
|
||||
pBufs_.clear();
|
||||
|
||||
for (const int proci : pBufs_.allProcs())
|
||||
@ -126,7 +124,7 @@ void Foam::zoneDistribute::setUpCommforZone
|
||||
}
|
||||
}
|
||||
|
||||
pBufs_.finishedSends(sendConnections_, sendProcs_, recvProcs_);
|
||||
pBufs_.finishedSends();
|
||||
|
||||
for (const int proci : pBufs_.allProcs())
|
||||
{
|
||||
|
||||
@ -93,15 +93,6 @@ class zoneDistribute
|
||||
//- Global cell/face index to send for processor-to-processor comms
|
||||
List<labelList> send_;
|
||||
|
||||
//- Parallel [cache]: send connectivity (true/false)
|
||||
bitSet sendConnections_;
|
||||
|
||||
//- Parallel [cache]: send data to these ranks
|
||||
DynamicList<label> sendProcs_;
|
||||
|
||||
//- Parallel [cache]: recv data from these ranks
|
||||
DynamicList<label> recvProcs_;
|
||||
|
||||
//- Persistent set of exchange buffers
|
||||
PstreamBuffers pBufs_;
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2020 DLR
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -161,18 +161,6 @@ Foam::Map<Type> Foam::zoneDistribute::getDatafromOtherProc
|
||||
|
||||
if (UPstream::parRun())
|
||||
{
|
||||
if (sendConnections_.empty())
|
||||
{
|
||||
WarningInFunction
|
||||
<< "The send/recv connections not initialized - "
|
||||
<< "likely that setUpCommforZone() was not called"
|
||||
<< endl;
|
||||
// But don't exit/abort for now
|
||||
}
|
||||
|
||||
// Stream the send data into PstreamBuffers,
|
||||
// which we also use to track the current topology.
|
||||
|
||||
pBufs_.clear();
|
||||
|
||||
for (const int proci : pBufs_.allProcs())
|
||||
@ -198,7 +186,7 @@ Foam::Map<Type> Foam::zoneDistribute::getDatafromOtherProc
|
||||
}
|
||||
}
|
||||
|
||||
pBufs_.finishedSends(sendConnections_, sendProcs_, recvProcs_);
|
||||
pBufs_.finishedSends();
|
||||
|
||||
for (const int proci : pBufs_.allProcs())
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -114,22 +114,6 @@ const Foam::PDRblock& Foam::PDRblock::null()
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::PDRblock::addDefaultPatches()
|
||||
{
|
||||
// Default boundaries with patchi == shapeFacei
|
||||
patches_.resize(6);
|
||||
for (label patchi=0; patchi < 6; ++patchi)
|
||||
{
|
||||
boundaryEntry& bentry = patches_.emplace_set(patchi);
|
||||
|
||||
bentry.name_ = "patch" + Foam::name(patchi);
|
||||
bentry.type_ = "patch";
|
||||
bentry.size_ = 0;
|
||||
bentry.faces_ = labelList(one{}, patchi);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::PDRblock::adjustSizes()
|
||||
{
|
||||
// Adjust i-j-k addressing
|
||||
@ -454,7 +438,9 @@ void Foam::PDRblock::readBoundary(const dictionary& dict)
|
||||
|
||||
// Save information for later access during mesh creation.
|
||||
|
||||
boundaryEntry& bentry = patches_.emplace_set(patchi);
|
||||
patches_.set(patchi, new boundaryEntry());
|
||||
|
||||
boundaryEntry& bentry = patches_[patchi];
|
||||
|
||||
bentry.name_ = patchName;
|
||||
bentry.type_ = patchType;
|
||||
@ -476,7 +462,9 @@ void Foam::PDRblock::readBoundary(const dictionary& dict)
|
||||
|
||||
if (missed.size())
|
||||
{
|
||||
boundaryEntry& bentry = patches_.emplace_back();
|
||||
patches_.append(new boundaryEntry());
|
||||
|
||||
boundaryEntry& bentry = patches_.last();
|
||||
|
||||
bentry.name_ = "defaultFaces";
|
||||
bentry.type_ = emptyPolyPatch::typeName;
|
||||
@ -535,20 +523,24 @@ Foam::PDRblock::PDRblock
|
||||
:
|
||||
PDRblock(dictionary::null, false)
|
||||
{
|
||||
addDefaultPatches();
|
||||
// Default boundaries with patchi == shapeFacei
|
||||
patches_.resize(6);
|
||||
for (label patchi=0; patchi < 6; ++patchi)
|
||||
{
|
||||
patches_.set(patchi, new boundaryEntry());
|
||||
|
||||
boundaryEntry& bentry = patches_[patchi];
|
||||
|
||||
bentry.name_ = "patch" + Foam::name(patchi);
|
||||
bentry.type_ = "patch";
|
||||
bentry.size_ = 0;
|
||||
bentry.faces_ = labelList(one{}, patchi);
|
||||
}
|
||||
|
||||
reset(xgrid, ygrid, zgrid);
|
||||
}
|
||||
|
||||
|
||||
Foam::PDRblock::PDRblock(const boundBox& box, const labelVector& nCells)
|
||||
:
|
||||
PDRblock(dictionary::null, false)
|
||||
{
|
||||
addDefaultPatches();
|
||||
reset(box, nCells);
|
||||
}
|
||||
|
||||
|
||||
Foam::PDRblock::PDRblock(const dictionary& dict, bool verboseOutput)
|
||||
:
|
||||
ijkMesh(),
|
||||
@ -639,28 +631,6 @@ void Foam::PDRblock::reset
|
||||
}
|
||||
|
||||
|
||||
void Foam::PDRblock::reset(const boundBox& box, const labelVector& nCells)
|
||||
{
|
||||
grid_.x().reset(box.min().x(), box.max().x(), nCells.x());
|
||||
grid_.y().reset(box.min().y(), box.max().y(), nCells.y());
|
||||
grid_.z().reset(box.min().z(), box.max().z(), nCells.z());
|
||||
|
||||
adjustSizes();
|
||||
|
||||
// Adjust boundaries
|
||||
for (boundaryEntry& bentry : patches_)
|
||||
{
|
||||
bentry.size_ = 0;
|
||||
|
||||
// Count patch faces
|
||||
for (const label shapeFacei : bentry.faces_)
|
||||
{
|
||||
bentry.size_ += nBoundaryFaces(shapeFacei);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::PDRblock::findCell(const point& pt, labelVector& pos) const
|
||||
{
|
||||
// Out-of-bounds is handled explicitly, for efficiency and consistency,
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -65,8 +65,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Foam_PDRblock_H
|
||||
#define Foam_PDRblock_H
|
||||
#ifndef PDRblock_H
|
||||
#define PDRblock_H
|
||||
|
||||
#include "ijkMesh.H"
|
||||
#include "boundBox.H"
|
||||
@ -122,9 +122,6 @@ public:
|
||||
{
|
||||
public:
|
||||
|
||||
//- Reset with min/max range and number of divisions
|
||||
void reset(const scalar low, const scalar upp, const label nCells);
|
||||
|
||||
//- The location list is valid if it contains 2 or more points
|
||||
inline bool valid() const;
|
||||
|
||||
@ -341,9 +338,6 @@ private:
|
||||
const UList<scalar>& pts
|
||||
);
|
||||
|
||||
//- Add zero-sized patches with default naming/types
|
||||
void addDefaultPatches();
|
||||
|
||||
//- Adjust sizing for updated grid points
|
||||
void adjustSizes();
|
||||
|
||||
@ -446,9 +440,6 @@ public:
|
||||
const UList<scalar>& zgrid
|
||||
);
|
||||
|
||||
//- Construct from cube with specified griding
|
||||
PDRblock(const boundBox& box, const labelVector& nCells);
|
||||
|
||||
//- Construct from dictionary
|
||||
explicit PDRblock(const dictionary& dict, bool verboseOutput=false);
|
||||
|
||||
@ -466,14 +457,11 @@ public:
|
||||
const UList<scalar>& zgrid
|
||||
);
|
||||
|
||||
//- Reset cube and mesh i-j-k sizing
|
||||
void reset(const boundBox& box, const labelVector& nCells);
|
||||
|
||||
|
||||
// Access
|
||||
|
||||
//- The grid point locations in the i,j,k (x,y,z) directions.
|
||||
const Vector<location>& grid() const noexcept { return grid_; }
|
||||
inline const Vector<location>& grid() const;
|
||||
|
||||
//- Equivalent edge grading descriptors in (x,y,z) directions.
|
||||
Vector<gradingDescriptors> grading() const;
|
||||
@ -488,10 +476,10 @@ public:
|
||||
using ijkMesh::sizes;
|
||||
|
||||
//- The mesh bounding box
|
||||
const boundBox& bounds() const noexcept { return bounds_; }
|
||||
inline const boundBox& bounds() const;
|
||||
|
||||
//- The min/max edge length
|
||||
const scalarMinMax& edgeLimits() const noexcept { return edgeLimits_; }
|
||||
inline const scalarMinMax& edgeLimits() const;
|
||||
|
||||
//- Cell size in x-direction at i position.
|
||||
inline scalar dx(const label i) const;
|
||||
|
||||
@ -252,7 +252,7 @@ Foam::Ostream& Foam::PDRblock::blockMeshDict
|
||||
*dummyTimePtr,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false // no register
|
||||
)
|
||||
);
|
||||
|
||||
@ -375,7 +375,7 @@ Foam::Ostream& Foam::PDRblock::blockMeshDict
|
||||
*dummyTimePtr,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false // do not register
|
||||
);
|
||||
|
||||
searchableSphere sphere(io, radialCentre, radialSizes);
|
||||
@ -796,7 +796,7 @@ void Foam::PDRblock::writeBlockMeshDict(const IOobject& io) const
|
||||
io.db(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false // no register
|
||||
)
|
||||
);
|
||||
|
||||
@ -831,7 +831,7 @@ Foam::PDRblock::createBlockMesh(const IOobject& io) const
|
||||
io.db(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false // no register
|
||||
),
|
||||
blockMeshDict()
|
||||
);
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -48,31 +48,31 @@ inline Foam::label Foam::PDRblock::location::nPoints() const
|
||||
|
||||
inline bool Foam::PDRblock::location::contains(const scalar p) const
|
||||
{
|
||||
return (scalarList::size() > 1 && front() <= p && p <= back());
|
||||
return (scalarList::size() > 1 && first() <= p && p <= last());
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::scalar& Foam::PDRblock::location::min() const
|
||||
{
|
||||
return scalarList::empty() ? pTraits<scalar>::rootMax : front();
|
||||
return scalarList::empty() ? pTraits<scalar>::rootMax : first();
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::scalar& Foam::PDRblock::location::max() const
|
||||
{
|
||||
return scalarList::empty() ? pTraits<scalar>::rootMin : back();
|
||||
return scalarList::empty() ? pTraits<scalar>::rootMin : last();
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::PDRblock::location::centre() const
|
||||
{
|
||||
return scalarList::empty() ? 0 : (0.5*front() + 0.5*back());
|
||||
return scalarList::empty() ? 0 : (0.5*first() + 0.5*last());
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::PDRblock::location::length() const
|
||||
{
|
||||
return scalarList::empty() ? 0 : mag(back() - front());
|
||||
return scalarList::empty() ? 0 : mag(last() - first());
|
||||
}
|
||||
|
||||
|
||||
@ -107,12 +107,12 @@ inline Foam::scalar Foam::PDRblock::location::C(const label i) const
|
||||
#endif
|
||||
|
||||
// "Halo" centre [-1] == x0 - 1/2 (x1 - x0)
|
||||
return front() - 0.5*(operator[](1) - front());
|
||||
return first() - 0.5*(operator[](1) - first());
|
||||
}
|
||||
else if (i > 1 && i == scalarList::size()-1)
|
||||
{
|
||||
// "Halo" centre [nCells] == xN + 1/2 (xN - xN1)
|
||||
return back() + 0.5*(back() - operator[](scalarList::size()-2));
|
||||
return last() + 0.5*(last() - operator[](scalarList::size()-2));
|
||||
}
|
||||
|
||||
#ifdef FULLDEBUG
|
||||
@ -128,13 +128,13 @@ Foam::PDRblock::location::clip(const scalar& val) const
|
||||
{
|
||||
if (scalarList::size())
|
||||
{
|
||||
if (val < front())
|
||||
if (val < first())
|
||||
{
|
||||
return front();
|
||||
return first();
|
||||
}
|
||||
else if (back() < val)
|
||||
else if (last() < val)
|
||||
{
|
||||
return back();
|
||||
return last();
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,6 +144,25 @@ Foam::PDRblock::location::clip(const scalar& val) const
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline const Foam::Vector<Foam::PDRblock::location>&
|
||||
Foam::PDRblock::grid() const
|
||||
{
|
||||
return grid_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::scalarMinMax& Foam::PDRblock::edgeLimits() const
|
||||
{
|
||||
return edgeLimits_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::boundBox& Foam::PDRblock::bounds() const
|
||||
{
|
||||
return bounds_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::PDRblock::dx(const label i) const
|
||||
{
|
||||
return grid_.x().width(i);
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -260,29 +260,6 @@ void Foam::PDRblock::gridControl::writeDict
|
||||
}
|
||||
|
||||
|
||||
void Foam::PDRblock::location::reset
|
||||
(
|
||||
const scalar low,
|
||||
const scalar upp,
|
||||
const label nCells
|
||||
)
|
||||
{
|
||||
scalarList& grid = *this;
|
||||
|
||||
grid.resize_nocopy(nCells+1);
|
||||
|
||||
grid.front() = low;
|
||||
grid.back() = upp;
|
||||
|
||||
const scalar span = (upp - low);
|
||||
|
||||
for (label pointi = 1; pointi < nCells; ++pointi)
|
||||
{
|
||||
grid[pointi] = low + (pointi*span)/nCells;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::scalarMinMax Foam::PDRblock::location::edgeLimits() const
|
||||
{
|
||||
scalarMinMax limits;
|
||||
|
||||
Reference in New Issue
Block a user