Commit e2482a4e authored by laurence's avatar laurence
Browse files

ENH: Merge searchableSurface and indexedOctree volumeType

parent 05b6a09b
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -155,10 +155,10 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
// For each cell in the mesh has it been determined if it is fully
// inside, outside, or overlaps the surface
labelList volumeStatus
List<volumeType> volumeStatus
(
mesh_.nCells(),
searchableSurface::UNKNOWN
volumeType::UNKNOWN
);
// Surface refinement
......@@ -168,7 +168,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
// Determine/update the status of each cell
forAll(volumeStatus, cellI)
{
if (volumeStatus[cellI] == searchableSurface::UNKNOWN)
if (volumeStatus[cellI] == volumeType::UNKNOWN)
{
treeBoundBox cellBb
(
......@@ -181,16 +181,15 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
if (geometry.overlaps(cellBb))
{
volumeStatus[cellI] = searchableSurface::MIXED;
volumeStatus[cellI] = volumeType::MIXED;
}
else if (geometry.inside(cellBb.midpoint()))
{
volumeStatus[cellI] = searchableSurface::INSIDE;
volumeStatus[cellI] = volumeType::INSIDE;
}
else
{
volumeStatus[cellI] =
searchableSurface::OUTSIDE;
volumeStatus[cellI] = volumeType::OUTSIDE;
}
}
}
......@@ -216,9 +215,9 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
{
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
......@@ -260,7 +259,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
const labelList& cellMap = map().cellMap();
labelList newVolumeStatus(cellMap.size());
List<volumeType> newVolumeStatus(cellMap.size());
forAll(cellMap, newCellI)
{
......@@ -268,8 +267,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
if (oldCellI == -1)
{
newVolumeStatus[newCellI] =
searchableSurface::UNKNOWN;
newVolumeStatus[newCellI] = volumeType::UNKNOWN;
}
else
{
......@@ -289,7 +287,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
// Determine/update the status of each cell
forAll(volumeStatus, cellI)
{
if (volumeStatus[cellI] == searchableSurface::UNKNOWN)
if (volumeStatus[cellI] == volumeType::UNKNOWN)
{
treeBoundBox cellBb
(
......@@ -302,16 +300,15 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
if (geometry.overlaps(cellBb))
{
volumeStatus[cellI] = searchableSurface::MIXED;
volumeStatus[cellI] = volumeType::MIXED;
}
else if (geometry.inside(cellBb.midpoint()))
{
volumeStatus[cellI] = searchableSurface::INSIDE;
volumeStatus[cellI] = volumeType::INSIDE;
}
else
{
volumeStatus[cellI] =
searchableSurface::OUTSIDE;
volumeStatus[cellI] = volumeType::OUTSIDE;
}
}
}
......@@ -325,7 +322,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
forAll(volumeStatus, cellI)
{
if (volumeStatus[cellI] == searchableSurface::OUTSIDE)
if (volumeStatus[cellI] == volumeType::OUTSIDE)
{
cellsToRemove.append(cellI);
}
......@@ -372,7 +369,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
const labelList& cellMap = map().cellMap();
labelList newVolumeStatus(cellMap.size());
List<volumeType> newVolumeStatus(cellMap.size());
forAll(cellMap, newCellI)
{
......@@ -380,13 +377,11 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
if (oldCellI == -1)
{
newVolumeStatus[newCellI] =
searchableSurface::UNKNOWN;
newVolumeStatus[newCellI] = volumeType::UNKNOWN;
}
else
{
newVolumeStatus[newCellI] =
volumeStatus[oldCellI];
newVolumeStatus[newCellI] = volumeStatus[oldCellI];
}
}
......@@ -511,7 +506,7 @@ void Foam::backgroundMeshDecomposition::printMeshData
bool Foam::backgroundMeshDecomposition::refineCell
(
label cellI,
label volType,
volumeType volType,
scalar& weightEstimate
) const
{
......@@ -531,7 +526,7 @@ bool Foam::backgroundMeshDecomposition::refineCell
weightEstimate = 1.0;
if (volType == searchableSurface::MIXED)
if (volType == volumeType::MIXED)
{
// // 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,
......@@ -611,7 +606,7 @@ bool Foam::backgroundMeshDecomposition::refineCell
// return true;
// }
}
else if (volType == searchableSurface::INSIDE)
else if (volType == volumeType::INSIDE)
{
// scalar s = cvMesh_.cellShapeControl_.cellSize(cellBb.midpoint());
......@@ -634,7 +629,7 @@ bool Foam::backgroundMeshDecomposition::refineCell
Foam::labelList Foam::backgroundMeshDecomposition::selectRefinementCells
(
labelList& volumeStatus,
List<volumeType>& volumeStatus,
volScalarField& cellWeights
) const
{
......@@ -645,7 +640,7 @@ Foam::labelList Foam::backgroundMeshDecomposition::selectRefinementCells
// Determine/update the status of each cell
forAll(volumeStatus, cellI)
{
if (volumeStatus[cellI] == searchableSurface::MIXED)
if (volumeStatus[cellI] == volumeType::MIXED)
{
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
(
......@@ -705,7 +700,12 @@ void Foam::backgroundMeshDecomposition::buildPatchAndTree()
(
new indexedOctree<treeDataBPatch>
(
treeDataBPatch(false, boundaryFacesPtr_()),
treeDataBPatch
(
false,
boundaryFacesPtr_(),
indexedOctree<treeDataBPatch>::perturbTol()
),
overallBb.extend(rnd, 1e-4),
10, // maxLevel
10, // leafSize
......@@ -1064,11 +1064,7 @@ bool Foam::backgroundMeshDecomposition::positionOnThisProcessor
{
// return bFTreePtr_().findAnyOverlap(pt, 0.0);
return
(
bFTreePtr_().getVolumeType(pt)
== indexedOctree<treeDataBPatch>::INSIDE
);
return (bFTreePtr_().getVolumeType(pt) == volumeType::INSIDE);
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -71,6 +71,7 @@ SourceFiles
#include "pointField.H"
#include "indexedOctree.H"
#include "treeDataPrimitivePatch.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -166,7 +167,7 @@ class backgroundMeshDecomposition
bool refineCell
(
label cellI,
label volType,
volumeType volType,
scalar& weightEstimate
) const;
......@@ -174,7 +175,7 @@ class backgroundMeshDecomposition
// meshed
labelList selectRefinementCells
(
labelList& volumeStatus,
List<volumeType>& volumeStatus,
volScalarField& cellWeights
) const;
......
......@@ -27,6 +27,7 @@ License
#include "addToRunTimeSelectionTable.H"
#include "triSurfaceMesh.H"
#include "triSurfaceFields.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -125,7 +126,7 @@ bool linearDistance::cellSize(const point& pt, scalar& size) const
}
pointField ptF(1, pt);
List<searchableSurface::volumeType> vTL;
List<volumeType> vTL;
surface_.getVolumeType(ptF, vTL);
......@@ -134,7 +135,7 @@ bool linearDistance::cellSize(const point& pt, scalar& size) const
if
(
sideMode_ == smInside
&& vTL[0] == searchableSurface::INSIDE
&& vTL[0] == volumeType::INSIDE
)
{
size = sizeFunction(hitPt, dist, hitIndex);
......@@ -144,7 +145,7 @@ bool linearDistance::cellSize(const point& pt, scalar& size) const
else if
(
sideMode_ == smOutside
&& vTL[0] == searchableSurface::OUTSIDE
&& vTL[0] == volumeType::OUTSIDE
)
{
size = sizeFunction(hitPt, dist, hitIndex);
......
......@@ -25,6 +25,7 @@ License
#include "linearSpatial.H"
#include "addToRunTimeSelectionTable.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -108,7 +109,7 @@ bool linearSpatial::cellSize
}
pointField ptF(1, pt);
List<searchableSurface::volumeType> vTL;
List<volumeType> vTL;
surface_.getVolumeType(ptF, vTL);
......@@ -117,7 +118,7 @@ bool linearSpatial::cellSize
if
(
sideMode_ == smInside
&& vTL[0] == searchableSurface::INSIDE
&& vTL[0] == volumeType::INSIDE
)
{
size = sizeFunction(pt);
......@@ -127,7 +128,7 @@ bool linearSpatial::cellSize
else if
(
sideMode_ == smOutside
&& vTL[0] == searchableSurface::OUTSIDE
&& vTL[0] == volumeType::OUTSIDE
)
{
size = sizeFunction(pt);
......
......@@ -25,6 +25,7 @@ License
#include "surfaceOffsetLinearDistance.H"
#include "addToRunTimeSelectionTable.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -194,7 +195,7 @@ bool surfaceOffsetLinearDistance::cellSize
}
pointField ptF(1, pt);
List<searchableSurface::volumeType> vTL;
List<volumeType> vTL;
surface_.getVolumeType(ptF, vTL);
......@@ -203,7 +204,7 @@ bool surfaceOffsetLinearDistance::cellSize
if
(
sideMode_ == smInside
&& vTL[0] == searchableSurface::INSIDE
&& vTL[0] == volumeType::INSIDE
)
{
size = sizeFunction(hitPt, dist, hitIndex);
......@@ -213,7 +214,7 @@ bool surfaceOffsetLinearDistance::cellSize
else if
(
sideMode_ == smOutside
&& vTL[0] == searchableSurface::OUTSIDE
&& vTL[0] == volumeType::OUTSIDE
)
{
size = sizeFunction(hitPt, dist, hitIndex);
......
......@@ -25,6 +25,7 @@ License
#include "uniform.H"
#include "addToRunTimeSelectionTable.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -103,7 +104,7 @@ bool uniform::cellSize
}
pointField ptF(1, pt);
List<searchableSurface::volumeType> vTL(1);
List<volumeType> vTL(1);
surface_.getVolumeType(ptF, vTL);
......@@ -112,7 +113,7 @@ bool uniform::cellSize
if
(
sideMode_ == smInside
&& vTL[0] == searchableSurface::INSIDE
&& vTL[0] == volumeType::INSIDE
)
{
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
......@@ -122,7 +123,7 @@ bool uniform::cellSize
else if
(
sideMode_ == smOutside
&& vTL[0] == searchableSurface::OUTSIDE
&& vTL[0] == volumeType::OUTSIDE
)
{
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
......
......@@ -25,7 +25,7 @@ License
#include "uniformDistance.H"
#include "addToRunTimeSelectionTable.H"
#include "dimensionSet.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -95,7 +95,7 @@ bool uniformDistance::cellSize
}
pointField ptF(1, pt);
List<searchableSurface::volumeType> vTL;
List<volumeType> vTL;
surface_.getVolumeType(ptF, vTL);
......@@ -104,7 +104,7 @@ bool uniformDistance::cellSize
if
(
sideMode_ == smInside
&& vTL[0] == searchableSurface::INSIDE
&& vTL[0] == volumeType::INSIDE
)
{
size = surfaceCellSizeFunction_().surfaceSize(hitInfo.index());
......@@ -114,7 +114,7 @@ bool uniformDistance::cellSize
else if
(
sideMode_ == smOutside
&& vTL[0] == searchableSurface::OUTSIDE
&& vTL[0] == volumeType::OUTSIDE
)
{
size = surfaceCellSizeFunction_().surfaceSize(hitInfo.index());
......
......@@ -27,11 +27,19 @@ License
#include "conformalVoronoiMesh.H"
#include "triSurface.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(conformationSurfaces, 0);
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
void Foam::conformationSurfaces::hasBoundedVolume
(
List<searchableSurface::volumeType>& referenceVolumeTypes
List<volumeType>& referenceVolumeTypes
) const
{
vector sum(vector::zero);
......@@ -41,14 +49,18 @@ void Foam::conformationSurfaces::hasBoundedVolume
{
const searchableSurface& surface(allGeometry_[surfaces_[s]]);
if (surface.hasVolumeType())
if
(
surface.hasVolumeType()
&& !baffleSurfaces_[regionOffset_[s]]
)
{
pointField pts(1, locationInMesh_);
List<searchableSurface::volumeType> vTypes
List<volumeType> vTypes
(
pts.size(),
searchableSurface::UNKNOWN
volumeType::UNKNOWN
);
surface.getVolumeType(pts, vTypes);
......@@ -56,7 +68,7 @@ void Foam::conformationSurfaces::hasBoundedVolume
referenceVolumeTypes[s] = vTypes[0];
Info<< " is "
<< searchableSurface::volumeTypeNames[referenceVolumeTypes[s]]
<< volumeType::names[referenceVolumeTypes[s]]
<< " surface " << surface.name()
<< endl;
}
......@@ -407,7 +419,7 @@ Foam::conformationSurfaces::conformationSurfaces
referenceVolumeTypes_.setSize
(
surfaces_.size(),
searchableSurface::UNKNOWN
volumeType::UNKNOWN
);
Info<< endl
......@@ -471,24 +483,24 @@ bool Foam::conformationSurfaces::outside
const point& samplePt
) 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 scalarField& testDistSqr,
bool testForInside
const scalarField& testDistSqr
) const
{
List<List<searchableSurface::volumeType> > surfaceVolumeTests
List<List<volumeType> > surfaceVolumeTests
(
surfaces_.size(),
List<searchableSurface::volumeType>
List<volumeType>
(
samplePts.size(),
searchableSurface::UNKNOWN
volumeType::UNKNOWN
)
);
......@@ -497,7 +509,9 @@ Foam::Field<bool> Foam::conformationSurfaces::wellInOutSide
{
const searchableSurface& surface(allGeometry_[surfaces_[s]]);
if (surface.hasVolumeType())
const label regionI = regionOffset_[s];
if (!baffleSurfaces_[regionI])
{
surface.getVolumeType(samplePts, surfaceVolumeTests[s]);
}
......@@ -508,7 +522,7 @@ Foam::Field<bool> Foam::conformationSurfaces::wellInOutSide
// distanceSquared
// 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
......@@ -534,37 +548,47 @@ Foam::Field<bool> Foam::conformationSurfaces::wellInOutSide
{
// If the point is within range of the surface, then it can't be
// well (in|out)side
inOutSidePoint[i] = false;
insidePoint[i] = false;
continue;
}
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
// 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 (surfaceVolumeTests[s][i] != referenceVolumeTypes_[s])
if (baffleSurfaces_[regionI])
{