Files
openfoam/src/meshTools/tetOverlapVolume/tetOverlapVolume.C
Mark Olesen 722d23f59c ENH: additional methods/operators for boundBox (related to #196)
- Constructor for bounding box of a single point.

- add(boundBox), add(point) ...
  -> Extend box to enclose the second box or point(s).

  Eg,
      bb.add(pt);
  vs.
      bb.min() = Foam::min(bb.min(), pt);
      bb.max() = Foam::max(bb.max(), pt);

Also works with other bounding boxes.
  Eg,
      bb.add(bb2);
      // OR
      bb += bb2;
  vs.
      bb.min() = Foam::min(bb.min(), bb2.min());
      bb.max() = Foam::max(bb.max(), bb2.max());

'+=' operator allows the reduction to be used in parallel
gather/scatter operations.

A global '+' operator is not currently needed.

Note: may be useful in the future to have a 'clear()' method
that resets to a zero-sized (inverted) box.

STYLE: make many bounding box constructors explicit
2017-01-25 19:26:50 +01:00

159 lines
3.8 KiB
C

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 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/>.
\*---------------------------------------------------------------------------*/
#include "tetOverlapVolume.H"
#include "tetrahedron.H"
#include "tetPoints.H"
#include "polyMesh.H"
#include "OFstream.H"
#include "treeBoundBox.H"
#include "indexedOctree.H"
#include "treeDataCell.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(tetOverlapVolume, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::tetOverlapVolume::tetOverlapVolume()
{}
// * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * * //
Foam::treeBoundBox Foam::tetOverlapVolume::pyrBb
(
const pointField& points,
const face& f,
const point& fc
)
{
treeBoundBox bb(fc);
bb.add(points, f);
return bb;
}
// * * * * * * * * * * * Public Member Functions * * * * * * * * * * * * * //
bool Foam::tetOverlapVolume::cellCellOverlapMinDecomp
(
const primitiveMesh& meshA,
const label cellAI,
const primitiveMesh& meshB,
const label cellBI,
const treeBoundBox& cellBbB,
const scalar threshold
) const
{
hasOverlapOp overlapCheckOp(threshold);
cellCellOverlapMinDecomp<hasOverlapOp>
(
meshA,
cellAI,
meshB,
cellBI,
cellBbB,
overlapCheckOp
);
return overlapCheckOp.ok_;
}
Foam::scalar Foam::tetOverlapVolume::cellCellOverlapVolumeMinDecomp
(
const primitiveMesh& meshA,
const label cellAI,
const primitiveMesh& meshB,
const label cellBI,
const treeBoundBox& cellBbB
) const
{
sumOverlapOp overlapSumOp;
cellCellOverlapMinDecomp<sumOverlapOp>
(
meshA,
cellAI,
meshB,
cellBI,
cellBbB,
overlapSumOp
);
return overlapSumOp.iop_.vol_;
}
Foam::Tuple2<Foam::scalar, Foam::point>
Foam::tetOverlapVolume::cellCellOverlapMomentMinDecomp
(
const primitiveMesh& meshA,
const label cellAI,
const primitiveMesh& meshB,
const label cellBI,
const treeBoundBox& cellBbB
) const
{
sumOverlapMomentOp overlapSumOp;
cellCellOverlapMinDecomp<sumOverlapMomentOp>
(
meshA,
cellAI,
meshB,
cellBI,
cellBbB,
overlapSumOp
);
return overlapSumOp.iop_.vol_;
}
Foam::labelList Foam::tetOverlapVolume::overlappingCells
(
const polyMesh& fromMesh,
const polyMesh& toMesh,
const label iTo
) const
{
const indexedOctree<treeDataCell>& treeA = fromMesh.cellTree();
treeBoundBox bbB(toMesh.points(), toMesh.cellPoints()[iTo]);
return treeA.findBox(bbB);
}
// ************************************************************************* //