From 820f93c3b4cde81fe4c99366577bc4e655b38878 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 3 Mar 2023 12:27:44 +0100 Subject: [PATCH] ENH: simplify box mesh construction (PDRblockMesh) ENH: construct or reset boundBox from zero_one for a 0-1 unit cube ENH: add some testing timings (for !596 and #2715) --- applications/test/boundBox2/Test-boundBox2.C | 2 +- .../test/polyMeshGeom-speed1/Make/files | 3 + .../test/polyMeshGeom-speed1/Make/options | 5 + .../Test-polyMeshGeom-speed1.C | 804 ++++++++++++++++++ .../Test-triangleIntersection.C | 3 +- src/OpenFOAM/meshes/boundBox/boundBox.H | 8 +- src/OpenFOAM/meshes/boundBox/boundBoxI.H | 16 +- src/OpenFOAM/meshes/ijkMesh/ijkAddressing.H | 4 +- src/OpenFOAM/meshes/ijkMesh/ijkMesh.H | 4 +- .../meshes/treeBoundBox/treeBoundBox.H | 5 +- .../meshes/treeBoundBox/treeBoundBoxI.H | 8 +- src/mesh/blockMesh/PDRblockMesh/PDRblock.C | 72 +- src/mesh/blockMesh/PDRblockMesh/PDRblock.H | 24 +- .../PDRblockMesh/PDRblockBlockMesh.C | 8 +- src/mesh/blockMesh/PDRblockMesh/PDRblockI.H | 43 +- .../blockMesh/PDRblockMesh/PDRblockLocation.C | 25 +- 16 files changed, 960 insertions(+), 74 deletions(-) create mode 100644 applications/test/polyMeshGeom-speed1/Make/files create mode 100644 applications/test/polyMeshGeom-speed1/Make/options create mode 100644 applications/test/polyMeshGeom-speed1/Test-polyMeshGeom-speed1.C diff --git a/applications/test/boundBox2/Test-boundBox2.C b/applications/test/boundBox2/Test-boundBox2.C index 3c88e70d51..4d929dd7a4 100644 --- a/applications/test/boundBox2/Test-boundBox2.C +++ b/applications/test/boundBox2/Test-boundBox2.C @@ -143,7 +143,7 @@ int main(int argc, char *argv[]) { #include "setRootCase.H" - treeBoundBox bb(cube(0, 1)); + treeBoundBox bb(zero_one{}); treeBoundBox sub(cube(0.1, 0.8)); Info<< nl diff --git a/applications/test/polyMeshGeom-speed1/Make/files b/applications/test/polyMeshGeom-speed1/Make/files new file mode 100644 index 0000000000..e6c64cc479 --- /dev/null +++ b/applications/test/polyMeshGeom-speed1/Make/files @@ -0,0 +1,3 @@ +Test-polyMeshGeom-speed1.C + +EXE = $(FOAM_USER_APPBIN)/Test-polyMeshGeom-speed1 diff --git a/applications/test/polyMeshGeom-speed1/Make/options b/applications/test/polyMeshGeom-speed1/Make/options new file mode 100644 index 0000000000..b4f99e5295 --- /dev/null +++ b/applications/test/polyMeshGeom-speed1/Make/options @@ -0,0 +1,5 @@ +EXE_INC = \ + -I$(LIB_SRC)/mesh/blockMesh/lnInclude + +EXE_LIBS = \ + -lblockMesh diff --git a/applications/test/polyMeshGeom-speed1/Test-polyMeshGeom-speed1.C b/applications/test/polyMeshGeom-speed1/Test-polyMeshGeom-speed1.C new file mode 100644 index 0000000000..4c268797dd --- /dev/null +++ b/applications/test/polyMeshGeom-speed1/Test-polyMeshGeom-speed1.C @@ -0,0 +1,804 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +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 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::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