CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[snappyHexMesh] jagged, ragged edges...

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 11, 2010, 06:06
Unhappy jagged, ragged edges...
  #1
Senior Member
 
Mieszko Młody
Join Date: Mar 2009
Location: POLAND, USA
Posts: 145
Rep Power: 17
ziemowitzima is on a distinguished road
Dear everyone !

I am doing flow in 3D abdominal aorta. To create mesh I utilized snappyHexMesh. But I obtained strange jagged edges where inlet (outlet) patches are joining with rest of the mesh. I attached figures showing this problem. If some of you know how to deal with this issue pleas let me know !!
Thanks
Ziemowit
Attached Images
File Type: jpg mesh-zoom.jpg (98.5 KB, 556 views)
File Type: jpg inlet-patch.jpg (45.3 KB, 375 views)

Last edited by ziemowitzima; February 11, 2010 at 06:36.
ziemowitzima is offline   Reply With Quote

Old   February 11, 2010, 06:11
Default
  #2
Senior Member
 
Mieszko Młody
Join Date: Mar 2009
Location: POLAND, USA
Posts: 145
Rep Power: 17
ziemowitzima is on a distinguished road
Here is my snappyHexMeshDict:

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// Which of the steps to run
castellatedMesh true;
snap true;
addLayers true;


// Geometry. Definition of all surfaces. All surfaces are of class
// searchableSurface.
// Surfaces are used
// - to specify refinement for any mesh cell intersecting it
// - to specify refinement for any mesh cell inside/outside/near
// - to 'snap' the mesh boundary to the surface
geometry
{
aortwz.stl
{
type triSurfaceMesh;
name aort;
}
inz.stl
{
type triSurfaceMesh;
name in;
}
out1z.stl
{
type triSurfaceMesh;
name out1;
}
out2z.stl
{
type triSurfaceMesh;
name out2;
}

// refinementBox
// {
// type searchableBox;
// min ( 0.07 0.05 -0.1);
// max ( 0.26 0.25 0.2);
// }
};


// Settings for the castellatedMesh generation.
castellatedMeshControls
{

// Refinement parameters
// ~~~~~~~~~~~~~~~~~~~~~

// While refining maximum number of cells per processor. This is basically
// the number of cells that fit on a processor. If you choose this too small
// it will do just more refinement iterations to obtain a similar mesh.
maxLocalCells 1000000;

// Overall cell limit (approximately). Refinement will stop immediately
// upon reaching this number so a refinement level might not complete.
// Note that this is the number of cells before removing the part which
// is not 'visible' from the keepPoint. The final number of cells might
// actually be a lot less.
maxGlobalCells 2000000;

// The surface refinement loop might spend lots of iterations refining just a
// few cells. This setting will cause refinement to stop if <= minimumRefine
// are selected for refinement. Note: it will at least do one iteration
// (unless the number of cells to refine is 0)
minRefinementCells 10;

// Number of buffer layers between different levels.
// 1 means normal 2:1 refinement restriction, larger means slower
// refinement.
nCellsBetweenLevels 3;



// Explicit feature edge refinement
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// Specifies a level for any cell intersected by its edges.
// This is a featureEdgeMesh, read from constant/triSurface for now.
features
(
//{
// file "someLine.eMesh";
// level 2;
//}
);



// Surface based refinement
// ~~~~~~~~~~~~~~~~~~~~~~~~

// Specifies two levels for every surface. The first is the minimum level,
// every cell intersecting a surface gets refined up to the minimum level.
// The second level is the maximum level. Cells that 'see' multiple
// intersections where the intersections make an
// angle > resolveFeatureAngle get refined up to the maximum level.

refinementSurfaces
{
aort
{
// Surface-wise min and max refinement level
level (4 4);
}
in
{
// Surface-wise min and max refinement level
level (4 4);
}
out1
{
// Surface-wise min and max refinement level
level (4 4);
}
out2
{
// Surface-wise min and max refinement level
level (4 4);
}
}

// Resolve sharp angles
resolveFeatureAngle 60;


// Region-wise refinement
// ~~~~~~~~~~~~~~~~~~~~~~

// Specifies refinement level for cells in relation to a surface. One of
// three modes
// - distance. 'levels' specifies per distance to the surface the
// wanted refinement level. The distances need to be specified in
// descending order.
// - inside. 'levels' is only one entry and only the level is used. All
// cells inside the surface get refined up to the level. The surface
// needs to be closed for this to be possible.
// - outside. Same but cells outside.

refinementRegions
{
// in
// {
// mode inside;
// levels ((1E15 4));
// }
}


// Mesh selection
// ~~~~~~~~~~~~~~

// After refinement patches get added for all refinementSurfaces and
// all cells intersecting the surfaces get put into these patches. The
// section reachable from the locationInMesh is kept.
// NOTE: This point should never be on a face, always inside a cell, even
// after refinement.
locationInMesh (1.5 1.25 5);
}



// Settings for the snapping.
snapControls
{
//- Number of patch smoothing iterations before finding correspondence
// to surface
nSmoothPatch 4;

//- Relative distance for points to be attracted by surface feature point
// or edge. True distance is this factor times local
// maximum edge length.
tolerance 4.0;//4

//- Number of mesh displacement relaxation iterations.
nSolveIter 30;

//- Maximum number of snapping relaxation iterations. Should stop
// before upon reaching a correct mesh.
nRelaxIter 7;
}



// Settings for the layer addition.
addLayersControls
{
relativeSizes true;

// Per final patch (so not geometry!) the layer information
layers
{

aort
{
nSurfaceLayers 2;
}
out1
{
nSurfaceLayers 2;
}
out2
{
nSurfaceLayers 2;
}
in
{
nSurfaceLayers 2;
}

}

// Expansion factor for layer mesh
expansionRatio 1;

//- 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.
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.
minThickness 0.1;

//- 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.
nGrow 1;


// Advanced settings

//- When not to extrude surface. 0 is flat surface, 90 is when two faces
// make straight angle.
featureAngle 60;

//- Maximum number of snapping relaxation iterations. Should stop
// before upon reaching a correct mesh.
nRelaxIter 3;

// Number of smoothing iterations of surface normals
nSmoothSurfaceNormals 1;//1

// Number of smoothing iterations of interior mesh movement direction
nSmoothNormals 3;

// Smooth layer thickness over surface patches
nSmoothThickness 10;

// Stop layer growth on highly warped cells
maxFaceThicknessRatio 0.5;

// Reduce layer growth where ratio thickness to medial
// distance is large
maxThicknessToMedialRatio 0.3;

// Angle used to pick up medial axis points
minMedianAxisAngle 130;

// Create buffer region for new layer terminations
nBufferCellsNoExtrude 0;

// Overall max number of layer addition iterations
nLayerIter 50;
}



// Generic mesh quality settings. At any undoable phase these determine
// where to undo.
meshQualityControls
{
//- Maximum non-orthogonality allowed. Set to 180 to disable.
maxNonOrtho 65;

//- Max skewness allowed. Set to <0 to disable.
maxBoundarySkewness 20;
maxInternalSkewness 4;

//- 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 projected area v.s. actual area. Set to -1 to disable.
minFlatness 0.5;

//- Minimum pyramid volume. Is absolute volume of cell pyramid.
// Set to very negative number (e.g. -1E30) to disable.
minVol 1e-13;

//- 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
minTwist 0.02;

//- minimum normalised cell determinant
//- 1 = hex, <= 0 = folded or flattened illegal cell
minDeterminant 0.001;

//- minFaceWeight (0 -> 0.5)
minFaceWeight 0.02;

//- minVolRatio (0 -> 1)
minVolRatio 0.01;

//must be >0 for Fluent compatibility
minTriangleTwist -1;


// Advanced

//- Number of error distribution iterations
nSmoothScale 4;
//- amount to scale back displacement at error points
errorReduction 0.75;
}


// Advanced

// Flags for optional output
// 0 : only write final meshes
// 1 : write intermediate meshes
// 2 : write volScalarField with cellLevel for postprocessing
// 4 : write current intersections as .obj files
debug 0;


// Merge tolerance. Is fraction of overall bounding box of initial mesh.
// Note: the write tolerance needs to be higher than this.
mergeTolerance 1E-6;


// ************************************************** *********************** //
ziemowitzima is offline   Reply With Quote

Old   February 11, 2010, 06:38
Default
  #3
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings Ziemowit,

In my limited experience, snappyHexMesh gets a bit annoyed when there are perpendicular edges. So, by what I know, you have two options:
  • make those edges a bit more curved in the STL;
  • set-up the snappyHexMeshDict to refine in area of the in/outlets.
The refinement process will only minimize those jagged edges into very small jagged edges! The curved STL will give a fighting chance to snappy to snap the cells along the curved surface

I've read somewhere on this forum about defining line edges on the snappyHexMeshDict, but last time I saw something about it, it was still on the TODO list for snappyHexMesh

Best Regards,
Bruno Santos

Last edited by wyldckat; February 11, 2010 at 06:40. Reason: missing a space :P
wyldckat is offline   Reply With Quote

Old   February 12, 2010, 05:07
Default
  #4
Senior Member
 
Mieszko Młody
Join Date: Mar 2009
Location: POLAND, USA
Posts: 145
Rep Power: 17
ziemowitzima is on a distinguished road
Hi Bruno,
Thanks for your quick answer and help.
I tried to use Explicit feature edge refinement:
features
(
{
file "someLine.eMesh";
level 2;
}
);

In the file someLine.eMesh I defined outflow edge (set of 132 points going around it circumference) and then edges.
But this didnt improved anything. I think that it is because I defined 131 edges from point to point. Similar like in igloo example.
Do you know how to use it to define one edge as spline for example ?

Best Regards
ZM
ziemowitzima is offline   Reply With Quote

Old   February 12, 2010, 06:02
Default
  #5
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Ziemowit,

Sadly, like I said, I have limited experience with snappyHexMesh. I have only dealt with the motorBike tutorial, and I have yet to test the igloo tutorial! And like I said, I don't know if they have already implemented the edge part of snappyHexMesh

My last advice is to search this forum for "snappyHexMesh edge" and hope to find some thread that already answers your question, or that have asked the same issue about the edge feature!

Best regards,
Bruno Santos

Last edited by wyldckat; February 12, 2010 at 06:03. Reason: typo...
wyldckat is offline   Reply With Quote

Old   March 31, 2010, 23:46
Default
  #6
bjr
Member
 
Ben Racine
Join Date: Mar 2009
Location: Seattle, WA, USA
Posts: 62
Rep Power: 17
bjr is on a distinguished road
Send a message via AIM to bjr Send a message via Skype™ to bjr
My (perhaps incorrect) understanding is that cranking up the 60 in...

// Resolve sharp angles
resolveFeatureAngle 60;

Is intended to do this? Would you volunteer to experiment? My geometries at hand don't lend themselves to quickly inspecting this?

Ben Racine
bjr is offline   Reply With Quote

Old   April 1, 2010, 05:18
Default
  #7
Senior Member
 
Mieszko Młody
Join Date: Mar 2009
Location: POLAND, USA
Posts: 145
Rep Power: 17
ziemowitzima is on a distinguished road
Hi Ben,
Thanks for you interest.
Of course I will experiment with "Resolve sharp angles" value.
But please let me know what value do u suggest ? 90 ?
All Best
Ziemowit
ziemowitzima is offline   Reply With Quote

Old   May 18, 2010, 00:56
Default
  #8
New Member
 
Roman Voronov
Join Date: May 2010
Location: Russia
Posts: 13
Rep Power: 15
rv82 is on a distinguished road
Hello!
Strange! My post appeared not in this topic, but in blogs. Here. Help me please!
rv82 is offline   Reply With Quote

Old   June 24, 2010, 03:05
Default
  #9
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29
niklas will become famous soon enoughniklas will become famous soon enough
I've written a little program that might help, I call it snapEdge.

http://openfoamwiki.net/index.php/Contrib_snapEdge
akidess likes this.
niklas is offline   Reply With Quote

Old   June 24, 2010, 04:15
Default
  #10
Senior Member
 
stephane sanchi
Join Date: Mar 2009
Posts: 314
Rep Power: 18
openfoam_user is on a distinguished road
Hi Niklas,

thanks a lot for the utility snapEdge.

I would like to try it.

Could you explain me how and where to install the directory snapEdge.

Best Regards,

Stephane.
openfoam_user is offline   Reply With Quote

Old   June 24, 2010, 04:33
Default
  #11
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29
niklas will become famous soon enoughniklas will become famous soon enough
I updated the wiki with some instructions.
niklas is offline   Reply With Quote

Old   June 24, 2010, 05:20
Default
  #12
Senior Member
 
stephane sanchi
Join Date: Mar 2009
Posts: 314
Rep Power: 18
openfoam_user is on a distinguished road
Hi Niklas,

I did another way for the installation.
1. Download snapEdge.tgz
2. Unpack it with 'tar zxfv snapEdge.tgz
3. Put the snapEdge folder in .../OpenFOAM/OpenFOAM-1.6.x/applications/utilities/preProcessing
4. Step back into .../OpenFOAM/OpenFOAM-1.6.x/
5. ./Allwmake

and then the snapEdge command runs well.

Thanks a lot Niklas !

I have attached 2 snapshots of a cube (before and after using the snapEdge utility). I have used your own settings.

The length of my cube is 10 meters. Maybe you know how to modify the settings (parameters) in order to obtain a perfect cube.

Thanks again.

Stephane.
Attached Images
File Type: jpg cube_before.jpg (65.5 KB, 478 views)
File Type: jpg cube_after.jpg (65.9 KB, 486 views)
openfoam_user is offline   Reply With Quote

Old   June 24, 2010, 06:20
Default
  #13
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29
niklas will become famous soon enoughniklas will become famous soon enough
Quote:
Originally Posted by openfoam_user View Post
The length of my cube is 10 meters. Maybe you know how to modify the settings (parameters) in order to obtain a perfect cube.
That case should be quite simple, try these

// only move those points that are closer to the features than the tolerance*| edge length |
tolerance 2.0;

// 1.0 = move the points to the edge, 0 = dont move the point
relaxation 1.0;

// number of iterations to move points towards edge
nIterations 1;
niklas is offline   Reply With Quote

Old   June 24, 2010, 06:59
Default
  #14
Senior Member
 
stephane sanchi
Join Date: Mar 2009
Posts: 314
Rep Power: 18
openfoam_user is on a distinguished road
hi,

no the result remains the same !

I attach a zipped tar file. If you have time you can try to improve the mesh.

tar xvzf cube.tar.gz

and run the following commands:
blockMesh
snappyHexMesh -overwrite
snapEdge

Regards,
Stephane
Attached Files
File Type: gz cube.tar.gz (8.1 KB, 70 views)
openfoam_user is offline   Reply With Quote

Old   June 24, 2010, 07:30
Default
  #15
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29
niklas will become famous soon enoughniklas will become famous soon enough
OK, no I see the problem. Your points are right on the vertices of the stl-triangles.

in snapEdge.C
change

Code:
if ((lam0 > 0.0) && (lam0 < 1.0))
to
Code:
if ((lam0 >= 0.0) && (lam0 <= 1.0))
and

Code:
if ((lam1 > 0.0) && (lam1 < 1.0))
to
Code:
if ((lam1 >= 0.0) && (lam1 <= 1.0))
recompile and try again
niklas is offline   Reply With Quote

Old   June 24, 2010, 07:46
Default
  #16
Senior Member
 
stephane sanchi
Join Date: Mar 2009
Posts: 314
Rep Power: 18
openfoam_user is on a distinguished road
Hi,

I made the changes.

Now along the edges the mesh is perfect.

Some small problems remain at the corners. Have a closer look at the second picture.

Stephane.
Attached Images
File Type: jpg cube_after2.jpg (61.0 KB, 216 views)
File Type: jpg cube_corner.jpg (45.1 KB, 261 views)
openfoam_user is offline   Reply With Quote

Old   June 24, 2010, 07:48
Default
  #17
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29
niklas will become famous soon enoughniklas will become famous soon enough
yeah, you have to live with that for now. I still dont know how to fix that
niklas is offline   Reply With Quote

Old   June 24, 2010, 08:14
Default
  #18
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29
niklas will become famous soon enoughniklas will become famous soon enough
hmmm...try this

replace

Code:
 if (d0 < minDist0)
with
Code:
 if ((d0 < minDist0) && (d0 > VSMALL))
and


Code:
 if (d1 < minDist1)
with
Code:
 if ((d1 < minDist1) && (d1 > VSMALL))
niklas is offline   Reply With Quote

Old   June 24, 2010, 08:52
Default
  #19
Senior Member
 
stephane sanchi
Join Date: Mar 2009
Posts: 314
Rep Power: 18
openfoam_user is on a distinguished road
The grid at the corner is improved. Now the corner locations are right, but still a very small problem remains. Look at the attached picture. Thanks !

Stephane
Attached Images
File Type: jpg cube_corner2.jpg (69.4 KB, 404 views)
openfoam_user is offline   Reply With Quote

Old   June 24, 2010, 09:18
Default
  #20
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29
niklas will become famous soon enoughniklas will become famous soon enough
right,

the points can now belong to more than 1 edge and because of that you
should decrease the tolerance to below 1, otherwise the corners will attract more points

set
tolerance 0.99

and this will fix it
niklas is offline   Reply With Quote

Reply

Tags
edges, jagged edges, snappyhexmesh


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[snappyHexMesh] snappyHexMesh sticking point natty_king OpenFOAM Meshing & Mesh Conversion 11 February 20, 2024 09:12
[snappyHexMesh] snappyHexMesh does not create any mesh except one for the reference cell Arman_N OpenFOAM Meshing & Mesh Conversion 1 May 20, 2019 17:16
[snappyHexMesh] sHM layer process keeps getting killed MBttR OpenFOAM Meshing & Mesh Conversion 4 August 15, 2016 03:21
[snappyHexMesh] No layers in a small gap bobburnquist OpenFOAM Meshing & Mesh Conversion 6 August 26, 2015 09:38
[snappyHexMesh] snappyHexMesh won't work - zeros everywhere! sc298 OpenFOAM Meshing & Mesh Conversion 2 March 27, 2011 21:11


All times are GMT -4. The time now is 18:55.