diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C index c2de2091d6..ad3db870f4 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C @@ -167,7 +167,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement() { if (volumeStatus[celli] == volumeType::UNKNOWN) { - treeBoundBox cellBb(mesh_.cells()[celli].box(mesh_)); + treeBoundBox cellBb(mesh_.cellBb(celli)); if (geometry.overlaps(cellBb)) { @@ -279,7 +279,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement() { if (volumeStatus[celli] == volumeType::UNKNOWN) { - treeBoundBox cellBb(mesh_.cells()[celli].box(mesh_)); + treeBoundBox cellBb(mesh_.cellBb(celli)); if (geometry.overlaps(cellBb)) { @@ -498,7 +498,7 @@ bool Foam::backgroundMeshDecomposition::refineCell // const conformationSurfaces& geometry = geometryToConformTo_; - treeBoundBox cellBb(mesh_.cells()[celli].box(mesh_)); + treeBoundBox cellBb(mesh_.cellBb(celli)); weightEstimate = 1.0; diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H index b369cdc68b..944cdb5367 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -71,6 +71,7 @@ namespace Foam // Forward Declarations class bitSet; +class boundBox; /*---------------------------------------------------------------------------*\ Class primitiveMesh Declaration @@ -769,6 +770,9 @@ public: // Useful derived info + //- The bounding box for given cell index + boundBox cellBb(const label celli) const; + //- Return true if the point in the cell bounding box. // The bounding box may be isotropically inflated by the fraction // inflationFraction @@ -779,7 +783,7 @@ public: scalar inflationFraction = 0 ) const; - //- Return true if the point is in the cell + //- Return true if the point is in the cell bool pointInCell(const point& p, label celli) const; //- Find the cell with the nearest cell centre to location diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFindCell.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFindCell.C index b26e01a3f7..8fe7f8a7a6 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFindCell.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFindCell.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2017 OpenCFD Ltd. + Copyright (C) 2017-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,6 +32,18 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +Foam::boundBox Foam::primitiveMesh::cellBb(const label celli) const +{ + if (hasCellPoints()) + { + // No reduction! + return boundBox(points(), cellPoints()[celli], false); + } + + return boundBox(cells()[celli].box(points(), faces())); +} + + bool Foam::primitiveMesh::pointInCellBB ( const point& p, @@ -39,15 +51,7 @@ bool Foam::primitiveMesh::pointInCellBB scalar inflationFraction ) const { - boundBox bb - ( - cells()[celli].points - ( - faces(), - points() - ), - false - ); + boundBox bb(cellBb(celli)); if (inflationFraction > SMALL) { diff --git a/src/functionObjects/randomProcesses/energySpectrum/energySpectrum.C b/src/functionObjects/randomProcesses/energySpectrum/energySpectrum.C index 13074535a0..045fce032d 100644 --- a/src/functionObjects/randomProcesses/energySpectrum/energySpectrum.C +++ b/src/functionObjects/randomProcesses/energySpectrum/energySpectrum.C @@ -150,13 +150,7 @@ bool Foam::functionObjects::energySpectrum::read(const dictionary& dict) const boundBox meshBb(mesh_.bounds()); // Assume all cells are the same size... - const cell& c = mesh_.cells()[0]; - boundBox cellBb(boundBox::invertedBox); - forAll(c, facei) - { - const face& f = mesh_.faces()[c[facei]]; - cellBb.add(mesh_.points(), f); - } + boundBox cellBb(mesh_.cellBb(0)); const vector L(meshBb.max() - meshBb.min()); const vector nCellXYZ(cmptDivide(L, cellBb.max() - cellBb.min())); diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyVoxelMeshDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyVoxelMeshDriver.C index d962bec77a..fa92a2fe51 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyVoxelMeshDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyVoxelMeshDriver.C @@ -133,9 +133,9 @@ void Foam::snappyVoxelMeshDriver::isInside } else { - for (const cell& c : mesh.cells()) + for (label celli = 0; celli < mesh.nCells(); ++celli) { - const boundBox cellBb(c.box(mesh)); + const boundBox cellBb(mesh.cellBb(celli)); voxelMeshSearch::fill ( diff --git a/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C b/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C index 962b8ac1db..37fea38605 100644 --- a/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C +++ b/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C @@ -236,20 +236,6 @@ void Foam::cellCellStencils::inverseDistance::markBoundaries } -Foam::treeBoundBox Foam::cellCellStencils::inverseDistance::cellBb -( - const primitiveMesh& mesh, - const label celli -) -{ - if (mesh.hasCellPoints()) - { - return treeBoundBox(mesh.points(), mesh.cellPoints(celli)); - } - return treeBoundBox(mesh.cells()[celli].box(mesh)); -} - - bool Foam::cellCellStencils::inverseDistance::overlaps ( const boundBox& bb, @@ -326,7 +312,7 @@ void Foam::cellCellStencils::inverseDistance::markPatchesAsHoles forAll(tgtCellMap, tgtCelli) { label celli = tgtCellMap[tgtCelli]; - treeBoundBox cBb(cellBb(mesh_, celli)); + treeBoundBox cBb(mesh_.cellBb(celli)); cBb.min() -= smallVec_; cBb.max() += smallVec_; @@ -396,9 +382,10 @@ void Foam::cellCellStencils::inverseDistance::markPatchesAsHoles forAll(tgtCellMap, tgtCelli) { label celli = tgtCellMap[tgtCelli]; - treeBoundBox cBb(cellBb(mesh_, celli)); + treeBoundBox cBb(mesh_.cellBb(celli)); cBb.min() -= smallVec_; cBb.max() += smallVec_; + if ( overlaps @@ -554,7 +541,7 @@ void Foam::cellCellStencils::inverseDistance::markDonors label celli = tgtCellMap[tgtCelli]; if (srcOverlapProcs.size()) { - treeBoundBox subBb(cellBb(mesh_, celli)); + treeBoundBox subBb(mesh_.cellBb(celli)); subBb.min() -= smallVec_; subBb.max() += smallVec_; diff --git a/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.H b/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.H index 99ae3c184f..aad9cc8160 100644 --- a/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.H +++ b/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.H @@ -179,13 +179,6 @@ protected: labelList& patchCellTypes ); - //- Calculate bounding box of cell - static treeBoundBox cellBb - ( - const primitiveMesh& mesh, - const label celli - ); - //- Mark all cells overlapping (a voxel covered by) a src patch // with type HOLE void markPatchesAsHoles diff --git a/src/overset/cellCellStencil/trackingInverseDistance/trackingInverseDistanceCellCellStencil.C b/src/overset/cellCellStencil/trackingInverseDistance/trackingInverseDistanceCellCellStencil.C index f2e2092300..515744366d 100644 --- a/src/overset/cellCellStencil/trackingInverseDistance/trackingInverseDistanceCellCellStencil.C +++ b/src/overset/cellCellStencil/trackingInverseDistance/trackingInverseDistanceCellCellStencil.C @@ -206,9 +206,6 @@ void Foam::cellCellStencils::trackingInverseDistance::markPatchesAsHoles labelList& allCellTypes ) const { - const pointField& allPoints = mesh_.points(); - const labelListList& allCellPoints = mesh_.cellPoints(); - const treeBoundBoxList& srcPatchBbs = patchBb[srcI]; const treeBoundBoxList& tgtPatchBbs = patchBb[tgtI]; const labelList& tgtCellMap = meshParts_[tgtI].cellMap(); @@ -226,7 +223,7 @@ void Foam::cellCellStencils::trackingInverseDistance::markPatchesAsHoles forAll(tgtCellMap, tgtCelli) { label celli = tgtCellMap[tgtCelli]; - boundBox cBb(allPoints, allCellPoints[celli], false); + boundBox cBb(mesh_.cellBb(celli)); cBb.min() -= smallVec_; cBb.max() += smallVec_; @@ -295,7 +292,7 @@ void Foam::cellCellStencils::trackingInverseDistance::markPatchesAsHoles forAll(tgtCellMap, tgtCelli) { label celli = tgtCellMap[tgtCelli]; - boundBox cBb(allPoints, allCellPoints[celli], false); + boundBox cBb(mesh_.cellBb(celli)); cBb.min() -= smallVec_; cBb.max() += smallVec_; @@ -412,7 +409,7 @@ void Foam::cellCellStencils::trackingInverseDistance::markDonors label celli = tgtCellMap[tgtCelli]; if (srcOverlapProcs.size()) { - treeBoundBox subBb(cellBb(mesh_, celli)); + treeBoundBox subBb(mesh_.cellBb(celli)); subBb.min() -= smallVec_; subBb.max() += smallVec_; diff --git a/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.C b/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.C index bf879b9c70..3d0034a8c0 100644 --- a/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.C +++ b/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.C @@ -54,23 +54,20 @@ Foam::labelList Foam::meshToMeshMethod::maskCells() const intersectBb.inflate(0.01); - const cellList& srcCells = src_.cells(); - const faceList& srcFaces = src_.faces(); - const pointField& srcPts = src_.points(); - DynamicList