ENH: Merge searchableSurface and indexedOctree volumeType

This commit is contained in:
laurence
2013-04-11 19:52:03 +01:00
parent 05b6a09bda
commit e2482a4e8b
42 changed files with 580 additions and 305 deletions

View File

@ -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) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -155,10 +155,10 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
// For each cell in the mesh has it been determined if it is fully // For each cell in the mesh has it been determined if it is fully
// inside, outside, or overlaps the surface // inside, outside, or overlaps the surface
labelList volumeStatus List<volumeType> volumeStatus
( (
mesh_.nCells(), mesh_.nCells(),
searchableSurface::UNKNOWN volumeType::UNKNOWN
); );
// Surface refinement // Surface refinement
@ -168,7 +168,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
// Determine/update the status of each cell // Determine/update the status of each cell
forAll(volumeStatus, cellI) forAll(volumeStatus, cellI)
{ {
if (volumeStatus[cellI] == searchableSurface::UNKNOWN) if (volumeStatus[cellI] == volumeType::UNKNOWN)
{ {
treeBoundBox cellBb treeBoundBox cellBb
( (
@ -181,16 +181,15 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
if (geometry.overlaps(cellBb)) if (geometry.overlaps(cellBb))
{ {
volumeStatus[cellI] = searchableSurface::MIXED; volumeStatus[cellI] = volumeType::MIXED;
} }
else if (geometry.inside(cellBb.midpoint())) else if (geometry.inside(cellBb.midpoint()))
{ {
volumeStatus[cellI] = searchableSurface::INSIDE; volumeStatus[cellI] = volumeType::INSIDE;
} }
else else
{ {
volumeStatus[cellI] = volumeStatus[cellI] = volumeType::OUTSIDE;
searchableSurface::OUTSIDE;
} }
} }
} }
@ -216,9 +215,9 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
{ {
label cellI = newCellsToRefine[nCTRI]; label cellI = newCellsToRefine[nCTRI];
if (volumeStatus[cellI] == searchableSurface::MIXED) if (volumeStatus[cellI] == volumeType::MIXED)
{ {
volumeStatus[cellI] = searchableSurface::UNKNOWN; volumeStatus[cellI] = volumeType::UNKNOWN;
} }
icellWeights[cellI] = max icellWeights[cellI] = max
@ -260,7 +259,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
const labelList& cellMap = map().cellMap(); const labelList& cellMap = map().cellMap();
labelList newVolumeStatus(cellMap.size()); List<volumeType> newVolumeStatus(cellMap.size());
forAll(cellMap, newCellI) forAll(cellMap, newCellI)
{ {
@ -268,8 +267,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
if (oldCellI == -1) if (oldCellI == -1)
{ {
newVolumeStatus[newCellI] = newVolumeStatus[newCellI] = volumeType::UNKNOWN;
searchableSurface::UNKNOWN;
} }
else else
{ {
@ -289,7 +287,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
// Determine/update the status of each cell // Determine/update the status of each cell
forAll(volumeStatus, cellI) forAll(volumeStatus, cellI)
{ {
if (volumeStatus[cellI] == searchableSurface::UNKNOWN) if (volumeStatus[cellI] == volumeType::UNKNOWN)
{ {
treeBoundBox cellBb treeBoundBox cellBb
( (
@ -302,16 +300,15 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
if (geometry.overlaps(cellBb)) if (geometry.overlaps(cellBb))
{ {
volumeStatus[cellI] = searchableSurface::MIXED; volumeStatus[cellI] = volumeType::MIXED;
} }
else if (geometry.inside(cellBb.midpoint())) else if (geometry.inside(cellBb.midpoint()))
{ {
volumeStatus[cellI] = searchableSurface::INSIDE; volumeStatus[cellI] = volumeType::INSIDE;
} }
else else
{ {
volumeStatus[cellI] = volumeStatus[cellI] = volumeType::OUTSIDE;
searchableSurface::OUTSIDE;
} }
} }
} }
@ -325,7 +322,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
forAll(volumeStatus, cellI) forAll(volumeStatus, cellI)
{ {
if (volumeStatus[cellI] == searchableSurface::OUTSIDE) if (volumeStatus[cellI] == volumeType::OUTSIDE)
{ {
cellsToRemove.append(cellI); cellsToRemove.append(cellI);
} }
@ -372,7 +369,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
const labelList& cellMap = map().cellMap(); const labelList& cellMap = map().cellMap();
labelList newVolumeStatus(cellMap.size()); List<volumeType> newVolumeStatus(cellMap.size());
forAll(cellMap, newCellI) forAll(cellMap, newCellI)
{ {
@ -380,13 +377,11 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
if (oldCellI == -1) if (oldCellI == -1)
{ {
newVolumeStatus[newCellI] = newVolumeStatus[newCellI] = volumeType::UNKNOWN;
searchableSurface::UNKNOWN;
} }
else else
{ {
newVolumeStatus[newCellI] = newVolumeStatus[newCellI] = volumeStatus[oldCellI];
volumeStatus[oldCellI];
} }
} }
@ -511,7 +506,7 @@ void Foam::backgroundMeshDecomposition::printMeshData
bool Foam::backgroundMeshDecomposition::refineCell bool Foam::backgroundMeshDecomposition::refineCell
( (
label cellI, label cellI,
label volType, volumeType volType,
scalar& weightEstimate scalar& weightEstimate
) const ) const
{ {
@ -531,7 +526,7 @@ bool Foam::backgroundMeshDecomposition::refineCell
weightEstimate = 1.0; weightEstimate = 1.0;
if (volType == searchableSurface::MIXED) if (volType == volumeType::MIXED)
{ {
// // Assess the cell size at the nearest point on the surface for the // // Assess the cell size at the nearest point on the surface for the
// // MIXED cells, if the cell is large with respect to the cell size, // // MIXED cells, if the cell is large with respect to the cell size,
@ -611,7 +606,7 @@ bool Foam::backgroundMeshDecomposition::refineCell
// return true; // return true;
// } // }
} }
else if (volType == searchableSurface::INSIDE) else if (volType == volumeType::INSIDE)
{ {
// scalar s = cvMesh_.cellShapeControl_.cellSize(cellBb.midpoint()); // scalar s = cvMesh_.cellShapeControl_.cellSize(cellBb.midpoint());
@ -634,7 +629,7 @@ bool Foam::backgroundMeshDecomposition::refineCell
Foam::labelList Foam::backgroundMeshDecomposition::selectRefinementCells Foam::labelList Foam::backgroundMeshDecomposition::selectRefinementCells
( (
labelList& volumeStatus, List<volumeType>& volumeStatus,
volScalarField& cellWeights volScalarField& cellWeights
) const ) const
{ {
@ -645,7 +640,7 @@ Foam::labelList Foam::backgroundMeshDecomposition::selectRefinementCells
// Determine/update the status of each cell // Determine/update the status of each cell
forAll(volumeStatus, cellI) forAll(volumeStatus, cellI)
{ {
if (volumeStatus[cellI] == searchableSurface::MIXED) if (volumeStatus[cellI] == volumeType::MIXED)
{ {
if (meshCutter_.cellLevel()[cellI] < minLevels_) if (meshCutter_.cellLevel()[cellI] < minLevels_)
{ {
@ -653,7 +648,7 @@ Foam::labelList Foam::backgroundMeshDecomposition::selectRefinementCells
} }
} }
if (volumeStatus[cellI] != searchableSurface::OUTSIDE) if (volumeStatus[cellI] != volumeType::OUTSIDE)
{ {
if if
( (
@ -705,7 +700,12 @@ void Foam::backgroundMeshDecomposition::buildPatchAndTree()
( (
new indexedOctree<treeDataBPatch> new indexedOctree<treeDataBPatch>
( (
treeDataBPatch(false, boundaryFacesPtr_()), treeDataBPatch
(
false,
boundaryFacesPtr_(),
indexedOctree<treeDataBPatch>::perturbTol()
),
overallBb.extend(rnd, 1e-4), overallBb.extend(rnd, 1e-4),
10, // maxLevel 10, // maxLevel
10, // leafSize 10, // leafSize
@ -1064,11 +1064,7 @@ bool Foam::backgroundMeshDecomposition::positionOnThisProcessor
{ {
// return bFTreePtr_().findAnyOverlap(pt, 0.0); // return bFTreePtr_().findAnyOverlap(pt, 0.0);
return return (bFTreePtr_().getVolumeType(pt) == volumeType::INSIDE);
(
bFTreePtr_().getVolumeType(pt)
== indexedOctree<treeDataBPatch>::INSIDE
);
} }

View File

@ -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) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -71,6 +71,7 @@ SourceFiles
#include "pointField.H" #include "pointField.H"
#include "indexedOctree.H" #include "indexedOctree.H"
#include "treeDataPrimitivePatch.H" #include "treeDataPrimitivePatch.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -166,7 +167,7 @@ class backgroundMeshDecomposition
bool refineCell bool refineCell
( (
label cellI, label cellI,
label volType, volumeType volType,
scalar& weightEstimate scalar& weightEstimate
) const; ) const;
@ -174,7 +175,7 @@ class backgroundMeshDecomposition
// meshed // meshed
labelList selectRefinementCells labelList selectRefinementCells
( (
labelList& volumeStatus, List<volumeType>& volumeStatus,
volScalarField& cellWeights volScalarField& cellWeights
) const; ) const;

View File

@ -27,6 +27,7 @@ License
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "triSurfaceMesh.H" #include "triSurfaceMesh.H"
#include "triSurfaceFields.H" #include "triSurfaceFields.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -125,7 +126,7 @@ bool linearDistance::cellSize(const point& pt, scalar& size) const
} }
pointField ptF(1, pt); pointField ptF(1, pt);
List<searchableSurface::volumeType> vTL; List<volumeType> vTL;
surface_.getVolumeType(ptF, vTL); surface_.getVolumeType(ptF, vTL);
@ -134,7 +135,7 @@ bool linearDistance::cellSize(const point& pt, scalar& size) const
if if
( (
sideMode_ == smInside sideMode_ == smInside
&& vTL[0] == searchableSurface::INSIDE && vTL[0] == volumeType::INSIDE
) )
{ {
size = sizeFunction(hitPt, dist, hitIndex); size = sizeFunction(hitPt, dist, hitIndex);
@ -144,7 +145,7 @@ bool linearDistance::cellSize(const point& pt, scalar& size) const
else if else if
( (
sideMode_ == smOutside sideMode_ == smOutside
&& vTL[0] == searchableSurface::OUTSIDE && vTL[0] == volumeType::OUTSIDE
) )
{ {
size = sizeFunction(hitPt, dist, hitIndex); size = sizeFunction(hitPt, dist, hitIndex);

View File

@ -25,6 +25,7 @@ License
#include "linearSpatial.H" #include "linearSpatial.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -108,7 +109,7 @@ bool linearSpatial::cellSize
} }
pointField ptF(1, pt); pointField ptF(1, pt);
List<searchableSurface::volumeType> vTL; List<volumeType> vTL;
surface_.getVolumeType(ptF, vTL); surface_.getVolumeType(ptF, vTL);
@ -117,7 +118,7 @@ bool linearSpatial::cellSize
if if
( (
sideMode_ == smInside sideMode_ == smInside
&& vTL[0] == searchableSurface::INSIDE && vTL[0] == volumeType::INSIDE
) )
{ {
size = sizeFunction(pt); size = sizeFunction(pt);
@ -127,7 +128,7 @@ bool linearSpatial::cellSize
else if else if
( (
sideMode_ == smOutside sideMode_ == smOutside
&& vTL[0] == searchableSurface::OUTSIDE && vTL[0] == volumeType::OUTSIDE
) )
{ {
size = sizeFunction(pt); size = sizeFunction(pt);

View File

@ -25,6 +25,7 @@ License
#include "surfaceOffsetLinearDistance.H" #include "surfaceOffsetLinearDistance.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -194,7 +195,7 @@ bool surfaceOffsetLinearDistance::cellSize
} }
pointField ptF(1, pt); pointField ptF(1, pt);
List<searchableSurface::volumeType> vTL; List<volumeType> vTL;
surface_.getVolumeType(ptF, vTL); surface_.getVolumeType(ptF, vTL);
@ -203,7 +204,7 @@ bool surfaceOffsetLinearDistance::cellSize
if if
( (
sideMode_ == smInside sideMode_ == smInside
&& vTL[0] == searchableSurface::INSIDE && vTL[0] == volumeType::INSIDE
) )
{ {
size = sizeFunction(hitPt, dist, hitIndex); size = sizeFunction(hitPt, dist, hitIndex);
@ -213,7 +214,7 @@ bool surfaceOffsetLinearDistance::cellSize
else if else if
( (
sideMode_ == smOutside sideMode_ == smOutside
&& vTL[0] == searchableSurface::OUTSIDE && vTL[0] == volumeType::OUTSIDE
) )
{ {
size = sizeFunction(hitPt, dist, hitIndex); size = sizeFunction(hitPt, dist, hitIndex);

View File

@ -25,6 +25,7 @@ License
#include "uniform.H" #include "uniform.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -103,7 +104,7 @@ bool uniform::cellSize
} }
pointField ptF(1, pt); pointField ptF(1, pt);
List<searchableSurface::volumeType> vTL(1); List<volumeType> vTL(1);
surface_.getVolumeType(ptF, vTL); surface_.getVolumeType(ptF, vTL);
@ -112,7 +113,7 @@ bool uniform::cellSize
if if
( (
sideMode_ == smInside sideMode_ == smInside
&& vTL[0] == searchableSurface::INSIDE && vTL[0] == volumeType::INSIDE
) )
{ {
size = surfaceCellSizeFunction_().interpolate(hitPt, index); size = surfaceCellSizeFunction_().interpolate(hitPt, index);
@ -122,7 +123,7 @@ bool uniform::cellSize
else if else if
( (
sideMode_ == smOutside sideMode_ == smOutside
&& vTL[0] == searchableSurface::OUTSIDE && vTL[0] == volumeType::OUTSIDE
) )
{ {
size = surfaceCellSizeFunction_().interpolate(hitPt, index); size = surfaceCellSizeFunction_().interpolate(hitPt, index);

View File

@ -25,7 +25,7 @@ License
#include "uniformDistance.H" #include "uniformDistance.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "dimensionSet.H" #include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -95,7 +95,7 @@ bool uniformDistance::cellSize
} }
pointField ptF(1, pt); pointField ptF(1, pt);
List<searchableSurface::volumeType> vTL; List<volumeType> vTL;
surface_.getVolumeType(ptF, vTL); surface_.getVolumeType(ptF, vTL);
@ -104,7 +104,7 @@ bool uniformDistance::cellSize
if if
( (
sideMode_ == smInside sideMode_ == smInside
&& vTL[0] == searchableSurface::INSIDE && vTL[0] == volumeType::INSIDE
) )
{ {
size = surfaceCellSizeFunction_().surfaceSize(hitInfo.index()); size = surfaceCellSizeFunction_().surfaceSize(hitInfo.index());
@ -114,7 +114,7 @@ bool uniformDistance::cellSize
else if else if
( (
sideMode_ == smOutside sideMode_ == smOutside
&& vTL[0] == searchableSurface::OUTSIDE && vTL[0] == volumeType::OUTSIDE
) )
{ {
size = surfaceCellSizeFunction_().surfaceSize(hitInfo.index()); size = surfaceCellSizeFunction_().surfaceSize(hitInfo.index());

View File

@ -27,11 +27,19 @@ License
#include "conformalVoronoiMesh.H" #include "conformalVoronoiMesh.H"
#include "triSurface.H" #include "triSurface.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(conformationSurfaces, 0);
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
void Foam::conformationSurfaces::hasBoundedVolume void Foam::conformationSurfaces::hasBoundedVolume
( (
List<searchableSurface::volumeType>& referenceVolumeTypes List<volumeType>& referenceVolumeTypes
) const ) const
{ {
vector sum(vector::zero); vector sum(vector::zero);
@ -41,14 +49,18 @@ void Foam::conformationSurfaces::hasBoundedVolume
{ {
const searchableSurface& surface(allGeometry_[surfaces_[s]]); const searchableSurface& surface(allGeometry_[surfaces_[s]]);
if (surface.hasVolumeType()) if
(
surface.hasVolumeType()
&& !baffleSurfaces_[regionOffset_[s]]
)
{ {
pointField pts(1, locationInMesh_); pointField pts(1, locationInMesh_);
List<searchableSurface::volumeType> vTypes List<volumeType> vTypes
( (
pts.size(), pts.size(),
searchableSurface::UNKNOWN volumeType::UNKNOWN
); );
surface.getVolumeType(pts, vTypes); surface.getVolumeType(pts, vTypes);
@ -56,7 +68,7 @@ void Foam::conformationSurfaces::hasBoundedVolume
referenceVolumeTypes[s] = vTypes[0]; referenceVolumeTypes[s] = vTypes[0];
Info<< " is " Info<< " is "
<< searchableSurface::volumeTypeNames[referenceVolumeTypes[s]] << volumeType::names[referenceVolumeTypes[s]]
<< " surface " << surface.name() << " surface " << surface.name()
<< endl; << endl;
} }
@ -407,7 +419,7 @@ Foam::conformationSurfaces::conformationSurfaces
referenceVolumeTypes_.setSize referenceVolumeTypes_.setSize
( (
surfaces_.size(), surfaces_.size(),
searchableSurface::UNKNOWN volumeType::UNKNOWN
); );
Info<< endl Info<< endl
@ -471,24 +483,24 @@ bool Foam::conformationSurfaces::outside
const point& samplePt const point& samplePt
) const ) const
{ {
return !inside(samplePt); return wellOutside(pointField(1, samplePt), scalarField(1, 0))[0];
//return !inside(samplePt);
} }
Foam::Field<bool> Foam::conformationSurfaces::wellInOutSide Foam::Field<bool> Foam::conformationSurfaces::wellInside
( (
const pointField& samplePts, const pointField& samplePts,
const scalarField& testDistSqr, const scalarField& testDistSqr
bool testForInside
) const ) const
{ {
List<List<searchableSurface::volumeType> > surfaceVolumeTests List<List<volumeType> > surfaceVolumeTests
( (
surfaces_.size(), surfaces_.size(),
List<searchableSurface::volumeType> List<volumeType>
( (
samplePts.size(), samplePts.size(),
searchableSurface::UNKNOWN volumeType::UNKNOWN
) )
); );
@ -497,7 +509,9 @@ Foam::Field<bool> Foam::conformationSurfaces::wellInOutSide
{ {
const searchableSurface& surface(allGeometry_[surfaces_[s]]); const searchableSurface& surface(allGeometry_[surfaces_[s]]);
if (surface.hasVolumeType()) const label regionI = regionOffset_[s];
if (!baffleSurfaces_[regionI])
{ {
surface.getVolumeType(samplePts, surfaceVolumeTests[s]); surface.getVolumeType(samplePts, surfaceVolumeTests[s]);
} }
@ -508,7 +522,7 @@ Foam::Field<bool> Foam::conformationSurfaces::wellInOutSide
// distanceSquared // distanceSquared
// Assume that the point is wellInside until demonstrated otherwise. // Assume that the point is wellInside until demonstrated otherwise.
Field<bool> inOutSidePoint(samplePts.size(), testForInside); Field<bool> insidePoint(samplePts.size(), true);
//Check if the points are inside the surface by the given distance squared //Check if the points are inside the surface by the given distance squared
@ -534,37 +548,47 @@ Foam::Field<bool> Foam::conformationSurfaces::wellInOutSide
{ {
// If the point is within range of the surface, then it can't be // If the point is within range of the surface, then it can't be
// well (in|out)side // well (in|out)side
inOutSidePoint[i] = false; insidePoint[i] = false;
continue; continue;
} }
forAll(surfaces_, s) forAll(surfaces_, s)
{ {
const label regionI = regionOffset_[s];
const searchableSurface& surface(allGeometry_[surfaces_[s]]);
if
(
!surface.hasVolumeType()
&& !surface.bounds().contains(samplePts[i])
)
{
continue;
}
// If one of the pattern tests is failed, then the point cannot be // If one of the pattern tests is failed, then the point cannot be
// inside, therefore, if this is a testForInside = true call, the // inside, therefore, if this is a testForInside = true call, the
// result is false. If this is a testForInside = false call, then // result is false. If this is a testForInside = false call, then
// the result is true. // the result is true.
if (surfaceVolumeTests[s][i] != referenceVolumeTypes_[s]) if (baffleSurfaces_[regionI])
{ {
inOutSidePoint[i] = !testForInside; continue;
}
if (surfaceVolumeTests[s][i] == volumeType::OUTSIDE)
{
insidePoint[i] = false;
break; break;
} }
} }
} }
return inOutSidePoint; return insidePoint;
}
//return wellInOutSide(samplePts, testDistSqr, true);
Foam::Field<bool> Foam::conformationSurfaces::wellInside
(
const pointField& samplePts,
const scalarField& testDistSqr
) const
{
return wellInOutSide(samplePts, testDistSqr, true);
} }
@ -584,7 +608,103 @@ Foam::Field<bool> Foam::conformationSurfaces::wellOutside
const scalarField& testDistSqr const scalarField& testDistSqr
) const ) const
{ {
return wellInOutSide(samplePts, testDistSqr, false); // First check if it is outside any closed surface
List<List<volumeType> > surfaceVolumeTests
(
surfaces_.size(),
List<volumeType>
(
samplePts.size(),
volumeType::UNKNOWN
)
);
// Get lists for the volumeTypes for each sample wrt each surface
forAll(surfaces_, s)
{
const searchableSurface& surface(allGeometry_[surfaces_[s]]);
const label regionI = regionOffset_[s];
if (!baffleSurfaces_[regionI])
{
surface.getVolumeType(samplePts, surfaceVolumeTests[s]);
}
}
// Compare the volumeType result for each point wrt to each surface with the
// reference value and if the points are inside the surface by a given
// distanceSquared
// Assume that the point is wellInside until demonstrated otherwise.
Field<bool> outsidePoint(samplePts.size(), true);
//Check if the points are inside the surface by the given distance squared
labelList hitSurfaces;
List<pointIndexHit> hitInfo;
searchableSurfacesQueries::findNearest
(
allGeometry_,
surfaces_,
samplePts,
testDistSqr,
hitSurfaces,
hitInfo
);
forAll(samplePts, i)
{
const pointIndexHit& pHit = hitInfo[i];
if (pHit.hit())
{
// If the point is within range of the surface, then it can't be
// well (in|out)side
outsidePoint[i] = false;
//continue;
}
forAll(surfaces_, s)
{
const searchableSurface& surface(allGeometry_[surfaces_[s]]);
if
(
!surface.hasVolumeType()
&& !surface.bounds().contains(samplePts[i])
)
{
continue;
}
const label regionI = regionOffset_[s];
// If one of the pattern tests is failed, then the point cannot be
// inside, therefore, if this is a testForInside = true call, the
// result is false. If this is a testForInside = false call, then
// the result is true.
if (baffleSurfaces_[regionI])
{
continue;
}
if (surfaceVolumeTests[s][i] == volumeType::INSIDE)
{
outsidePoint[i] = false;
break;
}
}
}
return outsidePoint;
//return wellInOutSide(samplePts, testDistSqr, false);
} }

View File

@ -39,6 +39,7 @@ SourceFiles
#include "searchableSurfacesQueries.H" #include "searchableSurfacesQueries.H"
#include "extendedFeatureEdgeMesh.H" #include "extendedFeatureEdgeMesh.H"
#include "boolList.H" #include "boolList.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -95,15 +96,12 @@ class conformationSurfaces
//- The pattern/signature of volumeTypes representing a point in the //- The pattern/signature of volumeTypes representing a point in the
// domain to be meshed // domain to be meshed
List<searchableSurface::volumeType> referenceVolumeTypes_; List<volumeType> referenceVolumeTypes_;
// Private Member Functions // Private Member Functions
void hasBoundedVolume void hasBoundedVolume(List<volumeType>& referenceVolumeTypes) const;
(
List<searchableSurface::volumeType>& referenceVolumeTypes
) const;
//- Read into features_ from a dictionary //- Read into features_ from a dictionary
void readFeatures void readFeatures
@ -122,6 +120,10 @@ class conformationSurfaces
public: public:
//- Runtime type information
ClassName("conformationSurfaces");
// Constructors // Constructors
//- Construct from dictionary and references to conformalVoronoiMesh and //- Construct from dictionary and references to conformalVoronoiMesh and
@ -186,12 +188,12 @@ public:
//- Check if point is closer to the surfaces to conform to than //- Check if point is closer to the surfaces to conform to than
// testDistSqr, in which case return false, otherwise assess in or // testDistSqr, in which case return false, otherwise assess in or
// outside and return a result depending on the testForInside flag // outside and return a result depending on the testForInside flag
Field<bool> wellInOutSide // Field<bool> wellInOutSide
( // (
const pointField& samplePts, // const pointField& samplePts,
const scalarField& testDistSqr, // const scalarField& testDistSqr,
bool testForInside // bool testForInside
) const; // ) const;
//- Check if point is inside surfaces to conform to by at least //- Check if point is inside surfaces to conform to by at least
// testDistSqr // testDistSqr

View File

@ -31,6 +31,7 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "triSurface.H" #include "triSurface.H"
#include "triSurfaceSearch.H"
#include "argList.H" #include "argList.H"
#include "OFstream.H" #include "OFstream.H"
#include "IFstream.H" #include "IFstream.H"
@ -40,6 +41,7 @@ Description
#include "indexedOctree.H" #include "indexedOctree.H"
#include "treeDataTriSurface.H" #include "treeDataTriSurface.H"
#include "Random.H" #include "Random.H"
#include "volumeType.H"
using namespace Foam; using namespace Foam;
@ -242,26 +244,16 @@ int main(int argc, char *argv[])
// Read surface to select on // Read surface to select on
triSurface selectSurf(surfName); triSurface selectSurf(surfName);
// bb of surface triSurfaceSearch searchSelectSurf
treeBoundBox bb(selectSurf.localPoints());
// Random number generator
Random rndGen(354543);
// search engine
indexedOctree<treeDataTriSurface> selectTree
( (
treeDataTriSurface selectSurf,
( indexedOctree<treeDataTriSurface>::perturbTol(),
selectSurf, 8
indexedOctree<treeDataTriSurface>::perturbTol()
),
bb.extend(rndGen, 1e-4), // slightly randomize bb
8, // maxLevel
10, // leafsize
3.0 // duplicity
); );
const indexedOctree<treeDataTriSurface>& selectTree =
searchSelectSurf.tree();
// Check if face (centre) is in outside or inside. // Check if face (centre) is in outside or inside.
forAll(facesToSubset, faceI) forAll(facesToSubset, faceI)
{ {
@ -269,14 +261,13 @@ int main(int argc, char *argv[])
{ {
const point fc(surf1[faceI].centre(surf1.points())); const point fc(surf1[faceI].centre(surf1.points()));
indexedOctree<treeDataTriSurface>::volumeType t = volumeType t = selectTree.getVolumeType(fc);
selectTree.getVolumeType(fc);
if if
( (
outside outside
? (t == indexedOctree<treeDataTriSurface>::OUTSIDE) ? (t == volumeType::OUTSIDE)
: (t == indexedOctree<treeDataTriSurface>::INSIDE) : (t == volumeType::INSIDE)
) )
{ {
facesToSubset[faceI] = true; facesToSubset[faceI] = true;

View File

@ -606,6 +606,7 @@ $(interpolationWeights)/splineInterpolationWeights/splineInterpolationWeights.C
algorithms/indexedOctree/indexedOctreeName.C algorithms/indexedOctree/indexedOctreeName.C
algorithms/indexedOctree/treeDataCell.C algorithms/indexedOctree/treeDataCell.C
algorithms/indexedOctree/volumeType.C
algorithms/dynamicIndexedOctree/dynamicIndexedOctreeName.C algorithms/dynamicIndexedOctree/dynamicIndexedOctreeName.C

View File

@ -334,15 +334,14 @@ void Foam::dynamicIndexedOctree<Type>::recursiveSubDivision
// Recurses to determine status of lowest level boxes. Level above is // Recurses to determine status of lowest level boxes. Level above is
// combination of octants below. // combination of octants below.
template<class Type> template<class Type>
typename Foam::dynamicIndexedOctree<Type>::volumeType Foam::volumeType Foam::dynamicIndexedOctree<Type>::calcVolumeType
Foam::dynamicIndexedOctree<Type>::calcVolumeType
( (
const label nodeI const label nodeI
) const ) const
{ {
const node& nod = nodes_[nodeI]; const node& nod = nodes_[nodeI];
volumeType myType = UNKNOWN; volumeType myType = volumeType::UNKNOWN;
for (direction octant = 0; octant < nod.subNodes_.size(); octant++) for (direction octant = 0; octant < nod.subNodes_.size(); octant++)
{ {
@ -359,7 +358,7 @@ Foam::dynamicIndexedOctree<Type>::calcVolumeType
{ {
// Contents. Depending on position in box might be on either // Contents. Depending on position in box might be on either
// side. // side.
subType = MIXED; subType = volumeType::MIXED;
} }
else else
{ {
@ -378,13 +377,13 @@ Foam::dynamicIndexedOctree<Type>::calcVolumeType
// Combine sub node types into type for treeNode. Result is 'mixed' if // Combine sub node types into type for treeNode. Result is 'mixed' if
// types differ among subnodes. // types differ among subnodes.
if (myType == UNKNOWN) if (myType == volumeType::UNKNOWN)
{ {
myType = subType; myType = subType;
} }
else if (subType != myType) else if (subType != myType)
{ {
myType = MIXED; myType = volumeType::MIXED;
} }
} }
return myType; return myType;
@ -392,8 +391,7 @@ Foam::dynamicIndexedOctree<Type>::calcVolumeType
template<class Type> template<class Type>
typename Foam::dynamicIndexedOctree<Type>::volumeType Foam::volumeType Foam::dynamicIndexedOctree<Type>::getVolumeType
Foam::dynamicIndexedOctree<Type>::getVolumeType
( (
const label nodeI, const label nodeI,
const point& sample const point& sample
@ -403,22 +401,22 @@ Foam::dynamicIndexedOctree<Type>::getVolumeType
direction octant = nod.bb_.subOctant(sample); direction octant = nod.bb_.subOctant(sample);
volumeType octantType = volumeType(nodeTypes_.get((nodeI<<3)+octant)); volumeType octantType = volumeType::type(nodeTypes_.get((nodeI<<3)+octant));
if (octantType == INSIDE) if (octantType == volumeType::INSIDE)
{ {
return octantType; return octantType;
} }
else if (octantType == OUTSIDE) else if (octantType == volumeType::OUTSIDE)
{ {
return octantType; return octantType;
} }
else if (octantType == UNKNOWN) else if (octantType == volumeType::UNKNOWN)
{ {
// Can happen for e.g. non-manifold surfaces. // Can happen for e.g. non-manifold surfaces.
return octantType; return octantType;
} }
else if (octantType == MIXED) else if (octantType == volumeType::MIXED)
{ {
labelBits index = nod.subNodes_[octant]; labelBits index = nod.subNodes_[octant];
@ -447,7 +445,7 @@ Foam::dynamicIndexedOctree<Type>::getVolumeType
<< "Empty subnode has invalid volume type MIXED." << "Empty subnode has invalid volume type MIXED."
<< abort(FatalError); << abort(FatalError);
return UNKNOWN; return volumeType::UNKNOWN;
} }
} }
else else
@ -462,14 +460,13 @@ Foam::dynamicIndexedOctree<Type>::getVolumeType
<< "Node has invalid volume type " << octantType << "Node has invalid volume type " << octantType
<< abort(FatalError); << abort(FatalError);
return UNKNOWN; return volumeType::UNKNOWN;
} }
} }
template<class Type> template<class Type>
typename Foam::dynamicIndexedOctree<Type>::volumeType Foam::volumeType Foam::dynamicIndexedOctree<Type>::getSide
Foam::dynamicIndexedOctree<Type>::getSide
( (
const vector& outsideNormal, const vector& outsideNormal,
const vector& vec const vector& vec
@ -477,11 +474,11 @@ Foam::dynamicIndexedOctree<Type>::getSide
{ {
if ((outsideNormal&vec) >= 0) if ((outsideNormal&vec) >= 0)
{ {
return OUTSIDE; return volumeType::OUTSIDE;
} }
else else
{ {
return INSIDE; return volumeType::INSIDE;
} }
} }
@ -2582,15 +2579,14 @@ const Foam::labelList& Foam::dynamicIndexedOctree<Type>::findIndices
// Determine type (inside/outside/mixed) per node. // Determine type (inside/outside/mixed) per node.
template<class Type> template<class Type>
typename Foam::dynamicIndexedOctree<Type>::volumeType Foam::volumeType Foam::dynamicIndexedOctree<Type>::getVolumeType
Foam::dynamicIndexedOctree<Type>::getVolumeType
( (
const point& sample const point& sample
) const ) const
{ {
if (nodes_.empty()) if (nodes_.empty())
{ {
return UNKNOWN; return volumeType::UNKNOWN;
} }
if (nodeTypes_.size() != 8*nodes_.size()) if (nodeTypes_.size() != 8*nodes_.size())
@ -2598,7 +2594,7 @@ Foam::dynamicIndexedOctree<Type>::getVolumeType
// Calculate type for every octant of node. // Calculate type for every octant of node.
nodeTypes_.setSize(8*nodes_.size()); nodeTypes_.setSize(8*nodes_.size());
nodeTypes_ = UNKNOWN; nodeTypes_ = volumeType::UNKNOWN;
calcVolumeType(0); calcVolumeType(0);
@ -2611,21 +2607,21 @@ Foam::dynamicIndexedOctree<Type>::getVolumeType
forAll(nodeTypes_, i) forAll(nodeTypes_, i)
{ {
volumeType type = volumeType(nodeTypes_.get(i)); volumeType type = volumeType::type(nodeTypes_.get(i));
if (type == UNKNOWN) if (type == volumeType::UNKNOWN)
{ {
nUNKNOWN++; nUNKNOWN++;
} }
else if (type == MIXED) else if (type == volumeType::MIXED)
{ {
nMIXED++; nMIXED++;
} }
else if (type == INSIDE) else if (type == volumeType::INSIDE)
{ {
nINSIDE++; nINSIDE++;
} }
else if (type == OUTSIDE) else if (type == volumeType::OUTSIDE)
{ {
nOUTSIDE++; nOUTSIDE++;
} }

View File

@ -43,6 +43,7 @@ SourceFiles
#include "HashSet.H" #include "HashSet.H"
#include "labelBits.H" #include "labelBits.H"
#include "PackedList.H" #include "PackedList.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -83,16 +84,6 @@ public:
// Data types // Data types
//- volume types
enum volumeType
{
UNKNOWN = 0,
MIXED = 1,
INSIDE = 2,
OUTSIDE = 3
};
//- Tree node. Has up pointer and down pointers. //- Tree node. Has up pointer and down pointers.
class node class node
{ {

View File

@ -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) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -57,13 +57,13 @@ Foam::dynamicTreeDataPoint::shapePoints() const
//- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
// Only makes sense for closed surfaces. // Only makes sense for closed surfaces.
Foam::label Foam::dynamicTreeDataPoint::getVolumeType Foam::volumeType Foam::dynamicTreeDataPoint::getVolumeType
( (
const dynamicIndexedOctree<dynamicTreeDataPoint>& oc, const dynamicIndexedOctree<dynamicTreeDataPoint>& oc,
const point& sample const point& sample
) const ) const
{ {
return dynamicIndexedOctree<dynamicTreeDataPoint>::UNKNOWN; return volumeType::UNKNOWN;
} }

View File

@ -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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,6 +43,7 @@ SourceFiles
#include "pointField.H" #include "pointField.H"
#include "treeBoundBox.H" #include "treeBoundBox.H"
#include "linePointRef.H" #include "linePointRef.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -92,7 +93,7 @@ public:
//- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
// Only makes sense for closed surfaces. // Only makes sense for closed surfaces.
label getVolumeType volumeType getVolumeType
( (
const dynamicIndexedOctree<dynamicTreeDataPoint>&, const dynamicIndexedOctree<dynamicTreeDataPoint>&,
const point& const point&

View File

@ -356,15 +356,14 @@ Foam::label Foam::indexedOctree<Type>::compactContents
// Recurses to determine status of lowest level boxes. Level above is // Recurses to determine status of lowest level boxes. Level above is
// combination of octants below. // combination of octants below.
template<class Type> template<class Type>
typename Foam::indexedOctree<Type>::volumeType Foam::volumeType Foam::indexedOctree<Type>::calcVolumeType
Foam::indexedOctree<Type>::calcVolumeType
( (
const label nodeI const label nodeI
) const ) const
{ {
const node& nod = nodes_[nodeI]; const node& nod = nodes_[nodeI];
volumeType myType = UNKNOWN; volumeType myType = volumeType::UNKNOWN;
for (direction octant = 0; octant < nod.subNodes_.size(); octant++) for (direction octant = 0; octant < nod.subNodes_.size(); octant++)
{ {
@ -381,7 +380,7 @@ Foam::indexedOctree<Type>::calcVolumeType
{ {
// Contents. Depending on position in box might be on either // Contents. Depending on position in box might be on either
// side. // side.
subType = MIXED; subType = volumeType::MIXED;
} }
else else
{ {
@ -389,10 +388,7 @@ Foam::indexedOctree<Type>::calcVolumeType
// of its bounding box. // of its bounding box.
const treeBoundBox subBb = nod.bb_.subBbox(octant); const treeBoundBox subBb = nod.bb_.subBbox(octant);
subType = volumeType subType = shapes_.getVolumeType(*this, subBb.midpoint());
(
shapes_.getVolumeType(*this, subBb.midpoint())
);
} }
// Store octant type // Store octant type
@ -400,13 +396,13 @@ Foam::indexedOctree<Type>::calcVolumeType
// Combine sub node types into type for treeNode. Result is 'mixed' if // Combine sub node types into type for treeNode. Result is 'mixed' if
// types differ among subnodes. // types differ among subnodes.
if (myType == UNKNOWN) if (myType == volumeType::UNKNOWN)
{ {
myType = subType; myType = subType;
} }
else if (subType != myType) else if (subType != myType)
{ {
myType = MIXED; myType = volumeType::MIXED;
} }
} }
return myType; return myType;
@ -414,8 +410,7 @@ Foam::indexedOctree<Type>::calcVolumeType
template<class Type> template<class Type>
typename Foam::indexedOctree<Type>::volumeType Foam::volumeType Foam::indexedOctree<Type>::getVolumeType
Foam::indexedOctree<Type>::getVolumeType
( (
const label nodeI, const label nodeI,
const point& sample const point& sample
@ -425,22 +420,22 @@ Foam::indexedOctree<Type>::getVolumeType
direction octant = nod.bb_.subOctant(sample); direction octant = nod.bb_.subOctant(sample);
volumeType octantType = volumeType(nodeTypes_.get((nodeI<<3)+octant)); volumeType octantType = volumeType::type(nodeTypes_.get((nodeI<<3)+octant));
if (octantType == INSIDE) if (octantType == volumeType::INSIDE)
{ {
return octantType; return octantType;
} }
else if (octantType == OUTSIDE) else if (octantType == volumeType::OUTSIDE)
{ {
return octantType; return octantType;
} }
else if (octantType == UNKNOWN) else if (octantType == volumeType::UNKNOWN)
{ {
// Can happen for e.g. non-manifold surfaces. // Can happen for e.g. non-manifold surfaces.
return octantType; return octantType;
} }
else if (octantType == MIXED) else if (octantType == volumeType::MIXED)
{ {
labelBits index = nod.subNodes_[octant]; labelBits index = nod.subNodes_[octant];
@ -469,7 +464,7 @@ Foam::indexedOctree<Type>::getVolumeType
<< "Empty subnode has invalid volume type MIXED." << "Empty subnode has invalid volume type MIXED."
<< abort(FatalError); << abort(FatalError);
return UNKNOWN; return volumeType::UNKNOWN;
} }
} }
else else
@ -484,14 +479,13 @@ Foam::indexedOctree<Type>::getVolumeType
<< "Node has invalid volume type " << octantType << "Node has invalid volume type " << octantType
<< abort(FatalError); << abort(FatalError);
return UNKNOWN; return volumeType::UNKNOWN;
} }
} }
template<class Type> template<class Type>
typename Foam::indexedOctree<Type>::volumeType Foam::volumeType Foam::indexedOctree<Type>::getSide
Foam::indexedOctree<Type>::getSide
( (
const vector& outsideNormal, const vector& outsideNormal,
const vector& vec const vector& vec
@ -499,11 +493,11 @@ Foam::indexedOctree<Type>::getSide
{ {
if ((outsideNormal&vec) >= 0) if ((outsideNormal&vec) >= 0)
{ {
return OUTSIDE; return volumeType::OUTSIDE;
} }
else else
{ {
return INSIDE; return volumeType::INSIDE;
} }
} }
@ -2972,23 +2966,29 @@ const Foam::labelList& Foam::indexedOctree<Type>::findIndices
// Determine type (inside/outside/mixed) per node. // Determine type (inside/outside/mixed) per node.
template<class Type> template<class Type>
typename Foam::indexedOctree<Type>::volumeType Foam::volumeType Foam::indexedOctree<Type>::getVolumeType
Foam::indexedOctree<Type>::getVolumeType
( (
const point& sample const point& sample
) const ) const
{ {
if (nodes_.empty()) if (nodes_.empty())
{ {
return UNKNOWN; return volumeType::UNKNOWN;
} }
// // If the sample is not within the octree, then have to query shapes
// // directly
// if (!nodes_[0].bb_.contains(sample))
// {
// return volumeType(shapes_.getVolumeType(*this, sample));
// }
if (nodeTypes_.size() != 8*nodes_.size()) if (nodeTypes_.size() != 8*nodes_.size())
{ {
// Calculate type for every octant of node. // Calculate type for every octant of node.
nodeTypes_.setSize(8*nodes_.size()); nodeTypes_.setSize(8*nodes_.size());
nodeTypes_ = UNKNOWN; nodeTypes_ = volumeType::UNKNOWN;
calcVolumeType(0); calcVolumeType(0);
@ -3001,21 +3001,21 @@ Foam::indexedOctree<Type>::getVolumeType
forAll(nodeTypes_, i) forAll(nodeTypes_, i)
{ {
volumeType type = volumeType(nodeTypes_.get(i)); volumeType type = volumeType::type(nodeTypes_.get(i));
if (type == UNKNOWN) if (type == volumeType::UNKNOWN)
{ {
nUNKNOWN++; nUNKNOWN++;
} }
else if (type == MIXED) else if (type == volumeType::MIXED)
{ {
nMIXED++; nMIXED++;
} }
else if (type == INSIDE) else if (type == volumeType::INSIDE)
{ {
nINSIDE++; nINSIDE++;
} }
else if (type == OUTSIDE) else if (type == volumeType::OUTSIDE)
{ {
nOUTSIDE++; nOUTSIDE++;
} }

View File

@ -42,6 +42,7 @@ SourceFiles
#include "HashSet.H" #include "HashSet.H"
#include "labelBits.H" #include "labelBits.H"
#include "PackedList.H" #include "PackedList.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -74,16 +75,6 @@ public:
// Data types // Data types
//- volume types
enum volumeType
{
UNKNOWN = 0,
MIXED = 1,
INSIDE = 2,
OUTSIDE = 3
};
//- Tree node. Has up pointer and down pointers. //- Tree node. Has up pointer and down pointers.
class node class node
{ {

View File

@ -38,6 +38,7 @@ SourceFiles
#include "polyMesh.H" #include "polyMesh.H"
#include "treeBoundBoxList.H" #include "treeBoundBoxList.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -196,7 +197,7 @@ public:
//- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
// Only makes sense for closed surfaces. // Only makes sense for closed surfaces.
label getVolumeType volumeType getVolumeType
( (
const indexedOctree<treeDataCell>&, const indexedOctree<treeDataCell>&,
const point& const point&
@ -207,7 +208,7 @@ public:
"treeDataCell::getVolumeType" "treeDataCell::getVolumeType"
"(const indexedOctree<treeDataCell>&, const point&)" "(const indexedOctree<treeDataCell>&, const point&)"
); );
return -1; return volumeType::UNKNOWN;
} }
//- Does (bb of) shape at index overlap bb //- Does (bb of) shape at index overlap bb

View File

@ -0,0 +1,79 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "volumeType.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
template<>
const char* Foam::NamedEnum
<
Foam::volumeType,
4
>::names[] =
{
"unknown",
"mixed",
"inside",
"outside"
};
}
const Foam::NamedEnum<Foam::volumeType, 4> Foam::volumeType::names;
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, volumeType& vt)
{
// Read beginning of volumeType
is.readBegin("volumeType");
int type;
is >> type;
vt.t_ = static_cast<volumeType::type>(type);
// Read end of volumeType
is.readEnd("volumeType");
// Check state of Istream
is.check("operator>>(Istream&, volumeType&)");
return is;
}
Foam::Ostream& Foam::operator<<(Ostream& os, const volumeType& vt)
{
os << static_cast<int>(vt.t_);
return os;
}
// ************************************************************************* //

View File

@ -0,0 +1,127 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::volumeType
Description
SourceFiles
volumeType.C
\*---------------------------------------------------------------------------*/
#ifndef volumeType_H
#define volumeType_H
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
class volumeType;
Istream& operator>>(Istream& is, volumeType&);
Ostream& operator<<(Ostream& os, const volumeType& C);
/*---------------------------------------------------------------------------*\
Class volumeType Declaration
\*---------------------------------------------------------------------------*/
class volumeType
{
public:
//- Volume types
enum type
{
UNKNOWN = 0,
MIXED = 1,
INSIDE = 2,
OUTSIDE = 3
};
private:
// Private data
//- Volume type
type t_;
public:
// Static data
static const NamedEnum<volumeType, 4> names;
// Constructors
//- Construct null
volumeType()
:
t_(UNKNOWN)
{}
//- Construct from components
volumeType(type t)
:
t_(t)
{}
// Member Functions
operator type() const
{
return t_;
}
// IOstream operators
friend Istream& operator>>(Istream& is, volumeType& vt);
friend Ostream& operator<<(Ostream& os, const volumeType& vt);
};
//- Data associated with volumeType type are contiguous
template<>
inline bool contiguous<volumeType>() {return true;}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -31,6 +31,7 @@ License
#include "labelPair.H" #include "labelPair.H"
#include "searchableSurfacesQueries.H" #include "searchableSurfacesQueries.H"
#include "UPtrList.H" #include "UPtrList.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -1302,7 +1303,7 @@ void Foam::refinementSurfaces::findInside
if (allGeometry_[surfaces_[surfI]].hasVolumeType()) if (allGeometry_[surfaces_[surfI]].hasVolumeType())
{ {
List<searchableSurface::volumeType> volType; List<volumeType> volType;
allGeometry_[surfaces_[surfI]].getVolumeType(pt, volType); allGeometry_[surfaces_[surfI]].getVolumeType(pt, volType);
forAll(volType, pointI) forAll(volType, pointI)
@ -1312,11 +1313,11 @@ void Foam::refinementSurfaces::findInside
if if
( (
( (
volType[pointI] == triSurfaceMesh::INSIDE volType[pointI] == volumeType::INSIDE
&& zoneInside_[surfI] == INSIDE && zoneInside_[surfI] == INSIDE
) )
|| ( || (
volType[pointI] == triSurfaceMesh::OUTSIDE volType[pointI] == volumeType::OUTSIDE
&& zoneInside_[surfI] == OUTSIDE && zoneInside_[surfI] == OUTSIDE
) )
) )

View File

@ -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) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -31,6 +31,7 @@ License
#include "searchableSurfaces.H" #include "searchableSurfaces.H"
#include "orientedSurface.H" #include "orientedSurface.H"
#include "pointIndexHit.H" #include "pointIndexHit.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -329,7 +330,7 @@ void Foam::shellSurfaces::findHigherLevel
candidateMap.setSize(candidateI); candidateMap.setSize(candidateI);
// Do the expensive nearest test only for the candidate points. // Do the expensive nearest test only for the candidate points.
List<searchableSurface::volumeType> volType; List<volumeType> volType;
allGeometry_[shells_[shellI]].getVolumeType(candidates, volType); allGeometry_[shells_[shellI]].getVolumeType(candidates, volType);
forAll(volType, i) forAll(volType, i)
@ -340,11 +341,11 @@ void Foam::shellSurfaces::findHigherLevel
( (
( (
modes_[shellI] == INSIDE modes_[shellI] == INSIDE
&& volType[i] == searchableSurface::INSIDE && volType[i] == volumeType::INSIDE
) )
|| ( || (
modes_[shellI] == OUTSIDE modes_[shellI] == OUTSIDE
&& volType[i] == searchableSurface::OUTSIDE && volType[i] == volumeType::OUTSIDE
) )
) )
{ {

View File

@ -132,13 +132,13 @@ Foam::pointField Foam::treeDataEdge::shapePoints() const
//- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
// Only makes sense for closed surfaces. // Only makes sense for closed surfaces.
Foam::label Foam::treeDataEdge::getVolumeType Foam::volumeType Foam::treeDataEdge::getVolumeType
( (
const indexedOctree<treeDataEdge>& oc, const indexedOctree<treeDataEdge>& oc,
const point& sample const point& sample
) const ) const
{ {
return indexedOctree<treeDataEdge>::UNKNOWN; return volumeType::UNKNOWN;
} }

View File

@ -37,6 +37,7 @@ SourceFiles
#include "treeBoundBoxList.H" #include "treeBoundBoxList.H"
#include "linePointRef.H" #include "linePointRef.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -197,7 +198,7 @@ public:
//- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
// Only makes sense for closed surfaces. // Only makes sense for closed surfaces.
label getVolumeType volumeType getVolumeType
( (
const indexedOctree<treeDataEdge>&, const indexedOctree<treeDataEdge>&,
const point& const point&

View File

@ -180,7 +180,7 @@ Foam::pointField Foam::treeDataFace::shapePoints() const
//- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
// Only makes sense for closed surfaces. // Only makes sense for closed surfaces.
Foam::label Foam::treeDataFace::getVolumeType Foam::volumeType Foam::treeDataFace::getVolumeType
( (
const indexedOctree<treeDataFace>& oc, const indexedOctree<treeDataFace>& oc,
const point& sample const point& sample
@ -433,7 +433,7 @@ Foam::label Foam::treeDataFace::getVolumeType
// - tolerances are wrong. (if e.g. face has zero area) // - tolerances are wrong. (if e.g. face has zero area)
// - or (more likely) surface is not closed. // - or (more likely) surface is not closed.
return indexedOctree<treeDataFace>::UNKNOWN; return volumeType::UNKNOWN;
} }

View File

@ -40,6 +40,7 @@ SourceFiles
#include "treeBoundBoxList.H" #include "treeBoundBoxList.H"
#include "PackedBoolList.H" #include "PackedBoolList.H"
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -200,7 +201,7 @@ public:
//- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
// Only makes sense for closed surfaces. // Only makes sense for closed surfaces.
label getVolumeType volumeType getVolumeType
( (
const indexedOctree<treeDataFace>&, const indexedOctree<treeDataFace>&,
const point& const point&

View File

@ -92,13 +92,13 @@ Foam::pointField Foam::treeDataPoint::shapePoints() const
//- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
// Only makes sense for closed surfaces. // Only makes sense for closed surfaces.
Foam::label Foam::treeDataPoint::getVolumeType Foam::volumeType Foam::treeDataPoint::getVolumeType
( (
const indexedOctree<treeDataPoint>& oc, const indexedOctree<treeDataPoint>& oc,
const point& sample const point& sample
) const ) const
{ {
return indexedOctree<treeDataPoint>::UNKNOWN; return volumeType::UNKNOWN;
} }

View File

@ -43,6 +43,7 @@ SourceFiles
#include "pointField.H" #include "pointField.H"
#include "treeBoundBox.H" #include "treeBoundBox.H"
#include "linePointRef.H" #include "linePointRef.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -172,7 +173,7 @@ public:
//- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
// Only makes sense for closed surfaces. // Only makes sense for closed surfaces.
label getVolumeType volumeType getVolumeType
( (
const indexedOctree<treeDataPoint>&, const indexedOctree<treeDataPoint>&,
const point& const point&

View File

@ -206,7 +206,7 @@ Foam::pointField Foam::treeDataPrimitivePatch<PatchType>::shapePoints() const
//- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
// Only makes sense for closed surfaces. // Only makes sense for closed surfaces.
template<class PatchType> template<class PatchType>
Foam::label Foam::treeDataPrimitivePatch<PatchType>::getVolumeType Foam::volumeType Foam::treeDataPrimitivePatch<PatchType>::getVolumeType
( (
const indexedOctree<treeDataPrimitivePatch<PatchType> >& oc, const indexedOctree<treeDataPrimitivePatch<PatchType> >& oc,
const point& sample const point& sample
@ -436,7 +436,7 @@ Foam::label Foam::treeDataPrimitivePatch<PatchType>::getVolumeType
// - tolerances are wrong. (if e.g. face has zero area) // - tolerances are wrong. (if e.g. face has zero area)
// - or (more likely) surface is not closed. // - or (more likely) surface is not closed.
return indexedOctree<treeDataPrimitivePatch>::UNKNOWN; return volumeType::UNKNOWN;
} }

View File

@ -36,6 +36,7 @@ SourceFiles
#define treeDataPrimitivePatch_H #define treeDataPrimitivePatch_H
#include "treeBoundBoxList.H" #include "treeBoundBoxList.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -213,7 +214,7 @@ public:
//- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
// Only makes sense for closed surfaces. // Only makes sense for closed surfaces.
label getVolumeType volumeType getVolumeType
( (
const indexedOctree<treeDataPrimitivePatch<PatchType> >&, const indexedOctree<treeDataPrimitivePatch<PatchType> >&,
const point& const point&

View File

@ -29,7 +29,7 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<> template<>
Foam::label Foam::treeDataPrimitivePatch<Foam::triSurface>::getVolumeType Foam::volumeType Foam::treeDataPrimitivePatch<Foam::triSurface>::getVolumeType
( (
const indexedOctree<treeDataPrimitivePatch<triSurface> >& oc, const indexedOctree<treeDataPrimitivePatch<triSurface> >& oc,
const point& sample const point& sample
@ -60,21 +60,21 @@ Foam::label Foam::treeDataPrimitivePatch<Foam::triSurface>::getVolumeType
if (t == triSurfaceTools::UNKNOWN) if (t == triSurfaceTools::UNKNOWN)
{ {
return indexedOctree<treeDataPrimitivePatch<triSurface> >::UNKNOWN; return volumeType::UNKNOWN;
} }
else if (t == triSurfaceTools::INSIDE) else if (t == triSurfaceTools::INSIDE)
{ {
return indexedOctree<treeDataPrimitivePatch<triSurface> >::INSIDE; return volumeType::INSIDE;
} }
else if (t == triSurfaceTools::OUTSIDE) else if (t == triSurfaceTools::OUTSIDE)
{ {
return indexedOctree<treeDataPrimitivePatch<triSurface> >::OUTSIDE; return volumeType::OUTSIDE;
} }
else else
{ {
FatalErrorIn("treeDataPrimitivePatch<PatchType>::getVolumeType(..)") FatalErrorIn("treeDataPrimitivePatch<PatchType>::getVolumeType(..)")
<< "problem" << abort(FatalError); << "problem" << abort(FatalError);
return indexedOctree<treeDataPrimitivePatch<triSurface> >::UNKNOWN; return volumeType::UNKNOWN;
} }
} }

View File

@ -39,6 +39,7 @@ SourceFiles
#include "triSurface.H" #include "triSurface.H"
#include "point.H" #include "point.H"
#include "indexedOctree.H" #include "indexedOctree.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -48,7 +49,7 @@ namespace Foam
//- Template specialisation of getVolumeType for treeDataTriSurface //- Template specialisation of getVolumeType for treeDataTriSurface
template<> template<>
label treeDataPrimitivePatch<triSurface>::getVolumeType volumeType treeDataPrimitivePatch<triSurface>::getVolumeType
( (
const indexedOctree<treeDataPrimitivePatch<triSurface> >& oc, const indexedOctree<treeDataPrimitivePatch<triSurface> >& oc,
const point& sample const point& sample

View File

@ -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) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -947,9 +947,7 @@ Foam::List<Foam::pointIndexHit> Foam::meshSearch::intersections
bool Foam::meshSearch::isInside(const point& p) const bool Foam::meshSearch::isInside(const point& p) const
{ {
return return (boundaryTree().getVolumeType(p) == volumeType::INSIDE);
boundaryTree().getVolumeType(p)
== indexedOctree<treeDataFace>::INSIDE;
} }

View File

@ -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) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -583,7 +583,7 @@ void Foam::searchableBox::getVolumeType
) const ) const
{ {
volType.setSize(points.size()); volType.setSize(points.size());
volType = INSIDE; volType = volumeType::INSIDE;
forAll(points, pointI) forAll(points, pointI)
{ {
@ -593,7 +593,7 @@ void Foam::searchableBox::getVolumeType
{ {
if (pt[dir] < min()[dir] || pt[dir] > max()[dir]) if (pt[dir] < min()[dir] || pt[dir] > max()[dir])
{ {
volType[pointI] = OUTSIDE; volType[pointI] = volumeType::OUTSIDE;
break; break;
} }
} }

View File

@ -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) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -673,7 +673,7 @@ void Foam::searchableCylinder::getVolumeType
) const ) const
{ {
volType.setSize(points.size()); volType.setSize(points.size());
volType = INSIDE; volType = volumeType::INSIDE;
forAll(points, pointI) forAll(points, pointI)
{ {
@ -687,12 +687,12 @@ void Foam::searchableCylinder::getVolumeType
if (parallel < 0) if (parallel < 0)
{ {
// left of point1 endcap // left of point1 endcap
volType[pointI] = OUTSIDE; volType[pointI] = volumeType::OUTSIDE;
} }
else if (parallel > magDir_) else if (parallel > magDir_)
{ {
// right of point2 endcap // right of point2 endcap
volType[pointI] = OUTSIDE; volType[pointI] = volumeType::OUTSIDE;
} }
else else
{ {
@ -701,11 +701,11 @@ void Foam::searchableCylinder::getVolumeType
if (mag(v) > radius_) if (mag(v) > radius_)
{ {
volType[pointI] = OUTSIDE; volType[pointI] = volumeType::OUTSIDE;
} }
else else
{ {
volType[pointI] = INSIDE; volType[pointI] = volumeType::INSIDE;
} }
} }
} }

View File

@ -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) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -334,7 +334,7 @@ void Foam::searchableSphere::getVolumeType
) const ) const
{ {
volType.setSize(points.size()); volType.setSize(points.size());
volType = INSIDE; volType = volumeType::INSIDE;
forAll(points, pointI) forAll(points, pointI)
{ {
@ -342,11 +342,11 @@ void Foam::searchableSphere::getVolumeType
if (magSqr(pt - centre_) <= sqr(radius_)) if (magSqr(pt - centre_) <= sqr(radius_))
{ {
volType[pointI] = INSIDE; volType[pointI] = volumeType::INSIDE;
} }
else else
{ {
volType[pointI] = OUTSIDE; volType[pointI] = volumeType::OUTSIDE;
} }
} }
} }

View File

@ -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) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -30,26 +30,12 @@ License
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(searchableSurface, 0);
defineRunTimeSelectionTable(searchableSurface, dict);
template<> defineTypeNameAndDebug(searchableSurface, 0);
const char* Foam::NamedEnum defineRunTimeSelectionTable(searchableSurface, dict);
<
Foam::searchableSurface::volumeType,
4
>::names[] =
{
"unknown",
"mixed",
"inside",
"outside"
};
} }
const Foam::NamedEnum<Foam::searchableSurface::volumeType, 4>
Foam::searchableSurface::volumeTypeNames;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -48,6 +48,7 @@ SourceFiles
#include "pointIndexHit.H" #include "pointIndexHit.H"
#include "linePointRef.H" #include "linePointRef.H"
#include "objectRegistry.H" #include "objectRegistry.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -67,25 +68,6 @@ class searchableSurface
: :
public regIOobject public regIOobject
{ {
public:
// Data types
//- Volume types
enum volumeType
{
UNKNOWN = 0,
MIXED = 1, // not used. only here to maintain consistency with
// indexedOctree volumeType.
INSIDE = 2,
OUTSIDE = 3
};
static const NamedEnum<volumeType, 4> volumeTypeNames;
private:
// Private data // Private data
const word name_; const word name_;

View File

@ -735,7 +735,7 @@ void Foam::searchableSurfacesQueries::signedDistance
const labelList& surfacesToTest, const labelList& surfacesToTest,
const pointField& samples, const pointField& samples,
const scalarField& nearestDistSqr, const scalarField& nearestDistSqr,
const searchableSurface::volumeType illegalHandling, const volumeType illegalHandling,
labelList& nearestSurfaces, labelList& nearestSurfaces,
scalarField& distance scalarField& distance
) )
@ -775,7 +775,7 @@ void Foam::searchableSurfacesQueries::signedDistance
} }
// Calculate sideness of these surface points // Calculate sideness of these surface points
List<searchableSurface::volumeType> volType; List<volumeType> volType;
allSurfaces[surfacesToTest[testI]].getVolumeType(surfPoints, volType); allSurfaces[surfacesToTest[testI]].getVolumeType(surfPoints, volType);
// Push back to original // Push back to original
@ -784,13 +784,13 @@ void Foam::searchableSurfacesQueries::signedDistance
label pointI = surfIndices[i]; label pointI = surfIndices[i];
scalar dist = mag(samples[pointI] - nearestInfo[pointI].hitPoint()); scalar dist = mag(samples[pointI] - nearestInfo[pointI].hitPoint());
searchableSurface::volumeType vT = volType[i]; volumeType vT = volType[i];
if (vT == searchableSurface::OUTSIDE) if (vT == volumeType::OUTSIDE)
{ {
distance[pointI] = dist; distance[pointI] = dist;
} }
else if (vT == searchableSurface::INSIDE) else if (vT == volumeType::INSIDE)
{ {
distance[i] = -dist; distance[i] = -dist;
} }
@ -798,12 +798,12 @@ void Foam::searchableSurfacesQueries::signedDistance
{ {
switch (illegalHandling) switch (illegalHandling)
{ {
case searchableSurface::OUTSIDE: case volumeType::OUTSIDE:
{ {
distance[pointI] = dist; distance[pointI] = dist;
break; break;
} }
case searchableSurface::INSIDE: case volumeType::INSIDE:
{ {
distance[pointI] = -dist; distance[pointI] = -dist;
break; break;
@ -817,7 +817,7 @@ void Foam::searchableSurfacesQueries::signedDistance
<< " surface:" << " surface:"
<< allSurfaces[surfacesToTest[testI]].name() << allSurfaces[surfacesToTest[testI]].name()
<< " volType:" << " volType:"
<< searchableSurface::volumeTypeNames[vT] << volumeType::names[vT]
<< exit(FatalError); << exit(FatalError);
break; break;
} }

View File

@ -206,7 +206,7 @@ public:
const labelList& surfacesToTest, const labelList& surfacesToTest,
const pointField& samples, const pointField& samples,
const scalarField& nearestDistSqr, const scalarField& nearestDistSqr,
const searchableSurface::volumeType illegalHandling, const volumeType illegalHandling,
labelList& nearestSurfaces, labelList& nearestSurfaces,
scalarField& distance scalarField& distance
); );

View File

@ -740,7 +740,7 @@ void Foam::triSurfaceMesh::getVolumeType
// - use cached volume type per each tree node // - use cached volume type per each tree node
// - cheat conversion since same values // - cheat conversion since same values
volType[pointI] = static_cast<volumeType>(tree().getVolumeType(pt)); volType[pointI] = tree().getVolumeType(pt);
} }
indexedOctree<treeDataTriSurface>::perturbTol() = oldTol; indexedOctree<treeDataTriSurface>::perturbTol() = oldTol;

View File

@ -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) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -29,6 +29,7 @@ License
#include "volPointInterpolation.H" #include "volPointInterpolation.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "fvMesh.H" #include "fvMesh.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -94,19 +95,19 @@ void Foam::distanceSurface::createGeometry()
if (signed_) if (signed_)
{ {
List<searchableSurface::volumeType> volType; List<volumeType> volType;
surfPtr_().getVolumeType(cc, volType); surfPtr_().getVolumeType(cc, volType);
forAll(volType, i) forAll(volType, i)
{ {
searchableSurface::volumeType vT = volType[i]; volumeType vT = volType[i];
if (vT == searchableSurface::OUTSIDE) if (vT == volumeType::OUTSIDE)
{ {
fld[i] = Foam::mag(cc[i] - nearest[i].hitPoint()); fld[i] = Foam::mag(cc[i] - nearest[i].hitPoint());
} }
else if (vT == searchableSurface::INSIDE) else if (vT == volumeType::INSIDE)
{ {
fld[i] = -Foam::mag(cc[i] - nearest[i].hitPoint()); fld[i] = -Foam::mag(cc[i] - nearest[i].hitPoint());
} }
@ -146,19 +147,19 @@ void Foam::distanceSurface::createGeometry()
if (signed_) if (signed_)
{ {
List<searchableSurface::volumeType> volType; List<volumeType> volType;
surfPtr_().getVolumeType(cc, volType); surfPtr_().getVolumeType(cc, volType);
forAll(volType, i) forAll(volType, i)
{ {
searchableSurface::volumeType vT = volType[i]; volumeType vT = volType[i];
if (vT == searchableSurface::OUTSIDE) if (vT == volumeType::OUTSIDE)
{ {
fld[i] = Foam::mag(cc[i] - nearest[i].hitPoint()); fld[i] = Foam::mag(cc[i] - nearest[i].hitPoint());
} }
else if (vT == searchableSurface::INSIDE) else if (vT == volumeType::INSIDE)
{ {
fld[i] = -Foam::mag(cc[i] - nearest[i].hitPoint()); fld[i] = -Foam::mag(cc[i] - nearest[i].hitPoint());
} }
@ -203,20 +204,20 @@ void Foam::distanceSurface::createGeometry()
if (signed_) if (signed_)
{ {
List<searchableSurface::volumeType> volType; List<volumeType> volType;
surfPtr_().getVolumeType(pts, volType); surfPtr_().getVolumeType(pts, volType);
forAll(volType, i) forAll(volType, i)
{ {
searchableSurface::volumeType vT = volType[i]; volumeType vT = volType[i];
if (vT == searchableSurface::OUTSIDE) if (vT == volumeType::OUTSIDE)
{ {
pointDistance_[i] = pointDistance_[i] =
Foam::mag(pts[i] - nearest[i].hitPoint()); Foam::mag(pts[i] - nearest[i].hitPoint());
} }
else if (vT == searchableSurface::INSIDE) else if (vT == volumeType::INSIDE)
{ {
pointDistance_[i] = pointDistance_[i] =
-Foam::mag(pts[i] - nearest[i].hitPoint()); -Foam::mag(pts[i] - nearest[i].hitPoint());