ENH: foamyHexMesh: meshableSide

This commit is contained in:
laurence
2013-06-20 11:35:25 +01:00
parent 8e04e92f74
commit cea555f49b
9 changed files with 170 additions and 67 deletions

View File

@ -240,7 +240,10 @@ void Foam::conformalVoronoiMesh::insertSurfacePointPairs
const Foam::point& surfacePt(surfaceHit.hitPoint()); const Foam::point& surfacePt(surfaceHit.hitPoint());
if (geometryToConformTo_.isBaffle(featureIndex, surfaceHit)) extendedFeatureEdgeMesh::sideVolumeType meshableSide =
geometryToConformTo_.meshableSide(featureIndex, surfaceHit);
if (meshableSide == extendedFeatureEdgeMesh::BOTH)
{ {
createBafflePointPair createBafflePointPair
( (
@ -250,7 +253,7 @@ void Foam::conformalVoronoiMesh::insertSurfacePointPairs
pts pts
); );
} }
else else if (meshableSide == extendedFeatureEdgeMesh::INSIDE)
{ {
createPointPair createPointPair
( (
@ -260,6 +263,25 @@ void Foam::conformalVoronoiMesh::insertSurfacePointPairs
pts pts
); );
} }
else if (meshableSide == extendedFeatureEdgeMesh::OUTSIDE)
{
createPointPair
(
pointPairDistance(surfacePt),
surfacePt,
-normal,
pts
);
}
else
{
WarningIn
(
"Foam::conformalVoronoiMesh::insertSurfacePointPairs"
"(const pointIndexHitAndFeatureList&, const fileName)"
) << meshableSide << ", bad"
<< endl;
}
} }
insertPoints(pts, true); insertPoints(pts, true);

View File

@ -989,8 +989,9 @@ bool Foam::conformalVoronoiMesh::surfaceLocationConformsToInside
{ {
vectorField norm(1); vectorField norm(1);
allGeometry_[info.second()].getNormal geometryToConformTo_.getNormal
( (
info.second(),
List<pointIndexHit>(1, info.first()), List<pointIndexHit>(1, info.first()),
norm norm
); );
@ -1133,8 +1134,9 @@ bool Foam::conformalVoronoiMesh::dualCellSurfaceAllIntersections
{ {
vectorField norm(1); vectorField norm(1);
allGeometry_[hitSurfaceIntersection].getNormal geometryToConformTo_.getNormal
( (
hitSurfaceIntersection,
List<pointIndexHit>(1, infoIntersection), List<pointIndexHit>(1, infoIntersection),
norm norm
); );

View File

@ -179,7 +179,7 @@ void Foam::conformalVoronoiMesh::createEdgePointGroupByCirculating
const labelList& edNormalIs = feMesh.edgeNormals()[edgeI]; const labelList& edNormalIs = feMesh.edgeNormals()[edgeI];
const labelList& feNormalDirections = feMesh.normalDirections()[edgeI]; const labelList& feNormalDirections = feMesh.normalDirections()[edgeI];
const PackedList<2>& normalVolumeTypes = feMesh.normalVolumeTypes(); const List<sideVolumeType>& normalVolumeTypes = feMesh.normalVolumeTypes();
const_circulator<labelList> circ(edNormalIs); const_circulator<labelList> circ(edNormalIs);
const_circulator<labelList> circNormalDirs(feNormalDirections); const_circulator<labelList> circNormalDirs(feNormalDirections);
@ -197,10 +197,8 @@ void Foam::conformalVoronoiMesh::createEdgePointGroupByCirculating
if (circ.size()) do if (circ.size()) do
{ {
const sideVolumeType volType = const sideVolumeType volType = normalVolumeTypes[circ()];
sideVolumeType(normalVolumeTypes[circ()]); const sideVolumeType nextVolType = normalVolumeTypes[circ.next()];
const sideVolumeType nextVolType =
sideVolumeType(normalVolumeTypes[circ.next()]);
const vector& normal = feNormals[circ()]; const vector& normal = feNormals[circ()];
const vector& nextNormal = feNormals[circ.next()]; const vector& nextNormal = feNormals[circ.next()];

View File

@ -53,7 +53,10 @@ void Foam::conformationSurfaces::hasBoundedVolume
if if
( (
surface.hasVolumeType() surface.hasVolumeType()
&& !baffleSurfaces_[regionOffset_[s]] && (
normalVolumeTypes_[regionOffset_[s]]
!= extendedFeatureEdgeMesh::BOTH
)
) )
{ {
pointField pts(1, locationInMesh_); pointField pts(1, locationInMesh_);
@ -87,7 +90,11 @@ void Foam::conformationSurfaces::hasBoundedVolume
+ regionOffset_[s]; + regionOffset_[s];
// Don't include baffle surfaces in the calculation // Don't include baffle surfaces in the calculation
if (!baffleSurfaces_[patchID]) if
(
normalVolumeTypes_[patchID]
!= extendedFeatureEdgeMesh::BOTH
)
{ {
sum += triSurf[sI].normal(surfPts); sum += triSurf[sI].normal(surfPts);
} }
@ -256,7 +263,7 @@ Foam::conformationSurfaces::conformationSurfaces
locationInMesh_(surfaceConformationDict.lookup("locationInMesh")), locationInMesh_(surfaceConformationDict.lookup("locationInMesh")),
surfaces_(), surfaces_(),
allGeometryToSurfaces_(), allGeometryToSurfaces_(),
baffleSurfaces_(), normalVolumeTypes_(),
patchNames_(), patchNames_(),
regionOffset_(), regionOffset_(),
patchInfo_(), patchInfo_(),
@ -283,7 +290,7 @@ Foam::conformationSurfaces::conformationSurfaces
allGeometryToSurfaces_.setSize(allGeometry_.size(), -1); allGeometryToSurfaces_.setSize(allGeometry_.size(), -1);
baffleSurfaces_.setSize(nSurf, false); normalVolumeTypes_.setSize(nSurf);
// Features may be attached to host surfaces or independent // Features may be attached to host surfaces or independent
features_.setSize(nSurf + nAddFeat); features_.setSize(nSurf + nAddFeat);
@ -294,8 +301,8 @@ Foam::conformationSurfaces::conformationSurfaces
PtrList<dictionary> globalPatchInfo(nSurf); PtrList<dictionary> globalPatchInfo(nSurf);
List<Map<autoPtr<dictionary> > > regionPatchInfo(nSurf); List<Map<autoPtr<dictionary> > > regionPatchInfo(nSurf);
boolList globalBaffleSurfaces(nSurf, false); List<sideVolumeType> globalVolumeTypes(nSurf);
List<Map<bool> > regionBaffleSurface(nSurf); List<Map<sideVolumeType> > regionVolumeTypes(nSurf);
label surfI = 0; label surfI = 0;
@ -324,12 +331,15 @@ Foam::conformationSurfaces::conformationSurfaces
const dictionary& surfaceSubDict(surfacesDict.subDict(surfaceName)); const dictionary& surfaceSubDict(surfacesDict.subDict(surfaceName));
globalBaffleSurfaces[surfI] = Switch globalVolumeTypes[surfI] =
( (
surfaceSubDict.lookupOrDefault("baffleSurface", false) extendedFeatureEdgeMesh::sideVolumeTypeNames_
[
surfaceSubDict.lookupOrDefault<word>("meshableSide", "inside")
]
); );
if (!globalBaffleSurfaces[surfI]) if (!globalVolumeTypes[surfI])
{ {
if (!allGeometry_[surfaces_[surfI]].hasVolumeType()) if (!allGeometry_[surfaces_[surfI]].hasVolumeType())
{ {
@ -384,22 +394,20 @@ Foam::conformationSurfaces::conformationSurfaces
regionI, regionI,
regionDict.subDict("patchInfo").clone() regionDict.subDict("patchInfo").clone()
); );
// Info<< " patchInfo: "
// << regionPatchInfo[surfI][regionI] << endl;
} }
if (regionDict.found("baffleSurface")) regionVolumeTypes[surfI].insert
{ (
regionBaffleSurface[surfI].insert regionI,
( extendedFeatureEdgeMesh::sideVolumeTypeNames_
regionI, [
regionDict.lookup("baffleSurface") regionDict.lookupOrDefault<word>
); (
"meshableSide",
// Info<< " baffle: " "inside"
// << regionBaffleSurface[surfI][regionI] << endl; )
} ]
);
readFeatures(regionDict, regionName, featureI); readFeatures(regionDict, regionName, featureI);
} }
@ -420,7 +428,7 @@ Foam::conformationSurfaces::conformationSurfaces
// Rework surface specific information into information per global region // Rework surface specific information into information per global region
patchInfo_.setSize(nRegions); patchInfo_.setSize(nRegions);
baffleSurfaces_.setSize(nRegions, false); normalVolumeTypes_.setSize(nRegions);
forAll(surfaces_, surfI) forAll(surfaces_, surfI)
{ {
@ -430,7 +438,7 @@ Foam::conformationSurfaces::conformationSurfaces
for (label i = 0; i < nRegions; i++) for (label i = 0; i < nRegions; i++)
{ {
label globalRegionI = regionOffset_[surfI] + i; label globalRegionI = regionOffset_[surfI] + i;
baffleSurfaces_[globalRegionI] = globalBaffleSurfaces[surfI]; normalVolumeTypes_[globalRegionI] = globalVolumeTypes[surfI];
if (globalPatchInfo.set(surfI)) if (globalPatchInfo.set(surfI))
{ {
patchInfo_.set patchInfo_.set
@ -441,12 +449,12 @@ Foam::conformationSurfaces::conformationSurfaces
} }
} }
forAllConstIter(Map<bool>, regionBaffleSurface[surfI], iter) forAllConstIter(Map<sideVolumeType>, regionVolumeTypes[surfI], iter)
{ {
label globalRegionI = regionOffset_[surfI] + iter.key(); label globalRegionI = regionOffset_[surfI] + iter.key();
baffleSurfaces_[globalRegionI] = normalVolumeTypes_[globalRegionI] =
regionBaffleSurface[surfI][iter.key()]; regionVolumeTypes[surfI][iter.key()];
} }
const Map<autoPtr<dictionary> >& localInfo = regionPatchInfo[surfI]; const Map<autoPtr<dictionary> >& localInfo = regionPatchInfo[surfI];
@ -516,7 +524,7 @@ Foam::conformationSurfaces::conformationSurfaces
Info<< "Names = " << allGeometry_.names() << endl; Info<< "Names = " << allGeometry_.names() << endl;
Info<< "Surfaces = " << surfaces_ << endl; Info<< "Surfaces = " << surfaces_ << endl;
Info<< "AllGeom to Surfaces = " << allGeometryToSurfaces_ << endl; Info<< "AllGeom to Surfaces = " << allGeometryToSurfaces_ << endl;
Info<< "Baffle Surfaces = " << baffleSurfaces_ << endl; Info<< "Volume types = " << normalVolumeTypes_ << endl;
Info<< "Patch names = " << patchNames_ << endl; Info<< "Patch names = " << patchNames_ << endl;
Info<< "Region Offset = " << regionOffset_ << endl; Info<< "Region Offset = " << regionOffset_ << endl;
@ -610,7 +618,7 @@ Foam::Field<bool> Foam::conformationSurfaces::wellInside
const label regionI = regionOffset_[s]; const label regionI = regionOffset_[s];
if (!baffleSurfaces_[regionI]) if (normalVolumeTypes_[regionI] != extendedFeatureEdgeMesh::BOTH)
{ {
// if (surface.hasVolumeType()) // if (surface.hasVolumeType())
// { // {
@ -653,9 +661,7 @@ Foam::Field<bool> Foam::conformationSurfaces::wellInside
//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
labelList hitSurfaces; labelList hitSurfaces;
List<pointIndexHit> hitInfo; List<pointIndexHit> hitInfo;
searchableSurfacesQueries::findNearest searchableSurfacesQueries::findNearest
( (
allGeometry_, allGeometry_,
@ -698,7 +704,7 @@ Foam::Field<bool> Foam::conformationSurfaces::wellInside
// 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 (baffleSurfaces_[regionI]) if (normalVolumeTypes_[regionI] == extendedFeatureEdgeMesh::BOTH)
{ {
continue; continue;
} }
@ -709,9 +715,27 @@ Foam::Field<bool> Foam::conformationSurfaces::wellInside
if (surfaceVolumeTests[s][i] == volumeType::OUTSIDE) if (surfaceVolumeTests[s][i] == volumeType::OUTSIDE)
// if (surfaceVolumeTests[s][i] != volumeType::INSIDE) // if (surfaceVolumeTests[s][i] != volumeType::INSIDE)
{ {
insidePoint[i] = false; if
(
break; normalVolumeTypes_[regionI]
== extendedFeatureEdgeMesh::INSIDE
)
{
insidePoint[i] = false;
break;
}
}
else if (surfaceVolumeTests[s][i] == volumeType::INSIDE)
{
if
(
normalVolumeTypes_[regionI]
== extendedFeatureEdgeMesh::OUTSIDE
)
{
insidePoint[i] = false;
break;
}
} }
} }
} }
@ -757,7 +781,7 @@ Foam::Field<bool> Foam::conformationSurfaces::wellOutside
const label regionI = regionOffset_[s]; const label regionI = regionOffset_[s];
if (!baffleSurfaces_[regionI]) if (normalVolumeTypes_[regionI] != extendedFeatureEdgeMesh::BOTH)
{ {
surface.getVolumeType(samplePts, surfaceVolumeTests[s]); surface.getVolumeType(samplePts, surfaceVolumeTests[s]);
} }
@ -773,9 +797,7 @@ Foam::Field<bool> Foam::conformationSurfaces::wellOutside
//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
labelList hitSurfaces; labelList hitSurfaces;
List<pointIndexHit> hitInfo; List<pointIndexHit> hitInfo;
searchableSurfacesQueries::findNearest searchableSurfacesQueries::findNearest
( (
allGeometry_, allGeometry_,
@ -795,13 +817,12 @@ Foam::Field<bool> Foam::conformationSurfaces::wellOutside
// 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
outsidePoint[i] = false; outsidePoint[i] = false;
//continue; //continue;
} }
forAll(surfaces_, s) forAll(surfaces_, s)
{ {
// const searchableSurface& surface(allGeometry_[surfaces_[s]]); const searchableSurface& surface(allGeometry_[surfaces_[s]]);
// if // if
// ( // (
@ -814,20 +835,42 @@ Foam::Field<bool> Foam::conformationSurfaces::wellOutside
const label regionI = regionOffset_[s]; const label regionI = regionOffset_[s];
// Info<< s << " " << surfaces_[s] << " " << surface.name() << " "
// << normalVolumeTypes_[regionI] << " "
// << surfaceVolumeTests[s][i] << endl;
// 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 (baffleSurfaces_[regionI]) if (normalVolumeTypes_[regionI] == extendedFeatureEdgeMesh::BOTH)
{ {
continue; continue;
} }
if (surfaceVolumeTests[s][i] == volumeType::OUTSIDE) if (surfaceVolumeTests[s][i] == volumeType::OUTSIDE)
{ {
outsidePoint[i] = true; if
(
break; normalVolumeTypes_[regionI]
== extendedFeatureEdgeMesh::INSIDE
)
{
outsidePoint[i] = true;
break;
}
}
else if (surfaceVolumeTests[s][i] == volumeType::INSIDE)
{
if
(
normalVolumeTypes_[regionI]
== extendedFeatureEdgeMesh::OUTSIDE
)
{
outsidePoint[i] = true;
break;
}
} }
} }
} }
@ -1281,7 +1324,8 @@ Foam::label Foam::conformationSurfaces::getPatchID
} }
bool Foam::conformationSurfaces::isBaffle Foam::extendedFeatureEdgeMesh::sideVolumeType
Foam::conformationSurfaces::meshableSide
( (
const label hitSurface, const label hitSurface,
const pointIndexHit& surfHit const pointIndexHit& surfHit
@ -1291,10 +1335,33 @@ bool Foam::conformationSurfaces::isBaffle
if (patchID == -1) if (patchID == -1)
{ {
return false; return extendedFeatureEdgeMesh::NEITHER;
} }
return baffleSurfaces_[patchID]; return normalVolumeTypes_[patchID];
}
void Foam::conformationSurfaces::getNormal
(
const label hitSurface,
const List<pointIndexHit>& surfHit,
vectorField& normal
) const
{
allGeometry_[hitSurface].getNormal
(
surfHit,
normal
);
const label patchID = regionOffset_[allGeometryToSurfaces_[hitSurface]];
// Now flip sign of normal depending on mesh side
if (normalVolumeTypes_[patchID] == extendedFeatureEdgeMesh::OUTSIDE)
{
normal *= -1;
}
} }

View File

@ -52,6 +52,8 @@ namespace Foam
class conformationSurfaces class conformationSurfaces
{ {
typedef extendedFeatureEdgeMesh::sideVolumeType sideVolumeType;
// Private data // Private data
const Time& runTime_; const Time& runTime_;
@ -78,7 +80,7 @@ class conformationSurfaces
//- A boolean value for each surface to be conformed to specifying if it //- A boolean value for each surface to be conformed to specifying if it
// is to be treated as a baffle // is to be treated as a baffle
boolList baffleSurfaces_; List<sideVolumeType> normalVolumeTypes_;
//- A flat list of all of the names of the patches from all of the //- A flat list of all of the names of the patches from all of the
// surfaces to be reproduced in the meshed geometry // surfaces to be reproduced in the meshed geometry
@ -337,12 +339,19 @@ public:
label findPatch(const point& pt) const; label findPatch(const point& pt) const;
//- Is the surface a baffle. //- Is the surface a baffle.
bool isBaffle extendedFeatureEdgeMesh::sideVolumeType meshableSide
( (
const label hitSurface, const label hitSurface,
const pointIndexHit& surfHit const pointIndexHit& surfHit
) const; ) const;
void getNormal
(
const label hitSurface,
const List<pointIndexHit>& surfHit,
vectorField& normal
) const;
// Write // Write

View File

@ -52,10 +52,16 @@ Foam::searchableBoxFeatures::searchableBoxFeatures
) )
: :
searchableSurfaceFeatures(surface, dict), searchableSurfaceFeatures(surface, dict),
mode_(extendedFeatureEdgeMesh::sideVolumeTypeNames_[dict.lookup("mode")]) mode_
(
extendedFeatureEdgeMesh::sideVolumeTypeNames_
[
dict.lookupOrDefault<word>("meshableSide", "INSIDE")
]
)
{ {
Info<< indent Info<< indent
<< " Mesh mode = " << " Meshable region = "
<< extendedFeatureEdgeMesh::sideVolumeTypeNames_[mode_] << extendedFeatureEdgeMesh::sideVolumeTypeNames_[mode_]
<< endl; << endl;
} }

View File

@ -399,7 +399,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
label openStart, label openStart,
label multipleStart, label multipleStart,
const vectorField& normals, const vectorField& normals,
const PackedList<2>& normalVolumeTypes, const List<sideVolumeType>& normalVolumeTypes,
const vectorField& edgeDirections, const vectorField& edgeDirections,
const labelListList& normalDirections, const labelListList& normalDirections,
const labelListList& edgeNormals, const labelListList& edgeNormals,

View File

@ -61,7 +61,6 @@ SourceFiles
#include "treeDataEdge.H" #include "treeDataEdge.H"
#include "treeDataPoint.H" #include "treeDataPoint.H"
#include "PrimitivePatch.H" #include "PrimitivePatch.H"
#include "PackedList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -163,7 +162,7 @@ private:
vectorField normals_; vectorField normals_;
//- //-
PackedList<2> normalVolumeTypes_; List<sideVolumeType> normalVolumeTypes_;
//- Flat and open edges require the direction of the edge //- Flat and open edges require the direction of the edge
vectorField edgeDirections_; vectorField edgeDirections_;
@ -287,7 +286,7 @@ public:
label openStart, label openStart,
label multipleStart, label multipleStart,
const vectorField& normals, const vectorField& normals,
const PackedList<2>& normalVolumeTypes, const List<sideVolumeType>& normalVolumeTypes,
const vectorField& edgeDirections, const vectorField& edgeDirections,
const labelListList& normalDirections, const labelListList& normalDirections,
const labelListList& edgeNormals, const labelListList& edgeNormals,
@ -392,7 +391,7 @@ public:
inline const vectorField& normals() const; inline const vectorField& normals() const;
//- Return //- Return
inline const PackedList<2>& normalVolumeTypes() const; inline const List<sideVolumeType>& normalVolumeTypes() const;
//- Return the edgeDirection vectors //- Return the edgeDirection vectors
inline const vectorField& edgeDirections() const; inline const vectorField& edgeDirections() const;

View File

@ -90,7 +90,7 @@ inline const Foam::vectorField& Foam::extendedFeatureEdgeMesh::normals() const
return normals_; return normals_;
} }
inline const Foam::PackedList<2>& inline const Foam::List<Foam::extendedFeatureEdgeMesh::sideVolumeType>&
Foam::extendedFeatureEdgeMesh::normalVolumeTypes() const Foam::extendedFeatureEdgeMesh::normalVolumeTypes() const
{ {
return normalVolumeTypes_; return normalVolumeTypes_;