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

Problem of sharp interface in mesh while using snappyHexMesh (SHM)

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 1 Post By chandra shekhar pant
  • 1 Post By xpqiu
  • 1 Post By Rasmusiwersen
  • 1 Post By Rasmusiwersen
  • 1 Post By Rasmusiwersen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 14, 2019, 04:31
Default Problem of sharp interface in mesh while using snappyHexMesh (SHM)
  #1
Senior Member
 
chandra shekhar pant
Join Date: Oct 2010
Posts: 220
Rep Power: 17
chandra shekhar pant is on a distinguished road
Dear Foamers,


Since I am new to the snappyHexMesh (SHM) thus tried to mesh a simple geometry of the aerofoil NACA0015 in 3D. Initially I started with the addlayers true, but found that, to start with this should be false, because it is the major source of error. But even for this simplified case, the mesh looks very bad, tried playing with the numbers like:
1. increasing the maxLocalCells and maxGlobalCells by 10 times
2. increasing the nCellsBetweenLevels from 2 to 4
3. increasing features level from
(
{
file "airfoil.eMesh";
level 3;
}
);
4.increasing refinmentSurfaces from level (4 4) to level (5 5)
refinementSurfaces
{
airfoil
{
level (5 5);
}
}
etc, the SHM script is attached herewith.
But still the mesh looks very much odd (attached herewith).
Any help/comments are highly welcomed. Thanks!
Attached Images
File Type: png mesh_discont_aerofoil.png (52.0 KB, 70 views)
Attached Files
File Type: c snappyHexMeshDict_cfdonline.c (11.3 KB, 4 views)
chandra shekhar pant is offline   Reply With Quote

Old   November 25, 2019, 08:05
Default
  #2
New Member
 
Qiu Xiaoping
Join Date: Apr 2013
Location: IPE CAS China
Posts: 14
Rep Power: 14
xpqiu is on a distinguished road
This is more a paraview "issue", before doing slice, deselect "Decompose polyhedra" in the tab "Properties", after create a slice, deselect "Triangule the slice". Another trick is to avoid coincidence of the location of slice with any grid point, for example, if your want a y=0 slice, you should instead offset the slice by a tiny number, say y=0.00001234454 . By the way, it is recommended to use a background mesh with equal size at all directions.
__________________
xpqiu
q.giskard@gmail.com
xpqiu is offline   Reply With Quote

Old   November 25, 2019, 08:29
Default
  #3
Senior Member
 
Kmeti Rao
Join Date: May 2019
Posts: 145
Rep Power: 8
Krao is on a distinguished road
Quote:
Originally Posted by xpqiu View Post
This is more a paraview "issue", before doing slice, deselect "Decompose polyhedra" in the tab "Properties", after create a slice, deselect "Triangule the slice". Another trick is to avoid coincidence of the location of slice with any grid point, for example, if your want a y=0 slice, you should instead offset the slice by a tiny number, say y=0.00001234454 . By the way, it is recommended to use a background mesh with equal size at all directions.
With those, you can also select Crinkle slice option.
Krao is offline   Reply With Quote

Old   November 25, 2019, 08:50
Default
  #4
Senior Member
 
chandra shekhar pant
Join Date: Oct 2010
Posts: 220
Rep Power: 17
chandra shekhar pant is on a distinguished road
Dear Qiu Xiaoping and K Rao,


Many thanks for your input. But still there is no improvement, I am still getting the steps in the mesh. I think there is a problem in my SHM script which is creating this issue. Please find the updated mesh pic herewith, as you can see there is no improvement in it.


Any further inputs are welcomed.


Thanks a lot!
Attached Images
File Type: png after_deselct_decomposepoly.png (31.0 KB, 34 views)
chandra shekhar pant is offline   Reply With Quote

Old   November 25, 2019, 09:31
Default
  #5
Senior Member
 
Kmeti Rao
Join Date: May 2019
Posts: 145
Rep Power: 8
Krao is on a distinguished road
I don't think there would be a problem in the script. I personally use cfMesh, but many people here in forum using SHM without any problem. Maybe you should see how your refinements are carried out. I have very little experience with SHM.
Krao is offline   Reply With Quote

Old   November 25, 2019, 09:36
Default
  #6
Senior Member
 
chandra shekhar pant
Join Date: Oct 2010
Posts: 220
Rep Power: 17
chandra shekhar pant is on a distinguished road
Dear K Rao,


Off course, I understand that, SHM is a great tool for meshing. I am just saying that I am not doing the things correctly. That's why I had shared my SHM script herewith to get some help in this regard. I think you misunderstood me. Sorry for that!


In simple words, I am bad not the "SHM"!
Krao likes this.
chandra shekhar pant is offline   Reply With Quote

Old   November 25, 2019, 23:51
Default
  #7
New Member
 
Qiu Xiaoping
Join Date: Apr 2013
Location: IPE CAS China
Posts: 14
Rep Power: 14
xpqiu is on a distinguished road
Aspect ratio of your background mesh is much larger than 1, this is not a good practice for snappyHexMesh. You have set nCellBetweenLevels to 4, which means 4 buffer cell are used between levels. Let's suppose the aspect ratio of your background box is 3:1(z:x), then 4 cells in the z direction will stretch 3 times farther than in the x direction, and I think this is the caustion of the steps you metioned above.
__________________
xpqiu
q.giskard@gmail.com
xpqiu is offline   Reply With Quote

Old   November 26, 2019, 02:44
Default
  #8
Senior Member
 
chandra shekhar pant
Join Date: Oct 2010
Posts: 220
Rep Power: 17
chandra shekhar pant is on a distinguished road
Hi Qiu Xiaoping,



Many thanks for these inputs, so what you suggest:


1. Change the background mesh (blockmesh) presently domain is (8.5 x 0.8 x 6) and mesh points are: (220 x 60 x 100) , to the mesh points of something: (180 x 17 x 128)?



2. Should I change the nCellbetweenLevels also ?


Any other suggestion, I will try with these and update.


Thanks again for your kind help.
chandra shekhar pant is offline   Reply With Quote

Old   November 26, 2019, 05:21
Default
  #9
Senior Member
 
chandra shekhar pant
Join Date: Oct 2010
Posts: 220
Rep Power: 17
chandra shekhar pant is on a distinguished road
Hello Qiu Xiaoping,



Many thanks for your inputs, your inputs had helped me to get off the issues of non-orthogonality and skewness while checking the checkMesh utility. What I had primarily done is :
1. Refine the background mesh using blockmesh
2. To make the aspect ratio of close 1, deltax=deltay=deltaz (Lx/Nx, Ly/Ny, Lz/Nz), where L is length and N are the no of points in the blockMesh.



But unfortunately, the mesh still looks very steppy, I don't know why?


The screenshot of the mesh, report of checkMesh, blockMesh and snappyHexMesh is attached herewith.


I am really grateful to you for your time and useful help.
Attached Images
File Type: png grid_bmesh.png (50.0 KB, 28 views)
Attached Files
File Type: c checkMesh_after_bmesh.c (3.4 KB, 0 views)
File Type: c log_blockMeshDict.c (1.7 KB, 0 views)
File Type: c log_snappyHexMeshDict.c (11.4 KB, 1 views)
chandra shekhar pant is offline   Reply With Quote

Old   November 26, 2019, 06:33
Default
  #10
Member
 
Rasmus Iwersen
Join Date: Jan 2019
Location: Denmark
Posts: 81
Rep Power: 8
Rasmusiwersen is on a distinguished road
Quote:
Originally Posted by chandra shekhar pant View Post
Hello Qiu Xiaoping,



Many thanks for your inputs, your inputs had helped me to get off the issues of non-orthogonality and skewness while checking the checkMesh utility. What I had primarily done is :
1. Refine the background mesh using blockmesh
2. To make the aspect ratio of close 1, deltax=deltay=deltaz (Lx/Nx, Ly/Ny, Lz/Nz), where L is length and N are the no of points in the blockMesh.



But unfortunately, the mesh still looks very steppy, I don't know why?


The screenshot of the mesh, report of checkMesh, blockMesh and snappyHexMesh is attached herewith.


I am really grateful to you for your time and useful help.
Have you tried using the "distance" mode in the refinementRegions subdictionary in snappy? It specifies a minimum distance from the .stl surface you have provided, and refines the mesh to a degree of your choosing making the transition between refinement layers much more smooth. The syntax is:

refinementRegions
{
SURFACENAME
{ //
mode distance; // refinement level 3 within 2.0 m
levels ((1.0 5) (2.0 3)); // (1.0 5) means refine mesh within 1 meter to level 5 and again (2.0 3) just means within 2 meters refine to level 3.
}
}
Hope this helps
Rasmusiwersen is offline   Reply With Quote

Old   November 26, 2019, 08:33
Default
  #11
Senior Member
 
chandra shekhar pant
Join Date: Oct 2010
Posts: 220
Rep Power: 17
chandra shekhar pant is on a distinguished road
Hello Rasmus Iwersen,

Many thanks for your input and will implement and update. A very naive question does the "levels ((1.0 5) (2.0 3))" changes depending on the geometry, or it is used as such. I would guess that the the parameters 1 and 2 depends on the refinement region and the computational box? Sorry for this question.
And many thanks for your time and help. I will update the outcome.
Thanks a lot!
chandra shekhar pant is offline   Reply With Quote

Old   November 26, 2019, 08:45
Default
  #12
Member
 
Rasmus Iwersen
Join Date: Jan 2019
Location: Denmark
Posts: 81
Rep Power: 8
Rasmusiwersen is on a distinguished road
Quote:
Originally Posted by chandra shekhar pant View Post
Hello Rasmus Iwersen,

Many thanks for your input and will implement and update. A very naive question does the "levels ((1.0 5) (2.0 3))" changes depending on the geometry, or it is used as such. I would guess that the the parameters 1 and 2 depends on the refinement region and the computational box? Sorry for this question.
And many thanks for your time and help. I will update the outcome.
Thanks a lot!
No worries, hope it helps!

Regarding your question, "levels ((1.0 5) (2.0 3))" should be changed according to your specific case. I've previously used it in the following way:

"levels ((0.125 5) (2 4) (4 3))"
because i needed to resolve the boundary layer, which i estimated extended to maximum 0.125 meters from the surface of interest, hence the refinement level of 5 (I should probably have used addLayers to resolve the boundary layer properly, although i didn't know how to use it at that point.. We all learn right?).
Then i refined a distance of 2 meters around the obstacle to refinement level 4 to ensure proper vortex generation and development.
Lastly i refined the outer region at a distance of 4 meters from the obstacle to ensure a smooth transition between the background mesh (where it was assumed that the effect of vortices had worn out) and the refinement regions.

So in summation, you can add as many refinement regions you want, and theoretically refine them to infinitisemal sizes. Note however, (in my experience) refinement levels (i.e. 5, 4 and 3 in the above example) should usually not exceed 5 or maybe 6, as this results in very fine mesh. Remember that snappy changes refinement levels by halfing each cell in 3 dimensions (for 3D simulations), meaning 1 cell in refinement 0 becomes 8 (2 new cells in x, 2 new cells in y and 2 new cells in z) cells in refinement level 1.

So in your case, you probably dont need a refinement region 4 meters from the surface, perhaps you can ude the addLayers control to resolve the boundary layer, then add one or two refinement regions around the airfoil to make sure vortex generated pressure gradients in "far field" are accounted for.

Hope it makes sense.
Rasmusiwersen is offline   Reply With Quote

Old   November 26, 2019, 09:22
Default
  #13
Senior Member
 
chandra shekhar pant
Join Date: Oct 2010
Posts: 220
Rep Power: 17
chandra shekhar pant is on a distinguished road
Hi Rasmus Iwersen,



Great! thanks a lot for the detailed explanation. What I mean by the changing the parameter is that, to start with I generally take a region called "refinementBox" , in this case it extends from [min (-0.1 -0.4 -0.5); max ( 2.5 0.4 0.5);], thus I guess that this refinementRegions should be compatible with the "refinementBox" ?



To your comment "We all learn right?", that's perfect. I am also trying with the nlayers to capture the yplus values. Please correct me, if I am doing it wrong:
1. Length scale = 0.1 m, velocity=11 m/s, for water viscosity=8.9x10-4
2. Using this link https://www.fluidmechanics101.com/pages/tools.html, i tend to find the yp close to 10^-5. corresponding to yplus of 20. Since in the previous post you and others have mentioned to be in range of 20-200 (I guess).
3. To account this yp, I change the SHM to add layers
4. Particularly, I add these lines:
layers
{
aerofoil
{
nSurfaceLayers 5;

}

}
and

firstLayerThickness 10^-5
I don't know if something else be done? Also not sure how many layers to be sufficient.


Since, now I found you who is an expert for me, I guess my problems related to SHM will be resolved. Thanks for your wonderful help and suggestions.


Thanks a lot!
chandra shekhar pant is offline   Reply With Quote

Old   November 26, 2019, 09:50
Default
  #14
Member
 
Rasmus Iwersen
Join Date: Jan 2019
Location: Denmark
Posts: 81
Rep Power: 8
Rasmusiwersen is on a distinguished road
Quote:
Originally Posted by chandra shekhar pant View Post
Hi Rasmus Iwersen,



Great! thanks a lot for the detailed explanation. What I mean by the changing the parameter is that, to start with I generally take a region called "refinementBox" , in this case it extends from [min (-0.1 -0.4 -0.5); max ( 2.5 0.4 0.5);], thus I guess that this refinementRegions should be compatible with the "refinementBox" ?
I see, i misunderstood sorry about that. No, it doesn't have to be inside the refinementBox. You can specify the refinementRegions anywhere you like with no regard to a refinementBox. RefinementBoxes are used in areas not in reference with the stl surface of interest. As an example, if you model a multiphase flow around a cylinder, and you for some reason want the interphase to be in a fine resolution, you can use the refinementBox.
In addition, you can make the refinementbox and refinement region overlap. As a matter of fact, this is what i am currently doing in a free surface flow around an array of cylinders. I need the surfaceelevation close to the cylinder, so i mix refinementRegion and refinementBox. I am not aware if this is common practice, or just an "ad hoc" solution no one else is using...


To your comment "We all learn right?", that's perfect. I am also trying with the nlayers to capture the yplus values. Please correct me, if I am doing it wrong:
Quote:
Originally Posted by chandra shekhar pant View Post
1. Length scale = 0.1 m, velocity=11 m/s, for water viscosity=8.9x10-4
I don't know the geometry you are modelling, but for reference i usually use Length scale = Diameter of cylinder.

2. Using this link
Quote:
Originally Posted by chandra shekhar pant View Post
https://www.fluidmechanics101.com/pages/tools.html, i tend to find the yp close to 10^-5. corresponding to yplus of 20. Since in the previous post you and others have mentioned to be in range of 20-200 (I guess).
Great! Good idea! Just for reference, the same "first cell height calculator" tool is also available on this site here: https://www.cfd-online.com/Tools/yplus.php .

Quote:
Originally Posted by chandra shekhar pant View Post
3. To account this yp, I change the SHM to add layers
4. Particularly, I add these lines:
layers
{
aerofoil
{
nSurfaceLayers 5;

}

}
and

firstLayerThickness 10^-5
I don't know if something else be done? Also not sure how many layers to be sufficient.
I haven't actually used firstLayerThickness, but instead finalLayerThickness... No particular reason why. I've managed to get the first layer to be equal to what the yPlus estimator suggested, which when postProcessing have provided me with the target yPlus.

Just for you to get inspired by, here is my addLayer control:
addLayersControls
{
// Are the thickness parameters below relative to the undistorted
// size of the refined cell outside layer (true) or absolute lengths(false).
relativeSizes false;

// Per final patch (so not geometry!) the layer information
layers
{
"cylinder1"
{
nSurfaceLayers 14; //Was 20
}
"cylinder2"
{
nSurfaceLayers 14; //Was 20
}
"cylinder3"
{
nSurfaceLayers 14; //Was 20
}
"cylinder4"
{
nSurfaceLayers 14; //Was 20
}
}

// Expansion factor for layer mesh
expansionRatio 1.1; //Was 1.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.
// See relativeSizes parameter.
finalLayerThickness 0.03;

// 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. Should be lower than final layer thickness!!!
minThickness 0.001;

// 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)
nGrow 0;

// Advanced settings

// When not to extrude surface. 0 is flat surface, 90 is when two faces
// are perpendicular
featureAngle 180;

// 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
// before upon reaching a correct mesh.
nRelaxIter 10; //Was 3

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

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

// Smooth layer thickness over surface patches
nSmoothThickness 15; //Was 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
// Note: changed(corrected) w.r.t 17x! 90 degrees corresponds to 130 in 17x.
minMedianAxisAngle 90;


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


// Overall max number of layer addition iterations. The mesher will exit
// if it reaches this number of iterations; possibly with an illegal
// mesh.
nLayerIter 75; //Was50
}
I have adjusted following parameters the most in my models:
relativeSizes false; (Setting it to false means what every you define from this point onwards is not relative to the patch dimensions. If set to true, finalLayerThickness would be in relation to the patch length. i.e. finalLayerThickness=0.5 would mean half the patch length. This is at least what I've experienced when looking for answers here on cfd-online.)
nSurfaceLayers 14; (This might seem slightly high, however this is how i controlled the value of yplus most directly in addition with finalLayerThickness)
finalLayerThickness 0.03; (This is just the maximum distance you want one cell in the boundary layer to have. Boundary layers are USUALLY not more than say 0.2 meters in height (note this is in terms of flow around cylinders in offshore construction representable dimensions). Therefore 0.03 meters for the outer layer in the boundary layer that i am creating seems fair.
expansionRatio 1.1; (This is a good way of not having too many cells in the same size as the one closest to your structure. Ultimately this speeds up calcualtions to some degree)
Since, now I found you who is an expert for me, I guess my problems related to SHM will be resolved. Thanks for your wonderful help and suggestions.
minThickness 0.001; (Should be lower than finalLayerThickness). Haven't really anything clever to say about this one, except by specifying this you wont have cells that are 1e-10 or so in size.

The geometries in my models are often very simple (circular, square, quadratic) so the other parameters are not of major importance for me. The more complex geometries you have, the more you need to adjust each parameter based on how the mesh looks when you are creating it.

Wauw... Sorry for all this text, i hope it is not too confusing. The subject is quite large and I am sure many others have different ways of reaching the same goal.

Oh.. And dont mind the //Was..... comments. They are just personal comments.
Rasmusiwersen is offline   Reply With Quote

Old   November 27, 2019, 03:22
Default
  #15
Senior Member
 
chandra shekhar pant
Join Date: Oct 2010
Posts: 220
Rep Power: 17
chandra shekhar pant is on a distinguished road
Hi Rasmus Iwersen,



Many thanks for your detailed answer. I will try to explain my set up, I am trying to mesh the aerofoil NACA0015, at an angle of attack of 9 degree, with chord length of 0.1 m, the spanwise length is 2% of chord length =0.02 m and the streamwise length is 0.015 m, therefore the overall bounding box of the aerofoil is

min (-3.2 x 10^-5, -0.01, -0.0157653) to max (0.0987688, 0.01, 0.0042869).


So essentially trying to see the wakes, tip vortices due to the aerofoil thus make a refinementbox, whose dimensions are:
min (0.01, -0.04, -0.05) to max (0.25, 0.04, 0.05).


Taking nCellsBetweenLevels be 5.


Extracting the features through level 5 as:

features
(
{
file "airfoil.eMesh";
level 5;
}
);
Defining the refinementSurfaces for aerofoil as:
refinementSurfaces
{
airfoil
{
// Surface-wise min and max refinement level
level (5 5);
}
}
resolveFeatureAngle 80;
refinementRegions
{
refinementBox
{
mode inside;
levels ((1E15 4));

}
}
The complete SHM file is attached herewith. So, effectively, I am defining the refinementSurfaces only for the aerofoil and not for the refinementbox, similarly defining the refinementRegions only for the refinementbox and not for the aerofoil. Is it correct?



I am very new to SHM so many of the things I might have copied from here and there without thinking about it. Sorry for that. To start with I am making the addLayers to be false.
Attached Files
File Type: c snappyHexMeshDict_naca0015.c (10.9 KB, 4 views)

Last edited by chandra shekhar pant; November 27, 2019 at 03:41. Reason: Sorry I was just trying to make it work, since earlier it was giving me an error
chandra shekhar pant is offline   Reply With Quote

Old   November 27, 2019, 03:25
Default
  #16
Member
 
Rasmus Iwersen
Join Date: Jan 2019
Location: Denmark
Posts: 81
Rep Power: 8
Rasmusiwersen is on a distinguished road
Just tried the firstLayerThickness on my model, turned out to be a better match compared to finalLayerThickness. The result is somewhat the same, i just find it easier to control the wanted layer around my obstacles. So thank you
Rasmusiwersen is offline   Reply With Quote

Old   November 27, 2019, 08:17
Default
  #17
Senior Member
 
chandra shekhar pant
Join Date: Oct 2010
Posts: 220
Rep Power: 17
chandra shekhar pant is on a distinguished road
Dear All,


I think I made it. May be useful for someone, I guess that in the features decrease the level 1 or may be 0. What I understand from this example is that, there are very fine edges at the stl file, which results in the amplified steps if I go on increasing the level of the feature. The updated screenshot is attached herewith.



Thanks a lot to all of you.
Attached Images
File Type: png corrected_aerofoil.png (82.9 KB, 23 views)
chandra shekhar pant is offline   Reply With Quote

Old   November 29, 2019, 07:20
Default
  #18
Senior Member
 
chandra shekhar pant
Join Date: Oct 2010
Posts: 220
Rep Power: 17
chandra shekhar pant is on a distinguished road
Hello Rasmus Iwersen,


I am surprised that while using finalLayerThickness I am able to add 1.93 layers, but by using the firstLayerThickness I am unable to add any layer.

Now, I am very much confused with the addlayers, could you please let me know what additional changes you have made from moving from finalLayerThickness to firstLayerThickness.


Also a general query that, does the adding 1.93 layers make sense? Also these short of layers are creating problem if I have to use the cyclic boundary condition. These issues looks very weird to me, I am guessing I am doing some thing very silly. Any help or comment is highly welcomed.
chandra shekhar pant is offline   Reply With Quote

Reply


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
[Other] splitMeshRegions does not create interface patch between regions fsan OpenFOAM Meshing & Mesh Conversion 10 June 6, 2022 06:56
[snappyHexMesh] Problem with skewd faces in SnappyHexMesh Friendly OpenFOAM Meshing & Mesh Conversion 1 June 19, 2019 08:05
[snappyHexMesh] problem with snappyHexMesh kanes OpenFOAM Meshing & Mesh Conversion 10 January 26, 2016 07:11
[mesh manipulation] Importing Multiple Meshes thomasnwalshiii OpenFOAM Meshing & Mesh Conversion 18 December 19, 2015 19:57
[snappyHexMesh] No layers in a small gap bobburnquist OpenFOAM Meshing & Mesh Conversion 6 August 26, 2015 10:38


All times are GMT -4. The time now is 19:48.