Commit b7cab04b authored by franjo.juretic@c-fields.com's avatar franjo.juretic@c-fields.com
Browse files

Intermediate work on feature edges + compilaion fixes for OpenFOAM-2.3


git-svn-id: https://pl5.projectlocker.com/igui/meshGeneration/svn@59 fdcce57e-7e00-11e2-b579-49867b4cea03
parent e500cefc
......@@ -5,8 +5,10 @@ meshSurfacePartitioner = utilities/surfaceTools/meshSurfacePartitioner
boundaryFacesGenerator = utilities/surfaceTools/boundaryFacesGenerator
boundaryLayers = utilities/boundaryLayers
checkMeshDict = utilities/checkMeshDict
meshSurfaceCheckInvertedVertices = utilities/surfaceTools/meshSurfaceCheckInvertedVertices
meshSurfaceCheckEdgeTypes = utilities/surfaceTools/meshSurfaceCheckEdgeTypes
meshSurfaceDetectPlanarRegions = utilities/surfaceTools/meshSurfaceDetectPlanarRegions
meshSurfaceCutter = utilities/surfaceTools/meshSurfaceCutter
meshSurfaceMapper = utilities/surfaceTools/meshSurfaceMapper
meshSurfaceMapper2D = utilities/surfaceTools/meshSurfaceMapper2D
......@@ -17,10 +19,12 @@ meshSurfaceEdgeExtractorNonTopo = utilities/surfaceTools/meshSurfaceEdgeExtracto
meshSurfaceEdgeExtractorFUN = utilities/surfaceTools/meshSurfaceEdgeExtractorFUN
meshSurfaceEdgeExtractor2D = utilities/surfaceTools/meshSurfaceEdgeExtractor2D
correctEdgesBetweenPatches = utilities/surfaceTools/correctEdgesBetweenPatches
createFundamentalSheetsBase = utilities/surfaceTools/createFundamentalSheets
createFundamentalSheets = $(createFundamentalSheetsBase)/createFundamentalSheets
createFundamentalSheetsJFS = $(createFundamentalSheetsBase)/createFundamentalSheetsJFS
createFundamentalSheetsFJ = $(createFundamentalSheetsBase)/createFundamentalSheetsFJ
decomposeCellsNearConcaveEdges = utilities/surfaceTools/decomposeCellsNearConcaveEdges
renameBoundaryPatches = utilities/surfaceTools/renameBoundaryPatches
......@@ -74,17 +78,18 @@ checkCellConnectionsOverFaces = $(topology)/checkCellConnectionsOverFaces
checkIrregularSurfaceConnections = $(topology)/checkIrregularSurfaceConnections
checkNonMappableCellConnections = $(topology)/checkNonMappableCellConnections
triSurfaceCleanupDuplicates = utilities/triSurfaceTools/triSurfaceCleanupDuplicates
triSurfaceCopyParts = utilities/triSurfaceTools/triSurfaceCopyParts
triSurfaceCurvatureEstimator = utilities/triSurfaceTools/triSurfaceCurvatureEstimator
triSurfacePartitioner = utilities/triSurfaceTools/triSurfacePartitioner
triSurfaceDetectMaterials = utilities/triSurfaceTools/triSurfaceDetectMaterials
triSurfaceDetectPlanarRegions = utilities/triSurfaceTools/triSurfaceDetectPlanarRegions
triSurfaceDetectFeatureEdges = utilities/triSurfaceTools/triSurfaceDetectFeatureEdges
triSurfaceClassifyEdges = utilities/triSurfaceTools/triSurfaceClassifyEdges
triSurfacePatchManipulator = utilities/triSurfaceTools/triSurfacePatchManipulator
triSurfaceRemoveFacets = utilities/triSurfaceTools/triSurfaceRemoveFacets
triSurfaceExtrude2DEdges = utilities/triSurfaceTools/triSurfaceExtrude2DEdges
triSurfaceTools = utilities/triSurfaceTools
triSurfaceCleanupDuplicates = $(triSurfaceTools)/triSurfaceCleanupDuplicates
triSurfaceCopyParts = $(triSurfaceTools)/triSurfaceCopyParts
triSurfaceCurvatureEstimator = $(triSurfaceTools)/triSurfaceCurvatureEstimator
triSurfacePartitioner = $(triSurfaceTools)/triSurfacePartitioner
triSurfaceDetectMaterials = $(triSurfaceTools)/triSurfaceDetectMaterials
triSurfaceDetectPlanarRegions = $(triSurfaceTools)/triSurfaceDetectPlanarRegions
triSurfaceDetectFeatureEdges = $(triSurfaceTools)/triSurfaceDetectFeatureEdges
triSurfaceClassifyEdges = $(triSurfaceTools)/triSurfaceClassifyEdges
triSurfacePatchManipulator = $(triSurfaceTools)/triSurfacePatchManipulator
triSurfaceRemoveFacets = $(triSurfaceTools)/triSurfaceRemoveFacets
triSurfaceExtrude2DEdges = $(triSurfaceTools)/triSurfaceExtrude2DEdges
polyMeshGen = utilities/meshes/polyMeshGen
boundaryPatch = utilities/meshes/polyMeshGen/boundaryPatch
......@@ -287,6 +292,8 @@ $(meshSurfaceCheckInvertedVertices)/meshSurfaceCheckInvertedVertices.C
$(meshSurfaceCheckEdgeTypes)/meshSurfaceCheckEdgeTypes.C
$(meshSurfaceDetectPlanarRegions)/meshSurfaceDetectPlanarRegions.C
$(meshSurfaceCutter)/meshSurfaceCutter.C
$(meshSurfaceCutter)/meshSurfaceCutterFaceCutter.C
$(meshSurfaceCutter)/meshSurfaceCutterInternalFaces.C
......@@ -303,6 +310,7 @@ $(meshSurfaceMapper2D)/meshSurfaceMapper2DMapVertices.C
$(meshSurfaceMapper2D)/meshSurfaceMapper2DPremapVertices.C
$(edgeExtractor)/edgeExtractor.C
$(edgeExtractor)/edgeExtractorCorners.C
$(meshSurfaceEdgeExtractor)/meshSurfaceEdgeExtractor.C
$(meshSurfaceEdgeExtractor)/meshSurfaceEdgeCreateEdgeVertices.C
......
......@@ -163,7 +163,7 @@ void cartesianMeshGenerator::mapMeshToSurface()
# endif
//- untangle surface faces
meshSurfaceOptimizer(*msePtr, *octreePtr_).preOptimizeSurface();
meshSurfaceOptimizer(*msePtr, *octreePtr_).untangleSurface();
# ifdef DEBUG
mesh_.write();
......@@ -196,34 +196,8 @@ void cartesianMeshGenerator::optimiseMeshSurface()
void cartesianMeshGenerator::generateBoundaryLayers()
{
//- add boundary layers
boundaryLayers bl(mesh_);
/* if( meshDict_.found("boundaryLayers") )
{
if( )
wordList createLayers;
if( meshDict_.isDict("boundaryLayers") )
{
const dictionary& dict = meshDict_.subDict("boundaryLayers");
createLayers = dict.toc();
}
else
{
wordList bndLayers(meshDict_.lookup("boundaryLayers"));
createLayers.transfer(bndLayers);
}
forAll(createLayers, patchI)
bl.addLayerForPatch(createLayers[patchI]);
}
else
{
//bl.createOTopologyLayers();
bl.addLayerForAllPatches();
}
*/
bl.addLayerForAllPatches();
# ifdef DEBUG
......@@ -251,14 +225,16 @@ void cartesianMeshGenerator::refBoundaryLayers()
void cartesianMeshGenerator::optimiseFinalMesh()
{
//- final optimisation
meshOptimizer optimizer(mesh_);
optimizer.optimizeSurface(*octreePtr_);
//- untangle the surface if needed
meshSurfaceEngine mse(mesh_);
meshSurfaceOptimizer(mse, *octreePtr_).optimizeSurface();
deleteDemandDrivenData(octreePtr_);
//- final optimisation
meshOptimizer optimizer(mesh_);
optimizer.optimizeMeshFV();
optimizer.optimizeLowQualityFaces();
optimizer.untangleMeshFV();
# ifdef DEBUG
mesh_.write();
......
......@@ -120,7 +120,7 @@ void hexMeshGenerator::mapMeshToSurface()
# endif
//- untangle surface faces
meshSurfaceOptimizer(*msePtr, *octreePtr_).preOptimizeSurface();
meshSurfaceOptimizer(*msePtr, *octreePtr_).untangleSurface();
# ifdef DEBUG
mesh_.write();
......
......@@ -90,6 +90,7 @@ void tetMeshGenerator::surfacePreparation()
void tetMeshGenerator::mapMeshToSurface()
{
return;
//- calculate mesh surface
meshSurfaceEngine* msePtr = new meshSurfaceEngine(mesh_);
......@@ -102,7 +103,7 @@ void tetMeshGenerator::mapMeshToSurface()
# endif
//- untangle surface faces
meshSurfaceOptimizer(*msePtr, *octreePtr_).preOptimizeSurface();
meshSurfaceOptimizer(*msePtr, *octreePtr_).untangleSurface();
# ifdef DEBUG
mesh_.write();
......
......@@ -761,14 +761,20 @@ void boundaryLayers::createNewFacesFromPointsParallel
const label fI = pointFaceCandidates(pointI, i);
const DynList<label, 4>& f = faceCandidates[fI];
Pair<label> pk
const labelPair pk
(
patchKey_[candidatePatches[fI][0]],
patchKey_[candidatePatches[fI][1]]
);
const labelPair rpk
(
patchKey_[candidatePatches[fI][1]],
patchKey_[candidatePatches[fI][0]]
);
if(
(f[0] == pointI) && ((pk == lp) || (pk.reversePair() == lp))
(f[0] == pointI) && ((pk == lp) || (rpk == lp))
)
{
//- found the processor containing other face
......
......@@ -47,18 +47,18 @@ namespace Foam
/*---------------------------------------------------------------------------*\
Class labelledPair Declaration
\*---------------------------------------------------------------------------*/
class labelledPair
{
// Private data
//- label
label pLabel_;
//- pair data
labelPair pair_;
public:
// Constructors
//- Null construct
labelledPair()
......@@ -66,7 +66,7 @@ class labelledPair
pLabel_(-1),
pair_()
{}
//- Construct from label and pair
labelledPair
(
......@@ -77,32 +77,32 @@ class labelledPair
pLabel_(pl),
pair_(lp)
{}
// Destructor
~labelledPair()
{}
// Member functions
//- return pair label
inline label pairLabel() const
{
return pLabel_;
}
//- return the pair
inline const labelPair& pair() const
{
return pair_;
}
// Member operators
inline void operator=(const labelledPair& lpp)
{
pLabel_ = lpp.pLabel_;
pair_ = lpp.pair_;
}
inline bool operator==
(
const labelledPair& lpp
......@@ -110,13 +110,17 @@ class labelledPair
{
if( pLabel_ != lpp.pLabel_ )
return false;
if( (pair_ != lpp.pair_) && (pair_.reversePair() != lpp.pair_) )
return false;
return true;
const labelPair& op = lpp.pair_;
if( (pair_.first() == op.first()) && (pair_.second() == op.second()) )
return true;
if( (pair_.first() == op.second()) && (pair_.second() == op.first()) )
return true;
return false;
}
inline bool operator!=
(
const labelledPair& lcc
......@@ -124,7 +128,7 @@ class labelledPair
{
return !this->operator==(lcc);
}
inline bool operator<(const labelledPair& lpp) const
{
if( pLabel_ < lpp.pLabel_ )
......@@ -135,22 +139,22 @@ class labelledPair
{
return false;
}
if(
(pair_.first() + pair_.second()) <
(lpp.pair().first() + lpp.pair().second())
)
return true;
if(
Foam::min(pair_.first(), pair_.second()) <
Foam::min(lpp.pair().first(), lpp.pair().second())
)
return true;
return false;
}
// Friend operators
friend Ostream& operator<<
(
......@@ -170,7 +174,7 @@ class labelledPair
return os;
}
friend Istream& operator>>
(
Istream& is,
......@@ -179,16 +183,16 @@ class labelledPair
{
// Read beginning of labelledPair
is.readBegin("labelledPair");
is >> lpp.pLabel_;
is >> lpp.pair_;
// Read end of labelledPair
is.readEnd("labelledPair");
// Check state of Istream
is.check("operator>>(Istream&, labelledPair");
return is;
}
};
......
......@@ -164,6 +164,7 @@ public:
(
point& nearest,
scalar& distSq,
label& nearestTriangle,
label& region,
const point& p
) const;
......@@ -173,6 +174,7 @@ public:
(
point& nearest,
scalar& distSq,
label& nearestTriangle,
const label region,
const point& p
) const;
......@@ -180,18 +182,20 @@ public:
//- find nearest feature-edges vertex to a given vertex
bool findNearestEdgePoint
(
const point& p,
const DynList<label>& regions,
point& edgePoint,
scalar& distSq
scalar& distSq,
label& nearestEdge,
const point& p,
const DynList<label>& regions
) const;
bool findNearestVertexToTheEdge
bool findNearestPointToEdge
(
const FixedList<point, 2>& edgePoints,
const FixedList<label, 2>& edgePointRegions,
point& nearest,
scalar& distSq
scalar& distSq,
label& nearestEdge,
const FixedList<point, 2>& edgePoints,
const FixedList<label, 2>& edgePointRegions
) const;
//- find nearest corner point
......@@ -199,12 +203,13 @@ public:
(
point& nearest,
scalar& distSq,
label& nearestPoint,
const point& p,
const DynList<label>& patches
) const;
//- find the nearest vertex to the given patches
bool findNearestVertexToPatches
bool findNearestPointToPatches
(
point& nearest,
scalar& distSq,
......
......@@ -45,11 +45,13 @@ void meshOctree::findNearestSurfacePoint
(
point& nearest,
scalar& distSq,
label& nearestTriangle,
label& region,
const point& p
) const
{
region = -1;
nearestTriangle = 1;
const label cLabel = findLeafContainingVertex(p);
vector sizeVec;
......@@ -96,6 +98,7 @@ void meshOctree::findNearestSurfacePoint
{
distSq = dSq;
nearest = p0;
nearestTriangle = el[tI];
region = surface_[el[tI]].region();
found = true;
}
......@@ -129,6 +132,7 @@ void meshOctree::findNearestSurfacePointInRegion
(
point& nearest,
scalar& distSq,
label& nearestTriangle,
const label region,
const point& p
) const
......@@ -149,12 +153,13 @@ void meshOctree::findNearestSurfacePointInRegion
bool found(false);
label iterationI(0);
DynList<const meshOctreeCube*, 256> neighbours;
nearestTriangle = -1;
distSq = VGREAT;
do
{
boundBox bb(p - sizeVec, p + sizeVec);
const boundBox bb(p - sizeVec, p + sizeVec);
neighbours.clear();
findLeavesContainedInBox(bb, neighbours);
......@@ -182,6 +187,7 @@ void meshOctree::findNearestSurfacePointInRegion
{
distSq = dSq;
nearest = p0;
nearestTriangle = el[tI];
found = true;
}
}
......@@ -198,10 +204,11 @@ void meshOctree::findNearestSurfacePointInRegion
bool meshOctree::findNearestEdgePoint
(
const point& p,
const DynList<label>& regions,
point& edgePoint,
scalar& distSq
scalar& distSq,
label& nearestEdge,
const point& p,
const DynList<label>& regions
) const
{
//- find the estimate for the searching range
......@@ -228,6 +235,7 @@ bool meshOctree::findNearestEdgePoint
label iterationI(0);
distSq = VGREAT;
nearestEdge = -1;
do
{
......@@ -274,6 +282,7 @@ bool meshOctree::findNearestEdgePoint
{
distSq = dSq;
edgePoint = np;
nearestEdge = ce[eI];
foundAnEdge = true;
}
}
......@@ -287,12 +296,13 @@ bool meshOctree::findNearestEdgePoint
return foundAnEdge;
}
bool meshOctree::findNearestVertexToTheEdge
bool meshOctree::findNearestPointToEdge
(
const FixedList<point, 2>& edgePoints,
const FixedList<label, 2>& edgePointRegions,
point& nearest,
scalar& distSq
scalar& distSq,
label& nearestEdge,
const FixedList<point, 2>& edgePoints,
const FixedList<label, 2>& edgePointRegions
) const
{
const point c = 0.5 * (edgePoints[0] + edgePoints[1]);
......@@ -309,6 +319,7 @@ bool meshOctree::findNearestVertexToTheEdge
const edgeLongList& surfaceEdges = surface_.edges();
distSq = VGREAT;
nearestEdge = -1;
bool found(false);
......@@ -357,6 +368,7 @@ bool meshOctree::findNearestVertexToTheEdge
if( magSqr(nearestOnEdge - nearestOnLine) < distSq )
{
nearest = nearestOnEdge;
nearestEdge = edges[eI];
distSq = magSqr(nearestOnEdge - nearestOnLine);
found = true;
}
......@@ -372,6 +384,7 @@ bool meshOctree::findNearestCorner
(
point& nearest,
scalar& distSq,
label& nearestPoint,
const point& p,
const DynList<label>& patches
) const
......@@ -400,6 +413,7 @@ bool meshOctree::findNearestCorner
const VRWGraph& eFacets = surface_.edgeFacets();
distSq = VGREAT;
nearestPoint = -1;
do
{
......@@ -438,7 +452,7 @@ bool meshOctree::findNearestCorner
{
const label eI = pEdges(spI, i);
if( pEdges.sizeOfRow(eI) < 2 )
if( eFacets.sizeOfRow(eI) != 2 )
break;
if(
......@@ -480,6 +494,7 @@ bool meshOctree::findNearestCorner
distSq = dSq;
found = true;
nearest = points[spI];
nearestPoint = spI;
}
}
}
......@@ -495,7 +510,7 @@ bool meshOctree::findNearestCorner
return found;
}
bool meshOctree::findNearestVertexToPatches
bool meshOctree::findNearestPointToPatches
(
point& nearest,
scalar& distSq,
......@@ -507,6 +522,21 @@ bool meshOctree::findNearestVertexToPatches
if( patches.size() == 0 )
return false;
point mapPoint(p);
scalar dSq(VGREAT);
bool found(false);
if( patches.size() == 2 )
{
label nse;
found = findNearestEdgePoint(mapPoint, dSq, nse, p, patches);
}
else if( patches.size() > 2 )
{
label nsp;
found = findNearestCorner(mapPoint, dSq, nsp, p, patches);
}
point mapPointApprox(p);
scalar distSqApprox;
label iter(0);
......@@ -516,10 +546,12 @@ bool meshOctree::findNearestVertexToPatches
forAll(patches, patchI)
{
point np;
label nearestTri;
this->findNearestSurfacePointInRegion
(
np,
distSqApprox,
nearestTri,
patches[patchI],
mapPointApprox
);
......@@ -528,7 +560,7 @@ bool meshOctree::findNearestVertexToPatches
}
newP /= patches.size();
if( Foam::magSqr(newP - mapPointApprox</