Skip to content
Snippets Groups Projects
Commit 6372b7bb authored by mattijs's avatar mattijs
Browse files

ENH: autoLayerShrink: mark medial axis points based extrusion direction instead of nearest point

parent 90d5787d
No related merge requests found
...@@ -33,6 +33,9 @@ Description ...@@ -33,6 +33,9 @@ Description
#include "motionSmoother.H" #include "motionSmoother.H"
#include "pointData.H" #include "pointData.H"
#include "PointEdgeWave.H" #include "PointEdgeWave.H"
#include "OFstream.H"
#include "meshTools.H"
#include "PatchTools.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
...@@ -334,11 +337,25 @@ bool Foam::autoLayerDriver::isMaxEdge ...@@ -334,11 +337,25 @@ bool Foam::autoLayerDriver::isMaxEdge
return false; return false;
} }
v0 /= magV0;
v1 /= magV1;
// Test angle. //- Detect based on vector to nearest point differing for both endpoints
if ((v0 & v1) < minCos) //v0 /= magV0;
//v1 /= magV1;
//
//// Test angle.
//if ((v0 & v1) < minCos)
//{
// return true;
//}
//else
//{
// return false;
//}
//- Detect based on extrusion vector differing for both endpoints
// the idea is that e.g. a sawtooth wall can still be extruded
// successfully as long as it is done all to the same direction.
if ((pointWallDist[e[0]].v() & pointWallDist[e[1]].v()) < minCos)
{ {
return true; return true;
} }
...@@ -670,7 +687,6 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo ...@@ -670,7 +687,6 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
const pointField& points = mesh.points(); const pointField& points = mesh.points();
const indirectPrimitivePatch& pp = meshMover.patch(); const indirectPrimitivePatch& pp = meshMover.patch();
const vectorField& faceNormals = pp.faceNormals();
const labelList& meshPoints = pp.meshPoints(); const labelList& meshPoints = pp.meshPoints();
// Predetermine mesh edges // Predetermine mesh edges
...@@ -700,44 +716,15 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo ...@@ -700,44 +716,15 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
// Determine pointNormal // Determine pointNormal
// ~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~
pointField pointNormals(pp.nPoints(), vector::zero); pointField pointNormals
{ (
labelList nPointFaces(pp.nPoints(), 0); PatchTools::pointNormals
forAll(faceNormals, faceI)
{
const face& f = pp.localFaces()[faceI];
forAll(f, fp)
{
pointNormals[f[fp]] += faceNormals[faceI];
nPointFaces[f[fp]] ++;
}
}
syncTools::syncPointList
(
mesh,
meshPoints,
pointNormals,
plusEqOp<vector>(),
vector::zero // null value
);
syncTools::syncPointList
( (
mesh, mesh,
meshPoints, pp,
nPointFaces, pp.addressing()
plusEqOp<label>(), )
label(0) // null value );
);
forAll(pointNormals, i)
{
pointNormals[i] /= nPointFaces[i];
}
}
// Smooth patch normal vectors // Smooth patch normal vectors
smoothPatchNormals smoothPatchNormals
...@@ -1012,6 +999,26 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance ...@@ -1012,6 +999,26 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
label numThicknessRatioExclude = 0; label numThicknessRatioExclude = 0;
// reduce thickness where thickness/medial axis distance large // reduce thickness where thickness/medial axis distance large
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
autoPtr<OFstream> str;
label vertI = 0;
if (debug)
{
str.reset
(
new OFstream
(
mesh.time().path()
/ "thicknessRatioExcludePoints_"
+ meshRefiner_.timeName()
+ ".obj"
)
);
Info<< "Writing points with too large a extrusion distance to "
<< str().name() << endl;
}
forAll(meshPoints, patchPointI) forAll(meshPoints, patchPointI)
{ {
if (extrudeStatus[patchPointI] != NOEXTRUDE) if (extrudeStatus[patchPointI] != NOEXTRUDE)
...@@ -1025,6 +1032,20 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance ...@@ -1025,6 +1032,20 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
if (thicknessRatio > maxThicknessToMedialRatio) if (thicknessRatio > maxThicknessToMedialRatio)
{ {
// Truncate thickness. // Truncate thickness.
if (debug)
{
Pout<< "truncating displacement at "
<< mesh.points()[pointI]
<< " from " << thickness[patchPointI]
<< " to "
<< 0.5
*(
minThickness[patchPointI]
+thickness[patchPointI]
)
<< endl;
}
thickness[patchPointI] = thickness[patchPointI] =
0.5*(minThickness[patchPointI]+thickness[patchPointI]); 0.5*(minThickness[patchPointI]+thickness[patchPointI]);
...@@ -1033,6 +1054,16 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance ...@@ -1033,6 +1054,16 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
* patchDisp[patchPointI] * patchDisp[patchPointI]
/ (mag(patchDisp[patchPointI]) + VSMALL); / (mag(patchDisp[patchPointI]) + VSMALL);
numThicknessRatioExclude++; numThicknessRatioExclude++;
if (str.valid())
{
const point& pt = mesh.points()[pointI];
meshTools::writeOBJ(str(), pt);
vertI++;
meshTools::writeOBJ(str(), pt+patchDisp[patchPointI]);
vertI++;
str()<< "l " << vertI-1 << ' ' << vertI << nl;
}
} }
} }
} }
...@@ -1121,6 +1152,31 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance ...@@ -1121,6 +1152,31 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
*dispVec[pointI]; *dispVec[pointI];
} }
if (debug)
{
const_cast<Time&>(mesh.time())++;
Info<< "Writing wanted-displacement mesh (possibly illegal) to "
<< meshRefiner_.timeName() << endl;
pointField oldPoints(mesh.points());
meshMover.movePoints
(
(
mesh.points()
+ (
meshMover.scale().internalField()
* displacement.internalField()
)
)()
);
meshRefiner_.write
(
debug,
mesh.time().path()/meshRefiner_.timeName()
);
meshMover.movePoints(oldPoints);
}
// Current faces to check. Gets modified in meshMover.scaleMesh // Current faces to check. Gets modified in meshMover.scaleMesh
labelList checkFaces(identity(mesh.nFaces())); labelList checkFaces(identity(mesh.nFaces()));
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment