Commit dcc82bf7 authored by Mark Olesen's avatar Mark Olesen
Browse files

boundingBox has mag() and span() methods - use them

parent 172b862c
......@@ -93,7 +93,7 @@ Foam::labelList Foam::blockMesh::createMergeList()
// the size of the block.
boundBox bb(blockCells[blockPlabel].points(blockFaces, blockPoints));
const scalar mergeSqrDist = SMALL*magSqr(bb.max() - bb.min());
const scalar mergeSqrDist = SMALL*magSqr(bb.span());
// This is an N^2 algorithm
......
......@@ -177,9 +177,9 @@ int main(int argc, char *argv[])
const boundBox& bb = mesh.globalData().bb();
const vector span(bb.max() - bb.min());
const vector span = bb.span();
const scalar minDim = min(span[0], min(span[1], span[2]));
const scalar mergeDim = 1E-4*minDim;
const scalar mergeDim = 1E-4 * minDim;
Pout<< "Mesh bounding box:" << bb << nl
<< " with span:" << span << nl
......
......@@ -55,7 +55,7 @@ using namespace Foam;
scalar getMergeDistance(const polyMesh& mesh, const scalar mergeTol)
{
const boundBox& meshBb = mesh.bounds();
scalar mergeDist = mergeTol*mag(meshBb.max() - meshBb.min());
scalar mergeDist = mergeTol * meshBb.mag();
scalar writeTol = std::pow
(
scalar(10.0),
......
......@@ -20,7 +20,7 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
// Min length
scalar minDistSqr = magSqr(1e-6*(globalBb.max() - globalBb.min()));
scalar minDistSqr = magSqr(1e-6 * globalBb.span());
// Non-empty directions
const Vector<label> validDirs = (mesh.directions() + Vector<label>::one)/2;
......
......@@ -471,7 +471,7 @@ int main(int argc, char *argv[])
bb.min() = min(bb.min(), domainBb.min());
bb.max() = max(bb.max(), domainBb.max());
}
const scalar mergeDist = mergeTol*mag(bb.max() - bb.min());
const scalar mergeDist = mergeTol * bb.mag();
Info<< "Overall mesh bounding box : " << bb << nl
<< "Relative tolerance : " << mergeTol << nl
......@@ -533,15 +533,14 @@ int main(int argc, char *argv[])
// Find geometrically shared points/faces.
autoPtr<faceCoupleInfo> couples =
determineCoupledFaces
(
fullMatch,
procI,
masterMesh,
meshToAdd,
mergeDist
);
autoPtr<faceCoupleInfo> couples = determineCoupledFaces
(
fullMatch,
procI,
masterMesh,
meshToAdd,
mergeDist
);
// Add elements to mesh
......
......@@ -244,7 +244,8 @@ scalar getMergeDistance
{
mergeTol = readScalar(IStringStream(args.options()["mergeTol"])());
}
scalar writeTol =
scalar writeTol =
Foam::pow(scalar(10.0), -scalar(IOstream::defaultPrecision()));
Info<< "Merge tolerance : " << mergeTol << nl
......@@ -263,7 +264,7 @@ scalar getMergeDistance
<< exit(FatalError);
}
scalar mergeDist = mergeTol*mag(bb.max() - bb.min());
scalar mergeDist = mergeTol * bb.mag();
Info<< "Overall meshes bounding box : " << bb << nl
<< "Relative tolerance : " << mergeTol << nl
......@@ -276,26 +277,15 @@ scalar getMergeDistance
void printMeshData(Ostream& os, const polyMesh& mesh)
{
os << "Number of points: "
<< mesh.points().size() << nl
<< " edges: "
<< mesh.edges().size() << nl
<< " faces: "
<< mesh.faces().size() << nl
<< " internal faces: "
<< mesh.faceNeighbour().size() << nl
<< " cells: "
<< mesh.cells().size() << nl
<< " boundary patches: "
<< mesh.boundaryMesh().size() << nl
<< " point zones: "
<< mesh.pointZones().size() << nl
<< " face zones: "
<< mesh.faceZones().size() << nl
<< " cell zones: "
<< mesh.cellZones().size() << nl;
os << "Number of points: " << mesh.points().size() << nl
<< " edges: " << mesh.edges().size() << nl
<< " faces: " << mesh.faces().size() << nl
<< " internal faces: " << mesh.faceNeighbour().size() << nl
<< " cells: " << mesh.cells().size() << nl
<< " boundary patches: " << mesh.boundaryMesh().size() << nl
<< " point zones: " << mesh.pointZones().size() << nl
<< " face zones: " << mesh.faceZones().size() << nl
<< " cell zones: " << mesh.cellZones().size() << nl;
}
......@@ -308,7 +298,7 @@ void writeDecomposition
)
{
Info<< "Writing wanted cell distribution to volScalarField " << name
<< " for postprocessing purposes." << nl << endl;
<< " for postprocessing purposes." << nl << endl;
volScalarField procCells
(
......
......@@ -325,7 +325,7 @@ int main(int argc, char *argv[])
Pout<< " " << min << " .. " << min+dist << " : "
<< 1.0/surf.size() * binCount[binI]
<< endl;
min += dist;
min += dist;
}
Pout<< endl;
......@@ -408,10 +408,10 @@ int main(int argc, char *argv[])
const pointField& localPoints = surf.localPoints();
const boundBox bb(localPoints);
scalar smallDim = 1E-6*mag(bb.max() - bb.min());
scalar smallDim = 1E-6 * bb.mag();
Pout<< "Checking for points less than 1E-6 of bounding box ("
<< bb.max() - bb.min() << " meter) apart."
Pout<< "Checking for points less than 1E-6 of bounding box ("
<< bb.span() << " meter) apart."
<< endl;
// Sort points
......@@ -495,7 +495,7 @@ int main(int argc, char *argv[])
nSingleEdges++;
}
}
label nMultEdges = 0;
forAll(eFaces, edgeI)
{
......@@ -654,7 +654,7 @@ int main(int argc, char *argv[])
}
Pout<< endl;
}
Pout<< "End\n" << endl;
......
......@@ -202,8 +202,7 @@ int main(int argc, char *argv[])
// Get search box. Anything not within this box will not be considered.
const boundBox& meshBb = mesh.globalData().bb();
const vector searchSpan(searchTol*(meshBb.max() - meshBb.min()));
const vector searchSpan = searchTol * meshBb.span();
Info<< "All boundary faces further away than " << searchTol
<< " of mesh bounding box " << meshBb
......@@ -217,7 +216,7 @@ int main(int argc, char *argv[])
{
Info<< " " << mesh.boundaryMesh()[patchI].name() << '\t'
<< mesh.boundaryMesh()[patchI].size() << endl;
}
}
Info<< endl;
......@@ -309,7 +308,7 @@ int main(int argc, char *argv[])
{
Info<< " " << mesh.boundaryMesh()[patchI].name() << '\t'
<< mesh.boundaryMesh()[patchI].size() << endl;
}
}
Info<< endl;
......@@ -318,7 +317,7 @@ int main(int argc, char *argv[])
// Write resulting mesh
Info << "Writing modified mesh to time " << runTime.value() << endl;
mesh.write();
}
}
Info<< "End\n" << endl;
......
......@@ -98,26 +98,37 @@ public:
// Access
//- Minimum describing the bounding box
const point& min() const
{
return min_;
}
//- Maximum describing the bounding box
const point& max() const
{
return max_;
}
//- Minimum describing the bounding box, non-const access
point& min()
{
return min_;
}
//- Maximum describing the bounding box, non-const access
point& max()
{
return max_;
}
//- The bounding box span (from minimum to maximum)
vector span() const
{
return (max_ - min_);
}
//- The magnitude of the bounding box span
scalar mag() const
{
return ::Foam::mag(max_ - min_);
......
......@@ -663,7 +663,7 @@ Foam::pointField Foam::globalMeshData::geometricSharedPoints() const
combineReduce(sharedPoints, plusEqOp<pointField>());
// Merge tolerance
scalar tolDim = matchTol_*mag(bb_.max() - bb_.min());
scalar tolDim = matchTol_ * bb_.mag();
// And see how many are unique
labelList pMap;
......@@ -731,7 +731,7 @@ void Foam::globalMeshData::updateMesh()
// Bounding box (does communication)
bb_ = boundBox(mesh_.points(), true);
scalar tolDim = matchTol_*mag(bb_.max() - bb_.min());
scalar tolDim = matchTol_ * bb_.mag();
if (debug)
{
......
......@@ -46,10 +46,8 @@ License
namespace Foam
{
defineTypeNameAndDebug(autoHexMeshDriver, 0);
} // End namespace Foam
defineTypeNameAndDebug(autoHexMeshDriver, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......@@ -59,7 +57,7 @@ Foam::scalar Foam::autoHexMeshDriver::getMergeDistance(const scalar mergeTol)
const
{
const boundBox& meshBb = mesh_.bounds();
scalar mergeDist = mergeTol*mag(meshBb.max() - meshBb.min());
scalar mergeDist = mergeTol * meshBb.mag();
scalar writeTol = std::pow
(
scalar(10.0),
......@@ -118,7 +116,7 @@ Foam::scalar Foam::autoHexMeshDriver::getMergeDistance(const scalar mergeTol)
//
// if (hasSurface)
// {
// const point outsidePt(2*overallBb.max() - overallBb.min());
// const point outsidePt = 2 * overallBb.span();
//
// //Info<< "Using point " << outsidePt << " to orient shells" << endl;
//
......
......@@ -193,7 +193,7 @@ void Foam::shellSurfaces::orient()
if (hasSurface)
{
const point outsidePt(2*overallBb.max() - overallBb.min());
const point outsidePt = 2 * overallBb.span();
//Info<< "Using point " << outsidePt << " to orient shells" << endl;
......
......@@ -4375,8 +4375,7 @@ void Foam::hexRef8::distribute(const mapDistributePolyMesh& map)
void Foam::hexRef8::checkMesh() const
{
const boundBox& meshBb = mesh_.globalData().bb();
const scalar smallDim = 1E-6*mag(meshBb.max() - meshBb.min());
const scalar smallDim = 1E-6 * mesh_.globalData().bb().mag();
if (debug)
{
......
......@@ -224,10 +224,8 @@ void Foam::displacementSBRStressFvMotionSolver::updateMesh
);
// Note: boundBox does reduce
const boundBox bb0(points0_, true);
const vector span0(bb0.max()-bb0.min());
const boundBox bb(points, true);
const vector span(bb.max()-bb.min());
const vector span0 = boundBox(points0_, true).span();
const vector span = boundBox(points, true).span();
vector scaleFactors(cmptDivide(span0, span));
......
......@@ -433,10 +433,8 @@ void Foam::displacementInterpolationFvMotionSolver::updateMesh
);
// Note: boundBox does reduce
const boundBox bb0(points0_, true);
const vector span0(bb0.max()-bb0.min());
const boundBox bb(points, true);
const vector span(bb.max()-bb.min());
const vector span0 = boundBox(points0_, true).span();
const vector span = boundBox(points, true).span();
vector scaleFactors(cmptDivide(span0, span));
......@@ -445,7 +443,7 @@ void Foam::displacementInterpolationFvMotionSolver::updateMesh
forAll(newPoints0, pointI)
{
label oldPointI = mpm.pointMap()[pointI];
if (oldPointI >= 0)
{
label masterPointI = mpm.reversePointMap()[oldPointI];
......
......@@ -166,7 +166,7 @@ Foam::displacementLaplacianFvMotionSolver::
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::pointField>
Foam::tmp<Foam::pointField>
Foam::displacementLaplacianFvMotionSolver::curPoints() const
{
volPointInterpolation::New(fvMesh_).interpolate
......@@ -272,10 +272,8 @@ void Foam::displacementLaplacianFvMotionSolver::updateMesh
);
// Note: boundBox does reduce
const boundBox bb0(points0_, true);
const vector span0(bb0.max()-bb0.min());
const boundBox bb(points, true);
const vector span(bb.max()-bb.min());
const vector span0 = boundBox(points0_, true).span();
const vector span = boundBox(points, true).span();
vector scaleFactors(cmptDivide(span0, span));
......@@ -284,7 +282,7 @@ void Foam::displacementLaplacianFvMotionSolver::updateMesh
forAll(newPoints0, pointI)
{
label oldPointI = mpm.pointMap()[pointI];
if (oldPointI >= 0)
{
label masterPointI = mpm.reversePointMap()[oldPointI];
......
......@@ -169,12 +169,12 @@ void surfaceSlipDisplacementPointPatchVectorField::evaluate
{
const polyMesh& mesh = patch().boundaryMesh().mesh()();
//const scalar deltaT = mesh.time().deltaT().value();
// const scalar deltaT = mesh.time().deltaT().value();
// Construct large enough vector in direction of projectDir so
// we're guaranteed to hit something.
const scalar projectLen = mag(mesh.bounds().max()-mesh.bounds().min());
const scalar projectLen = mesh.bounds().mag();
// For case of fixed projection vector:
vector projectVec;
......@@ -307,7 +307,7 @@ void surfaceSlipDisplacementPointPatchVectorField::evaluate
rightHit
);
}
List<pointIndexHit> leftHit;
{
labelList leftSurf;
......
......@@ -243,7 +243,7 @@ void Foam::directMappedPolyPatch::findSamples
nearInfo = boundaryTree().findNearest
(
sample,
magSqr(patchBb.max()-patchBb.min())
magSqr(patchBb.span())
);
if (!nearInfo.hit())
......
......@@ -220,7 +220,7 @@ Foam::label Foam::treeDataTriSurface::getVolumeType
max
(
Foam::sqr(GREAT),
Foam::magSqr(treeBb.max() - treeBb.min())
Foam::magSqr(treeBb.span())
)
);
......
......@@ -100,8 +100,8 @@ Foam::label Foam::meshSearch::findNearestCellTree(const point& location) const
{
const indexedOctree<treeDataPoint>& tree = cellCentreTree();
scalar span = mag(tree.bb().max() - tree.bb().min());
scalar span = tree.bb().mag();
pointIndexHit info = tree.findNearest(location, Foam::sqr(span));
if (!info.hit())
......@@ -177,7 +177,7 @@ Foam::label Foam::meshSearch::findNearestFaceTree(const point& location) const
// Search nearest cell centre.
const indexedOctree<treeDataPoint>& tree = cellCentreTree();
scalar span = mag(tree.bb().max() - tree.bb().min());
scalar span = tree.bb().mag();
// Search with decent span
pointIndexHit info = tree.findNearest(location, Foam::sqr(span));
......@@ -803,7 +803,7 @@ Foam::label Foam::meshSearch::findNearestBoundaryFace
{
const indexedOctree<treeDataFace>& tree = boundaryTree();
scalar span = mag(tree.bb().max() - tree.bb().min());
scalar span = tree.bb().mag();
pointIndexHit info = boundaryTree().findNearest
(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment