mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: snappyHexMesh: allow layer thickness specification by total thickness
This commit is contained in:
@ -226,36 +226,36 @@ castellatedMeshControls
|
||||
// Settings for the snapping.
|
||||
snapControls
|
||||
{
|
||||
//- Number of patch smoothing iterations before finding correspondence
|
||||
// Number of patch smoothing iterations before finding correspondence
|
||||
// to surface
|
||||
nSmoothPatch 3;
|
||||
|
||||
//- Maximum relative distance for points to be attracted by surface.
|
||||
// Maximum relative distance for points to be attracted by surface.
|
||||
// True distance is this factor times local maximum edge length.
|
||||
// Note: changed(corrected) w.r.t 17x! (17x used 2* tolerance)
|
||||
tolerance 2.0;
|
||||
|
||||
//- Number of mesh displacement relaxation iterations.
|
||||
// Number of mesh displacement relaxation iterations.
|
||||
nSolveIter 30;
|
||||
|
||||
//- Maximum number of snapping relaxation iterations. Should stop
|
||||
// Maximum number of snapping relaxation iterations. Should stop
|
||||
// before upon reaching a correct mesh.
|
||||
nRelaxIter 5;
|
||||
|
||||
// Feature snapping
|
||||
|
||||
//- Number of feature edge snapping iterations.
|
||||
// Number of feature edge snapping iterations.
|
||||
// Leave out altogether to disable.
|
||||
nFeatureSnapIter 10;
|
||||
|
||||
//- Detect (geometric only) features by sampling the surface
|
||||
// Detect (geometric only) features by sampling the surface
|
||||
// (default=false).
|
||||
implicitFeatureSnap false;
|
||||
|
||||
//- Use castellatedMeshControls::features (default = true)
|
||||
// Use castellatedMeshControls::features (default = true)
|
||||
explicitFeatureSnap true;
|
||||
|
||||
//- Detect features between multiple surfaces
|
||||
// Detect features between multiple surfaces
|
||||
// (only for explicitFeatureSnap, default = false)
|
||||
multiRegionFeatureSnap false;
|
||||
}
|
||||
@ -267,9 +267,43 @@ addLayersControls
|
||||
// size of the refined cell outside layer (true) or absolute sizes (false).
|
||||
relativeSizes true;
|
||||
|
||||
// Layer thickness specification. This can be specified in one of four ways
|
||||
// - expansionRatio and finalLayerThickness (cell nearest internal mesh)
|
||||
// - expansionRatio and firstLayerThickness (cell on surface)
|
||||
// - overall thickness and firstLayerThickness
|
||||
// - overall thickness and finalLayerThickness
|
||||
|
||||
// Expansion factor for layer mesh
|
||||
expansionRatio 1.0;
|
||||
|
||||
// Wanted thickness of the layer furthest away from the wall.
|
||||
// If relativeSizes this is relative to undistorted size of cell
|
||||
// outside layer.
|
||||
finalLayerThickness 0.3;
|
||||
|
||||
// Wanted thickness of the layer next to the wall.
|
||||
// If relativeSizes this is relative to undistorted size of cell
|
||||
// outside layer.
|
||||
//firstLayerThickness 0.3;
|
||||
|
||||
// Wanted overall thickness of layers.
|
||||
// If relativeSizes this is relative to undistorted size of cell
|
||||
// outside layer.
|
||||
//thickness 0.5
|
||||
|
||||
|
||||
// Minimum overall thickness of total layers. If for any reason layer
|
||||
// cannot be above minThickness do not add layer.
|
||||
// If relativeSizes this is relative to undistorted size of cell
|
||||
// outside layer..
|
||||
minThickness 0.25;
|
||||
|
||||
|
||||
// Per final patch (so not geometry!) the layer information
|
||||
// Note: This behaviour changed after 21x. Any non-mentioned patches
|
||||
// now slide unless nSurfaceLayers is explicitly mentioned to be 0.
|
||||
// now slide unless:
|
||||
// - nSurfaceLayers is explicitly mentioned to be 0.
|
||||
// - angle to nearest surface < slipFeatureAngle (see below)
|
||||
layers
|
||||
{
|
||||
sphere.stl_firstSolid
|
||||
@ -294,24 +328,7 @@ addLayersControls
|
||||
}
|
||||
}
|
||||
|
||||
// Expansion factor for layer mesh
|
||||
expansionRatio 1.0;
|
||||
|
||||
//- Wanted thickness of final added cell layer. If multiple layers
|
||||
// is the
|
||||
// thickness of the layer furthest away from the wall.
|
||||
// Relative to undistorted size of cell outside layer.
|
||||
// is the thickness of the layer furthest away from the wall.
|
||||
// See relativeSizes parameter.
|
||||
finalLayerThickness 0.3;
|
||||
|
||||
//- Minimum thickness of cell layer. If for any reason layer
|
||||
// cannot be above minThickness do not add layer.
|
||||
// Relative to undistorted size of cell outside layer.
|
||||
// See relativeSizes parameter.
|
||||
minThickness 0.25;
|
||||
|
||||
//- If points get not extruded do nGrow layers of connected faces that are
|
||||
// If points get not extruded do nGrow layers of connected faces that are
|
||||
// also not grown. This helps convergence of the layer addition process
|
||||
// close to features.
|
||||
// Note: changed(corrected) w.r.t 17x! (didn't do anything in 17x)
|
||||
@ -319,15 +336,15 @@ addLayersControls
|
||||
|
||||
// Advanced settings
|
||||
|
||||
//- When not to extrude surface. 0 is flat surface, 90 is when two faces
|
||||
// When not to extrude surface. 0 is flat surface, 90 is when two faces
|
||||
// make straight angle.
|
||||
featureAngle 60;
|
||||
|
||||
//- At non-patched sides allow mesh to slip if extrusion direction makes
|
||||
// At non-patched sides allow mesh to slip if extrusion direction makes
|
||||
// angle larger than slipFeatureAngle.
|
||||
slipFeatureAngle 30;
|
||||
|
||||
//- Maximum number of snapping relaxation iterations. Should stop
|
||||
// Maximum number of snapping relaxation iterations. Should stop
|
||||
// before upon reaching a correct mesh.
|
||||
nRelaxIter 5;
|
||||
|
||||
@ -374,24 +391,24 @@ addLayersControls
|
||||
// where to undo.
|
||||
meshQualityControls
|
||||
{
|
||||
//- Maximum non-orthogonality allowed. Set to 180 to disable.
|
||||
// Maximum non-orthogonality allowed. Set to 180 to disable.
|
||||
maxNonOrtho 65;
|
||||
|
||||
//- Max skewness allowed. Set to <0 to disable.
|
||||
// Max skewness allowed. Set to <0 to disable.
|
||||
maxBoundarySkewness 20;
|
||||
maxInternalSkewness 4;
|
||||
|
||||
//- Max concaveness allowed. Is angle (in degrees) below which concavity
|
||||
// Max concaveness allowed. Is angle (in degrees) below which concavity
|
||||
// is allowed. 0 is straight face, <0 would be convex face.
|
||||
// Set to 180 to disable.
|
||||
maxConcave 80;
|
||||
|
||||
//- Minimum pyramid volume. Is absolute volume of cell pyramid.
|
||||
// Minimum pyramid volume. Is absolute volume of cell pyramid.
|
||||
// Set to a sensible fraction of the smallest cell volume expected.
|
||||
// Set to very negative number (e.g. -1E30) to disable.
|
||||
minVol 1e-13;
|
||||
|
||||
//- Minimum quality of the tet formed by the face-centre
|
||||
// Minimum quality of the tet formed by the face-centre
|
||||
// and variable base point minimum decomposition triangles and
|
||||
// the cell centre. This has to be a positive number for tracking
|
||||
// to work. Set to very negative number (e.g. -1E30) to
|
||||
@ -401,21 +418,21 @@ meshQualityControls
|
||||
// 1 = regular tet
|
||||
minTetQuality 1e-9;
|
||||
|
||||
//- Minimum face area. Set to <0 to disable.
|
||||
// Minimum face area. Set to <0 to disable.
|
||||
minArea -1;
|
||||
|
||||
//- Minimum face twist. Set to <-1 to disable. dot product of face normal
|
||||
//- and face centre triangles normal
|
||||
// Minimum face twist. Set to <-1 to disable. dot product of face normal
|
||||
// and face centre triangles normal
|
||||
minTwist 0.05;
|
||||
|
||||
//- minimum normalised cell determinant
|
||||
//- 1 = hex, <= 0 = folded or flattened illegal cell
|
||||
// minimum normalised cell determinant
|
||||
// 1 = hex, <= 0 = folded or flattened illegal cell
|
||||
minDeterminant 0.001;
|
||||
|
||||
//- minFaceWeight (0 -> 0.5)
|
||||
// minFaceWeight (0 -> 0.5)
|
||||
minFaceWeight 0.05;
|
||||
|
||||
//- minVolRatio (0 -> 1)
|
||||
// minVolRatio (0 -> 1)
|
||||
minVolRatio 0.01;
|
||||
|
||||
// must be >0 for Fluent compatibility
|
||||
@ -429,9 +446,9 @@ meshQualityControls
|
||||
|
||||
// Advanced
|
||||
|
||||
//- Number of error distribution iterations
|
||||
// Number of error distribution iterations
|
||||
nSmoothScale 4;
|
||||
//- amount to scale back displacement at error points
|
||||
// amount to scale back displacement at error points
|
||||
errorReduction 0.75;
|
||||
|
||||
// Optional : some meshing phases allow usage of relaxed rules.
|
||||
|
||||
@ -318,7 +318,6 @@ void Foam::autoLayerDriver::handleNonManifolds
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Info<< "Set displacement to zero for all " << nNonManif
|
||||
<< " non-manifold points" << endl;
|
||||
}
|
||||
@ -443,86 +442,6 @@ void Foam::autoLayerDriver::handleFeatureAngle
|
||||
}
|
||||
|
||||
|
||||
//Foam::tmp<Foam::scalarField> Foam::autoLayerDriver::undistortedEdgeLength
|
||||
//(
|
||||
// const indirectPrimitivePatch& pp,
|
||||
// const bool relativeSizes,
|
||||
// const bool faceSize
|
||||
//)
|
||||
//{
|
||||
// const fvMesh& mesh = meshRefiner_.mesh();
|
||||
//
|
||||
// tmp<scalarField> tfld(new scalarField());
|
||||
// scalarField& fld = tfld();
|
||||
//
|
||||
// if (faceSize)
|
||||
// {
|
||||
// fld.setSize(pp.size());
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// fld.setSize(pp.nPoints());
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if (relativeSizes)
|
||||
// {
|
||||
// const scalar edge0Len = meshRefiner_.meshCutter().level0EdgeLength();
|
||||
// const labelList& cellLevel = meshRefiner_.meshCutter().cellLevel();
|
||||
//
|
||||
// if (faceSize)
|
||||
// {
|
||||
// forAll(pp, i)
|
||||
// {
|
||||
// label faceI = pp.addressing()[i];
|
||||
// label ownLevel = cellLevel[mesh.faceOwner()[faceI]];
|
||||
// fld[i] = edge0Len/(1<<ownLevel);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // Determine per point the max cell level of connected cells
|
||||
// // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// labelList maxPointLevel(pp.nPoints(), labelMin);
|
||||
//
|
||||
// forAll(pp, i)
|
||||
// {
|
||||
// label faceI = pp.addressing()[i];
|
||||
// label ownLevel = cellLevel[mesh.faceOwner()[faceI]];
|
||||
//
|
||||
// const face& f = pp.localFaces()[i];
|
||||
// forAll(f, fp)
|
||||
// {
|
||||
// maxPointLevel[f[fp]] =
|
||||
// max(maxPointLevel[f[fp]], ownLevel);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// syncTools::syncPointList
|
||||
// (
|
||||
// mesh,
|
||||
// pp.meshPoints(),
|
||||
// maxPointLevel,
|
||||
// maxEqOp<label>(),
|
||||
// labelMin // null value
|
||||
// );
|
||||
//
|
||||
//
|
||||
// forAll(maxPointLevel, pointI)
|
||||
// {
|
||||
// // Find undistorted edge size for this level.
|
||||
// fld[i] = edge0Len/(1<<maxPointLevel[pointI]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // Use actual cell size
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
// No extrusion on cells with warped faces. Calculates the thickness of the
|
||||
// layer and compares it to the space the warped face takes up. Disables
|
||||
// extrusion if layer thickness is more than faceRatio of the thickness of
|
||||
@ -702,7 +621,6 @@ void Foam::autoLayerDriver::handleWarpedFaces
|
||||
//}
|
||||
|
||||
|
||||
// No extrusion on faces with differing number of layers for points
|
||||
void Foam::autoLayerDriver::setNumLayers
|
||||
(
|
||||
const labelList& patchToNLayers,
|
||||
@ -865,15 +783,6 @@ Foam::autoLayerDriver::makeLayerDisplacementField
|
||||
}
|
||||
|
||||
|
||||
//Pout<< "*** makeLayerDisplacementField : boundary conditions:" << endl;
|
||||
//forAll(patchFieldTypes, patchI)
|
||||
//{
|
||||
// Pout<< "\t" << patchI << " name:" << pointPatches[patchI].name()
|
||||
// << " type:" << patchFieldTypes[patchI]
|
||||
// << " nLayers:" << numLayers[patchI]
|
||||
// << endl;
|
||||
//}
|
||||
|
||||
const polyMesh& mesh = pMesh();
|
||||
|
||||
// Note: time().timeName() instead of meshRefinement::timeName() since
|
||||
@ -1053,11 +962,10 @@ void Foam::autoLayerDriver::determineSidePatches
|
||||
patchDict.add("nFaces", 0);
|
||||
patchDict.add("startFace", mesh.nFaces());
|
||||
|
||||
Pout<< "Adding patch " << patchI
|
||||
<< " name:" << name
|
||||
<< " between " << Pstream::myProcNo()
|
||||
<< " and " << nbrProcI
|
||||
<< endl;
|
||||
//Pout<< "Adding patch " << patchI
|
||||
// << " name:" << name
|
||||
// << " between " << Pstream::myProcNo()
|
||||
// << " and " << nbrProcI << endl;
|
||||
|
||||
label procPatchI = meshRefiner_.appendPatch
|
||||
(
|
||||
@ -1090,12 +998,7 @@ void Foam::autoLayerDriver::calculateLayerThickness
|
||||
(
|
||||
const indirectPrimitivePatch& pp,
|
||||
const labelList& patchIDs,
|
||||
const scalarField& patchExpansionRatio,
|
||||
|
||||
const bool relativeSizes,
|
||||
const scalarField& patchFinalLayerThickness,
|
||||
const scalarField& patchMinThickness,
|
||||
|
||||
const layerParameters& layerParams,
|
||||
const labelList& cellLevel,
|
||||
const labelList& patchNLayers,
|
||||
const scalar edge0Len,
|
||||
@ -1111,12 +1014,13 @@ void Foam::autoLayerDriver::calculateLayerThickness
|
||||
|
||||
// Rework patch-wise layer parameters into minimum per point
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Note: only layer parameters consistent with layer specification
|
||||
// method (see layerParameters) will be correct.
|
||||
scalarField firstLayerThickness(pp.nPoints(), GREAT);
|
||||
scalarField finalLayerThickness(pp.nPoints(), GREAT);
|
||||
scalarField totalThickness(pp.nPoints(), GREAT);
|
||||
scalarField expRatio(pp.nPoints(), GREAT);
|
||||
|
||||
// Reuse input fields
|
||||
expansionRatio.setSize(pp.nPoints());
|
||||
expansionRatio = GREAT;
|
||||
thickness.setSize(pp.nPoints());
|
||||
thickness = GREAT;
|
||||
minThickness.setSize(pp.nPoints());
|
||||
minThickness = GREAT;
|
||||
|
||||
@ -1130,20 +1034,30 @@ void Foam::autoLayerDriver::calculateLayerThickness
|
||||
{
|
||||
label ppPointI = pp.meshPointMap()[meshPoints[patchPointI]];
|
||||
|
||||
expansionRatio[ppPointI] = min
|
||||
firstLayerThickness[ppPointI] = min
|
||||
(
|
||||
expansionRatio[ppPointI],
|
||||
patchExpansionRatio[patchI]
|
||||
firstLayerThickness[ppPointI],
|
||||
layerParams.firstLayerThickness()[patchI]
|
||||
);
|
||||
thickness[ppPointI] = min
|
||||
finalLayerThickness[ppPointI] = min
|
||||
(
|
||||
thickness[ppPointI],
|
||||
patchFinalLayerThickness[patchI]
|
||||
finalLayerThickness[ppPointI],
|
||||
layerParams.finalLayerThickness()[patchI]
|
||||
);
|
||||
totalThickness[ppPointI] = min
|
||||
(
|
||||
totalThickness[ppPointI],
|
||||
layerParams.thickness()[patchI]
|
||||
);
|
||||
expRatio[ppPointI] = min
|
||||
(
|
||||
expRatio[ppPointI],
|
||||
layerParams.expansionRatio()[patchI]
|
||||
);
|
||||
minThickness[ppPointI] = min
|
||||
(
|
||||
minThickness[ppPointI],
|
||||
patchMinThickness[patchI]
|
||||
layerParams.minThickness()[patchI]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1152,7 +1066,7 @@ void Foam::autoLayerDriver::calculateLayerThickness
|
||||
(
|
||||
mesh,
|
||||
pp.meshPoints(),
|
||||
expansionRatio,
|
||||
firstLayerThickness,
|
||||
minEqOp<scalar>(),
|
||||
GREAT // null value
|
||||
);
|
||||
@ -1160,7 +1074,23 @@ void Foam::autoLayerDriver::calculateLayerThickness
|
||||
(
|
||||
mesh,
|
||||
pp.meshPoints(),
|
||||
thickness,
|
||||
finalLayerThickness,
|
||||
minEqOp<scalar>(),
|
||||
GREAT // null value
|
||||
);
|
||||
syncTools::syncPointList
|
||||
(
|
||||
mesh,
|
||||
pp.meshPoints(),
|
||||
totalThickness,
|
||||
minEqOp<scalar>(),
|
||||
GREAT // null value
|
||||
);
|
||||
syncTools::syncPointList
|
||||
(
|
||||
mesh,
|
||||
pp.meshPoints(),
|
||||
expRatio,
|
||||
minEqOp<scalar>(),
|
||||
GREAT // null value
|
||||
);
|
||||
@ -1182,14 +1112,18 @@ void Foam::autoLayerDriver::calculateLayerThickness
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// by multiplying with the internal cell size.
|
||||
|
||||
if (relativeSizes)
|
||||
if (layerParams.relativeSizes())
|
||||
{
|
||||
if (min(patchMinThickness) < 0 || max(patchMinThickness) > 2)
|
||||
if
|
||||
(
|
||||
min(layerParams.minThickness()) < 0
|
||||
|| max(layerParams.minThickness()) > 2
|
||||
)
|
||||
{
|
||||
FatalErrorIn("calculateLayerThickness(..)")
|
||||
<< "Thickness should be factor of local undistorted cell size."
|
||||
<< " Valid values are [0..2]." << nl
|
||||
<< " minThickness:" << patchMinThickness
|
||||
<< " minThickness:" << layerParams.minThickness()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -1225,38 +1159,114 @@ void Foam::autoLayerDriver::calculateLayerThickness
|
||||
{
|
||||
// Find undistorted edge size for this level.
|
||||
scalar edgeLen = edge0Len/(1<<maxPointLevel[pointI]);
|
||||
thickness[pointI] *= edgeLen;
|
||||
firstLayerThickness[pointI] *= edgeLen;
|
||||
finalLayerThickness[pointI] *= edgeLen;
|
||||
totalThickness[pointI] *= edgeLen;
|
||||
minThickness[pointI] *= edgeLen;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Rework thickness (of final layer) into overall thickness of all layers
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Rework thickness parameters into overall thickness
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
forAll(thickness, pointI)
|
||||
{
|
||||
// Calculate layer thickness based on expansion ratio
|
||||
// and final layer height
|
||||
if (expansionRatio[pointI] == 1)
|
||||
{
|
||||
thickness[pointI] *= patchNLayers[pointI];
|
||||
}
|
||||
else
|
||||
forAll(firstLayerThickness, pointI)
|
||||
{
|
||||
thickness[pointI] = layerParams.layerThickness
|
||||
(
|
||||
patchNLayers[pointI],
|
||||
firstLayerThickness[pointI],
|
||||
finalLayerThickness[pointI],
|
||||
totalThickness[pointI],
|
||||
expRatio[pointI]
|
||||
);
|
||||
|
||||
scalar invExpansion = 1.0 / expansionRatio[pointI];
|
||||
label nLay = patchNLayers[pointI];
|
||||
thickness[pointI] *=
|
||||
(1.0 - pow(invExpansion, nLay))
|
||||
/ (1.0 - invExpansion);
|
||||
expansionRatio[pointI] = layerParams.layerExpansionRatio
|
||||
(
|
||||
patchNLayers[pointI],
|
||||
firstLayerThickness[pointI],
|
||||
finalLayerThickness[pointI],
|
||||
totalThickness[pointI],
|
||||
expRatio[pointI]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Info<< "calculateLayerThickness : min:" << gMin(thickness)
|
||||
// << " max:" << gMax(thickness) << endl;
|
||||
|
||||
// Print a bit
|
||||
{
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
// Find maximum length of a patch name, for a nicer output
|
||||
label maxPatchNameLen = 0;
|
||||
forAll(patchIDs, i)
|
||||
{
|
||||
label patchI = patchIDs[i];
|
||||
word patchName = patches[patchI].name();
|
||||
maxPatchNameLen = max(maxPatchNameLen, label(patchName.size()));
|
||||
}
|
||||
|
||||
Info<< nl
|
||||
<< setf(ios_base::left) << setw(maxPatchNameLen) << "patch"
|
||||
<< setw(0) << " faces layers avg thickness[m]" << nl
|
||||
<< setf(ios_base::left) << setw(maxPatchNameLen) << " "
|
||||
<< setw(0) << " near-wall overall" << nl
|
||||
<< setf(ios_base::left) << setw(maxPatchNameLen) << "-----"
|
||||
<< setw(0) << " ----- ------ --------- -------" << endl;
|
||||
|
||||
forAll(patchIDs, i)
|
||||
{
|
||||
label patchI = patchIDs[i];
|
||||
|
||||
const labelList& meshPoints = patches[patchI].meshPoints();
|
||||
|
||||
scalar sumThickness = 0;
|
||||
scalar sumNearWallThickness = 0;
|
||||
|
||||
forAll(meshPoints, patchPointI)
|
||||
{
|
||||
label ppPointI = pp.meshPointMap()[meshPoints[patchPointI]];
|
||||
|
||||
sumThickness += thickness[ppPointI];
|
||||
sumNearWallThickness += layerParams.firstLayerThickness
|
||||
(
|
||||
patchNLayers[ppPointI],
|
||||
firstLayerThickness[ppPointI],
|
||||
finalLayerThickness[ppPointI],
|
||||
thickness[ppPointI],
|
||||
expansionRatio[ppPointI]
|
||||
);
|
||||
}
|
||||
|
||||
label totNPoints = returnReduce(meshPoints.size(), sumOp<label>());
|
||||
|
||||
// For empty patches, totNPoints is 0.
|
||||
scalar avgThickness = 0;
|
||||
scalar avgNearWallThickness = 0;
|
||||
|
||||
if (totNPoints > 0)
|
||||
{
|
||||
avgThickness =
|
||||
returnReduce(sumThickness, sumOp<scalar>())
|
||||
/ totNPoints;
|
||||
avgNearWallThickness =
|
||||
returnReduce(sumNearWallThickness, sumOp<scalar>())
|
||||
/ totNPoints;
|
||||
}
|
||||
|
||||
Info<< setf(ios_base::left) << setw(maxPatchNameLen)
|
||||
<< patches[patchI].name() << setprecision(3)
|
||||
<< " " << setw(8)
|
||||
<< returnReduce(patches[patchI].size(), sumOp<scalar>())
|
||||
<< " " << setw(6) << layerParams.numLayers()[patchI]
|
||||
<< " " << setw(8) << avgNearWallThickness
|
||||
<< " " << setw(8) << avgThickness
|
||||
<< endl;
|
||||
}
|
||||
Info<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2618,7 +2628,8 @@ void Foam::autoLayerDriver::addLayers
|
||||
const scalar edge0Len = meshRefiner_.meshCutter().level0EdgeLength();
|
||||
const labelList& cellLevel = meshRefiner_.meshCutter().cellLevel();
|
||||
|
||||
// Determine (wanted) point-wise layer thickness and expansion ratio
|
||||
// Determine (wanted) point-wise overall layer thickness and expansion
|
||||
// ratio
|
||||
scalarField thickness(pp().nPoints());
|
||||
scalarField minThickness(pp().nPoints());
|
||||
scalarField expansionRatio(pp().nPoints());
|
||||
@ -2626,12 +2637,7 @@ void Foam::autoLayerDriver::addLayers
|
||||
(
|
||||
pp,
|
||||
meshMover().adaptPatchIDs(),
|
||||
layerParams.expansionRatio(),
|
||||
|
||||
layerParams.relativeSizes(), // thickness relative to cellsize?
|
||||
layerParams.finalLayerThickness(), // wanted thicknes
|
||||
layerParams.minThickness(), // minimum thickness
|
||||
|
||||
layerParams,
|
||||
cellLevel,
|
||||
patchNLayers,
|
||||
edge0Len,
|
||||
@ -2642,87 +2648,6 @@ void Foam::autoLayerDriver::addLayers
|
||||
);
|
||||
|
||||
|
||||
// Print a bit
|
||||
{
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
// Find maximum length of a patch name, for a nicer output
|
||||
label maxPatchNameLen = 0;
|
||||
forAll(meshMover().adaptPatchIDs(), i)
|
||||
{
|
||||
label patchI = meshMover().adaptPatchIDs()[i];
|
||||
word patchName = patches[patchI].name();
|
||||
maxPatchNameLen = max(maxPatchNameLen, label(patchName.size()));
|
||||
}
|
||||
|
||||
Info<< nl
|
||||
<< setf(ios_base::left) << setw(maxPatchNameLen) << "patch"
|
||||
<< setw(0) << " faces layers avg thickness[m]" << nl
|
||||
<< setf(ios_base::left) << setw(maxPatchNameLen) << " "
|
||||
<< setw(0) << " near-wall overall" << nl
|
||||
<< setf(ios_base::left) << setw(maxPatchNameLen) << "-----"
|
||||
<< setw(0) << " ----- ------ --------- -------" << endl;
|
||||
|
||||
forAll(meshMover().adaptPatchIDs(), i)
|
||||
{
|
||||
label patchI = meshMover().adaptPatchIDs()[i];
|
||||
|
||||
const labelList& meshPoints = patches[patchI].meshPoints();
|
||||
|
||||
scalar sumThickness = 0;
|
||||
scalar sumNearWallThickness = 0;
|
||||
|
||||
forAll(meshPoints, patchPointI)
|
||||
{
|
||||
label ppPointI = pp().meshPointMap()[meshPoints[patchPointI]];
|
||||
|
||||
sumThickness += thickness[ppPointI];
|
||||
|
||||
label nLay = patchNLayers[ppPointI];
|
||||
if (nLay > 0)
|
||||
{
|
||||
if (expansionRatio[ppPointI] == 1)
|
||||
{
|
||||
sumNearWallThickness += thickness[ppPointI]/nLay;
|
||||
}
|
||||
else
|
||||
{
|
||||
scalar s =
|
||||
(1.0-pow(expansionRatio[ppPointI], nLay))
|
||||
/ (1.0-expansionRatio[ppPointI]);
|
||||
sumNearWallThickness += thickness[ppPointI]/s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
label totNPoints = returnReduce(meshPoints.size(), sumOp<label>());
|
||||
|
||||
// For empty patches, totNPoints is 0.
|
||||
scalar avgThickness = 0;
|
||||
scalar avgNearWallThickness = 0;
|
||||
|
||||
if (totNPoints > 0)
|
||||
{
|
||||
avgThickness =
|
||||
returnReduce(sumThickness, sumOp<scalar>())
|
||||
/ totNPoints;
|
||||
avgNearWallThickness =
|
||||
returnReduce(sumNearWallThickness, sumOp<scalar>())
|
||||
/ totNPoints;
|
||||
}
|
||||
|
||||
Info<< setf(ios_base::left) << setw(maxPatchNameLen)
|
||||
<< patches[patchI].name() << setprecision(3)
|
||||
<< " " << setw(8)
|
||||
<< returnReduce(patches[patchI].size(), sumOp<scalar>())
|
||||
<< " " << setw(6) << layerParams.numLayers()[patchI]
|
||||
<< " " << setw(8) << avgNearWallThickness
|
||||
<< " " << setw(8) << avgThickness
|
||||
<< endl;
|
||||
}
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
// Calculate wall to medial axis distance for smoothing displacement
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@ -2959,7 +2884,7 @@ void Foam::autoLayerDriver::addLayers
|
||||
// handles the slow termination of layers when going switching layers
|
||||
|
||||
labelList nPatchPointLayers(pp().nPoints(), -1);
|
||||
labelList nPatchFaceLayers(pp().localFaces().size(),-1);
|
||||
labelList nPatchFaceLayers(pp().size(), -1);
|
||||
setupLayerInfoTruncation
|
||||
(
|
||||
meshMover(),
|
||||
@ -2970,30 +2895,21 @@ void Foam::autoLayerDriver::addLayers
|
||||
nPatchFaceLayers
|
||||
);
|
||||
|
||||
// Calculate displacement for first layer for addPatchLayer.
|
||||
// (first layer = layer of cells next to the original mesh)
|
||||
vectorField firstDisp(patchNLayers.size(), vector::zero);
|
||||
// Calculate displacement for final layer for addPatchLayer.
|
||||
// (layer of cells next to the original mesh)
|
||||
vectorField finalDisp(patchNLayers.size(), vector::zero);
|
||||
|
||||
forAll(nPatchPointLayers, i)
|
||||
{
|
||||
if (nPatchPointLayers[i] > 0)
|
||||
{
|
||||
if (expansionRatio[i] == 1.0)
|
||||
{
|
||||
firstDisp[i] = patchDisp[i]/nPatchPointLayers[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
label nLay = nPatchPointLayers[i];
|
||||
scalar h =
|
||||
pow(expansionRatio[i], nLay - 1)
|
||||
* (1.0 - expansionRatio[i])
|
||||
/ (1.0 - pow(expansionRatio[i], nLay));
|
||||
firstDisp[i] = h*patchDisp[i];
|
||||
}
|
||||
}
|
||||
scalar ratio = layerParams.finalLayerThicknessRatio
|
||||
(
|
||||
nPatchPointLayers[i],
|
||||
expansionRatio[i]
|
||||
);
|
||||
finalDisp[i] = ratio*patchDisp[i];
|
||||
}
|
||||
|
||||
|
||||
const scalarField invExpansionRatio(1.0/expansionRatio);
|
||||
|
||||
// Add topo regardless of whether extrudeStatus is extruderemove.
|
||||
@ -3009,7 +2925,7 @@ void Foam::autoLayerDriver::addLayers
|
||||
labelList(0), // exposed patchIDs, not used for adding layers
|
||||
nPatchFaceLayers, // layers per face
|
||||
nPatchPointLayers, // layers per point
|
||||
firstDisp, // thickness of layer nearest internal mesh
|
||||
finalDisp, // thickness of layer nearest internal mesh
|
||||
meshMod
|
||||
);
|
||||
|
||||
|
||||
@ -237,12 +237,7 @@ class autoLayerDriver
|
||||
(
|
||||
const indirectPrimitivePatch& pp,
|
||||
const labelList& patchIDs,
|
||||
|
||||
const scalarField& patchExpansionRatio,
|
||||
const bool relativeSizes,
|
||||
const scalarField& patchFinalLayerThickness,
|
||||
const scalarField& patchMinThickness,
|
||||
|
||||
const layerParameters& layerParams,
|
||||
const labelList& cellLevel,
|
||||
const labelList& patchNLayers,
|
||||
const scalar edge0Len,
|
||||
|
||||
@ -34,6 +34,72 @@ License
|
||||
const Foam::scalar Foam::layerParameters::defaultConcaveAngle = 90;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::layerParameters::layerExpansionRatio
|
||||
(
|
||||
const label n,
|
||||
const scalar totalOverFirst
|
||||
) const
|
||||
{
|
||||
if (n <= 1)
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
//scalar totalOverFirst = totalThickness/firstLayerThickess;
|
||||
|
||||
const label maxIters = 10;
|
||||
const scalar tol = 1e-8;
|
||||
|
||||
|
||||
if (mag(n-totalOverFirst) < tol)
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
// Calculate the bounds of the solution
|
||||
scalar minR;
|
||||
scalar maxR;
|
||||
|
||||
if (totalOverFirst < n)
|
||||
{
|
||||
minR = 0.0;
|
||||
maxR = pow(totalOverFirst/n, 1/(n-1));
|
||||
}
|
||||
else
|
||||
{
|
||||
minR = pow(totalOverFirst/n, 1/(n-1));
|
||||
maxR = totalOverFirst/(n - 1);
|
||||
}
|
||||
|
||||
//Info<< "Solution bounds = (" << minR << ", " << maxR << ")" << nl << endl;
|
||||
|
||||
// Starting guess
|
||||
scalar r = 0.5*(minR + maxR);
|
||||
|
||||
for (label i = 0; i < maxIters; ++i)
|
||||
{
|
||||
const scalar prevr = r;
|
||||
|
||||
const scalar fx = pow(r, n) - totalOverFirst*r - (1 - totalOverFirst);
|
||||
const scalar dfx = n*pow(r, n - 1) - totalOverFirst;
|
||||
|
||||
r -= fx/dfx;
|
||||
|
||||
const scalar error = mag(r - prevr);
|
||||
|
||||
//Info<< i << " " << r << " Error = " << error << endl;
|
||||
|
||||
if (error < tol)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from dictionary
|
||||
@ -44,17 +110,12 @@ Foam::layerParameters::layerParameters
|
||||
)
|
||||
:
|
||||
numLayers_(boundaryMesh.size(), -1),
|
||||
expansionRatio_
|
||||
(
|
||||
boundaryMesh.size(),
|
||||
readScalar(dict.lookup("expansionRatio"))
|
||||
),
|
||||
relativeSizes_(dict.lookup("relativeSizes")),
|
||||
finalLayerThickness_
|
||||
(
|
||||
boundaryMesh.size(),
|
||||
readScalar(dict.lookup("finalLayerThickness"))
|
||||
),
|
||||
layerSpec_(ILLEGAL),
|
||||
firstLayerThickness_(boundaryMesh.size(), -123),
|
||||
finalLayerThickness_(boundaryMesh.size(), -123),
|
||||
thickness_(boundaryMesh.size(), -123),
|
||||
expansionRatio_(boundaryMesh.size(), -123),
|
||||
minThickness_
|
||||
(
|
||||
boundaryMesh.size(),
|
||||
@ -103,24 +164,108 @@ Foam::layerParameters::layerParameters
|
||||
nRelaxedIter_(labelMax),
|
||||
additionalReporting_(dict.lookupOrDefault("additionalReporting", false))
|
||||
{
|
||||
if (nGrow_ > 0)
|
||||
// Detect layer specification mode
|
||||
|
||||
label nSpec = 0;
|
||||
|
||||
bool haveFirst = dict.found("firstLayerThickness");
|
||||
if (haveFirst)
|
||||
{
|
||||
WarningIn("layerParameters::layerParameters(..)")
|
||||
<< "The nGrow parameter effect has changed with respect to 1.6.x."
|
||||
<< endl
|
||||
<< "Please set nGrow=0 for 1.6.x behaviour."
|
||||
firstLayerThickness_ = scalarField
|
||||
(
|
||||
boundaryMesh.size(),
|
||||
readScalar(dict.lookup("firstLayerThickness"))
|
||||
);
|
||||
nSpec++;
|
||||
}
|
||||
bool haveFinal = dict.found("finalLayerThickness");
|
||||
if (haveFinal)
|
||||
{
|
||||
finalLayerThickness_ = scalarField
|
||||
(
|
||||
boundaryMesh.size(),
|
||||
readScalar(dict.lookup("finalLayerThickness"))
|
||||
);
|
||||
nSpec++;
|
||||
}
|
||||
bool haveTotal = dict.found("thickness");
|
||||
if (haveTotal)
|
||||
{
|
||||
thickness_ = scalarField
|
||||
(
|
||||
boundaryMesh.size(),
|
||||
readScalar(dict.lookup("thickness"))
|
||||
);
|
||||
nSpec++;
|
||||
}
|
||||
bool haveExp = dict.found("expansionRatio");
|
||||
if (haveExp)
|
||||
{
|
||||
expansionRatio_ = scalarField
|
||||
(
|
||||
boundaryMesh.size(),
|
||||
readScalar(dict.lookup("expansionRatio"))
|
||||
);
|
||||
nSpec++;
|
||||
}
|
||||
|
||||
|
||||
if (haveFirst && haveTotal)
|
||||
{
|
||||
layerSpec_ = FIRST_AND_TOTAL;
|
||||
Info<< "Layer thickness specified as first layer and overall thickness."
|
||||
<< endl;
|
||||
}
|
||||
else if (haveFirst && haveExp)
|
||||
{
|
||||
layerSpec_ = FIRST_AND_EXPANSION;
|
||||
Info<< "Layer thickness specified as first layer and expansion ratio."
|
||||
<< endl;
|
||||
}
|
||||
else if (haveFinal && haveTotal)
|
||||
{
|
||||
layerSpec_ = FINAL_AND_TOTAL;
|
||||
Info<< "Layer thickness specified as final layer and overall thickness."
|
||||
<< endl;
|
||||
}
|
||||
else if (haveFinal && haveExp)
|
||||
{
|
||||
layerSpec_ = FINAL_AND_EXPANSION;
|
||||
Info<< "Layer thickness specified as final layer and expansion ratio."
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
if (layerSpec_ == ILLEGAL || nSpec != 2)
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"layerParameters::layerParameters"
|
||||
"(const dictionary&, const polyBoundaryMesh&)",
|
||||
dict
|
||||
) << "Over- or underspecified layer thickness."
|
||||
<< " Please specify" << nl
|
||||
<< " first layer thickness ('firstLayerThickness')"
|
||||
<< " and overall thickness ('thickness') or" << nl
|
||||
<< " first layer thickness ('firstLayerThickness')"
|
||||
<< " and expansion ratio ('expansionRatio') or" << nl
|
||||
<< " final layer thickness ('finalLayerThickness')"
|
||||
<< " and expansion ratio ('expansionRatio') or" << nl
|
||||
<< " final layer thickness ('finalLayerThickness')"
|
||||
<< " and overall thickness ('thickness')"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
|
||||
dict.readIfPresent("nRelaxedIter", nRelaxedIter_);
|
||||
|
||||
if (nLayerIter_ < 0 || nRelaxedIter_ < 0)
|
||||
{
|
||||
FatalErrorIn("layerParameters::layerParameters(..)")
|
||||
FatalIOErrorIn("layerParameters::layerParameters(..)", dict)
|
||||
<< "Layer iterations should be >= 0." << endl
|
||||
<< "nLayerIter:" << nLayerIter_
|
||||
<< " nRelaxedIter:" << nRelaxedIter_
|
||||
<< exit(FatalError);
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
|
||||
@ -130,7 +275,7 @@ Foam::layerParameters::layerParameters
|
||||
{
|
||||
if (iter().isDict())
|
||||
{
|
||||
const word& key = iter().keyword();
|
||||
const keyType& key = iter().keyword();
|
||||
const labelHashSet patchIDs
|
||||
(
|
||||
boundaryMesh.patchSet(List<wordRe>(1, key))
|
||||
@ -154,16 +299,69 @@ Foam::layerParameters::layerParameters
|
||||
numLayers_[patchI] =
|
||||
readLabel(layerDict.lookup("nSurfaceLayers"));
|
||||
|
||||
switch (layerSpec_)
|
||||
{
|
||||
case FIRST_AND_TOTAL:
|
||||
layerDict.readIfPresent
|
||||
(
|
||||
"firstLayerThickness",
|
||||
firstLayerThickness_[patchI]
|
||||
);
|
||||
layerDict.readIfPresent
|
||||
(
|
||||
"thickness",
|
||||
thickness_[patchI]
|
||||
);
|
||||
break;
|
||||
|
||||
case FIRST_AND_EXPANSION:
|
||||
layerDict.readIfPresent
|
||||
(
|
||||
"firstLayerThickness",
|
||||
firstLayerThickness_[patchI]
|
||||
);
|
||||
layerDict.readIfPresent
|
||||
(
|
||||
"expansionRatio",
|
||||
expansionRatio_[patchI]
|
||||
);
|
||||
break;
|
||||
|
||||
case FINAL_AND_TOTAL:
|
||||
layerDict.readIfPresent
|
||||
(
|
||||
"finalLayerThickness",
|
||||
finalLayerThickness_[patchI]
|
||||
);
|
||||
layerDict.readIfPresent
|
||||
(
|
||||
"thickness",
|
||||
thickness_[patchI]
|
||||
);
|
||||
break;
|
||||
|
||||
case FINAL_AND_EXPANSION:
|
||||
layerDict.readIfPresent
|
||||
(
|
||||
"finalLayerThickness",
|
||||
finalLayerThickness_[patchI]
|
||||
);
|
||||
layerDict.readIfPresent
|
||||
(
|
||||
"expansionRatio",
|
||||
expansionRatio_[patchI]
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"layerParameters::layerParameters(..)",
|
||||
dict
|
||||
) << "problem." << exit(FatalIOError);
|
||||
break;
|
||||
}
|
||||
|
||||
layerDict.readIfPresent
|
||||
(
|
||||
"minThickness",
|
||||
@ -176,4 +374,190 @@ Foam::layerParameters::layerParameters
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::layerParameters::layerThickness
|
||||
(
|
||||
const label nLayers,
|
||||
const scalar firstLayerThickess,
|
||||
const scalar finalLayerThickess,
|
||||
const scalar totalThickness,
|
||||
const scalar expansionRatio
|
||||
) const
|
||||
{
|
||||
switch (layerSpec_)
|
||||
{
|
||||
case FIRST_AND_TOTAL:
|
||||
case FINAL_AND_TOTAL:
|
||||
{
|
||||
return totalThickness;
|
||||
}
|
||||
break;
|
||||
|
||||
case FIRST_AND_EXPANSION:
|
||||
{
|
||||
if (mag(expansionRatio-1) < SMALL)
|
||||
{
|
||||
return firstLayerThickess * nLayers;
|
||||
}
|
||||
else
|
||||
{
|
||||
return firstLayerThickess *
|
||||
(1.0 - pow(expansionRatio, nLayers))
|
||||
/ (1.0 - expansionRatio);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case FINAL_AND_EXPANSION:
|
||||
{
|
||||
if (mag(expansionRatio-1) < SMALL)
|
||||
{
|
||||
return finalLayerThickess * nLayers;
|
||||
}
|
||||
else
|
||||
{
|
||||
scalar invExpansion = 1.0 / expansionRatio;
|
||||
return finalLayerThickess *
|
||||
(1.0 - pow(invExpansion, nLayers))
|
||||
/ (1.0 - invExpansion);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
FatalErrorIn("layerParameters::layerThickness(..)")
|
||||
<< "Illegal thickness specification " << layerSpec_
|
||||
<< exit(FatalError);
|
||||
return -VGREAT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::layerParameters::layerExpansionRatio
|
||||
(
|
||||
const label nLayers,
|
||||
const scalar firstLayerThickess,
|
||||
const scalar finalLayerThickess,
|
||||
const scalar totalThickness,
|
||||
const scalar expansionRatio
|
||||
) const
|
||||
{
|
||||
switch (layerSpec_)
|
||||
{
|
||||
case FIRST_AND_EXPANSION:
|
||||
case FINAL_AND_EXPANSION:
|
||||
{
|
||||
return expansionRatio;
|
||||
}
|
||||
break;
|
||||
|
||||
case FIRST_AND_TOTAL:
|
||||
{
|
||||
return layerExpansionRatio
|
||||
(
|
||||
nLayers,
|
||||
totalThickness/firstLayerThickess
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case FINAL_AND_TOTAL:
|
||||
{
|
||||
return
|
||||
1.0
|
||||
/ layerExpansionRatio
|
||||
(
|
||||
nLayers,
|
||||
totalThickness/finalLayerThickess
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
FatalErrorIn("layerParameters::layerThickness(..)")
|
||||
<< "Illegal thickness specification" << exit(FatalError);
|
||||
return -VGREAT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::layerParameters::firstLayerThickness
|
||||
(
|
||||
const label nLayers,
|
||||
const scalar firstLayerThickess,
|
||||
const scalar finalLayerThickess,
|
||||
const scalar totalThickness,
|
||||
const scalar expansionRatio
|
||||
) const
|
||||
{
|
||||
switch (layerSpec_)
|
||||
{
|
||||
case FIRST_AND_EXPANSION:
|
||||
case FIRST_AND_TOTAL:
|
||||
{
|
||||
return firstLayerThickess;
|
||||
}
|
||||
|
||||
case FINAL_AND_EXPANSION:
|
||||
{
|
||||
return finalLayerThickess*pow(1.0/expansionRatio, nLayers-1);
|
||||
}
|
||||
break;
|
||||
|
||||
case FINAL_AND_TOTAL:
|
||||
{
|
||||
scalar r = layerExpansionRatio
|
||||
(
|
||||
nLayers,
|
||||
firstLayerThickess,
|
||||
finalLayerThickess,
|
||||
totalThickness,
|
||||
expansionRatio
|
||||
);
|
||||
return finalLayerThickess/pow(r, nLayers-1);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
FatalErrorIn("layerParameters::layerThickness(..)")
|
||||
<< "Illegal thickness specification" << exit(FatalError);
|
||||
return -VGREAT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::layerParameters::finalLayerThicknessRatio
|
||||
(
|
||||
const label nLayers,
|
||||
const scalar expansionRatio
|
||||
) const
|
||||
{
|
||||
if (nLayers > 0)
|
||||
{
|
||||
if (mag(expansionRatio-1) < SMALL)
|
||||
{
|
||||
return 1.0/nLayers;
|
||||
}
|
||||
else
|
||||
{
|
||||
return
|
||||
pow(expansionRatio, nLayers - 1)
|
||||
* (1.0 - expansionRatio)
|
||||
/ (1.0 - pow(expansionRatio, nLayers));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -55,6 +55,27 @@ class refinementSurfaces;
|
||||
|
||||
class layerParameters
|
||||
{
|
||||
public:
|
||||
|
||||
// Public data types
|
||||
|
||||
//- Enumeration defining the layer specification:
|
||||
// - first and total thickness specified
|
||||
// - first and expansion ratio specified
|
||||
// - final and total thickness specified
|
||||
// - final and expansion ratio specified
|
||||
enum layerSpecification
|
||||
{
|
||||
ILLEGAL,
|
||||
FIRST_AND_TOTAL,
|
||||
FIRST_AND_EXPANSION,
|
||||
FINAL_AND_TOTAL,
|
||||
FINAL_AND_EXPANSION
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Static data members
|
||||
|
||||
//- Default angle for faces to be convcave
|
||||
@ -68,12 +89,21 @@ class layerParameters
|
||||
//- How many layers to add.
|
||||
labelList numLayers_;
|
||||
|
||||
scalarField expansionRatio_;
|
||||
|
||||
//- Are sizes relative to local cell size
|
||||
Switch relativeSizes_;
|
||||
|
||||
//- How thickness is specified.
|
||||
layerSpecification layerSpec_;
|
||||
|
||||
scalarField firstLayerThickness_;
|
||||
|
||||
scalarField finalLayerThickness_;
|
||||
|
||||
scalarField thickness_;
|
||||
|
||||
scalarField expansionRatio_;
|
||||
|
||||
//- Minimum total thickness
|
||||
scalarField minThickness_;
|
||||
|
||||
|
||||
@ -111,6 +141,14 @@ class layerParameters
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate expansion ratio from overall size v.s. thickness of
|
||||
// first layer.
|
||||
scalar layerExpansionRatio
|
||||
(
|
||||
const label n,
|
||||
const scalar totalOverFirst
|
||||
) const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
layerParameters(const layerParameters&);
|
||||
|
||||
@ -128,8 +166,6 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
// Per patch information
|
||||
|
||||
//- How many layers to add.
|
||||
@ -142,12 +178,6 @@ public:
|
||||
return numLayers_;
|
||||
}
|
||||
|
||||
// Expansion factor for layer mesh
|
||||
const scalarField& expansionRatio() const
|
||||
{
|
||||
return expansionRatio_;
|
||||
}
|
||||
|
||||
//- Are size parameters relative to inner cell size or
|
||||
// absolute distances.
|
||||
bool relativeSizes() const
|
||||
@ -155,9 +185,14 @@ public:
|
||||
return relativeSizes_;
|
||||
}
|
||||
|
||||
//- Wanted thickness of final added cell layer. If multiple
|
||||
// layers is the thickness of the layer furthest away
|
||||
// from the wall (i.e. nearest the original mesh)
|
||||
// Expansion factor for layer mesh
|
||||
const scalarField& expansionRatio() const
|
||||
{
|
||||
return expansionRatio_;
|
||||
}
|
||||
|
||||
//- Wanted thickness of the layer furthest away
|
||||
// from the wall (i.e. nearest the original mesh).
|
||||
// If relativeSize() this number is relative to undistorted
|
||||
// size of the cell outside layer.
|
||||
const scalarField& finalLayerThickness() const
|
||||
@ -165,7 +200,23 @@ public:
|
||||
return finalLayerThickness_;
|
||||
}
|
||||
|
||||
//- Minimum thickness of cell layer. If for any reason layer
|
||||
//- Wanted thickness of the layer nearest to the wall.
|
||||
// If relativeSize() this number is relative to undistorted
|
||||
// size of the cell outside layer.
|
||||
const scalarField& firstLayerThickness() const
|
||||
{
|
||||
return firstLayerThickness_;
|
||||
}
|
||||
|
||||
//- Wanted overall thickness of all layers.
|
||||
// If relativeSize() this number is relative to undistorted
|
||||
// size of the cell outside layer.
|
||||
const scalarField& thickness() const
|
||||
{
|
||||
return thickness_;
|
||||
}
|
||||
|
||||
//- Minimum overall thickness of cell layer. If for any reason layer
|
||||
// cannot be above minThickness do not add layer.
|
||||
// If relativeSize() this number is relative to undistorted
|
||||
// size of the cell outside layer.
|
||||
@ -276,6 +327,48 @@ public:
|
||||
}
|
||||
|
||||
|
||||
// Helper
|
||||
|
||||
//- Determine overall thickness. Uses two of the four parameters
|
||||
// according to the layerSpecification
|
||||
scalar layerThickness
|
||||
(
|
||||
const label nLayers,
|
||||
const scalar firstLayerThickess,
|
||||
const scalar finalLayerThickess,
|
||||
const scalar totalThickness,
|
||||
const scalar expansionRatio
|
||||
) const;
|
||||
|
||||
//- Determine expansion ratio. Uses two of the four parameters
|
||||
// according to the layerSpecification
|
||||
scalar layerExpansionRatio
|
||||
(
|
||||
const label nLayers,
|
||||
const scalar firstLayerThickess,
|
||||
const scalar finalLayerThickess,
|
||||
const scalar totalThickness,
|
||||
const scalar expansionRatio
|
||||
) const;
|
||||
|
||||
//- Determine first layer (near-wall) thickness. Uses two of the
|
||||
// four parameters according to the layerSpecification
|
||||
scalar firstLayerThickness
|
||||
(
|
||||
const label nLayers,
|
||||
const scalar firstLayerThickess,
|
||||
const scalar finalLayerThickess,
|
||||
const scalar totalThickness,
|
||||
const scalar expansionRatio
|
||||
) const;
|
||||
|
||||
//- Determine ratio of final layer thickness to
|
||||
// overall layer thickness
|
||||
scalar finalLayerThicknessRatio
|
||||
(
|
||||
const label nLayers,
|
||||
const scalar expansionRatio
|
||||
) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user