BUG: autoLayerDriver: update local data

This commit is contained in:
mattijs
2013-12-02 11:08:08 +00:00
parent 1f35db6234
commit a4d50f98ec
10 changed files with 388 additions and 437 deletions

View File

@ -55,6 +55,10 @@ Description
#include "fixedValueFvPatchFields.H"
#include "localPointRegion.H"
#include "externalDisplacementMeshMover.H"
#include "medialAxisMeshMover.H"
#include "scalarIOField.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
@ -1378,8 +1382,8 @@ void Foam::autoLayerDriver::syncPatchDisplacement
mesh,
meshPoints,
patchDisp,
minEqOp<vector>(),
point::max // null value
minMagSqrEqOp<vector>(),
point::rootMax // null value
);
// Unmark if displacement too small
@ -1487,7 +1491,7 @@ void Foam::autoLayerDriver::syncPatchDisplacement
// patch point.
void Foam::autoLayerDriver::getPatchDisplacement
(
const motionSmoother& meshMover,
const indirectPrimitivePatch& pp,
const scalarField& thickness,
const scalarField& minThickness,
pointField& patchDisp,
@ -1499,7 +1503,6 @@ void Foam::autoLayerDriver::getPatchDisplacement
<< " according to pointNormal ..." << endl;
const fvMesh& mesh = meshRefiner_.mesh();
const indirectPrimitivePatch& pp = meshMover.patch();
const vectorField& faceNormals = pp.faceNormals();
const labelListList& pointFaces = pp.pointFaces();
const pointField& localPoints = pp.localPoints();
@ -1594,6 +1597,11 @@ void Foam::autoLayerDriver::getPatchDisplacement
nExtrudeRemove++;
}
else
{
// All surrounding points are not extruded. Leave patchDisp
// intact.
}
}
}
@ -1720,7 +1728,7 @@ Foam::label Foam::autoLayerDriver::truncateDisplacement
(
const globalIndex& globalFaces,
const labelListList& edgeGlobalFaces,
const motionSmoother& meshMover,
const indirectPrimitivePatch& pp,
const scalarField& minThickness,
const faceSet& illegalPatchFaces,
pointField& patchDisp,
@ -1728,8 +1736,7 @@ Foam::label Foam::autoLayerDriver::truncateDisplacement
List<extrudeMode>& extrudeStatus
) const
{
const polyMesh& mesh = meshMover.mesh();
const indirectPrimitivePatch& pp = meshMover.patch();
const fvMesh& mesh = meshRefiner_.mesh();
label nChanged = 0;
@ -2034,7 +2041,7 @@ Foam::label Foam::autoLayerDriver::truncateDisplacement
// regions where layer mesh terminates.
void Foam::autoLayerDriver::setupLayerInfoTruncation
(
const motionSmoother& meshMover,
const indirectPrimitivePatch& pp,
const labelList& patchNLayers,
const List<extrudeMode>& extrudeStatus,
const label nBufferCellsNoExtrude,
@ -2044,8 +2051,7 @@ void Foam::autoLayerDriver::setupLayerInfoTruncation
{
Info<< nl << "Setting up information for layer truncation ..." << endl;
const indirectPrimitivePatch& pp = meshMover.patch();
const polyMesh& mesh = meshMover.mesh();
const fvMesh& mesh = meshRefiner_.mesh();
if (nBufferCellsNoExtrude < 0)
{
@ -2917,26 +2923,6 @@ void Foam::autoLayerDriver::addLayers
);
// Construct iterative mesh mover.
Info<< "Constructing mesh displacer ..." << endl;
autoPtr<motionSmoother> meshMover
(
new motionSmoother
(
mesh,
pp(),
patchIDs,
makeLayerDisplacementField
(
pointMesh::New(mesh),
layerParams.numLayers()
),
motionDict
)
);
// Point-wise extrusion data
// ~~~~~~~~~~~~~~~~~~~~~~~~~
@ -2961,7 +2947,7 @@ void Foam::autoLayerDriver::addLayers
setNumLayers
(
layerParams.numLayers(), // per patch the num layers
meshMover().adaptPatchIDs(),// patches that are being moved
patchIDs, // patches that are being moved
pp, // indirectpatch for all faces moving
patchDisp,
@ -3059,12 +3045,22 @@ void Foam::autoLayerDriver::addLayers
// Determine (wanted) point-wise overall layer thickness and expansion
// ratio
scalarField thickness(pp().nPoints());
scalarField minThickness(pp().nPoints());
scalarIOField minThickness
(
IOobject
(
"minThickness",
meshRefiner_.timeName(),
mesh,
IOobject::NO_READ
),
pp().nPoints()
);
scalarField expansionRatio(pp().nPoints());
calculateLayerThickness
(
pp,
meshMover().adaptPatchIDs(),
patchIDs,
layerParams,
cellLevel,
patchNLayers,
@ -3077,89 +3073,36 @@ void Foam::autoLayerDriver::addLayers
// Calculate wall to medial axis distance for smoothing displacement
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pointScalarField pointMedialDist
// Overall displacement field
pointVectorField displacement
(
IOobject
makeLayerDisplacementField
(
"pointMedialDist",
meshRefiner_.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
meshMover().pMesh(),
dimensionedScalar("pointMedialDist", dimLength, 0.0)
pointMesh::New(mesh),
layerParams.numLayers()
)
);
pointVectorField dispVec
(
IOobject
// Allocate run-time selectable mesh mover
autoPtr<externalDisplacementMeshMover> medialAxisMoverPtr;
{
// Set up controls for meshMover
dictionary combinedDict(layerParams.dict());
// Add mesh quality constraints
combinedDict.merge(motionDict);
// Where to get minThickness from
combinedDict.add("minThicknessName", minThickness.name());
// Take over patchDisp as boundary conditions on displacement
// pointVectorField
medialAxisMoverPtr = externalDisplacementMeshMover::New
(
"dispVec",
meshRefiner_.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
meshMover().pMesh(),
dimensionedVector("dispVec", dimLength, vector::zero)
);
pointScalarField medialRatio
(
IOobject
(
"medialRatio",
meshRefiner_.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
meshMover().pMesh(),
dimensionedScalar("medialRatio", dimless, 0.0)
);
pointVectorField medialVec
(
IOobject
(
"medialVec",
meshRefiner_.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
meshMover().pMesh(),
dimensionedVector("medialVec", dimLength, vector::zero)
);
// Setup information for medial axis smoothing. Calculates medial axis
// and a smoothed displacement direction.
// - pointMedialDist : distance to medial axis
// - dispVec : normalised direction of nearest displacement
// - medialRatio : ratio of medial distance to wall distance.
// (1 at wall, 0 at medial axis)
medialAxisSmoothingInfo
(
meshMover,
layerParams.nSmoothNormals(),
layerParams.nSmoothSurfaceNormals(),
layerParams.minMedianAxisAngleCos(),
layerParams.slipFeatureAngle(),
dispVec,
medialRatio,
pointMedialDist,
medialVec
);
layerParams.meshShrinker(),
combinedDict,
baffles,
displacement
);
}
// Saved old points
@ -3215,7 +3158,7 @@ void Foam::autoLayerDriver::addLayers
// Displacement acc. to pointnormals
getPatchDisplacement
(
meshMover,
pp,
thickness,
minThickness,
patchDisp,
@ -3229,43 +3172,39 @@ void Foam::autoLayerDriver::addLayers
{
pointField oldPatchPos(pp().localPoints());
//// Laplacian displacement shrinking.
//shrinkMeshDistance
//(
// debug,
// meshMover,
// -patchDisp, // Shrink in opposite direction of addedPoints
// layerParams.nSmoothDisp(),
// layerParams.nSnap()
//);
// Medial axis based shrinking
shrinkMeshMedialDistance
// Take over patchDisp into pointDisplacement field and
// adjust both for multi-patch constraints
motionSmootherAlgo::setDisplacement
(
meshMover(),
meshQualityDict,
baffles,
layerParams.nSmoothThickness(),
layerParams.nSmoothDisplacement(),
layerParams.maxThicknessToMedialRatio(),
nAllowableErrors,
layerParams.nSnap(),
layerParams.layerTerminationCos(),
thickness,
minThickness,
dispVec,
medialRatio,
pointMedialDist,
medialVec,
extrudeStatus,
patchIDs,
pp,
patchDisp,
patchNLayers
displacement
);
// Move mesh
// ~~~~~~~~~
// Set up controls for meshMover
dictionary combinedDict(layerParams.dict());
// Add standard quality constraints
combinedDict.merge(motionDict);
// Add relaxed constraints (overrides standard ones)
combinedDict.merge(meshQualityDict);
// Where to get minThickness from
combinedDict.add("minThicknessName", minThickness.name());
labelList checkFaces(identity(mesh.nFaces()));
medialAxisMoverPtr().move
(
combinedDict,
nAllowableErrors,
checkFaces
);
pp().movePoints(mesh.points());
// Update patchDisp (since not all might have been honoured)
patchDisp = oldPatchPos - pp().localPoints();
}
@ -3278,7 +3217,7 @@ void Foam::autoLayerDriver::addLayers
(
globalFaces,
edgeGlobalFaces,
meshMover(),
pp,
minThickness,
dummySet,
patchDisp,
@ -3331,7 +3270,7 @@ void Foam::autoLayerDriver::addLayers
labelList nPatchFaceLayers(pp().size(), -1);
setupLayerInfoTruncation
(
meshMover(),
pp,
patchNLayers,
extrudeStatus,
layerParams.nBufferCellsNoExtrude(),
@ -3456,7 +3395,7 @@ void Foam::autoLayerDriver::addLayers
<< endl;
newMesh.write();
cellSet addedCellSet(newMesh," addedCells", nAddedCells);
cellSet addedCellSet(newMesh, "addedCells", nAddedCells);
forAll(cellNLayers, cellI)
{
if (cellNLayers[cellI] > 0)
@ -3521,10 +3460,7 @@ void Foam::autoLayerDriver::addLayers
// Reset mesh points and start again
mesh.movePoints(oldPoints);
// Update meshmover for change of mesh geometry
meshMover().movePoints();
meshMover().correct();
pp().movePoints(mesh.points());
// Grow out region of non-extrusion
for (label i = 0; i < layerParams.nGrow(); i++)

View File

@ -277,7 +277,7 @@ private:
//- Get nearest point on surface to snap to
void getPatchDisplacement
(
const motionSmoother& meshMover,
const indirectPrimitivePatch& pp,
const scalarField& thickness,
const scalarField& minThickness,
pointField& patchDisp,
@ -315,7 +315,7 @@ private:
(
const globalIndex& globalFaces,
const labelListList& edgeGlobalFaces,
const motionSmoother& meshMover,
const indirectPrimitivePatch& pp,
const scalarField& minThickness,
const faceSet& illegalPatchFaces,
pointField& patchDisp,
@ -331,7 +331,7 @@ private:
// to go into the actual layer addition engine.
void setupLayerInfoTruncation
(
const motionSmoother& meshMover,
const indirectPrimitivePatch& pp,
const labelList& patchNLayers,
const List<extrudeMode>& extrudeStatus,
const label nBufferCellsNoExtrude,

View File

@ -752,15 +752,15 @@ void Foam::autoLayerDriver::findIsolatedRegions
nPointCounter++;
nChanged++;
}
}
}
}
}
if (returnReduce(nChanged, sumOp<label>()) == 0)
{
break;
}
}
if (returnReduce(nChanged, sumOp<label>()) == 0)
{
break;
}
}
const edgeList& edges = pp.edges();

View File

@ -28,6 +28,7 @@ License
#include "unitConversion.H"
#include "refinementSurfaces.H"
#include "searchableSurfaces.H"
#include "medialAxisMeshMover.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -109,6 +110,7 @@ Foam::layerParameters::layerParameters
const polyBoundaryMesh& boundaryMesh
)
:
dict_(dict),
numLayers_(boundaryMesh.size(), -1),
relativeSizes_(dict.lookup("relativeSizes")),
layerSpec_(ILLEGAL),
@ -163,7 +165,15 @@ Foam::layerParameters::layerParameters
nSnap_(readLabel(dict.lookup("nRelaxIter"))),
nLayerIter_(readLabel(dict.lookup("nLayerIter"))),
nRelaxedIter_(labelMax),
additionalReporting_(dict.lookupOrDefault("additionalReporting", false))
additionalReporting_(dict.lookupOrDefault("additionalReporting", false)),
meshShrinker_
(
dict.lookupOrDefault
(
"meshShrinker",
medialAxisMeshMover::typeName
)
)
{
// Detect layer specification mode

View File

@ -86,6 +86,9 @@ private:
// Private data
const dictionary dict_;
// Per patch (not region!) information
//- How many layers to add.
@ -143,6 +146,8 @@ private:
Switch additionalReporting_;
word meshShrinker_;
// Private Member Functions
//- Calculate expansion ratio from overall size v.s. thickness of
@ -170,6 +175,12 @@ public:
// Member Functions
const dictionary& dict() const
{
return dict_;
}
// Per patch information
//- How many layers to add.
@ -230,98 +241,7 @@ public:
}
scalar featureAngle() const
{
return featureAngle_;
}
//- At non-patched sides allow mesh to slip if extrusion
// direction makes angle larger than slipFeatureAngle.
scalar slipFeatureAngle() const
{
return slipFeatureAngle_;
}
scalar concaveAngle() const
{
return concaveAngle_;
}
//- If points get not extruded do nGrow layers of connected faces
// that are not grown. Is used to not do layers at all close to
// features.
label nGrow() const
{
return nGrow_;
}
//- Number of smoothing iterations of surface normals
label nSmoothSurfaceNormals() const
{
return nSmoothSurfaceNormals_;
}
//- Number of smoothing iterations of interior mesh movement
// direction
label nSmoothNormals() const
{
return nSmoothNormals_;
}
//- Stop layer growth on highly warped cells
scalar maxFaceThicknessRatio() const
{
return maxFaceThicknessRatio_;
}
scalar layerTerminationCos() const
{
return layerTerminationCos_;
}
//- Smooth internal displacement
label nSmoothDisplacement() const
{
return nSmoothDisplacement_;
}
//- Smooth layer thickness over surface patches
label nSmoothThickness() const
{
return nSmoothThickness_;
}
//- Reduce layer growth where ratio thickness to medial
// distance is large
scalar maxThicknessToMedialRatio() const
{
return maxThicknessToMedialRatio_;
}
//- Angle used to pick up medial axis points
scalar minMedianAxisAngleCos() const
{
return minMedianAxisAngleCos_;
}
//- Create buffer region for new layer terminations
label nBufferCellsNoExtrude() const
{
return nBufferCellsNoExtrude_;
}
label nSnap() const
{
return nSnap_;
}
const Switch& additionalReporting() const
{
return additionalReporting_;
}
// Overall
// Control
//- Number of overall layer addition iterations
label nLayerIter() const
@ -337,6 +257,109 @@ public:
}
// Control
scalar featureAngle() const
{
return featureAngle_;
}
scalar concaveAngle() const
{
return concaveAngle_;
}
//- If points get not extruded do nGrow layers of connected faces
// that are not grown. Is used to not do layers at all close to
// features.
label nGrow() const
{
return nGrow_;
}
//- Stop layer growth on highly warped cells
scalar maxFaceThicknessRatio() const
{
return maxFaceThicknessRatio_;
}
//- Create buffer region for new layer terminations
label nBufferCellsNoExtrude() const
{
return nBufferCellsNoExtrude_;
}
const Switch& additionalReporting() const
{
return additionalReporting_;
}
//- Type of mesh shrinker
const word& meshShrinker() const
{
return meshShrinker_;
}
// Specific to medial axis mesh shrinking
//- At non-patched sides allow mesh to slip if extrusion
// direction makes angle larger than slipFeatureAngle.
scalar slipFeatureAngle() const
{
return slipFeatureAngle_;
}
//- Number of smoothing iterations of surface normals
label nSmoothSurfaceNormals() const
{
return nSmoothSurfaceNormals_;
}
//- Number of smoothing iterations of interior mesh movement
// direction
label nSmoothNormals() const
{
return nSmoothNormals_;
}
scalar layerTerminationCos() const
{
return layerTerminationCos_;
}
//- Smooth internal displacement
label nSmoothDisplacement() const
{
return nSmoothDisplacement_;
}
//- Smooth layer thickness over surface patches
label nSmoothThickness() const
{
return nSmoothThickness_;
}
//- Reduce layer growth where ratio thickness to medial
// distance is large
scalar maxThicknessToMedialRatio() const
{
return maxThicknessToMedialRatio_;
}
//- Angle used to pick up medial axis points
scalar minMedianAxisAngleCos() const
{
return minMedianAxisAngleCos_;
}
label nSnap() const
{
return nSnap_;
}
// Helper
//- Determine overall thickness. Uses two of the four parameters

View File

@ -105,7 +105,8 @@ void Foam::displacementMeshMoverMotionSolver::solve()
pointDisplacement().boundaryField().updateCoeffs();
label nAllowableErrors = 0;
meshMover().move(nAllowableErrors);
labelList checkFaces(identity(mesh().nFaces()));
meshMover().move(coeffDict(), nAllowableErrors, checkFaces);
}

View File

@ -44,7 +44,6 @@ Foam::externalDisplacementMeshMover::externalDisplacementMeshMover
pointVectorField& pointDisplacement
)
:
dict_(dict),
baffles_(baffles),
pointDisplacement_(pointDisplacement)
{}

View File

@ -28,7 +28,10 @@ Description
Virtual base class for mesh movers with externally provided displacement
field giving the boundary conditions. Move the mesh from the current
location to a new location (so modify the mesh; v.s. motionSolver that
only returns the new location)
only returns the new location).
All mesh movers are expected to read the dictionary settings at invocation
of move(), i.e. not cache any settings.
SourceFiles
externalDisplacementMeshMover.C
@ -57,9 +60,6 @@ protected:
// Protected data
//- Settings
dictionary dict_;
//- Baffles in the mesh
List<labelPair> baffles_;
@ -104,7 +104,8 @@ public:
// Constructors
//- Construct from dictionary and displacement field
//- Construct from dictionary and displacement field. Dictionary is
// allowed to go out of scope!
externalDisplacementMeshMover
(
const dictionary& dict,
@ -158,8 +159,16 @@ public:
// Mesh mover
//- Move mesh. Return true if succesful
virtual bool move(const label nAllowableErrors) = 0;
//- Move mesh using current pointDisplacement boundary values
// and current dictionary settings. Return true if succesful
// (errors on checkFaces less than allowable). Updates
// pointDisplacement.
virtual bool move
(
const dictionary&,
const label nAllowableErrors,
labelList& checkFaces
) = 0;
//- Update local data for geometry changes
virtual void movePoints(const pointField&);

View File

@ -52,51 +52,6 @@ namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
const Foam::dictionary& Foam::medialAxisMeshMover::coeffDict() const
{
return dict_;
}
const Foam::dictionary& Foam::medialAxisMeshMover::meshQualityDict() const
{
return dict_;
}
void Foam::medialAxisMeshMover::read()
{
nSmoothPatchThickness_ = readLabel(coeffDict().lookup("nSmoothThickness"));
nSmoothDisplacement_ = coeffDict().lookupOrDefault
(
"nSmoothDisplacement",
0
);
maxThicknessToMedialRatio_ = readScalar
(
coeffDict().lookup("maxThicknessToMedialRatio")
);
featureAngle_ = readScalar(coeffDict().lookup("featureAngle"));
minCosLayerTermination_ = Foam::cos(degToRad(0.5*featureAngle_));
nSmoothNormals_ = readLabel(coeffDict().lookup("nSmoothNormals"));
nSmoothSurfaceNormals_ = readLabel
(
coeffDict().lookup("nSmoothSurfaceNormals")
);
minMedianAxisAngleCos_ = Foam::cos
(
degToRad(readScalar(coeffDict().lookup("minMedianAxisAngle")))
);
slipFeatureAngle_ =
(
coeffDict().found("slipFeatureAngle")
? readScalar(coeffDict().lookup("slipFeatureAngle"))
: 0.5*featureAngle_
);
nSnap_ = readLabel(coeffDict().lookup("nRelaxIter"));
}
Foam::labelList Foam::medialAxisMeshMover::getFixedValueBCs
(
const pointVectorField& fld
@ -444,7 +399,7 @@ bool Foam::medialAxisMeshMover::isMaxEdge
}
void Foam::medialAxisMeshMover::update()
void Foam::medialAxisMeshMover::update(const dictionary& coeffDict)
{
Info<< typeName
<< " : Calculate distance to Medial Axis ..." << endl;
@ -455,29 +410,37 @@ void Foam::medialAxisMeshMover::update()
const labelList& meshPoints = pp.meshPoints();
// Look up a few controls
// ~~~~~~~~~~~~~~~~~~~~~~
// const label nSmoothNormals
// (
// readLabel(coeffDict().lookup("nSmoothNormals"))
// );
// const label nSmoothSurfaceNormals
// (
// readLabel(coeffDict().lookup("nSmoothSurfaceNormals"))
// );
// const scalar minMedianAxisAngleCos
// (
// Foam::cos
// (
// degToRad(readScalar(coeffDict().lookup("minMedianAxisAngle")))
// )
// );
// const scalar slipFeatureAngle
// (
// coeffDict().found("slipFeatureAngle")
// ? readScalar(coeffDict().lookup("slipFeatureAngle"))
// : 0.5*readScalar(coeffDict().lookup("featureAngle"))
// );
// Read a few parameters
// ~~~~~~~~~~~~~~~~~~~~~
//- Smooth surface normals
const label nSmoothSurfaceNormals = readLabel
(
coeffDict.lookup("nSmoothSurfaceNormals")
);
//- When is medial axis
const scalar minMedianAxisAngleCos = Foam::cos
(
degToRad(readScalar(coeffDict.lookup("minMedianAxisAngle")))
);
//- Feature angle when to stop adding layers
const scalar featureAngle = readScalar(coeffDict.lookup("featureAngle"));
//- When to slip along wall
const scalar slipFeatureAngle =
(
coeffDict.found("slipFeatureAngle")
? readScalar(coeffDict.lookup("slipFeatureAngle"))
: 0.5*featureAngle
);
//- Smooth internal normals
const label nSmoothNormals = readLabel
(
coeffDict.lookup("nSmoothNormals")
);
// Predetermine mesh edges
@ -505,7 +468,7 @@ void Foam::medialAxisMeshMover::update()
// Smooth patch normal vectors
smoothPatchNormals
(
nSmoothSurfaceNormals_,
nSmoothSurfaceNormals,
isMasterPoint,
isMasterEdge,
meshEdges,
@ -602,7 +565,7 @@ void Foam::medialAxisMeshMover::update()
{
// Unvisited point. See above about nUnvisit warning
}
else if (isMaxEdge(pointWallDist, edgeI, minMedianAxisAngleCos_))
else if (isMaxEdge(pointWallDist, edgeI, minMedianAxisAngleCos))
{
// Both end points of edge have very different nearest wall
// point. Mark both points as medial axis points.
@ -722,11 +685,11 @@ void Foam::medialAxisMeshMover::update()
// on this patch.
Info<< "Inserting points on patch " << pp.name()
<< " if angle to nearest layer patch > "
<< slipFeatureAngle_ << " degrees." << endl;
<< slipFeatureAngle << " degrees." << endl;
scalar slipFeatureAngleCos = Foam::cos
(
degToRad(slipFeatureAngle_)
degToRad(slipFeatureAngle)
);
pointField pointNormals
(
@ -818,7 +781,7 @@ void Foam::medialAxisMeshMover::update()
// Smooth normal vectors. Do not change normals on pp.meshPoints
smoothNormals
(
nSmoothNormals_,
nSmoothNormals,
isMasterPoint,
isMasterEdge,
meshPoints,
@ -854,7 +817,7 @@ void Foam::medialAxisMeshMover::update()
}
//if (debug)
if (debug)
{
Info<< typeName
<< " : Writing medial axis fields:" << nl
@ -926,8 +889,8 @@ void Foam::medialAxisMeshMover::syncPatchDisplacement
mesh(),
meshPoints,
patchDisp,
minEqOp<vector>(),
point::max // null value
minMagSqrEqOp<vector>(),
point::rootMax // null value
);
// Unmark if displacement too small
@ -1323,15 +1286,14 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
nPointCounter++;
nChanged++;
}
}
}
}
}
if (returnReduce(nChanged, sumOp<label>()) == 0)
{
break;
}
}
if (returnReduce(nChanged, sumOp<label>()) == 0)
{
break;
}
}
const edgeList& edges = pp.edges();
@ -1554,7 +1516,7 @@ Foam::medialAxisMeshMover::medialAxisMeshMover
scale_,
oldPoints_,
adaptPatchIDs_,
coeffDict()
dict
),
dispVec_
(
@ -1613,8 +1575,7 @@ Foam::medialAxisMeshMover::medialAxisMeshMover
dimensionedVector("medialVec", dimLength, vector::zero)
)
{
read();
update();
update(dict);
}
@ -1628,6 +1589,7 @@ Foam::medialAxisMeshMover::~medialAxisMeshMover()
void Foam::medialAxisMeshMover::calculateDisplacement
(
const dictionary& coeffDict,
const scalarField& minThickness,
List<autoLayerDriver::extrudeMode>& extrudeStatus,
pointField& patchDisp
@ -1639,29 +1601,36 @@ void Foam::medialAxisMeshMover::calculateDisplacement
const labelList& meshPoints = pp.meshPoints();
// Look up a few controls
// ~~~~~~~~~~~~~~~~~~~~~~
// Read settings
// ~~~~~~~~~~~~~
// const label nSmoothPatchThickness
// (
// readLabel(coeffDict().lookup("nSmoothThickness"))
// );
// const label nSmoothDisplacement
// (
// coeffDict().lookupOrDefault("nSmoothDisplacement", 0)
// );
// const scalar maxThicknessToMedialRatio
// (
// readScalar(coeffDict().lookup("maxThicknessToMedialRatio"))
// );
// const scalar featureAngle
// (
// readScalar(coeffDict().lookup("featureAngle"))
// );
// const scalar minCosLayerTermination
// (
// Foam::cos(degToRad(0.5*featureAngle))
// );
//- (lambda-mu) smoothing of internal displacement
const label nSmoothDisplacement = coeffDict.lookupOrDefault
(
"nSmoothDisplacement",
0
);
//- Layer thickness too big
const scalar maxThicknessToMedialRatio = readScalar
(
coeffDict.lookup("maxThicknessToMedialRatio")
);
//- Feature angle when to stop adding layers
const scalar featureAngle = readScalar(coeffDict.lookup("featureAngle"));
//- Stop layer growth where mesh wraps around sharp edge
const scalar minCosLayerTermination = Foam::cos
(
degToRad(0.5*featureAngle)
);
//- Smoothing wanted patch thickness
const label nSmoothPatchThickness = readLabel
(
coeffDict.lookup("nSmoothThickness")
);
// Precalulate master points/edge (only relevant for shared points/edges)
@ -1749,7 +1718,7 @@ void Foam::medialAxisMeshMover::calculateDisplacement
mVec /= mag(mVec)+VSMALL;
thicknessRatio *= (n&mVec);
if (thicknessRatio > maxThicknessToMedialRatio_)
if (thicknessRatio > maxThicknessToMedialRatio)
{
// Truncate thickness.
if (debug)
@ -1810,7 +1779,7 @@ void Foam::medialAxisMeshMover::calculateDisplacement
findIsolatedRegions
(
minCosLayerTermination_,
minCosLayerTermination,
isMasterPoint,
isMasterEdge,
meshEdges,
@ -1833,7 +1802,7 @@ void Foam::medialAxisMeshMover::calculateDisplacement
// smooth layer thickness on moving patch
minSmoothField
(
nSmoothPatchThickness_,
nSmoothPatchThickness,
isMasterPoint,
isMasterEdge,
meshEdges,
@ -1911,11 +1880,11 @@ void Foam::medialAxisMeshMover::calculateDisplacement
// Smear displacement away from fixed values (medialRatio=0 or 1)
if (nSmoothDisplacement_ > 0)
if (nSmoothDisplacement > 0)
{
smoothLambdaMuDisplacement
(
nSmoothDisplacement_,
nSmoothDisplacement,
isMasterPoint,
isMasterEdge,
displacement
@ -1927,25 +1896,29 @@ void Foam::medialAxisMeshMover::calculateDisplacement
bool Foam::medialAxisMeshMover::shrinkMesh
(
const dictionary& meshQualityDict,
const label nAllowableErrors
const label nAllowableErrors,
labelList& checkFaces
)
{
//- Number of attempts shrinking the mesh
const label nSnap = readLabel(meshQualityDict.lookup("nRelaxIter"));
// Make sure displacement boundary conditions is uptodate with
// internal field
meshMover_.setDisplacementPatchFields();
// Current faces to check. Gets modified in meshMover.scaleMesh
labelList checkFaces(identity(mesh().nFaces()));
Info<< typeName << " : Moving mesh ..." << endl;
scalar oldErrorReduction = -1;
bool meshOk = false;
for (label iter = 0; iter < 2*nSnap_ ; iter++)
for (label iter = 0; iter < 2*nSnap ; iter++)
{
Info<< "Iteration " << iter << endl;
if (iter == nSnap_)
if (iter == nSnap)
{
Info<< "Displacement scaling for error reduction set to 0." << endl;
oldErrorReduction = meshMover_.setErrorReduction(0.0);
@ -1981,8 +1954,20 @@ bool Foam::medialAxisMeshMover::shrinkMesh
}
bool Foam::medialAxisMeshMover::move(const label nAllowableErrors)
bool Foam::medialAxisMeshMover::move
(
const dictionary& moveDict,
const label nAllowableErrors,
labelList& checkFaces
)
{
// Read a few settings
// ~~~~~~~~~~~~~~~~~~~
//- Name of field specifying min thickness
const word minThicknessName = word(moveDict.lookup("minThicknessName"));
// The points have moved so before calculation update
// the mesh and motionSolver accordingly
movePoints(mesh().points());
@ -1994,6 +1979,19 @@ bool Foam::medialAxisMeshMover::move(const label nAllowableErrors)
// Extract out patch-wise displacement
const indirectPrimitivePatch& pp = adaptPatchPtr_();
scalarField zeroMinThickness;
if (minThicknessName == "none")
{
zeroMinThickness = scalarField(pp.nPoints(), 0.0);
}
const scalarField& minThickness =
(
(minThicknessName == "none")
? zeroMinThickness
: mesh().lookupObject<scalarField>(minThicknessName)
);
pointField patchDisp
(
pointDisplacement_.internalField(),
@ -2005,18 +2003,24 @@ bool Foam::medialAxisMeshMover::move(const label nAllowableErrors)
pp.nPoints(),
autoLayerDriver::EXTRUDE
);
forAll(extrudeStatus, pointI)
{
if (mag(patchDisp[pointI]) <= minThickness[pointI]+SMALL)
{
extrudeStatus[pointI] = autoLayerDriver::NOEXTRUDE;
}
}
const scalarField minThickness(patchDisp.size(), 0.0);
// Solve displacement
calculateDisplacement(minThickness, extrudeStatus, patchDisp);
calculateDisplacement(moveDict, minThickness, extrudeStatus, patchDisp);
//- Move mesh according to calculated displacement
return shrinkMesh
(
meshQualityDict(), // meshQualityDict,
nAllowableErrors // nAllowableErrors
moveDict, // meshQualityDict,
nAllowableErrors, // nAllowableErrors
checkFaces
);
}

View File

@ -73,39 +73,6 @@ class medialAxisMeshMover
motionSmootherAlgo meshMover_;
// Settings
//- Smoothing wanted patch thickness
label nSmoothPatchThickness_;
//- (lambda-mu) smoothing of internal displacement
label nSmoothDisplacement_;
//- Layer thickness too big
scalar maxThicknessToMedialRatio_;
//- Feature angle when to stop adding layers
scalar featureAngle_;
//- Stop layer growth where mesh wraps around sharp edge
scalar minCosLayerTermination_;
//- Smooth internal normals
label nSmoothNormals_;
//- Smooth surface normals
label nSmoothSurfaceNormals_;
//- When is medial axis
scalar minMedianAxisAngleCos_;
//- When to slip along wall
scalar slipFeatureAngle_;
//- Number of attempts shrinking the mesh
label nSnap_;
// Pre-calculated medial axis information
//- normal of nearest wall. Where this normal changes direction
@ -125,13 +92,6 @@ class medialAxisMeshMover
// Private Member Functions
const dictionary& coeffDict() const;
const dictionary& meshQualityDict() const;
//- Read model coefficients
void read();
//- Extract fixed-value patchfields
static labelList getFixedValueBCs(const pointVectorField&);
@ -201,8 +161,9 @@ class medialAxisMeshMover
const scalar minCos
) const;
//- Initialise medial axis
void update();
//- Initialise medial axis. Uses pointDisplacement field only
// for boundary types, not values.
void update(const dictionary&);
// Calculation of mesh movement
@ -272,6 +233,7 @@ class medialAxisMeshMover
// (in pointDisplacement)
void calculateDisplacement
(
const dictionary&,
const scalarField& minThickness,
List<autoLayerDriver::extrudeMode>& extrudeStatus,
pointField& patchDisp
@ -281,10 +243,10 @@ class medialAxisMeshMover
bool shrinkMesh
(
const dictionary& meshQualityDict,
const label nAllowableErrors
const label nAllowableErrors,
labelList& checkFaces
);
//- Disallow default bitwise copy construct
medialAxisMeshMover
(
@ -319,8 +281,15 @@ public:
// Member Functions
//- Move mesh. Return true if succesful
virtual bool move(const label nAllowableErrors);
//- Move mesh using current pointDisplacement boundary values.
// Return true if succesful (errors on checkFaces less than
// allowable). Updates pointDisplacement.
virtual bool move
(
const dictionary&,
const label nAllowableErrors,
labelList& checkFaces
);
//- Update local data for geometry changes
virtual void movePoints(const pointField&);