Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
fcc77aae
Commit
fcc77aae
authored
Oct 01, 2012
by
mattijs
Browse files
ENH: snappyHexMesh: allow sliding
parent
e7569aa7
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C
View file @
fcc77aae
...
...
@@ -710,7 +710,8 @@ void Foam::autoLayerDriver::setNumLayers
const
indirectPrimitivePatch
&
pp
,
pointField
&
patchDisp
,
labelList
&
patchNLayers
,
List
<
extrudeMode
>&
extrudeStatus
List
<
extrudeMode
>&
extrudeStatus
,
label
&
nAddedCells
)
const
{
const
fvMesh
&
mesh
=
meshRefiner_
.
mesh
();
...
...
@@ -797,6 +798,24 @@ void Foam::autoLayerDriver::setNumLayers
}
}
// Calculate number of cells to create
nAddedCells
=
0
;
forAll
(
pp
.
localFaces
(),
faceI
)
{
const
face
&
f
=
pp
.
localFaces
()[
faceI
];
// Get max of extrusion per point
label
nCells
=
0
;
forAll
(
f
,
fp
)
{
nCells
=
max
(
nCells
,
patchNLayers
[
f
[
fp
]]);
}
nAddedCells
+=
nCells
;
}
reduce
(
nAddedCells
,
sumOp
<
label
>
());
//reduce(nConflicts, sumOp<label>());
//
//Info<< "Set displacement to zero for " << nConflicts
...
...
@@ -2491,9 +2510,13 @@ void Foam::autoLayerDriver::addLayers
// extrudeStatus = EXTRUDE.
labelList
patchNLayers
(
pp
().
nPoints
(),
0
);
// Ideal number of cells added
label
nIdealAddedCells
=
0
;
// Whether to add edge for all pp.localPoints.
List
<
extrudeMode
>
extrudeStatus
(
pp
().
nPoints
(),
EXTRUDE
);
{
// Get number of layer per point from number of layers per patch
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
...
@@ -2506,7 +2529,8 @@ void Foam::autoLayerDriver::addLayers
patchDisp
,
patchNLayers
,
extrudeStatus
extrudeStatus
,
nIdealAddedCells
);
// Precalculate mesh edge labels for patch edges
...
...
@@ -2776,6 +2800,7 @@ void Foam::autoLayerDriver::addLayers
layerParams
.
nSmoothNormals
(),
layerParams
.
nSmoothSurfaceNormals
(),
layerParams
.
minMedianAxisAngleCos
(),
layerParams
.
featureAngle
(),
dispVec
,
medialRatio
,
...
...
@@ -3101,10 +3126,24 @@ void Foam::autoLayerDriver::addLayers
label
nExtruded
=
countExtrusion
(
pp
,
extrudeStatus
);
label
nTotFaces
=
returnReduce
(
pp
().
size
(),
sumOp
<
label
>
());
label
nAddedCells
=
0
;
{
forAll
(
flaggedCells
,
cellI
)
{
if
(
flaggedCells
[
cellI
])
{
nAddedCells
++
;
}
}
reduce
(
nAddedCells
,
sumOp
<
label
>
());
}
Info
<<
"Extruding "
<<
nExtruded
<<
" out of "
<<
nTotFaces
<<
" faces ("
<<
100
.
0
*
nExtruded
/
nTotFaces
<<
"%)."
<<
" Removed extrusion at "
<<
nTotChanged
<<
" faces."
<<
endl
<<
"Added "
<<
nAddedCells
<<
" out of "
<<
nIdealAddedCells
<<
" cells ("
<<
100
.
0
*
nAddedCells
/
nIdealAddedCells
<<
"%)."
<<
endl
;
if
(
nTotChanged
==
0
)
...
...
src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H
View file @
fcc77aae
...
...
@@ -192,7 +192,8 @@ class autoLayerDriver
const
indirectPrimitivePatch
&
pp
,
pointField
&
patchDisp
,
labelList
&
patchNLayers
,
List
<
extrudeMode
>&
extrudeStatus
List
<
extrudeMode
>&
extrudeStatus
,
label
&
nIdealAddedCells
)
const
;
//- Helper function to make a pointVectorField with correct
...
...
@@ -469,6 +470,7 @@ class autoLayerDriver
const
label
nSmoothNormals
,
const
label
nSmoothSurfaceNormals
,
const
scalar
minMedianAxisAngleCos
,
const
scalar
featureAngle
,
pointVectorField
&
dispVec
,
pointScalarField
&
medialRatio
,
...
...
src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C
View file @
fcc77aae
...
...
@@ -33,9 +33,10 @@ Description
#include "motionSmoother.H"
#include "pointData.H"
#include "PointEdgeWave.H"
#include "O
F
stream.H"
#include "O
BJ
stream.H"
#include "meshTools.H"
#include "PatchTools.H"
#include "unitConversion.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
...
...
@@ -775,6 +776,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
const
label
nSmoothNormals
,
const
label
nSmoothSurfaceNormals
,
const
scalar
minMedianAxisAngleCos
,
const
scalar
featureAngle
,
pointVectorField
&
dispVec
,
pointScalarField
&
medialRatio
,
...
...
@@ -904,7 +906,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
const
edge
&
e
=
edges
[
edgeI
];
// Approximate medial axis location on edge.
//const point medialAxisPt = e.centre(points);
vector
eVec
=
e
.
vec
(
mesh
.
points
()
);
vector
eVec
=
e
.
vec
(
points
);
scalar
eMag
=
mag
(
eVec
);
if
(
eMag
>
VSMALL
)
{
...
...
@@ -961,42 +963,111 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
labelHashSet
adaptPatches
(
meshMover
.
adaptPatchIDs
());
forAll
(
patches
,
patchI
)
{
const
polyPatch
&
pp
=
patches
[
patchI
];
//
const pointPatchVectorField& pvf =
//
meshMover.displacement().boundaryField()[patchI];
const
pointPatchVectorField
&
pvf
=
meshMover
.
displacement
().
boundaryField
()[
patchI
];
if
(
!
pp
.
coupled
()
&&
!
isA
<
emptyPolyPatch
>
(
pp
)
//&& pvf.constraintType() != word::null //exclude fixedValue
&&
!
adaptPatches
.
found
(
patchI
)
)
{
Info
<<
"Inserting points on patch "
<<
pp
.
name
()
<<
endl
;
const
labelList
&
meshPoints
=
pp
.
meshPoints
();
forAll
(
meshPoints
,
i
)
// Check the type of the patchField. The types are
// - fixedValue (0 or more layers) but the >0 layers have
// already been handled in the adaptPatches loop
// - constraint (but not coupled) types, e.g. symmetryPlane,
// slip.
if
(
pvf
.
fixesValue
())
{
label
pointI
=
meshPoints
[
i
];
// Disable all movement on fixedValue patchFields
Info
<<
"Inserting all points on patch "
<<
pp
.
name
()
<<
endl
;
if
(
!
pointMedialDist
[
pointI
].
valid
(
dummyTrackData
)
)
forAll
(
meshPoints
,
i
)
{
maxPoints
.
append
(
pointI
);
maxInfo
.
append
label
pointI
=
meshPoints
[
i
];
if
(
!
pointMedialDist
[
pointI
].
valid
(
dummyTrackData
))
{
maxPoints
.
append
(
pointI
);
maxInfo
.
append
(
pointData
(
points
[
pointI
],
0
.
0
,
pointI
,
// passive data
vector
::
zero
// passive data
)
);
pointMedialDist
[
pointI
]
=
maxInfo
.
last
();
}
}
}
else
{
// Based on geometry: analyse angle w.r.t. nearest moving
// point. In the pointWallDist we transported the
// normal as the passive vector. Note that this points
// out of the originating wall so inside of the domain
// on this patch.
Info
<<
"Inserting points on patch "
<<
pp
.
name
()
<<
" if angle to nearest layer patch > "
<<
featureAngle
<<
" degrees."
<<
endl
;
scalar
featureAngleCos
=
Foam
::
cos
(
degToRad
(
featureAngle
));
pointField
pointNormals
(
PatchTools
::
pointNormals
(
pointData
mesh
,
pp
,
identity
(
pp
.
size
())
+
pp
.
start
()
)
);
forAll
(
meshPoints
,
i
)
{
label
pointI
=
meshPoints
[
i
];
if
(
!
pointMedialDist
[
pointI
].
valid
(
dummyTrackData
))
{
// Check if angle not too large.
scalar
cosAngle
=
(
points
[
pointI
],
0
.
0
,
pointI
,
// passive data
vector
::
zero
// passive data
)
);
pointMedialDist
[
pointI
]
=
maxInfo
.
last
();
-
pointWallDist
[
pointI
].
v
()
&
pointNormals
[
i
]
);
if
(
cosAngle
>
featureAngleCos
)
{
// Extrusion direction practically perpendicular
// to the patch. Disable movement at the patch.
maxPoints
.
append
(
pointI
);
maxInfo
.
append
(
pointData
(
points
[
pointI
],
0
.
0
,
pointI
,
// passive data
vector
::
zero
// passive data
)
);
pointMedialDist
[
pointI
]
=
maxInfo
.
last
();
}
else
{
// Extrusion direction makes angle with patch
// so allow sliding - don't insert zero points
}
}
}
}
}
...
...
@@ -1141,13 +1212,12 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
// reduce thickness where thickness/medial axis distance large
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
autoPtr
<
OFstream
>
str
;
label
vertI
=
0
;
autoPtr
<
OBJstream
>
str
;
if
(
debug
)
{
str
.
reset
(
new
O
F
stream
new
O
BJ
stream
(
mesh
.
time
().
path
()
/
"thicknessRatioExcludePoints_"
...
...
@@ -1159,13 +1229,12 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
<<
str
().
name
()
<<
endl
;
}
autoPtr
<
OFstream
>
medialVecStr
;
label
medialVertI
=
0
;
autoPtr
<
OBJstream
>
medialVecStr
;
if
(
debug
)
{
medialVecStr
.
reset
(
new
O
F
stream
new
O
BJ
stream
(
mesh
.
time
().
path
()
/
"thicknessRatioExcludeMedialVec_"
...
...
@@ -1227,21 +1296,19 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
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
;
str
().
write
(
linePointRef
(
pt
,
pt
+
patchDisp
[
patchPointI
]));
}
if
(
medialVecStr
.
valid
())
{
const
point
&
pt
=
mesh
.
points
()[
pointI
];
meshTools
::
writeOBJ
(
medialVecStr
(),
pt
);
medialVertI
++
;
meshTools
::
writeOBJ
(
medialVecStr
(),
medialVec
[
pointI
]);
medialVertI
++
;
medialVecStr
()
<<
"l "
<<
medialVertI
-
1
<<
' '
<<
medialVertI
<<
nl
;
medialVecStr
().
write
(
linePointRef
(
pt
,
medialVec
[
pointI
]
)
);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment