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

[snappyHexMesh] 2D Cylinder mesh problems with Snappy

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 13, 2010, 06:40
Default 2D Cylinder mesh problems with Snappy
  #1
Senior Member
 
Ivan Flaminio Cozza
Join Date: Mar 2009
Location: Torino, Piemonte, Italia
Posts: 210
Rep Power: 18
ivan_cozza is on a distinguished road
Send a message via MSN to ivan_cozza
Hi Foamers,
I'm trying to mesh a 2D cylinder (1 cell in z direction) using snappy, following the tutorial tutorials/incompressible/pimpleDyMFoam/wingFlutter, where a 2D airfoil is meshed with snappy.

It seems that with my settings snappy is not capable to recognize correctly the cylinder (that is an stl surface obtained with gmsh), and it doesn't cut the mesh.

I attach the resulting mesh, blockMeshDict and snappyHexMeshDict.

Could anybody help me to fix it?

Thanks, Ivan

http://img547.imageshack.us/i/snappycyl.jpg/

http://img821.imageshack.us/i/snappycylonly.jpg/

http://img547.imageshack.us/i/snappycylzoom.jpg/
Attached Files
File Type: txt blockMeshDict.txt (1.5 KB, 115 views)
File Type: txt snappyHexMeshDict.txt (9.9 KB, 135 views)

Last edited by wyldckat; September 3, 2015 at 18:47. Reason: disabled embedded images
ivan_cozza is offline   Reply With Quote

Old   September 13, 2010, 12:22
Default
  #2
Senior Member
 
Join Date: Mar 2009
Location: My oyster
Posts: 124
Rep Power: 17
ziad is on a distinguished road
Hi Ivan,

It looks like there is a problem with your stl file. The surface cylinder is not closed. Also your refinement boxes seem messed up. If you're doing 2D they should be like this:

refinementBox1
{
type searchableBox;
min (-1 -0.5 -0.1);
max ( 1 0.5 0.1); //changed 0.06 to 0.1
}
refinementBox2
{
type searchableBox;
min (-0.05 -0.05 -0.1);
max ( 0.05 0.05 0.01); //changed -0.01 to 0.1
}

otherwise with the old settings you will probably get more than one cell in the z-direction.
ziad is offline   Reply With Quote

Old   October 26, 2010, 22:02
Default
  #3
Senior Member
 
Daniel
Join Date: Jul 2009
Location: Montreal, Canada
Posts: 156
Rep Power: 17
dancfd is on a distinguished road
Hi Ziad,

I am running into a problem that you might have an answer to, given your last response to Ivan. I am trying to make snappyHexMesh produce a 2D mesh on the airfoil in the wingMotion tutorial. I tried changing the snappyHexMeshDict refinement box as follows:

Code:
    refinementBox
    {
        type searchableBox;
        min (-1 -1 -0.1);//min (-1 -1 -1);
        max (5 1 0.1);//max ( 5  1  1);
    }
changing the z-coordinate to match the bounding box in the blockMeshDict. Unfortunately, this had no effect on the number of cells in the z-direction; still >1 therefore not 2D. Do you have any idea how I could make this 2D?

I posted this issue first a couple of days ago in another thread (http://www.cfd-online.com/Forums/ope...-tutorial.html) before I saw your post.

Thanks,

Dan
dancfd is offline   Reply With Quote

Old   October 26, 2010, 22:22
Default
  #4
Senior Member
 
Join Date: Mar 2009
Location: My oyster
Posts: 124
Rep Power: 17
ziad is on a distinguished road
Hi Daniel,

I tried once to make a 2D mesh with sHM but got more than one cell in the z direction. I think this is due to the fact that sHM divides whatever you have initially in blockMesh in the z direction by the specified number of levels. Not sure how to get around that. Since it was a simple rectangular shape I ended up using blockMesh which is quite good for simple cartesian shapes.

Try maybe meshing only one of the empty bc planes with sHM and then extrude the mesh in the z direction? You should only have one z coordinate throughout sHMDict.

Let me know how it works.
Ziad
ziad is offline   Reply With Quote

Old   October 26, 2010, 22:36
Default
  #5
Senior Member
 
Daniel
Join Date: Jul 2009
Location: Montreal, Canada
Posts: 156
Rep Power: 17
dancfd is on a distinguished road
Hi Ziad,

Thanks for the response. The z-coordinate only appears twice in sHMdict, where the boundingbox is defined. Unfortunately, I do not think the extrude function will not work for me because I have divided my geometry (airfoil) into two patches (a wing and a flap), but since there is one continuous object, extrude followed by autoPatch would recognize the airfoil as only one patch. Is it possible to delete the offensive points, blocks and edges from the polyMesh directory manuallly? I imagine this might be next to impossible. I'll keep working this.

Thanks again,

Dan
dancfd is offline   Reply With Quote

Old   October 26, 2010, 23:10
Default
  #6
Senior Member
 
Join Date: Mar 2009
Location: My oyster
Posts: 124
Rep Power: 17
ziad is on a distinguished road
Quote:
Originally Posted by dancfd View Post
Hi Ziad,

Thanks for the response. The z-coordinate only appears twice in sHMdict, where the boundingbox is defined. Unfortunately, I do not think the extrude function will not work for me because I have divided my geometry (airfoil) into two patches (a wing and a flap), but since there is one continuous object, extrude followed by autoPatch would recognize the airfoil as only one patch. Is it possible to delete the offensive points, blocks and edges from the polyMesh directory manuallly? I imagine this might be next to impossible. I'll keep working this.

Thanks again,

Dan
Just set the z-coordinate to one value everywhere. I just took a look at the extrudeMesh tool and it seems to allow specification of individual patches so you might not run into problems there. Of course I am assuming sHM will be able to handle a pure 2D mesh to start with. We're kinda cheating here but it's worth a shot.
ziad is offline   Reply With Quote

Old   October 27, 2010, 04:25
Default
  #7
Senior Member
 
Ivan Flaminio Cozza
Join Date: Mar 2009
Location: Torino, Piemonte, Italia
Posts: 210
Rep Power: 18
ivan_cozza is on a distinguished road
Send a message via MSN to ivan_cozza
Hi Daniel,
I've answered you about 2D in SHM on your other thread.
Can you give me in more details your problem in extruding an unconnected boundary like a wing with a slat? I have a very similar problem, for which I'm managing to use extrude...

Quote:
Originally Posted by dancfd View Post
Hi Ziad,

Thanks for the response. The z-coordinate only appears twice in sHMdict, where the boundingbox is defined. Unfortunately, I do not think the extrude function will not work for me because I have divided my geometry (airfoil) into two patches (a wing and a flap), but since there is one continuous object, extrude followed by autoPatch would recognize the airfoil as only one patch. Is it possible to delete the offensive points, blocks and edges from the polyMesh directory manuallly? I imagine this might be next to impossible. I'll keep working this.

Thanks again,

Dan
ivan_cozza is offline   Reply With Quote

Old   October 27, 2010, 09:50
Default
  #8
Senior Member
 
Join Date: Mar 2009
Location: My oyster
Posts: 124
Rep Power: 17
ziad is on a distinguished road
Quote:
Originally Posted by ziad View Post
Just set the z-coordinate to one value everywhere. I just took a look at the extrudeMesh tool and it seems to allow specification of individual patches so you might not run into problems there. Of course I am assuming sHM will be able to handle a pure 2D mesh to start with. We're kinda cheating here but it's worth a shot.
actually come to think of it you could keep the original sHM mesh with more than 1 cell in the z-dir, extrude one of the empty faces exactly one cell in the z-direction, select that set of the mesh and cut it out.
ziad is offline   Reply With Quote

Old   October 27, 2010, 18:01
Default
  #9
Senior Member
 
Daniel
Join Date: Jul 2009
Location: Montreal, Canada
Posts: 156
Rep Power: 17
dancfd is on a distinguished road
Hi Ziad,

I tried setting the boundingBox coordinates in the same xy plane, however this just eliminated the effect of the boundingBox. I am very interested in using the extrusion to cut the mesh. Can you please provide some detail about how to do this? Looking at the extrudeProperties dictionary, I do not see how it is possible to cut the mesh. I have attached pictures of the side view of the mesh. The zoomed-out pic shows the majority of the domain as 1-cell deep, with a white square in the center. The zoomed-in pic shows the upper-left corner of this white square, which is in fact a highly resolved mesh of the front/back of the airfoil. If I extrude the empty front patch one cell, will it cut one "airfoil thickness" cell, or one "majority of the domain" cell deep?

Thanks,
Dan
Attached Images
File Type: jpg sideview.jpg (10.4 KB, 188 views)
File Type: jpg sideviewzoom.jpg (82.3 KB, 205 views)
dancfd is offline   Reply With Quote

Old   October 27, 2010, 19:43
Default
  #10
Senior Member
 
Join Date: Mar 2009
Location: My oyster
Posts: 124
Rep Power: 17
ziad is on a distinguished road
Hi Dan,

The extrude/cut process involves using extrudeMesh (which doesn't cut) first and then splitMesh (which cuts) to make the internal boundary external. splitMesh is a bit tricky to use. Will take a look at both later tonight and post what I can come up with.

Just a thought about using sHM in pure 2D mode, you'll probably have to start up your domain in blockMesh with blocks consisting of one flat plane. You'd have to collapse one empty plane into the other, or in other words, use exactly the same physical points on both empty planes.

Ziad

Quote:
Originally Posted by dancfd View Post
Hi Ziad,

I tried setting the boundingBox coordinates in the same xy plane, however this just eliminated the effect of the boundingBox. I am very interested in using the extrusion to cut the mesh. Can you please provide some detail about how to do this? Looking at the extrudeProperties dictionary, I do not see how it is possible to cut the mesh. I have attached pictures of the side view of the mesh. The zoomed-out pic shows the majority of the domain as 1-cell deep, with a white square in the center. The zoomed-in pic shows the upper-left corner of this white square, which is in fact a highly resolved mesh of the front/back of the airfoil. If I extrude the empty front patch one cell, will it cut one "airfoil thickness" cell, or one "majority of the domain" cell deep?

Thanks,
Dan
ziad is offline   Reply With Quote

Old   October 27, 2010, 21:38
Default
  #11
Senior Member
 
Daniel
Join Date: Jul 2009
Location: Montreal, Canada
Posts: 156
Rep Power: 17
dancfd is on a distinguished road
Hi Ziad,

There is also another tool called "removeFaces" which, from the brief description in the user guide, should merge cells. If I could do this to all of the cells across the z-axis, then I would arrive at a 2-D mesh. Have you used removeFaces before? I have looked at the code and scanned the boards, but documentation on using it appears to be scarce.

Code:
Usage: removeFaces <faceSet> [-overwrite] [-parallel] [-case dir]  [-help] [-doc] [-srcDoc]
It looks to me like I need to identify the faces that are between the two "empty" planes and parallel to them, then list all of these faces in a file and run removeFaces with reference to that file. To identify the appropriate faces from the list of 500K+, I will have to select the faces that consist only of points in the same z-plane, where that plane is not one of the empty planes. I will try to write a script to accomplish this, and let you know what I find.

Dan

Thanks,
Dan

Last edited by dancfd; October 27, 2010 at 22:24.
dancfd is offline   Reply With Quote

Old   October 28, 2010, 22:31
Default SnappyHexMesh in 2D
  #12
Senior Member
 
Daniel
Join Date: Jul 2009
Location: Montreal, Canada
Posts: 156
Rep Power: 17
dancfd is on a distinguished road
In case anyone is interested, I have attached a script that can be run in Octave that will read the points and faces files of a mesh and output all of the internal faces parallel to the empty patches into a faceSet file. Place the faceSet file in the polymesh/sets directory, run removeFaces remFaces -overwrite, and you will transform your snappyHexMesh from 3D into a 2D mesh. I just tried it on the movingWing tutorial and it appears to have worked. Note that the z-coordinates of the empty patches must be entered in the script - it is hardcoded for z = +- 0.1 now. Enjoy.

Dan
Attached Files
File Type: zip removeFacesScriptv2.m.zip (1.4 KB, 36 views)
dancfd is offline   Reply With Quote

Old   October 30, 2010, 15:05
Default creating a 2D mesh with snappyHexMesh
  #13
Senior Member
 
Join Date: Mar 2009
Location: My oyster
Posts: 124
Rep Power: 17
ziad is on a distinguished road
Hi Daniel,

I finally got to spend some time on this and figured out how to do it using only OpenFoam tools. The procedure outline is the following but does not require splitMesh:

  1. run blockMesh: to get the mesh bounding box.
  2. run snappyHexMesh -overwrite: to get the full mesh in the constant/polyMesh directory.
  3. run extrudeMesh: on boundary front by a positive distance, the sign of the outward normal to this boundary. I used delta_z = 1.0 from the original z = 0.1 plane. The extrudeProperties dictionary is provided and should reside in the constant directory. It will create 3 patches, originalPatch (the original front patch in plane z = 0.1), otherSide (extruded front patch now in plane z=1.1), and sides. The last one, sides, consists of the extrusions of the bounding curves of the original front. Therefore it includes the extrusions of inlet, exit, top, bottom and airfoil. These will be separated next.
  4. run autoPatch 90: where 90 is the feature angle to search for and the actual angle between the parts of sides and the other two patches. You will get 7 additional patches named auto0 to auto6. The original three patches from the extrusion process now have 0 faces in them in the constant/polyMesh/boundary file and the total boundary number is 10 right after the file header. Edit the constant/polyMesh/boundary file, remove the sections pertaining to the original 3 extrusion boundaries, and adjust the total number of boundaries to 7. You might want to rename the boundaries from auto* to more meaningful names such as inlet, exit, airfoil, etc. I've provided my final boundary file from that step as well for reference.
The following 3 steps are optional. Use them if you want to divide the airfoil in parts (slats, flaps, whatever...):
    1. run faceSet: now we want to extract the faces from the airfoil patch and put them in a new face set, f0, in order to separate the flap in the next step. Here we use options "action new" and patchToFace. These are commented in the provided faceSetDict file which should reside in the system folder.
    2. run faceSet: now we want to extract the flap part from the existing face set f0, so we use options "action subset" and boxToFace where the specified box should enclose the face centres of the flap part of the airfoil. I picked the last delta-x = 0.4 therefore my box extends from x = 0.6 to x = 1 (yeah I know, that's a ridiculously huge flap ). faceSet will now use the existing set f0 after creating a backup to f0_old. After the command finishes f0 will only have flap faces in it.
    3. run createPatch: this is the last step where we create the flap patch from face set f0. You'll need the createPatchDict file (provided) which should reside in the system folder. We need to use options "constructFrom set" and "set f0" in the patchInfo section. Note that createPatch will also adjust the entire mesh and remove any boundaries that might end up with 0 faces in them. The final mesh will be in folder 1/polyMesh. You can have it written directly in constant/polyMesh by using the -overwrite flag.
That's it! It looks lengthy because of all the explanations but it's really not that bad.
Attached Files
File Type: gz boundary_withFlap.tar.gz (539 Bytes, 78 views)
File Type: gz createPatchDict.tar.gz (1.2 KB, 76 views)
File Type: gz extrudeProperties.tar.gz (951 Bytes, 141 views)
File Type: gz faceSetDict.tar.gz (689 Bytes, 62 views)
File Type: gz boundary.tar.gz (559 Bytes, 71 views)
onyir likes this.
ziad is offline   Reply With Quote

Old   October 30, 2010, 19:05
Default
  #14
Senior Member
 
Daniel
Join Date: Jul 2009
Location: Montreal, Canada
Posts: 156
Rep Power: 17
dancfd is on a distinguished road
Hi Ziad,

I cannot thank you enough. What you have done is far easier than the method I had attempted. I really appreciate you taking the time to explain everything in such detail as well.

Regards,

Dan
dancfd is offline   Reply With Quote

Old   October 30, 2010, 19:15
Default
  #15
Senior Member
 
Join Date: Mar 2009
Location: My oyster
Posts: 124
Rep Power: 17
ziad is on a distinguished road
You're quite welcome Daniel. I've been promising myself to formalize this for a while now so thanks for providing a little nudge. This is all going towards creating a wiki page.

what are you working on by the way?
ziad is offline   Reply With Quote

Old   October 30, 2010, 22:20
Default
  #16
Senior Member
 
Daniel
Join Date: Jul 2009
Location: Montreal, Canada
Posts: 156
Rep Power: 17
dancfd is on a distinguished road
I am trying to create a simulation of a wing with an oscillating flap. I began with a basic c-grid using blockMesh, but I could not get the diffusivity to work and the mesh turned itself inside out at the trailing edge. The diffusivity works fine on the movingWing example, but I could not create the same mesh in 2D until now. Apart from creating the wiki, what are you working on?

Dan
dancfd is offline   Reply With Quote

Old   October 31, 2010, 10:57
Default
  #17
Senior Member
 
Join Date: Mar 2009
Location: My oyster
Posts: 124
Rep Power: 17
ziad is on a distinguished road
Interesting problem. Are the oscillations self-induced or operator driven?

My work is on snow, ice and rain simulations using two-fluid formulations. I've done some work in aircraft icing as well.
ziad is offline   Reply With Quote

Old   November 1, 2010, 17:32
Default
  #18
Senior Member
 
Daniel
Join Date: Jul 2009
Location: Montreal, Canada
Posts: 156
Rep Power: 17
dancfd is on a distinguished road
The oscillations are operator-driven. Aircraft icing and multi-phase simulations sound very interesting as well!
dancfd is offline   Reply With Quote

Old   April 26, 2011, 07:00
Default
  #19
New Member
 
RDG
Join Date: Feb 2011
Posts: 29
Rep Power: 15
onyir is on a distinguished road
Quote:
Originally Posted by ziad View Post
Hi Daniel,

I finally got to spend some time on this and figured out how to do it using only OpenFoam tools. The procedure outline is the following but does not require splitMesh:

  1. run blockMesh: to get the mesh bounding box.
  2. run snappyHexMesh -overwrite: to get the full mesh in the constant/polyMesh directory.
  3. run extrudeMesh: on boundary front by a positive distance, the sign of the outward normal to this boundary. I used delta_z = 1.0 from the original z = 0.1 plane. The extrudeProperties dictionary is provided and should reside in the constant directory. It will create 3 patches, originalPatch (the original front patch in plane z = 0.1), otherSide (extruded front patch now in plane z=1.1), and sides. The last one, sides, consists of the extrusions of the bounding curves of the original front. Therefore it includes the extrusions of inlet, exit, top, bottom and airfoil. These will be separated next.
  4. run autoPatch 90: where 90 is the feature angle to search for and the actual angle between the parts of sides and the other two patches. You will get 7 additional patches named auto0 to auto6. The original three patches from the extrusion process now have 0 faces in them in the constant/polyMesh/boundary file and the total boundary number is 10 right after the file header. Edit the constant/polyMesh/boundary file, remove the sections pertaining to the original 3 extrusion boundaries, and adjust the total number of boundaries to 7. You might want to rename the boundaries from auto* to more meaningful names such as inlet, exit, airfoil, etc. I've provided my final boundary file from that step as well for reference.
The following 3 steps are optional. Use them if you want to divide the airfoil in parts (slats, flaps, whatever...):
    1. run faceSet: now we want to extract the faces from the airfoil patch and put them in a new face set, f0, in order to separate the flap in the next step. Here we use options "action new" and patchToFace. These are commented in the provided faceSetDict file which should reside in the system folder.
    2. run faceSet: now we want to extract the flap part from the existing face set f0, so we use options "action subset" and boxToFace where the specified box should enclose the face centres of the flap part of the airfoil. I picked the last delta-x = 0.4 therefore my box extends from x = 0.6 to x = 1 (yeah I know, that's a ridiculously huge flap ). faceSet will now use the existing set f0 after creating a backup to f0_old. After the command finishes f0 will only have flap faces in it.
    3. run createPatch: this is the last step where we create the flap patch from face set f0. You'll need the createPatchDict file (provided) which should reside in the system folder. We need to use options "constructFrom set" and "set f0" in the patchInfo section. Note that createPatch will also adjust the entire mesh and remove any boundaries that might end up with 0 faces in them. The final mesh will be in folder 1/polyMesh. You can have it written directly in constant/polyMesh by using the -overwrite flag.
That's it! It looks lengthy because of all the explanations but it's really not that bad.
Hi, i really like your explanation, but I have kind of problem. If I try to run snappyhexmesh in parallel, either it fails because of the empty boundaries, or doesn't add layers if I define the boundaries front and back as walls.
Any idea how to manage this?
onyir is offline   Reply With Quote

Old   April 27, 2011, 12:47
Default
  #20
Senior Member
 
Join Date: Mar 2009
Location: My oyster
Posts: 124
Rep Power: 17
ziad is on a distinguished road
It sounds like your dict file is not properly set up. Can you post your case as a tar.gz attachment?
ziad is offline   Reply With Quote

Reply

Tags
2d mesh, airfoil, cylinder, extrudemesh, 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] Help with Snappy: no layers growing GianF OpenFOAM Meshing & Mesh Conversion 2 September 23, 2020 09:26
[snappyHexMesh] Snappy Hex Mesh - issue with smoothness of the model edges olek.warc OpenFOAM Meshing & Mesh Conversion 1 August 31, 2018 12:31
[snappyHexMesh] Snappy Hex Mesh Generation: error preventing the .eMesh file generation. Mariana Garcia OpenFOAM Meshing & Mesh Conversion 1 January 7, 2016 05:24
[snappyHexMesh] Layers:problem with curvature giulio.topazio OpenFOAM Meshing & Mesh Conversion 10 August 22, 2012 10:03
Ugly mesh around cylinder rks171 STAR-CCM+ 4 May 9, 2012 15:35


All times are GMT -4. The time now is 10:20.