CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Meshing & Mesh Conversion (https://www.cfd-online.com/Forums/openfoam-meshing/)
-   -   [snappyHexMesh] snappyHexMesh feature edge (https://www.cfd-online.com/Forums/openfoam-meshing/89669-snappyhexmesh-feature-edge.html)

lovecraft22 June 19, 2011 13:04

snappyHexMesh feature edge
 
Hi all;
I'm trying to mesh a simple circular cylinder but I'm having the classical snappyHexMesh troubles with the free end edge.
Now, I saw this news on the openfoam website:
http://www.openfoam.com/news/snappyH...ature-edge.php

It could help me out a lot. How does that work? Any idea? Could not find anything on the user guide…

Thank you!

wyldckat June 19, 2011 14:23

Hi lovecraft22,

I was thinking about this myself... It's here: "tutorials/mesh/snappyHexMesh/flange"
Keep in mind that you must have at least OpenFOAM 2.0.0!

Check the Allrun script on that folder for more details.

And next time you want to find a file, here's two example commands:
Code:

find . -name "snappy*Dict"
find . -iname "snappy*dict"

Best regards,
Bruno

PS: must... stop... drooling.... :p since OpenFOAM 1.5 that people have been waiting for this feature... me included :)

bastil June 19, 2011 14:32

Quote:

Originally Posted by wyldckat (Post 312639)
:p since OpenFOAM 1.5 that people have been waiting for this feature... me included :)

Yes I agree. I think we should use this thread to exchange experience with this new feature - how does it work,...?

Regards Bastian

wyldckat June 19, 2011 14:55

Hi Bastian,

OK, to sum up:
  • This command automagically extracts the feature edges:
    Code:

    surfaceFeatureExtract -includedAngle 150 -writeObj constant/triSurface/flange.stl flange
    It creates the file constant/triSurface/flange.eMesh.
  • It also creates a lot of debug related data, such as *.obj files, ./flange and constant/extendedFeatureEdgeMesh/flange.extendedFeatureEdgeMesh
  • In system/snappyHexMeshDict is defined that:
    Code:

    // 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 "flange.eMesh";
                level 0;
            }
        );

The rest is the usual must refine here and there in snappyHexMeshDict ;)

Tip - Try running:
Code:

surfaceFeatureExtract -help
Best regards,
Bruno

PS: who needs drugs, when one can drool so easily...... :D

lovecraft22 June 19, 2011 15:10

Thank you wyldckat, can't see any difference though…
I did the same ad the tutorial with my cylinder without any difference with or without the feature edge…

lovecraft22 June 19, 2011 15:20

Did you manage to get it working with nice results?

Any way to check whether the edge was picked up correctly? Paraview doesn't seem to like this .eMesh file…

wyldckat June 19, 2011 15:37

5 Attachment(s)
Attached are a few pictures showing details about the snapped edges...

Note: I'm not using the official OpenFOAM mesh reader for ParaView, I'm using the internal reader in ParaView 3.8.0... so there might be some referential discrepancies, therefore that might be the reason why the STL seems a bit offset from the resulting mesh.

edit: there's plenty of files with info about the edges, but currently I have no clue how to visualize them. I haven't built the official plug-ins yet, so I haven't check them yet either :(

edit2: Just tested with the official plugins and I've confirmed that the snapping isn't perfect, so the attached pictures are validated. There might be some tolerance variable somewhere... or additional refinement is necessary.

Best regards,
Bruno

bastil June 20, 2011 04:31

Bruno,

Quote:

Originally Posted by wyldckat (Post 312645)


  • // Specifies a level for any cell intersected by its edges.
    // This is a featureEdgeMesh, read from constant/triSurface for now.
    features
    (
    {
    file "flange.eMesh";
    level 0;
    }
    );[/CODE]


This is old staff. This eMesh file is used to refine to a specified level (0 in your case which means no refinement at all) at all explicit feature edges given in the file. This has already been possible before. I think the following parameter is the one, did you use it in your test?
Code:

//- Highly experimental and wip: number of feature edge snapping
//  iterations. Leave out altogether to disable.
nFeatureSnapIter 10;

What I am not sure is if it only works with both a eMesh-File and the parameter nFeatureSnapIter > 0 or if the eMesh-File is not required in case you wanto do to snapping to edges but no additional edge refinement.. However, since level 0 does not really make sense for refinement (since it does not refine at all) I guess that the eMesh-File is required for feature edge snapping.

Regards Bastian

wyldckat June 20, 2011 05:49

Greetings to all!

Quote:

Originally Posted by lovecraft22 (Post 312649)
Any way to check whether the edge was picked up correctly? Paraview doesn't seem to like this .eMesh file…

I've just spotted something interesting: JavaView
This application can be used to open ".obj" files, as indicated here:
Quote:

Originally Posted by http://www.openfoam.com/features/mesh-conversion.php
writeMeshObj For mesh debugging: writes mesh as three separate OBJ files which can be viewed with e.g. javaview

As I said before, *.obj files are generated in the tutorial case.

I haven't tested JavaView yet... hopefully it might open eMesh files as well... but I doubt it, since last I looked, it was an OpenFOAM format.

@Bastian:
Quote:

Originally Posted by bastil (Post 312684)
I think the following parameter is the one, did you use it in your test?

I only skimmed through the files and only picked up on the big things... I didn't see that option, nor have I tried to figure out how it all works...

Best regards,
Bruno

lovecraft22 June 20, 2011 13:04

Yu can load the .obj files in paraview…

lovecraft22 June 20, 2011 13:52

Quote:

Originally Posted by bastil (Post 312684)
Code:

//- Highly experimental and wip: number of feature edge snapping
//  iterations. Leave out altogether to disable.
nFeatureSnapIter 10;

What I am not sure is if it only works with both a eMesh-File and the parameter nFeatureSnapIter > 0 or if the eMesh-File is not required in case you wanto do to snapping to edges but no additional edge refinement.. However, since level 0 does not really make sense for refinement (since it does not refine at all) I guess that the eMesh-File is required for feature edge snapping.

Regards Bastian

You're right Bastian, that's the key parameter!
Here's the difference between having it set to 10 (on the left) and having it commented out (on the right):

http://dl.dropbox.com/u/2459663/Senza%20titolo.jpg

bastil June 21, 2011 03:15

Quote:

Originally Posted by lovecraft22 (Post 312760)
You're right Bastian, that's the key parameter!
Here's the difference between having it set to 10 (on the left) and having it commented out (on the right):http://dl.dropbox.com/u/2459663/Senza%20titolo.jpg

Thanks. Pictures are missing but its ok. The only question left: Did you additionally use an eMesh file (I think so) or did it work without? I suspect that the eMesh files is required to "mark" the features to snap to.

Regards Bastian

lovecraft22 June 21, 2011 04:01

I can see the pictures, try opening the url directly.

I haven't tested without the eMesh file. I'll do that when I'll get back home in 10 hours al let you know.

lovecraft22 June 21, 2011 14:46

I commented out these lines
Code:

{
file "flange.eMesh";
level 0;
}

and I did not get the same nice result in the cylinder free end. So this .eMesh file is quite important…

wyldckat June 22, 2011 03:53

Greetings to all!
Quote:

Originally Posted by lovecraft22 (Post 312649)
Any way to check whether the edge was picked up correctly? Paraview doesn't seem to like this .eMesh file…

I believe I've found how to make them readable in ParaView:
Quote:

Originally Posted by http://www.openfoam.com/docs/user/standard-utilities.php
surfaceFeatureConvert Convert between edgeMesh formats

That page deserves a very close reading... there are so many new goodies in OpenFOAM 2.0 :D

Ah, and the directory listing can also help get our attention on some more genuine pearls: http://foam.sourceforge.net/docs/cpp/dirs.html

Quote:

Originally Posted by lovecraft22 (Post 312757)
Yu can load the .obj files in paraview…

I forgot about that...

Best regards,
Bruno

bastil June 22, 2011 17:46

Quote:

Originally Posted by wyldckat (Post 313023)
Greetings to all!

I believe I've found how to make them readable in ParaView:

More important than imprting the features to keep into Paraview (btw. what format do you need to convert it to?) is to check which of thease features are really captured by the snapping process and which are not. Maybe this could be done by finding the features (with the same angle) on the final mesh and compare theses edges with the initial once? Ideas how to do that?

Regards Bastian

wyldckat June 23, 2011 05:23

I made a post-and-run yesterday so I didn't give any details, nor did I have a compiled OpenFOAM 2.0.0/x at hand.

Now that I have a build at hand and a bit more time:
  1. Formats on the Directories link I gave before: edgeFormats
  2. When it doesn't tell you, use bananas:
    Code:

    surfaceFeatureConvert flange.eMesh flange.banana
    (...)
    Unknown file extension for writing : banana
    Valid types: ( eMesh inp obj vtk )

    I chose vtk for ParaView :)
    And somehow NAS doesn't seem to be on the list... I believe inp is a STARCD format.
  3. We have to give it the full or relative path for each file, so there isn't any smart system for loading from dictionary as in snappyHexMesh.
As for:
Quote:

Originally Posted by bastil (Post 313166)
is to check which of thease features are really captured by the snapping process and which are not. Maybe this could be done by finding the features (with the same angle) on the final mesh and compare theses edges with the initial once? Ideas how to do that?

Sadly I'm not experienced enough to figure this out :(

All I know is that from the tutorial we can easily have access to the edges used by snappyHexMesh, namely:
  • We can see the eMesh from the converted format.
  • We can see the object files .obj exported by surfaceFeatureExtract.
The rest for now is visual analysis. I think some of the edges that have bad snaps are due to lack of resolution, but I'm possibly/probably wrong :( Such example is Björn's blog post: http://www.discretizer.org/ from June 18, 2011.

Best regards,
Bruno

sebasthe December 9, 2011 09:57

5 Attachment(s)
Hi there!

I am new to OpenFOAM and tried my very best but I stuck at a question about snappyHexMesh which could belong to this thread.

What I am trying to do for a first step is to build a triangular geometry which later will be used to construct a rod bundle geometry. But unfortunately as you see in the pictures I attached there is a problem with sharp edges.

What I tried:
- with and without featureEdgeRefinement
- gave it a try with a slightely modified geometry (rounded edges -> see picture)
- tried to adjust a lot of parameters in the snappyHesMeshDict (without success)
-I created the .stl by myself but also tried an CAD export without improvements.
- checked my boundary file: inlet and outlet are empty while the sides of my block are set as wall boundaries.

I found a thread from last year which is about a tool called snapEdge. But in case I got that right, by now OF2.0.1 (which I use) originaly brings those functions. So there is no need for snapEdge anymore. Please correct me if I am wrong. :-)

I hope I provided all relevant information and am looking forward for any tips and hints.

Thank you in advance :-)

cheers
Sebastian

snappyHexMeshDict:
Attachment 10391


Pictures:
Attachment 10387 Attachment 10388 Attachment 10389 Attachment 10390

bastil December 12, 2011 11:32

Quote:

Originally Posted by sebasthe (Post 335295)
I found a thread from last year which is about a tool called snapEdge. But in case I got that right, by now OF2.0.1 (which I use) originaly brings those functions. So there is no need for snapEdge anymore. Please correct me if I am wrong. :-)

Sebastian, you are right about the fact that OF2.0.1 snappyHexMesh comes with featureEdgeHandling. The corners of you triangle look fine but the sides are the problem - how is the "box" constructed?

Regards Bastian

wyldckat December 12, 2011 16:49

Greetings to all!

@Sebastian: My guess is that surfaceFeatureExtract didn't give you a good ".eMesh". A bad angle will result in bad line references for snapping :(
Open the ".obj" files in ParaView, namely the ones that were placed in your case folder after running surfaceFeatureExtract. Check if there are any/all necessary lines for actually snapping the edges ;) If not, try another angle!

Best regards,
Bruno

sebasthe December 13, 2011 12:08

2 Attachment(s)
Thank you Bastian and Bruno for your quick replies to my problem!

@Bastian: I am not completely sure what you mean by
Quote:

-how is the "box" constructed?
I suppose you mean the blue block one can see in the pictures above. I constructed that block with blockMesh. Actually the construction is part of a script which in the end helps me to automise my mesh generation - once I get I to run :-) According to some geometric settings in a text file this script generates me a bunch of cylinder .stl files and a blockMeshDict fitting to those zylinders.

@Bruno: Just out of curiosity would checking the .eMesh file give me the same information or is there a difference one should have in mind between .obj and eMesh features? According to your suggestion I checked the .obj files which seems to be right.
But not all of the lines lay inside my blockMesh block. Actually this could be the reason for the bad edges I get. I think I have to change my procedure as I used to have stl geoemtries overlapping my blockmesh (see images of my first post). Now I seem to need the stl geometry beeing completely surrounded by a blockmesh. In other words all edges have to be inside the blockmesh. Can you confirm that according to your experience?

Today I only had time for a quick test which actually showed some improvements. Tomorrow I will have some more time for further test and will let you know about my progress.

Kind regards
Sebastian

Attachment 10417 Attachment 10418

bastil December 15, 2011 05:52

Quote:

Originally Posted by sebasthe (Post 335709)
@Bastian: I am not completely sure what you mean by I suppose you mean the blue block one can see in the pictures above. I constructed that block with blockMesh.

Ok I expected that. Your geometry intersects the box constructed by blockMesh and there is not feature line for this intersection in the emesh-File, is it? That is why there features are not snapped whereas the features at the geometry itself contain feature lines in the emesh-File and they are snapped.
You need to generate feature lines at the intersections in your emesh-File.

Regards Bastian

sebasthe December 17, 2011 04:27

1 Attachment(s)
This whole topic seems to be more complicated than expected.

Bastian, I read your answer several times and thought about it. But I'm still not completely sure if I got you right.The white lines in the picture below are my feature lines (eMesh-File). They intersect the block. I think this is what you mean by:
Quote:

Originally Posted by bastil (Post 335918)
whereas the features at the geometry itself contain feature lines in the emesh-File and they are snapped.

I suppose the missing features you talk about are feature lines in a shape of what I highlighted red in the picture, right?

I tried some workarounds for this problem:
1.) Having the geometry completely surrounded by the blockMesh box. As front and back are now inside the box, there are now intersection lines. But this didn't solve the problem.

2.) Paradoxically if only the front of the prism lies inside whereas the back overlaps the box I get relatively nice results. Unfortunately I don't understand why as I would expect my first workaround to be better than the second.

As the second workaround doesn't make any sense to me, although I now get a nice prism, I still don't have the impression that I really solved the problem. Was that a lucky strike?

cheers
Sebastian

Attachment 10451

bastil December 17, 2011 08:49

Quote:

Originally Posted by sebasthe (Post 336147)
This whole topic seems to be more complicated than expected.
I suppose the missing features you talk about are feature lines in a shape of what I highlighted red in the picture, right?

Exactly. But they need to be placed at the intersections between the box and the shape, not at the end of the shape outside the box. It should not e to hard to create these features.

Regards Bastian

sebasthe January 14, 2012 14:03

Hi all,

sorry that I havn't replied until now. I didn't have the time to follow up on this until this week.

@bastil: thank you very much for your input and tips on this!! I tried with several different modifications of the featureEdges - unfortunately without success.

For all who might have some similar issues: unfortunately I couldn't find a clean way to solve my problem. But I now have kind of a smooth solution with which I can deal. I used the described workarround - one side of the geometry overlapping and one side inside the blockMesh block. Even after hours of trying and thinking about, I really don't now why this is working. My best guess is that the featureEdge funtion is not fully developped until now.

With the workaround I used one problem remains: at the edges my wall patch (prism sides) owns one line of cells of the inlet patch. But this I could solve with a combination of autoPatch and createPatch.

Tip: sometimes it helps to run snappyHexMesh a second time.

Thanks for your help!
Sebastian

aqua February 27, 2012 12:39

Quote:

Originally Posted by wyldckat (Post 312639)
Hi lovecraft22,

I was thinking about this myself... It's here: "tutorials/mesh/snappyHexMesh/flange"
Keep in mind that you must have at least OpenFOAM 2.0.0!

Check the Allrun script on that folder for more details.

And next time you want to find a file, here's two example commands:
Code:

find . -name "snappy*Dict"
find . -iname "snappy*dict"

Best regards,
Bruno

Hello Bruno,
I tried to run the command :
surfaceFeatureExtract -includedAngle 150 icube.stl icube

but the error showed up such as :
--> FOAM FATAL ERROR:
Cannnot read "icube.stl"

From function triSurface::read(const fileName&, const word&, const bool)
in file triSurface/triSurface.C at line 370.

Could you please tell me how to solve this?
my icube.stl file was created by ProE, if i just perform SHM, it worked fine.
But why couldn't I extract the feature?

Thank you so much!
Aqua

anon_a February 28, 2012 07:32

Hey aqua

Are you sure your STL is located in the right directory?
It should be in constant/triSurface

aqua February 29, 2012 07:20

Quote:

Originally Posted by anon_a (Post 346653)
Hey aqua

Are you sure your STL is located in the right directory?
It should be in constant/triSurface

Hello,anon_a,
Thank you so much for your reply. But yes, I have the stl file under triSurface.
Actually I successfully creat mesh by snappyHexMesh, which should means the stl file is right.
But just couldnt perform surfaceFeatureExtract...

Regards!
Yebo

anon_a February 29, 2012 07:54

But in this case, shouldn't you also adjust the directory in the surfaceFeatureExtract command as well?

For example, I use
surfaceFeatureExtract -includedAngle 150 -writeObj constant/triSurface/myGeometry.stl myGeometry

wyldckat February 29, 2012 08:17

Greetings to all!
Quote:

Originally Posted by anon_a (Post 346888)
For example, I use
surfaceFeatureExtract -includedAngle 150 -writeObj constant/triSurface/myGeometry.stl myGeometry

That was going to be my answer... :rolleyes:

@Aqua: you had quoted my post #2... on post #4 was the answer to your question!! ;)

Best regards,
Bruno

aqua February 29, 2012 09:59

Quote:

Originally Posted by wyldckat (Post 346891)
Greetings to all!

That was going to be my answer... :rolleyes:

@Aqua: you had quoted my post #2... on post #4 was the answer to your question!! ;)

Best regards,
Bruno

Hi, Bruno,
Yes, I got it! Thank you so much!

Cheers!

Aqua

aqua February 29, 2012 10:00

Quote:

Originally Posted by anon_a (Post 346888)
But in this case, shouldn't you also adjust the directory in the surfaceFeatureExtract command as well?

For example, I use
surfaceFeatureExtract -includedAngle 150 -writeObj constant/triSurface/myGeometry.stl myGeometry

Hello anon_a,

You are right! I forgot the directory....

Thank you so much for your help~

Cheers~

Aqua

aqua March 2, 2012 06:03

Hey, Bruno,
I am using foamToCGNS, the mesh is created in OpenFoam by SnappyHexMesh, but when run foamToCGNS, error happens like :

Wrong number of vertices in cell
expected 4,5,6, or 8, found 0

From function foamToCGNS
in file writeCGNS.H at line 219.


Does CGNS deal with polyhedral cell created by snappyHexMesh? If not, is there some other way to convert OF mesh to CFX?

Thank you so much!

Aqua

wyldckat March 2, 2012 06:46

Hi Aqua,

Quote:

Originally Posted by aqua (Post 347267)
Does CGNS deal with polyhedral cell created by snappyHexMesh? If not, is there some other way to convert OF mesh to CFX?

I don't know. But I suggest that you first check if the mesh is sane:
Code:

checkMesh
Best regards,
Bruno

aqua March 2, 2012 06:56

Quote:

Originally Posted by wyldckat (Post 347277)
Hi Aqua,


I don't know. But I suggest that you first check if the mesh is sane:
Code:

checkMesh
Best regards,
Bruno

Hi, Bruno,
Thank you so much for your reply!
I did checkMesh, but the solution is mesh ok!

" Min volume = 0.0373576. Max volume = 936694. Total volume = 1.02747e+10. Cell volumes OK.
Mesh non-orthogonality Max: 54.4594 average: 10.6017 Threshold = 70
Non-orthogonality check OK.
Face pyramids OK.
Max skewness = 1.18109 OK.
Mesh OK.
End"

Do you know some way to convert the polyhedral cell into hex or tetra? as long as no polyhedral is fine for me..

Thank you so much!

Aqua

wyldckat March 2, 2012 07:00

Quote:

Originally Posted by aqua (Post 347281)
Do you know some way to convert the polyhedral cell into hex or tetra? as long as no polyhedral is fine for me..

I saw here on the forum someone asking the same question... if I remember correctly, the best thing to do is to use NETGEN instead, since that gives you a lot more control over the mesh... but my memory might be failing me...

aqua March 2, 2012 08:07

Quote:

Originally Posted by wyldckat (Post 347282)
I saw here on the forum someone asking the same question... if I remember correctly, the best thing to do is to use NETGEN instead, since that gives you a lot more control over the mesh... but my memory might be failing me...

Dear Bruno,
That was me, too... but no one answers me, so I asked many times...

I will check netgen, thank you so much for your suggestion!

Aqua

wyldckat March 2, 2012 08:25

Hi Aqua,

Quote:

Originally Posted by aqua (Post 347289)
That was me, too... but no one answers me, so I asked many times...

Nope, wasn't you: http://www.cfd-online.com/Forums/ope...dral-mesh.html
And there seems to be some hope:
Quote:

Originally Posted by Martin80 (Post 345748)
I have found in openfoam-1.6-ext the application "tetDecomposition", but this application adds additional points.

Best regards,
Bruno

tfuwa March 23, 2012 02:14

Hi there,

Can anyone please guide me on how to control the mesh density at the tip of the cylinder as show in the post picture? Which parameter and how to realize? Thanks in advance.

Quote:

Originally Posted by lovecraft22 (Post 312760)
You're right Bastian, that's the key parameter!
Here's the difference between having it set to 10 (on the left) and having it commented out (on the right):

http://dl.dropbox.com/u/2459663/Senza%20titolo.jpg


lovecraft22 March 23, 2012 04:14

I just set 2 levels for the mesh of the cylinder in snappy and then I used feature edge to have a sharp edge. Read the whole discussion, I think you should be able to sort that out and if not just get back and explain where you're having a hard time.


All times are GMT -4. The time now is 04:23.