mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -40,8 +40,8 @@ boundBox cube(scalar start, scalar width)
|
|||||||
{
|
{
|
||||||
return boundBox
|
return boundBox
|
||||||
(
|
(
|
||||||
point(start, start, start),
|
point::uniform(start),
|
||||||
point(start + width, start + width, start + width)
|
point::uniform(start + width)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,10 +59,19 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<<"boundBox faces: " << boundBox::faces << endl;
|
Info<<"boundBox faces: " << boundBox::faces << endl;
|
||||||
Info<<"hex faces: " << hex.modelFaces() << endl;
|
Info<<"hex faces: " << hex.modelFaces() << endl;
|
||||||
|
Info<<"tree-bb faces: " << treeBoundBox::faces << endl;
|
||||||
|
Info<<"tree-bb edges: " << treeBoundBox::edges << endl;
|
||||||
|
|
||||||
boundBox bb = boundBox::greatBox;
|
boundBox bb = boundBox::greatBox;
|
||||||
Info<<"great box: " << bb << endl;
|
Info<<"great box: " << bb << endl;
|
||||||
|
|
||||||
|
// bb.clear();
|
||||||
|
// Info<<"zero box: " << bb << endl;
|
||||||
|
|
||||||
|
bb = boundBox::invertedBox;
|
||||||
|
Info<<"invalid box: " << bb << endl;
|
||||||
|
Info<< nl << endl;
|
||||||
|
|
||||||
if (Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
{
|
{
|
||||||
bb = cube(Pstream::myProcNo(), 1.1);
|
bb = cube(Pstream::myProcNo(), 1.1);
|
||||||
@ -71,6 +80,48 @@ int main(int argc, char *argv[])
|
|||||||
bb.reduce();
|
bb.reduce();
|
||||||
Pout<<"reduced: " << bb << endl;
|
Pout<<"reduced: " << bb << endl;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bb = cube(0, 1);
|
||||||
|
Info<<"starting box: " << bb << endl;
|
||||||
|
|
||||||
|
point pt(Zero);
|
||||||
|
bb.add(pt);
|
||||||
|
Info<<"enclose point " << pt << " -> " << bb << endl;
|
||||||
|
|
||||||
|
pt = point(0,1.5,0.5);
|
||||||
|
bb.add(pt);
|
||||||
|
Info<<"enclose point " << pt << " -> " << bb << endl;
|
||||||
|
|
||||||
|
pt = point(5,2,-2);
|
||||||
|
bb.add(pt);
|
||||||
|
Info<<"enclose point " << pt << " -> " << bb << endl;
|
||||||
|
|
||||||
|
// restart with same points
|
||||||
|
bb = boundBox::invertedBox;
|
||||||
|
bb.add(point(1,1,1));
|
||||||
|
bb.add(point::zero);
|
||||||
|
bb.add(point(0,1.5,0.5));
|
||||||
|
bb.add(point(5,2,-2));
|
||||||
|
|
||||||
|
Info<<"repeated " << bb << endl;
|
||||||
|
|
||||||
|
boundBox box1 = cube(0, 1);
|
||||||
|
boundBox box2 = cube(0, 0.75);
|
||||||
|
boundBox box3 = cube(0.5, 1);
|
||||||
|
boundBox box4 = cube(-1, 0.5);
|
||||||
|
|
||||||
|
Info<<"union of " << box1 << " and " << box2 << " => ";
|
||||||
|
|
||||||
|
box1.add(box2);
|
||||||
|
Info<< box1 << endl;
|
||||||
|
|
||||||
|
box1.add(box3);
|
||||||
|
Info<<"union with " << box3 << " => " << box1 << endl;
|
||||||
|
|
||||||
|
box1.add(box4);
|
||||||
|
Info<<"union with " << box4 << " => " << box1 << endl;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,14 +66,14 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
pointField newPoints(mesh.points());
|
pointField newPoints(mesh.points());
|
||||||
|
|
||||||
const point half(0.5*(meshBb.min() + meshBb.max()));
|
const point half = meshBb.midpoint();
|
||||||
|
|
||||||
forAll(newPoints, pointi)
|
forAll(newPoints, pointi)
|
||||||
{
|
{
|
||||||
point& pt = newPoints[pointi];
|
point& pt = newPoints[pointi];
|
||||||
|
|
||||||
// expand around half
|
// expand around half
|
||||||
pt.y() += pt.y() - half.y();
|
pt.y() += pt.y() - half.y();
|
||||||
}
|
}
|
||||||
|
|
||||||
mesh.movePoints(newPoints);
|
mesh.movePoints(newPoints);
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -719,17 +719,13 @@ void Foam::backgroundMeshDecomposition::buildPatchAndTree()
|
|||||||
Pstream::gatherList(allBackgroundMeshBounds_);
|
Pstream::gatherList(allBackgroundMeshBounds_);
|
||||||
Pstream::scatterList(allBackgroundMeshBounds_);
|
Pstream::scatterList(allBackgroundMeshBounds_);
|
||||||
|
|
||||||
point bbMin(GREAT, GREAT, GREAT);
|
// find global bounding box
|
||||||
point bbMax(-GREAT, -GREAT, -GREAT);
|
globalBackgroundBounds_ = treeBoundBox::invertedBox;
|
||||||
|
|
||||||
forAll(allBackgroundMeshBounds_, proci)
|
forAll(allBackgroundMeshBounds_, proci)
|
||||||
{
|
{
|
||||||
bbMin = min(bbMin, allBackgroundMeshBounds_[proci].min());
|
globalBackgroundBounds_.add(allBackgroundMeshBounds_[proci]);
|
||||||
bbMax = max(bbMax, allBackgroundMeshBounds_[proci].max());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
globalBackgroundBounds_ = treeBoundBox(bbMin, bbMax);
|
|
||||||
|
|
||||||
if (false)
|
if (false)
|
||||||
{
|
{
|
||||||
OFstream fStr
|
OFstream fStr
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -558,18 +558,11 @@ Foam::label Foam::checkTopology
|
|||||||
|
|
||||||
if (allGeometry)
|
if (allGeometry)
|
||||||
{
|
{
|
||||||
const pointField& pts = pp.points();
|
|
||||||
const labelList& mp = pp.meshPoints();
|
const labelList& mp = pp.meshPoints();
|
||||||
|
|
||||||
if (returnReduce(mp.size(), sumOp<label>()) > 0)
|
if (returnReduce(mp.size(), sumOp<label>()) > 0)
|
||||||
{
|
{
|
||||||
boundBox bb(point::max, point::min);
|
boundBox bb(pp.points(), mp, true); // reduce
|
||||||
forAll(mp, i)
|
|
||||||
{
|
|
||||||
bb.min() = min(bb.min(), pts[mp[i]]);
|
|
||||||
bb.max() = max(bb.max(), pts[mp[i]]);
|
|
||||||
}
|
|
||||||
bb.reduce();
|
|
||||||
Info<< ' ' << bb;
|
Info<< ' ' << bb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -336,10 +336,7 @@ boundBox procBounds
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
boundBox domainBb(points, false);
|
bb.add(points);
|
||||||
|
|
||||||
bb.min() = min(bb.min(), domainBb.min());
|
|
||||||
bb.max() = max(bb.max(), domainBb.max());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bb;
|
return bb;
|
||||||
|
|||||||
@ -49,33 +49,23 @@ const Foam::faceList Foam::boundBox::faces
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::boundBox::calculate(const UList<point>& points, const bool doReduce)
|
void Foam::boundBox::calculate(const UList<point>& points, bool doReduce)
|
||||||
{
|
{
|
||||||
if (points.empty())
|
if (points.empty())
|
||||||
{
|
{
|
||||||
min_ = Zero;
|
|
||||||
max_ = Zero;
|
|
||||||
|
|
||||||
if (doReduce && Pstream::parRun())
|
if (doReduce && Pstream::parRun())
|
||||||
{
|
{
|
||||||
// Use values that get overwritten by reduce minOp, maxOp below
|
// Values that get overwritten by subsequent reduce operation
|
||||||
min_ = point(VGREAT, VGREAT, VGREAT);
|
operator=(invertedBox);
|
||||||
max_ = point(-VGREAT, -VGREAT, -VGREAT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
min_ = points[0];
|
operator=(invertedBox);
|
||||||
max_ = points[0];
|
add(points);
|
||||||
|
|
||||||
for (label i = 1; i < points.size(); i++)
|
|
||||||
{
|
|
||||||
min_ = ::Foam::min(min_, points[i]);
|
|
||||||
max_ = ::Foam::max(max_, points[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduce parallel information
|
// Parallel reduction
|
||||||
if (doReduce)
|
if (doReduce)
|
||||||
{
|
{
|
||||||
reduce();
|
reduce();
|
||||||
@ -85,7 +75,7 @@ void Foam::boundBox::calculate(const UList<point>& points, const bool doReduce)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::boundBox::boundBox(const UList<point>& points, const bool doReduce)
|
Foam::boundBox::boundBox(const UList<point>& points, bool doReduce)
|
||||||
:
|
:
|
||||||
min_(Zero),
|
min_(Zero),
|
||||||
max_(Zero)
|
max_(Zero)
|
||||||
@ -94,13 +84,13 @@ Foam::boundBox::boundBox(const UList<point>& points, const bool doReduce)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::boundBox::boundBox(const tmp<pointField>& points, const bool doReduce)
|
Foam::boundBox::boundBox(const tmp<pointField>& tpoints, bool doReduce)
|
||||||
:
|
:
|
||||||
min_(Zero),
|
min_(Zero),
|
||||||
max_(Zero)
|
max_(Zero)
|
||||||
{
|
{
|
||||||
calculate(points(), doReduce);
|
calculate(tpoints(), doReduce);
|
||||||
points.clear();
|
tpoints.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -108,7 +98,7 @@ Foam::boundBox::boundBox
|
|||||||
(
|
(
|
||||||
const UList<point>& points,
|
const UList<point>& points,
|
||||||
const labelUList& indices,
|
const labelUList& indices,
|
||||||
const bool doReduce
|
bool doReduce
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
min_(Zero),
|
min_(Zero),
|
||||||
@ -118,24 +108,17 @@ Foam::boundBox::boundBox
|
|||||||
{
|
{
|
||||||
if (doReduce && Pstream::parRun())
|
if (doReduce && Pstream::parRun())
|
||||||
{
|
{
|
||||||
// Use values that get overwritten by reduce minOp, maxOp below
|
// Values that get overwritten by subsequent reduce operation
|
||||||
min_ = point(VGREAT, VGREAT, VGREAT);
|
operator=(invertedBox);
|
||||||
max_ = point(-VGREAT, -VGREAT, -VGREAT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
min_ = points[indices[0]];
|
operator=(invertedBox);
|
||||||
max_ = points[indices[0]];
|
add(points, indices);
|
||||||
|
|
||||||
for (label i=1; i < indices.size(); ++i)
|
|
||||||
{
|
|
||||||
min_ = ::Foam::min(min_, points[indices[i]]);
|
|
||||||
max_ = ::Foam::max(max_, points[indices[i]]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduce parallel information
|
// Parallel reduction
|
||||||
if (doReduce)
|
if (doReduce)
|
||||||
{
|
{
|
||||||
reduce();
|
reduce();
|
||||||
@ -147,8 +130,8 @@ Foam::boundBox::boundBox
|
|||||||
|
|
||||||
Foam::tmp<Foam::pointField> Foam::boundBox::points() const
|
Foam::tmp<Foam::pointField> Foam::boundBox::points() const
|
||||||
{
|
{
|
||||||
tmp<pointField> tPts = tmp<pointField>(new pointField(8));
|
tmp<pointField> tpoints = tmp<pointField>(new pointField(8));
|
||||||
pointField& pt = tPts.ref();
|
pointField& pt = tpoints.ref();
|
||||||
|
|
||||||
pt[0] = min_; // min-x, min-y, min-z
|
pt[0] = min_; // min-x, min-y, min-z
|
||||||
pt[1] = point(max_.x(), min_.y(), min_.z()); // max-x, min-y, min-z
|
pt[1] = point(max_.x(), min_.y(), min_.z()); // max-x, min-y, min-z
|
||||||
@ -159,13 +142,13 @@ Foam::tmp<Foam::pointField> Foam::boundBox::points() const
|
|||||||
pt[6] = max_; // max-x, max-y, max-z
|
pt[6] = max_; // max-x, max-y, max-z
|
||||||
pt[7] = point(min_.x(), max_.y(), max_.z()); // min-x, max-y, max-z
|
pt[7] = point(min_.x(), max_.y(), max_.z()); // min-x, max-y, max-z
|
||||||
|
|
||||||
return tPts;
|
return tpoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::boundBox::inflate(const scalar s)
|
void Foam::boundBox::inflate(const scalar s)
|
||||||
{
|
{
|
||||||
vector ext = vector::one*s*mag();
|
const vector ext = vector::one*s*mag();
|
||||||
|
|
||||||
min_ -= ext;
|
min_ -= ext;
|
||||||
max_ += ext;
|
max_ += ext;
|
||||||
@ -179,6 +162,15 @@ void Foam::boundBox::reduce()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::boundBox::intersect(const boundBox& bb)
|
||||||
|
{
|
||||||
|
min_ = ::Foam::max(min_, bb.min_);
|
||||||
|
max_ = ::Foam::min(max_, bb.max_);
|
||||||
|
|
||||||
|
return !empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::boundBox::contains(const UList<point>& points) const
|
bool Foam::boundBox::contains(const UList<point>& points) const
|
||||||
{
|
{
|
||||||
if (points.empty())
|
if (points.empty())
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -60,22 +60,19 @@ class boundBox
|
|||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Minimum and maximum describing the bounding box
|
//- Minimum and maximum points describing the bounding box
|
||||||
point min_, max_;
|
point min_, max_;
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Calculate the bounding box from the given points.
|
//- Calculate the bounding box from the given points.
|
||||||
// Does parallel communication (doReduce = true)
|
// Does parallel communication (doReduce = true)
|
||||||
void calculate(const UList<point>&, const bool doReduce = true);
|
void calculate(const UList<point>& points, bool doReduce = true);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|
||||||
//- The great value used for greatBox and invertedBox
|
|
||||||
static const scalar great;
|
|
||||||
|
|
||||||
//- A very large boundBox: min/max == -/+ VGREAT
|
//- A very large boundBox: min/max == -/+ VGREAT
|
||||||
static const boundBox greatBox;
|
static const boundBox greatBox;
|
||||||
|
|
||||||
@ -91,46 +88,52 @@ public:
|
|||||||
//- Construct null, setting points to zero
|
//- Construct null, setting points to zero
|
||||||
inline boundBox();
|
inline boundBox();
|
||||||
|
|
||||||
|
//- Construct a bounding box containing a single initial point
|
||||||
|
explicit inline boundBox(const point& pt);
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
inline boundBox(const point& min, const point& max);
|
inline boundBox(const point& min, const point& max);
|
||||||
|
|
||||||
//- Construct as the bounding box of the given points
|
//- Construct as the bounding box of the given points
|
||||||
// Does parallel communication (doReduce = true)
|
// Does parallel communication (doReduce = true)
|
||||||
boundBox(const UList<point>&, const bool doReduce = true);
|
explicit boundBox(const UList<point>& points, bool doReduce = true);
|
||||||
|
|
||||||
//- Construct as the bounding box of the given temporary pointField.
|
//- Construct as the bounding box of the given temporary pointField.
|
||||||
// Does parallel communication (doReduce = true)
|
// Does parallel communication (doReduce = true)
|
||||||
boundBox(const tmp<pointField>&, const bool doReduce = true);
|
explicit boundBox(const tmp<pointField>& tpoints, bool doReduce = true);
|
||||||
|
|
||||||
//- Construct bounding box as subset of the pointField.
|
//- Construct bounding box as an indirect subset of the points.
|
||||||
// The indices could be from cell/face etc.
|
// The indices could be from cell/face etc.
|
||||||
// Does parallel communication (doReduce = true)
|
// Does parallel communication (doReduce = true)
|
||||||
boundBox
|
boundBox
|
||||||
(
|
(
|
||||||
const UList<point>&,
|
const UList<point>& points,
|
||||||
const labelUList& indices,
|
const labelUList& indices,
|
||||||
const bool doReduce = true
|
bool doReduce = true
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct bounding box as subset of the pointField.
|
//- Construct bounding box as an indirect subset of the points.
|
||||||
// The indices could be from edge/triFace etc.
|
// The indices could be from edge/triFace etc.
|
||||||
// Does parallel communication (doReduce = true)
|
// Does parallel communication (doReduce = true)
|
||||||
template<unsigned Size>
|
template<unsigned Size>
|
||||||
boundBox
|
boundBox
|
||||||
(
|
(
|
||||||
const UList<point>&,
|
const UList<point>& points,
|
||||||
const FixedList<label, Size>& indices,
|
const FixedList<label, Size>& indices,
|
||||||
const bool doReduce = true
|
bool doReduce = true
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
inline boundBox(Istream&);
|
inline boundBox(Istream& is);
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
// Member functions
|
||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
|
//- Bounding box is inverted, contains no points.
|
||||||
|
inline bool empty() const;
|
||||||
|
|
||||||
//- Minimum describing the bounding box
|
//- Minimum describing the bounding box
|
||||||
inline const point& min() const;
|
inline const point& min() const;
|
||||||
|
|
||||||
@ -170,83 +173,130 @@ public:
|
|||||||
|
|
||||||
// Manipulate
|
// Manipulate
|
||||||
|
|
||||||
|
//- Extend to include the second box.
|
||||||
|
inline void add(const boundBox& bb);
|
||||||
|
|
||||||
|
//- Extend to include the point.
|
||||||
|
inline void add(const point& pt);
|
||||||
|
|
||||||
|
//- Extend to include the points.
|
||||||
|
inline void add(const UList<point>& points);
|
||||||
|
|
||||||
|
//- Extend to include the points from the temporary point field.
|
||||||
|
inline void add(const tmp<pointField>& tpoints);
|
||||||
|
|
||||||
|
//- Extend to include the subset of the point field.
|
||||||
|
// The indices could be from cell/face etc.
|
||||||
|
inline void add
|
||||||
|
(
|
||||||
|
const UList<point>& points,
|
||||||
|
const labelUList& indices
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Extend to include the points.
|
||||||
|
template<unsigned Size>
|
||||||
|
void add(const FixedList<point, Size>& points);
|
||||||
|
|
||||||
|
//- Extend to include the subset of the point field.
|
||||||
|
// The indices could be from edge/triFace etc.
|
||||||
|
template<unsigned Size>
|
||||||
|
void add
|
||||||
|
(
|
||||||
|
const UList<point>& points,
|
||||||
|
const FixedList<label, Size>& indices
|
||||||
|
);
|
||||||
|
|
||||||
//- Inflate box by factor*mag(span) in all dimensions
|
//- Inflate box by factor*mag(span) in all dimensions
|
||||||
void inflate(const scalar s);
|
void inflate(const scalar s);
|
||||||
|
|
||||||
//- Parallel reduction of min/max values
|
//- Parallel reduction of min/max values
|
||||||
void reduce();
|
void reduce();
|
||||||
|
|
||||||
|
//- Intersection (union) with the second box.
|
||||||
|
// The return value is true if the intersection is non-empty.
|
||||||
|
bool intersect(const boundBox& bb);
|
||||||
|
|
||||||
|
|
||||||
// Query
|
// Query
|
||||||
|
|
||||||
//- Overlaps/touches boundingBox?
|
//- Overlaps/touches boundingBox?
|
||||||
inline bool overlaps(const boundBox&) const;
|
inline bool overlaps(const boundBox& bb) const;
|
||||||
|
|
||||||
//- Overlaps boundingSphere (centre + sqr(radius))?
|
//- Overlaps boundingSphere (centre + sqr(radius))?
|
||||||
inline bool overlaps(const point&, const scalar radiusSqr) const;
|
inline bool overlaps
|
||||||
|
(
|
||||||
|
const point& centre,
|
||||||
|
const scalar radiusSqr
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Contains point? (inside or on edge)
|
//- Contains point? (inside or on edge)
|
||||||
inline bool contains(const point&) const;
|
inline bool contains(const point& pt) const;
|
||||||
|
|
||||||
//- Fully contains other boundingBox?
|
//- Fully contains other boundingBox?
|
||||||
inline bool contains(const boundBox&) const;
|
inline bool contains(const boundBox& bb) const;
|
||||||
|
|
||||||
//- Contains point? (inside only)
|
//- Contains point? (inside only)
|
||||||
inline bool containsInside(const point&) const;
|
inline bool containsInside(const point& pt) const;
|
||||||
|
|
||||||
//- Contains all of the points? (inside or on edge)
|
//- Contains all of the points? (inside or on edge)
|
||||||
bool contains(const UList<point>&) const;
|
bool contains(const UList<point>& points) const;
|
||||||
|
|
||||||
//- Contains all of the points? (inside or on edge)
|
//- Contains all of the subset of points? (inside or on edge)
|
||||||
bool contains
|
bool contains
|
||||||
(
|
(
|
||||||
const UList<point>&,
|
const UList<point>& points,
|
||||||
const labelUList& indices
|
const labelUList& indices
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Contains all of the points? (inside or on edge)
|
//- Contains all of the subset of points? (inside or on edge)
|
||||||
template<unsigned Size>
|
template<unsigned Size>
|
||||||
bool contains
|
bool contains
|
||||||
(
|
(
|
||||||
const UList<point>&,
|
const UList<point>& points,
|
||||||
const FixedList<label, Size>& indices
|
const FixedList<label, Size>& indices
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
//- Contains any of the points? (inside or on edge)
|
//- Contains any of the points? (inside or on edge)
|
||||||
bool containsAny(const UList<point>&) const;
|
bool containsAny(const UList<point>& points) const;
|
||||||
|
|
||||||
//- Contains any of the points? (inside or on edge)
|
//- Contains any of the subset of points? (inside or on edge)
|
||||||
bool containsAny
|
bool containsAny
|
||||||
(
|
(
|
||||||
const UList<point>&,
|
const UList<point>& points,
|
||||||
const labelUList& indices
|
const labelUList& indices
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Contains any of the points? (inside or on edge)
|
//- Contains any of the subset of points? (inside or on edge)
|
||||||
template<unsigned Size>
|
template<unsigned Size>
|
||||||
bool containsAny
|
bool containsAny
|
||||||
(
|
(
|
||||||
const UList<point>&,
|
const UList<point>& points,
|
||||||
const FixedList<label, Size>& indices
|
const FixedList<label, Size>& indices
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Return the nearest point on the boundBox to the supplied point.
|
//- Return the nearest point on the boundBox to the supplied point.
|
||||||
// If point is inside the boundBox then the point is returned
|
// If point is inside the boundBox then the point is returned
|
||||||
// unchanged.
|
// unchanged.
|
||||||
point nearest(const point&) const;
|
point nearest(const point& pt) const;
|
||||||
|
|
||||||
|
|
||||||
|
// Member Operators
|
||||||
|
|
||||||
|
//- Extend box to include the second box, as per the add() method.
|
||||||
|
inline void operator+=(const boundBox& bb);
|
||||||
|
|
||||||
|
|
||||||
// Friend Operators
|
// Friend Operators
|
||||||
|
|
||||||
inline friend bool operator==(const boundBox&, const boundBox&);
|
inline friend bool operator==(const boundBox& a, const boundBox& b);
|
||||||
inline friend bool operator!=(const boundBox&, const boundBox&);
|
inline friend bool operator!=(const boundBox& a, const boundBox& b);
|
||||||
|
|
||||||
|
|
||||||
// IOstream operator
|
// IOstream operator
|
||||||
|
|
||||||
friend Istream& operator>>(Istream&, boundBox&);
|
friend Istream& operator>>(Istream& is, boundBox& bb);
|
||||||
friend Ostream& operator<<(Ostream&, const boundBox&);
|
friend Ostream& operator<<(Ostream& os, const boundBox& bb);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -24,7 +24,6 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "boundBox.H"
|
#include "boundBox.H"
|
||||||
#include "pointField.H"
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
@ -36,6 +35,13 @@ inline Foam::boundBox::boundBox()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::boundBox::boundBox(const point& pt)
|
||||||
|
:
|
||||||
|
min_(pt),
|
||||||
|
max_(pt)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::boundBox::boundBox(const point& min, const point& max)
|
inline Foam::boundBox::boundBox(const point& min, const point& max)
|
||||||
:
|
:
|
||||||
min_(min),
|
min_(min),
|
||||||
@ -51,6 +57,12 @@ inline Foam::boundBox::boundBox(Istream& is)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline bool Foam::boundBox::empty() const
|
||||||
|
{
|
||||||
|
return (min_ > max_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::point& Foam::boundBox::min() const
|
inline const Foam::point& Foam::boundBox::min() const
|
||||||
{
|
{
|
||||||
return min_;
|
return min_;
|
||||||
@ -117,6 +129,52 @@ inline Foam::scalar Foam::boundBox::avgDim() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Foam::boundBox::add(const boundBox& bb)
|
||||||
|
{
|
||||||
|
min_ = ::Foam::min(min_, bb.min_);
|
||||||
|
max_ = ::Foam::max(max_, bb.max_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Foam::boundBox::add(const point& pt)
|
||||||
|
{
|
||||||
|
min_ = ::Foam::min(min_, pt);
|
||||||
|
max_ = ::Foam::max(max_, pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Foam::boundBox::add(const UList<point>& points)
|
||||||
|
{
|
||||||
|
forAll(points, i)
|
||||||
|
{
|
||||||
|
add(points[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Foam::boundBox::add(const tmp<pointField>& tpoints)
|
||||||
|
{
|
||||||
|
add(tpoints());
|
||||||
|
tpoints.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Foam::boundBox::add
|
||||||
|
(
|
||||||
|
const UList<point>& points,
|
||||||
|
const labelUList& indices
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!points.empty())
|
||||||
|
{
|
||||||
|
forAll(indices, i)
|
||||||
|
{
|
||||||
|
add(points[indices[i]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::boundBox::overlaps(const boundBox& bb) const
|
inline bool Foam::boundBox::overlaps(const boundBox& bb) const
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
@ -138,7 +196,7 @@ inline bool Foam::boundBox::overlaps
|
|||||||
// Find nearest point on bb.
|
// Find nearest point on bb.
|
||||||
scalar distSqr = 0;
|
scalar distSqr = 0;
|
||||||
|
|
||||||
for (direction dir = 0; dir < vector::nComponents; dir++)
|
for (direction dir = 0; dir < vector::nComponents; ++dir)
|
||||||
{
|
{
|
||||||
scalar d0 = min_[dir] - centre[dir];
|
scalar d0 = min_[dir] - centre[dir];
|
||||||
scalar d1 = max_[dir] - centre[dir];
|
scalar d1 = max_[dir] - centre[dir];
|
||||||
@ -178,7 +236,6 @@ inline bool Foam::boundBox::contains(const point& pt) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// this.bb fully contains bb
|
|
||||||
inline bool Foam::boundBox::contains(const boundBox& bb) const
|
inline bool Foam::boundBox::contains(const boundBox& bb) const
|
||||||
{
|
{
|
||||||
return contains(bb.min()) && contains(bb.max());
|
return contains(bb.min()) && contains(bb.max());
|
||||||
@ -196,6 +253,14 @@ inline bool Foam::boundBox::containsInside(const point& pt) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline void Foam::boundBox::operator+=(const boundBox& bb)
|
||||||
|
{
|
||||||
|
add(bb);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline bool Foam::operator==(const boundBox& a, const boundBox& b)
|
inline bool Foam::operator==(const boundBox& a, const boundBox& b)
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -26,7 +26,6 @@ License
|
|||||||
#include "boundBox.H"
|
#include "boundBox.H"
|
||||||
#include "FixedList.H"
|
#include "FixedList.H"
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<unsigned Size>
|
template<unsigned Size>
|
||||||
@ -34,7 +33,7 @@ Foam::boundBox::boundBox
|
|||||||
(
|
(
|
||||||
const UList<point>& points,
|
const UList<point>& points,
|
||||||
const FixedList<label, Size>& indices,
|
const FixedList<label, Size>& indices,
|
||||||
const bool doReduce
|
bool doReduce
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
min_(Zero),
|
min_(Zero),
|
||||||
@ -45,24 +44,17 @@ Foam::boundBox::boundBox
|
|||||||
{
|
{
|
||||||
if (doReduce && Pstream::parRun())
|
if (doReduce && Pstream::parRun())
|
||||||
{
|
{
|
||||||
// Use values that get overwritten by reduce minOp, maxOp below
|
// Values that get overwritten by subsequent reduce operation
|
||||||
min_ = point(VGREAT, VGREAT, VGREAT);
|
operator=(invertedBox);
|
||||||
max_ = point(-VGREAT, -VGREAT, -VGREAT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
min_ = points[indices[0]];
|
operator=(invertedBox);
|
||||||
max_ = points[indices[0]];
|
add(points, indices);
|
||||||
|
|
||||||
for (unsigned i=1; i < Size; ++i)
|
|
||||||
{
|
|
||||||
min_ = ::Foam::min(min_, points[indices[i]]);
|
|
||||||
max_ = ::Foam::max(max_, points[indices[i]]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduce parallel information
|
// Parallel reduction
|
||||||
if (doReduce)
|
if (doReduce)
|
||||||
{
|
{
|
||||||
reduce();
|
reduce();
|
||||||
@ -72,6 +64,38 @@ Foam::boundBox::boundBox
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<unsigned Size>
|
||||||
|
void Foam::boundBox::add
|
||||||
|
(
|
||||||
|
const FixedList<point, Size>& points
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// a FixedList is never empty
|
||||||
|
for (unsigned i=0; i < Size; ++i)
|
||||||
|
{
|
||||||
|
add(points[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<unsigned Size>
|
||||||
|
void Foam::boundBox::add
|
||||||
|
(
|
||||||
|
const UList<point>& points,
|
||||||
|
const FixedList<label, Size>& indices
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// points may be empty, but a FixedList is never empty
|
||||||
|
if (!points.empty())
|
||||||
|
{
|
||||||
|
for (unsigned i=0; i < Size; ++i)
|
||||||
|
{
|
||||||
|
add(points[indices[i]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<unsigned Size>
|
template<unsigned Size>
|
||||||
bool Foam::boundBox::contains
|
bool Foam::boundBox::contains
|
||||||
(
|
(
|
||||||
@ -79,7 +103,7 @@ bool Foam::boundBox::contains
|
|||||||
const FixedList<label, Size>& indices
|
const FixedList<label, Size>& indices
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// a FixedList is never empty
|
// points may be empty, but a FixedList is never empty
|
||||||
if (points.empty())
|
if (points.empty())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -104,7 +128,7 @@ bool Foam::boundBox::containsAny
|
|||||||
const FixedList<label, Size>& indices
|
const FixedList<label, Size>& indices
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// a FixedList is never empty
|
// points may be empty, but a FixedList is never empty
|
||||||
if (points.empty())
|
if (points.empty())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -236,9 +236,8 @@ void Foam::PatchTools::calcBounds
|
|||||||
label pointi = f[fp];
|
label pointi = f[fp];
|
||||||
if (pointIsUsed.set(pointi, 1u))
|
if (pointIsUsed.set(pointi, 1u))
|
||||||
{
|
{
|
||||||
bb.min() = ::Foam::min(bb.min(), points[pointi]);
|
bb.add(points[pointi]);
|
||||||
bb.max() = ::Foam::max(bb.max(), points[pointi]);
|
++nPoints;
|
||||||
nPoints++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -48,8 +48,7 @@ bool Foam::primitiveMesh::pointInCellBB
|
|||||||
|
|
||||||
if (inflationFraction > SMALL)
|
if (inflationFraction > SMALL)
|
||||||
{
|
{
|
||||||
vector inflation = inflationFraction*vector::one*mag(bb.span());
|
bb.inflate(inflationFraction);
|
||||||
bb = boundBox(bb.min() - inflation, bb.max() + inflation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bb.contains(p);
|
return bb.contains(p);
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -92,11 +92,10 @@ public:
|
|||||||
//- Calculate the bounding box
|
//- Calculate the bounding box
|
||||||
inline treeBoundBox bounds() const
|
inline treeBoundBox bounds() const
|
||||||
{
|
{
|
||||||
treeBoundBox bb(operator[](0), operator[](0));
|
treeBoundBox bb(operator[](0));
|
||||||
for (label i = 1; i < size(); i++)
|
for (label i = 1; i < size(); ++i)
|
||||||
{
|
{
|
||||||
bb.min() = min(bb.min(), operator[](i));
|
bb.add(operator[](i));
|
||||||
bb.max() = max(bb.max(), operator[](i));
|
|
||||||
}
|
}
|
||||||
return bb;
|
return bb;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -78,11 +78,10 @@ public:
|
|||||||
//- Calculate the bounding box
|
//- Calculate the bounding box
|
||||||
inline treeBoundBox bounds() const
|
inline treeBoundBox bounds() const
|
||||||
{
|
{
|
||||||
treeBoundBox bb(operator[](0), operator[](0));
|
treeBoundBox bb(operator[](0));
|
||||||
for (label i = 1; i < size(); i++)
|
for (label i = 1; i < size(); ++i)
|
||||||
{
|
{
|
||||||
bb.min() = min(bb.min(), operator[](i));
|
bb.add(operator[](i));
|
||||||
bb.max() = max(bb.max(), operator[](i));
|
|
||||||
}
|
}
|
||||||
return bb;
|
return bb;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -24,50 +24,33 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "treeBoundBox.H"
|
#include "treeBoundBox.H"
|
||||||
#include "ListOps.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const Foam::scalar Foam::treeBoundBox::great(GREAT);
|
|
||||||
|
|
||||||
const Foam::treeBoundBox Foam::treeBoundBox::greatBox
|
const Foam::treeBoundBox Foam::treeBoundBox::greatBox
|
||||||
(
|
(
|
||||||
vector(-GREAT, -GREAT, -GREAT),
|
point::uniform(-GREAT),
|
||||||
vector(GREAT, GREAT, GREAT)
|
point::uniform(GREAT)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
const Foam::treeBoundBox Foam::treeBoundBox::invertedBox
|
const Foam::treeBoundBox Foam::treeBoundBox::invertedBox
|
||||||
(
|
(
|
||||||
vector(GREAT, GREAT, GREAT),
|
point::uniform(GREAT),
|
||||||
vector(-GREAT, -GREAT, -GREAT)
|
point::uniform(-GREAT)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//! \cond ignoreDocumentation
|
|
||||||
//- Skip documentation : local scope only
|
|
||||||
const Foam::label facesArray[6][4] =
|
|
||||||
{
|
|
||||||
{0, 4, 6, 2}, // left
|
|
||||||
{1, 3, 7, 5}, // right
|
|
||||||
{0, 1, 5, 4}, // bottom
|
|
||||||
{2, 6, 7, 3}, // top
|
|
||||||
{0, 2, 3, 1}, // back
|
|
||||||
{4, 5, 7, 6} // front
|
|
||||||
};
|
|
||||||
//! \endcond
|
|
||||||
|
|
||||||
|
|
||||||
const Foam::faceList Foam::treeBoundBox::faces
|
const Foam::faceList Foam::treeBoundBox::faces
|
||||||
(
|
({
|
||||||
initListList<face, label, 6, 4>(facesArray)
|
face{0, 4, 6, 2}, // left
|
||||||
);
|
face{1, 3, 7, 5}, // right
|
||||||
|
face{0, 1, 5, 4}, // bottom
|
||||||
|
face{2, 6, 7, 3}, // top
|
||||||
|
face{0, 2, 3, 1}, // back
|
||||||
|
face{4, 5, 7, 6} // front
|
||||||
|
});
|
||||||
|
|
||||||
|
const Foam::edgeList Foam::treeBoundBox::edges
|
||||||
//! \cond ignoreDocumentation
|
({
|
||||||
//- Skip documentation : local scope only
|
|
||||||
const Foam::label edgesArray[12][2] =
|
|
||||||
{
|
|
||||||
{0, 1}, // 0
|
{0, 1}, // 0
|
||||||
{1, 3},
|
{1, 3},
|
||||||
{2, 3}, // 2
|
{2, 3}, // 2
|
||||||
@ -80,48 +63,17 @@ const Foam::label edgesArray[12][2] =
|
|||||||
{1, 5},
|
{1, 5},
|
||||||
{3, 7}, // 10
|
{3, 7}, // 10
|
||||||
{2, 6}
|
{2, 6}
|
||||||
};
|
});
|
||||||
//! \endcond
|
|
||||||
|
|
||||||
|
|
||||||
const Foam::edgeList Foam::treeBoundBox::edges
|
|
||||||
(
|
|
||||||
//initListList<edge, label, 12, 2>(edgesArray)
|
|
||||||
calcEdges(edgesArray)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
const Foam::FixedList<Foam::vector, 6> Foam::treeBoundBox::faceNormals
|
const Foam::FixedList<Foam::vector, 6> Foam::treeBoundBox::faceNormals
|
||||||
(
|
({
|
||||||
calcFaceNormals()
|
vector(-1, 0, 0), // left
|
||||||
);
|
vector( 1, 0, 0), // right
|
||||||
|
vector( 0, -1, 0), // bottom
|
||||||
|
vector( 0, 1, 0), // top
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
vector( 0, 0, -1), // back
|
||||||
|
vector( 0, 0, 1) // front
|
||||||
Foam::edgeList Foam::treeBoundBox::calcEdges(const label edgesArray[12][2])
|
});
|
||||||
{
|
|
||||||
edgeList edges(12);
|
|
||||||
forAll(edges, edgeI)
|
|
||||||
{
|
|
||||||
edges[edgeI][0] = edgesArray[edgeI][0];
|
|
||||||
edges[edgeI][1] = edgesArray[edgeI][1];
|
|
||||||
}
|
|
||||||
return edges;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::FixedList<Foam::vector, 6> Foam::treeBoundBox::calcFaceNormals()
|
|
||||||
{
|
|
||||||
FixedList<vector, 6> normals;
|
|
||||||
normals[LEFT] = vector(-1, 0, 0);
|
|
||||||
normals[RIGHT] = vector( 1, 0, 0);
|
|
||||||
normals[BOTTOM] = vector( 0, -1, 0);
|
|
||||||
normals[TOP] = vector( 0, 1, 0);
|
|
||||||
normals[BACK] = vector( 0, 0, -1);
|
|
||||||
normals[FRONT] = vector( 0, 0, 1);
|
|
||||||
return normals;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
@ -164,15 +116,15 @@ Foam::treeBoundBox::treeBoundBox
|
|||||||
|
|
||||||
Foam::tmp<Foam::pointField> Foam::treeBoundBox::points() const
|
Foam::tmp<Foam::pointField> Foam::treeBoundBox::points() const
|
||||||
{
|
{
|
||||||
tmp<pointField> tPts = tmp<pointField>(new pointField(8));
|
tmp<pointField> tpoints = tmp<pointField>(new pointField(8));
|
||||||
pointField& points = tPts.ref();
|
pointField& pts = tpoints.ref();
|
||||||
|
|
||||||
forAll(points, octant)
|
forAll(pts, octant)
|
||||||
{
|
{
|
||||||
points[octant] = corner(octant);
|
pts[octant] = corner(octant);
|
||||||
}
|
}
|
||||||
|
|
||||||
return tPts;
|
return tpoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -394,7 +346,7 @@ bool Foam::treeBoundBox::contains(const vector& dir, const point& pt) const
|
|||||||
{
|
{
|
||||||
// Compare all components against min and max of bb
|
// Compare all components against min and max of bb
|
||||||
|
|
||||||
for (direction cmpt=0; cmpt<3; cmpt++)
|
for (direction cmpt=0; cmpt<3; ++cmpt)
|
||||||
{
|
{
|
||||||
if (pt[cmpt] < min()[cmpt])
|
if (pt[cmpt] < min()[cmpt])
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -46,7 +46,6 @@ Description
|
|||||||
|
|
||||||
For the front plane add 4 to the point labels.
|
For the front plane add 4 to the point labels.
|
||||||
|
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
treeBoundBoxI.H
|
treeBoundBoxI.H
|
||||||
treeBoundBox.C
|
treeBoundBox.C
|
||||||
@ -74,11 +73,11 @@ class Random;
|
|||||||
|
|
||||||
class treeBoundBox;
|
class treeBoundBox;
|
||||||
|
|
||||||
bool operator==(const treeBoundBox&, const treeBoundBox&);
|
bool operator==(const treeBoundBox& a, const treeBoundBox& b);
|
||||||
bool operator!=(const treeBoundBox&, const treeBoundBox&);
|
bool operator!=(const treeBoundBox& a, const treeBoundBox& b);
|
||||||
|
|
||||||
Istream& operator>>(Istream& is, treeBoundBox&);
|
Istream& operator>>(Istream& is, treeBoundBox& bb);
|
||||||
Ostream& operator<<(Ostream& os, const treeBoundBox&);
|
Ostream& operator<<(Ostream& os, const treeBoundBox& bb);
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
@ -90,21 +89,10 @@ class treeBoundBox
|
|||||||
public boundBox
|
public boundBox
|
||||||
{
|
{
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//- To initialise edges.
|
|
||||||
static edgeList calcEdges(const label[12][2]);
|
|
||||||
|
|
||||||
//- To initialise faceNormals.
|
|
||||||
static FixedList<vector, 6> calcFaceNormals();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|
||||||
//- The great value used for greatBox and invertedBox
|
|
||||||
static const scalar great;
|
|
||||||
|
|
||||||
//- As per boundBox::greatBox, but with GREAT instead of VGREAT
|
//- As per boundBox::greatBox, but with GREAT instead of VGREAT
|
||||||
static const treeBoundBox greatBox;
|
static const treeBoundBox greatBox;
|
||||||
|
|
||||||
@ -169,7 +157,7 @@ public:
|
|||||||
//- Edge to point addressing
|
//- Edge to point addressing
|
||||||
static const edgeList edges;
|
static const edgeList edges;
|
||||||
|
|
||||||
//- Per face the unit normal
|
//- The unit normal per face
|
||||||
static const FixedList<vector, 6> faceNormals;
|
static const FixedList<vector, 6> faceNormals;
|
||||||
|
|
||||||
|
|
||||||
@ -181,16 +169,19 @@ public:
|
|||||||
//- Construct from a boundBox
|
//- Construct from a boundBox
|
||||||
explicit inline treeBoundBox(const boundBox& bb);
|
explicit inline treeBoundBox(const boundBox& bb);
|
||||||
|
|
||||||
|
//- Construct a bounding box containing a single initial point
|
||||||
|
explicit inline treeBoundBox(const point& pt);
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
inline treeBoundBox(const point& min, const point& max);
|
inline treeBoundBox(const point& min, const point& max);
|
||||||
|
|
||||||
//- Construct as the bounding box of the given pointField.
|
//- Construct as the bounding box of the given pointField.
|
||||||
// Local processor domain only (no reduce as in boundBox)
|
// Local processor domain only (no reduce as in boundBox)
|
||||||
explicit treeBoundBox(const UList<point>&);
|
explicit treeBoundBox(const UList<point>& points);
|
||||||
|
|
||||||
//- Construct as subset of points
|
//- Construct as subset of points
|
||||||
// Local processor domain only (no reduce as in boundBox)
|
// Local processor domain only (no reduce as in boundBox)
|
||||||
treeBoundBox(const UList<point>&, const labelUList& indices);
|
treeBoundBox(const UList<point>& points, const labelUList& indices);
|
||||||
|
|
||||||
//- Construct as subset of points
|
//- Construct as subset of points
|
||||||
// The indices could be from edge/triFace etc.
|
// The indices could be from edge/triFace etc.
|
||||||
@ -198,13 +189,13 @@ public:
|
|||||||
template<unsigned Size>
|
template<unsigned Size>
|
||||||
treeBoundBox
|
treeBoundBox
|
||||||
(
|
(
|
||||||
const UList<point>&,
|
const UList<point>& points,
|
||||||
const FixedList<label, Size>& indices
|
const FixedList<label, Size>& indices
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
inline treeBoundBox(Istream&);
|
inline treeBoundBox(Istream& is);
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
// Member functions
|
||||||
@ -220,13 +211,13 @@ public:
|
|||||||
|
|
||||||
// Check
|
// Check
|
||||||
|
|
||||||
//- Corner point given octant
|
//- Corner point of given octant
|
||||||
inline point corner(const direction) const;
|
inline point corner(const direction octant) const;
|
||||||
|
|
||||||
//- Sub box given by octant number. Midpoint calculated.
|
//- Sub-box of given octant. Midpoint calculated.
|
||||||
treeBoundBox subBbox(const direction) const;
|
treeBoundBox subBbox(const direction octant) const;
|
||||||
|
|
||||||
//- Sub box given by octant number. Midpoint provided.
|
//- Sub-box given by octant number. Midpoint provided.
|
||||||
treeBoundBox subBbox(const point& mid, const direction) const;
|
treeBoundBox subBbox(const point& mid, const direction) const;
|
||||||
|
|
||||||
//- Returns octant number given point and the calculated midpoint.
|
//- Returns octant number given point and the calculated midpoint.
|
||||||
@ -318,10 +309,10 @@ public:
|
|||||||
bool contains(const vector& dir, const point&) const;
|
bool contains(const vector& dir, const point&) const;
|
||||||
|
|
||||||
//- Code position of point on bounding box faces
|
//- Code position of point on bounding box faces
|
||||||
direction faceBits(const point&) const;
|
direction faceBits(const point& pt) const;
|
||||||
|
|
||||||
//- Position of point relative to bounding box
|
//- Position of point relative to bounding box
|
||||||
direction posBits(const point&) const;
|
direction posBits(const point& pt) const;
|
||||||
|
|
||||||
//- Calculate nearest and furthest (to point) vertex coords of
|
//- Calculate nearest and furthest (to point) vertex coords of
|
||||||
// bounding box
|
// bounding box
|
||||||
@ -333,7 +324,7 @@ public:
|
|||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Returns distance point to furthest away corner.
|
//- Returns distance point to furthest away corner.
|
||||||
scalar maxDist(const point&) const;
|
scalar maxDist(const point& pt) const;
|
||||||
|
|
||||||
//- Compare distance to point with other bounding box
|
//- Compare distance to point with other bounding box
|
||||||
// return:
|
// return:
|
||||||
@ -342,22 +333,24 @@ public:
|
|||||||
// +1 : all vertices of my bounding box are further away than
|
// +1 : all vertices of my bounding box are further away than
|
||||||
// any of other
|
// any of other
|
||||||
// 0 : none of the above.
|
// 0 : none of the above.
|
||||||
label distanceCmp(const point&, const treeBoundBox& other) const;
|
label distanceCmp(const point& pt, const treeBoundBox& other) const;
|
||||||
|
|
||||||
//- Return slightly wider bounding box
|
//- Return slightly wider bounding box
|
||||||
// Extends all dimensions with s*span*Random::scalar01()
|
// Extends all dimensions with s*span*Random::scalar01()
|
||||||
// and guarantees in any direction s*mag(span) minimum width
|
// and guarantees in any direction s*mag(span) minimum width
|
||||||
inline treeBoundBox extend(Random&, const scalar s) const;
|
inline treeBoundBox extend(Random& rndGen, const scalar s) const;
|
||||||
|
|
||||||
|
|
||||||
// Friend Operators
|
// Friend Operators
|
||||||
|
|
||||||
friend bool operator==(const treeBoundBox&, const treeBoundBox&);
|
friend bool operator==(const treeBoundBox& a, const treeBoundBox& b);
|
||||||
friend bool operator!=(const treeBoundBox&, const treeBoundBox&);
|
friend bool operator!=(const treeBoundBox& a, const treeBoundBox& b);
|
||||||
|
|
||||||
|
|
||||||
// IOstream operator
|
// IOstream operator
|
||||||
|
|
||||||
friend Istream& operator>>(Istream& is, treeBoundBox&);
|
friend Istream& operator>>(Istream& is, treeBoundBox& bb);
|
||||||
friend Ostream& operator<<(Ostream& os, const treeBoundBox&);
|
friend Ostream& operator<<(Ostream& os, const treeBoundBox& bb);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -34,18 +34,24 @@ inline Foam::treeBoundBox::treeBoundBox()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::treeBoundBox::treeBoundBox(const point& min, const point& max)
|
|
||||||
:
|
|
||||||
boundBox(min, max)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
inline Foam::treeBoundBox::treeBoundBox(const boundBox& bb)
|
inline Foam::treeBoundBox::treeBoundBox(const boundBox& bb)
|
||||||
:
|
:
|
||||||
boundBox(bb)
|
boundBox(bb)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::treeBoundBox::treeBoundBox(const point& pt)
|
||||||
|
:
|
||||||
|
boundBox(pt)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::treeBoundBox::treeBoundBox(const point& min, const point& max)
|
||||||
|
:
|
||||||
|
boundBox(min, max)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::treeBoundBox::treeBoundBox(Istream& is)
|
inline Foam::treeBoundBox::treeBoundBox(Istream& is)
|
||||||
:
|
:
|
||||||
boundBox(is)
|
boundBox(is)
|
||||||
@ -312,7 +318,6 @@ inline void Foam::treeBoundBox::searchOrder
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Return slightly wider bounding box
|
|
||||||
inline Foam::treeBoundBox Foam::treeBoundBox::extend
|
inline Foam::treeBoundBox Foam::treeBoundBox::extend
|
||||||
(
|
(
|
||||||
Random& rndGen,
|
Random& rndGen,
|
||||||
@ -326,7 +331,7 @@ inline Foam::treeBoundBox Foam::treeBoundBox::extend
|
|||||||
// Make 3D
|
// Make 3D
|
||||||
scalar minSpan = s * Foam::mag(newSpan);
|
scalar minSpan = s * Foam::mag(newSpan);
|
||||||
|
|
||||||
for (direction dir = 0; dir < vector::nComponents; dir++)
|
for (direction dir = 0; dir < vector::nComponents; ++dir)
|
||||||
{
|
{
|
||||||
newSpan[dir] = Foam::max(newSpan[dir], minSpan);
|
newSpan[dir] = Foam::max(newSpan[dir], minSpan);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -125,8 +125,7 @@ void Foam::polyMeshGeometry::updateCellCentresAndVols
|
|||||||
{
|
{
|
||||||
const point& fc = faceCentres_[cFaces[cFaceI]];
|
const point& fc = faceCentres_[cFaces[cFaceI]];
|
||||||
cEst += fc;
|
cEst += fc;
|
||||||
bb.max() = max(bb.max(), fc);
|
bb.add(fc);
|
||||||
bb.min() = min(bb.min(), fc);
|
|
||||||
}
|
}
|
||||||
cEst /= cFaces.size();
|
cEst /= cFaces.size();
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -199,21 +199,9 @@ void Foam::shellSurfaces::orient()
|
|||||||
|
|
||||||
if (shell.triSurface::size())
|
if (shell.triSurface::size())
|
||||||
{
|
{
|
||||||
const pointField& points = shell.points();
|
|
||||||
|
|
||||||
hasSurface = true;
|
hasSurface = true;
|
||||||
|
|
||||||
boundBox shellBb(points[0], points[0]);
|
|
||||||
// Assume surface is compact!
|
// Assume surface is compact!
|
||||||
forAll(points, i)
|
overallBb.add(shell.points());
|
||||||
{
|
|
||||||
const point& pt = points[i];
|
|
||||||
shellBb.min() = min(shellBb.min(), pt);
|
|
||||||
shellBb.max() = max(shellBb.max(), pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
overallBb.min() = min(overallBb.min(), shellBb.min());
|
|
||||||
overallBb.max() = max(overallBb.max(), shellBb.max());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -198,10 +198,10 @@ void Foam::AABBTree<Type>::createBoxes
|
|||||||
// Assign the objects to min or max bin
|
// Assign the objects to min or max bin
|
||||||
|
|
||||||
DynamicList<label> minBinObjectIDs(objectIDs.size());
|
DynamicList<label> minBinObjectIDs(objectIDs.size());
|
||||||
treeBoundBox minBb(point::max, point::min);
|
treeBoundBox minBb(boundBox::invertedBox);
|
||||||
|
|
||||||
DynamicList<label> maxBinObjectIDs(objectIDs.size());
|
DynamicList<label> maxBinObjectIDs(objectIDs.size());
|
||||||
treeBoundBox maxBb(point::max, point::min);
|
treeBoundBox maxBb(boundBox::invertedBox);
|
||||||
|
|
||||||
forAll(objectIDs, i)
|
forAll(objectIDs, i)
|
||||||
{
|
{
|
||||||
@ -229,16 +229,12 @@ void Foam::AABBTree<Type>::createBoxes
|
|||||||
if (intoMin)
|
if (intoMin)
|
||||||
{
|
{
|
||||||
minBinObjectIDs.append(objI);
|
minBinObjectIDs.append(objI);
|
||||||
const boundBox objBb(points, obj, false);
|
minBb.add(points, obj);
|
||||||
minBb.min() = min(minBb.min(), objBb.min());
|
|
||||||
minBb.max() = max(minBb.max(), objBb.max());
|
|
||||||
}
|
}
|
||||||
if (intoMax)
|
if (intoMax)
|
||||||
{
|
{
|
||||||
maxBinObjectIDs.append(objI);
|
maxBinObjectIDs.append(objI);
|
||||||
const boundBox objBb(points, obj, false);
|
maxBb.add(points, obj);
|
||||||
maxBb.min() = min(maxBb.min(), objBb.min());
|
|
||||||
maxBb.max() = max(maxBb.max(), objBb.max());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -41,20 +41,7 @@ namespace Foam
|
|||||||
|
|
||||||
Foam::treeBoundBox Foam::treeDataFace::calcBb(const label facei) const
|
Foam::treeBoundBox Foam::treeDataFace::calcBb(const label facei) const
|
||||||
{
|
{
|
||||||
const pointField& points = mesh_.points();
|
return treeBoundBox(mesh_.points(), mesh_.faces()[facei]);
|
||||||
|
|
||||||
const face& f = mesh_.faces()[facei];
|
|
||||||
|
|
||||||
treeBoundBox bb(points[f[0]], points[f[0]]);
|
|
||||||
|
|
||||||
for (label fp = 1; fp < f.size(); fp++)
|
|
||||||
{
|
|
||||||
const point& p = points[f[fp]];
|
|
||||||
|
|
||||||
bb.min() = min(bb.min(), p);
|
|
||||||
bb.max() = max(bb.max(), p);
|
|
||||||
}
|
|
||||||
return bb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -31,26 +31,6 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class PatchType>
|
|
||||||
Foam::treeBoundBox Foam::treeDataPrimitivePatch<PatchType>::calcBb
|
|
||||||
(
|
|
||||||
const pointField& points,
|
|
||||||
const face& f
|
|
||||||
)
|
|
||||||
{
|
|
||||||
treeBoundBox bb(points[f[0]], points[f[0]]);
|
|
||||||
|
|
||||||
for (label fp = 1; fp < f.size(); fp++)
|
|
||||||
{
|
|
||||||
const point& p = points[f[fp]];
|
|
||||||
|
|
||||||
bb.min() = min(bb.min(), p);
|
|
||||||
bb.max() = max(bb.max(), p);
|
|
||||||
}
|
|
||||||
return bb;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class PatchType>
|
template<class PatchType>
|
||||||
void Foam::treeDataPrimitivePatch<PatchType>::update()
|
void Foam::treeDataPrimitivePatch<PatchType>::update()
|
||||||
{
|
{
|
||||||
@ -60,7 +40,7 @@ void Foam::treeDataPrimitivePatch<PatchType>::update()
|
|||||||
|
|
||||||
forAll(patch_, i)
|
forAll(patch_, i)
|
||||||
{
|
{
|
||||||
bbs_[i] = calcBb(patch_.points(), patch_[i]);
|
bbs_[i] = treeBoundBox(patch_.points(), patch_[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -386,19 +366,14 @@ bool Foam::treeDataPrimitivePatch<PatchType>::overlaps
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// 1. Quick rejection: bb does not intersect face bb at all
|
// 1. Quick rejection: bb does not intersect face bb at all
|
||||||
if (cacheBb_)
|
if
|
||||||
|
(
|
||||||
|
cacheBb_
|
||||||
|
? !cubeBb.overlaps(bbs_[index])
|
||||||
|
: !cubeBb.overlaps(treeBoundBox(patch_.points(), patch_[index]))
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (!cubeBb.overlaps(bbs_[index]))
|
return false;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!cubeBb.overlaps(calcBb(patch_.points(), patch_[index])))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -459,19 +434,14 @@ bool Foam::treeDataPrimitivePatch<PatchType>::overlaps
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// 1. Quick rejection: sphere does not intersect face bb at all
|
// 1. Quick rejection: sphere does not intersect face bb at all
|
||||||
if (cacheBb_)
|
if
|
||||||
|
(
|
||||||
|
cacheBb_
|
||||||
|
? !bbs_[index].overlaps(centre, radiusSqr)
|
||||||
|
: !treeBoundBox(patch_.points(),patch_[index]).overlaps(centre, radiusSqr)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (!bbs_[index].overlaps(centre, radiusSqr))
|
return false;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!calcBb(patch_.points(), patch_[index]).overlaps(centre, radiusSqr))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const pointField& points = patch_.points();
|
const pointField& points = patch_.points();
|
||||||
|
|||||||
@ -80,9 +80,6 @@ class treeDataPrimitivePatch
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Calculate face bounding box
|
|
||||||
static treeBoundBox calcBb(const pointField&, const face&);
|
|
||||||
|
|
||||||
//- Initialise all member data
|
//- Initialise all member data
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -244,8 +244,8 @@ Foam::searchableSurfaceCollection::searchableSurfaceCollection
|
|||||||
subGeom_.setSize(surfI);
|
subGeom_.setSize(surfI);
|
||||||
indexOffset_.setSize(surfI+1);
|
indexOffset_.setSize(surfI+1);
|
||||||
|
|
||||||
// Bounds is the overall bounds
|
// Bounds is the overall bounds - prepare for min/max ops
|
||||||
bounds() = boundBox(point::max, point::min);
|
bounds() = boundBox::invertedBox;
|
||||||
|
|
||||||
forAll(subGeom_, surfI)
|
forAll(subGeom_, surfI)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -659,18 +659,14 @@ Foam::boundBox Foam::searchableSurfacesQueries::bounds
|
|||||||
const labelList& surfacesToTest
|
const labelList& surfacesToTest
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
pointField bbPoints(2*surfacesToTest.size());
|
boundBox bb(boundBox::invertedBox);
|
||||||
|
|
||||||
forAll(surfacesToTest, testI)
|
forAll(surfacesToTest, testi)
|
||||||
{
|
{
|
||||||
const searchableSurface& surface(allSurfaces[surfacesToTest[testI]]);
|
bb.add(allSurfaces[surfacesToTest[testi]].bounds());
|
||||||
|
|
||||||
bbPoints[2*testI] = surface.bounds().min();
|
|
||||||
|
|
||||||
bbPoints[2*testI + 1] = surface.bounds().max();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return boundBox(bbPoints);
|
return bb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -55,13 +55,9 @@ Foam::treeBoundBox Foam::tetOverlapVolume::pyrBb
|
|||||||
const point& fc
|
const point& fc
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
treeBoundBox bb(fc, fc);
|
treeBoundBox bb(fc);
|
||||||
forAll(f, fp)
|
bb.add(points, f);
|
||||||
{
|
|
||||||
const point& pt = points[f[fp]];
|
|
||||||
bb.min() = min(bb.min(), pt);
|
|
||||||
bb.max() = max(bb.max(), pt);
|
|
||||||
}
|
|
||||||
return bb;
|
return bb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -891,28 +891,19 @@ Foam::distributedTriSurfaceMesh::independentlyDistributedBbs
|
|||||||
|
|
||||||
// Find bounding box for all triangles on new distribution.
|
// Find bounding box for all triangles on new distribution.
|
||||||
|
|
||||||
// Initialise to inverted box (VGREAT, -VGREAT)
|
// Initialise to inverted box (GREAT, -GREAT)
|
||||||
List<List<treeBoundBox>> bbs(Pstream::nProcs());
|
List<List<treeBoundBox>> bbs(Pstream::nProcs());
|
||||||
forAll(bbs, procI)
|
forAll(bbs, procI)
|
||||||
{
|
{
|
||||||
bbs[procI].setSize(1);
|
bbs[procI].setSize(1, treeBoundBox::invertedBox);
|
||||||
//bbs[procI][0] = boundBox::invertedBox;
|
|
||||||
bbs[procI][0].min() = point( VGREAT, VGREAT, VGREAT);
|
|
||||||
bbs[procI][0].max() = point(-VGREAT, -VGREAT, -VGREAT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll(s, triI)
|
forAll(s, triI)
|
||||||
{
|
{
|
||||||
point& bbMin = bbs[distribution[triI]][0].min();
|
|
||||||
point& bbMax = bbs[distribution[triI]][0].max();
|
|
||||||
|
|
||||||
const triSurface::FaceType& f = s[triI];
|
const triSurface::FaceType& f = s[triI];
|
||||||
forAll(f, fp)
|
|
||||||
{
|
treeBoundBox& bb = bbs[distribution[triI]][0];
|
||||||
const point& pt = s.points()[f[fp]];
|
bb.add(s.points(), f);
|
||||||
bbMin = ::Foam::min(bbMin, pt);
|
|
||||||
bbMax = ::Foam::max(bbMax, pt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now combine for all processors and convert to correct format.
|
// Now combine for all processors and convert to correct format.
|
||||||
@ -936,17 +927,14 @@ bool Foam::distributedTriSurfaceMesh::overlaps
|
|||||||
const point& p2
|
const point& p2
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
treeBoundBox triBb(p0);
|
||||||
|
triBb.add(p1);
|
||||||
|
triBb.add(p2);
|
||||||
|
|
||||||
forAll(bbs, bbI)
|
forAll(bbs, bbI)
|
||||||
{
|
{
|
||||||
const treeBoundBox& bb = bbs[bbI];
|
const treeBoundBox& bb = bbs[bbI];
|
||||||
|
|
||||||
treeBoundBox triBb(p0, p0);
|
|
||||||
triBb.min() = min(triBb.min(), p1);
|
|
||||||
triBb.min() = min(triBb.min(), p2);
|
|
||||||
|
|
||||||
triBb.max() = max(triBb.max(), p1);
|
|
||||||
triBb.max() = max(triBb.max(), p2);
|
|
||||||
|
|
||||||
// Exact test of triangle intersecting bb
|
// Exact test of triangle intersecting bb
|
||||||
|
|
||||||
// Quick rejection. If whole bounding box of tri is outside cubeBb then
|
// Quick rejection. If whole bounding box of tri is outside cubeBb then
|
||||||
@ -2022,7 +2010,7 @@ Foam::triSurface Foam::distributedTriSurfaceMesh::overlappingSurface
|
|||||||
const scalar eps = 1.0e-4;
|
const scalar eps = 1.0e-4;
|
||||||
forAll(bbs, i)
|
forAll(bbs, i)
|
||||||
{
|
{
|
||||||
const point mid = 0.5*(bbs[i].min() + bbs[i].max());
|
const point mid = bbs[i].midpoint();
|
||||||
const vector halfSpan = (1.0+eps)*(bbs[i].max() - mid);
|
const vector halfSpan = (1.0+eps)*(bbs[i].max() - mid);
|
||||||
|
|
||||||
bbsX[i].min() = mid - halfSpan;
|
bbsX[i].min() = mid - halfSpan;
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -177,14 +177,13 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
|
|||||||
const cell& c = cells[celli];
|
const cell& c = cells[celli];
|
||||||
|
|
||||||
// determine bounding box of tgt cell
|
// determine bounding box of tgt cell
|
||||||
boundBox cellBb(point::max, point::min);
|
boundBox cellBb(boundBox::invertedBox);
|
||||||
forAll(c, facei)
|
forAll(c, facei)
|
||||||
{
|
{
|
||||||
const face& f = faces[c[facei]];
|
const face& f = faces[c[facei]];
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
cellBb.min() = min(cellBb.min(), points[f[fp]]);
|
cellBb.add(points, f);
|
||||||
cellBb.max() = max(cellBb.max(), points[f[fp]]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -79,12 +79,9 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
|
|||||||
{
|
{
|
||||||
bndFaces[nFaces++] = pp.start()+i;
|
bndFaces[nFaces++] = pp.start()+i;
|
||||||
const face& f = pp[i];
|
const face& f = pp[i];
|
||||||
forAll(f, fp)
|
|
||||||
{
|
// Without reduction.
|
||||||
const point& pt = pp.points()[f[fp]];
|
overallBb.add(pp.points(), f);
|
||||||
overallBb.min() = min(overallBb.min(), pt);
|
|
||||||
overallBb.max() = max(overallBb.max(), pt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -74,7 +74,7 @@ void Foam::patchCloudSet::calcSamples
|
|||||||
|
|
||||||
labelList patchFaces(sz);
|
labelList patchFaces(sz);
|
||||||
sz = 0;
|
sz = 0;
|
||||||
treeBoundBox bb(point::max, point::min);
|
treeBoundBox bb(treeBoundBox::invertedBox);
|
||||||
forAllConstIter(labelHashSet, patchSet_, iter)
|
forAllConstIter(labelHashSet, patchSet_, iter)
|
||||||
{
|
{
|
||||||
const polyPatch& pp = mesh().boundaryMesh()[iter.key()];
|
const polyPatch& pp = mesh().boundaryMesh()[iter.key()];
|
||||||
@ -84,11 +84,8 @@ void Foam::patchCloudSet::calcSamples
|
|||||||
patchFaces[sz++] = pp.start()+i;
|
patchFaces[sz++] = pp.start()+i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not do reduction.
|
// Without reduction.
|
||||||
const boundBox patchBb(pp.points(), pp.meshPoints(), false);
|
bb.add(pp.points(), pp.meshPoints());
|
||||||
|
|
||||||
bb.min() = min(bb.min(), patchBb.min());
|
|
||||||
bb.max() = max(bb.max(), patchBb.max());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not very random
|
// Not very random
|
||||||
@ -97,8 +94,8 @@ void Foam::patchCloudSet::calcSamples
|
|||||||
bb = bb.extend(rndGen, 1e-4);
|
bb = bb.extend(rndGen, 1e-4);
|
||||||
|
|
||||||
// Make sure bb is 3D.
|
// Make sure bb is 3D.
|
||||||
bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
bb.min() -= point::uniform(ROOTVSMALL);
|
||||||
bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
bb.max() += point::uniform(ROOTVSMALL);
|
||||||
|
|
||||||
|
|
||||||
indexedOctree<treeDataFace> patchTree
|
indexedOctree<treeDataFace> patchTree
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -778,8 +778,8 @@ bool Foam::sampledTriSurfaceMesh::update()
|
|||||||
surface_.triSurface::points(),
|
surface_.triSurface::points(),
|
||||||
surface_.triSurface::meshPoints()
|
surface_.triSurface::meshPoints()
|
||||||
);
|
);
|
||||||
bb.min() = max(bb.min(), mesh().bounds().min());
|
|
||||||
bb.max() = min(bb.max(), mesh().bounds().max());
|
bb.intersect(mesh().bounds());
|
||||||
|
|
||||||
// Extend a bit
|
// Extend a bit
|
||||||
const vector span(bb.span());
|
const vector span(bb.span());
|
||||||
|
|||||||
@ -1106,7 +1106,7 @@ void Foam::triSurface::writeStats(Ostream& os) const
|
|||||||
PackedBoolList pointIsUsed(points().size());
|
PackedBoolList pointIsUsed(points().size());
|
||||||
|
|
||||||
label nPoints = 0;
|
label nPoints = 0;
|
||||||
boundBox bb = boundBox::invertedBox;
|
boundBox bb(boundBox::invertedBox);
|
||||||
|
|
||||||
forAll(*this, facei)
|
forAll(*this, facei)
|
||||||
{
|
{
|
||||||
@ -1117,9 +1117,8 @@ void Foam::triSurface::writeStats(Ostream& os) const
|
|||||||
label pointi = f[fp];
|
label pointi = f[fp];
|
||||||
if (pointIsUsed.set(pointi, 1))
|
if (pointIsUsed.set(pointi, 1))
|
||||||
{
|
{
|
||||||
bb.min() = ::Foam::min(bb.min(), points()[pointi]);
|
bb.add(points()[pointi]);
|
||||||
bb.max() = ::Foam::max(bb.max(), points()[pointi]);
|
++nPoints;
|
||||||
nPoints++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user