CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   enGrid (http://www.cfd-online.com/Forums/engrid/)
-   -   engrid -> save as .stl with boundarie codes (http://www.cfd-online.com/Forums/engrid/76255-engrid-save-stl-boundarie-codes.html)

Zymon May 19, 2010 09:49

engrid -> save as .stl with boundarie codes
 
Hallo Foamers,

I have a question concerning enGrid. Maybe it is a stupid question, but I tried it all day and couldn't find a solution, nor any solution on the web.

So, I have a .stl file and want to put boundary conditions to it for the snappyHexMesh utility. I know that I have to split the model in several parts within the .stl file. In enGrid I can set the boundary code perfectly but when I export it again to .stl file the model isn't split up in parts (as in the motorBike example). So I decided to export the parts (inlet, outlet,...) seperatly and put the files together afterwards. But in enGrid I can't delete part of the model. Does anybody know if it works or should I use another program? I tried to install Netgen, but it doesn't work at the moment.

Thanks!

AlanR May 19, 2010 17:25

Zymon,

I'm not familiar with enGrid, but you could just import your geometry and set up the boundaries in blockMesh. If you look at the motorBike tutorial blockMeshDict file, you will see how to do it. You set up blockMesh as a box around your geometry and define the boundaries. After that, you use snappy to 'adjust' the mesh to your .stl geometry. Depending on your model, you don't have to split the CAD geometry into multiple parts for snappy (like in the motorBike tutorial). If the geometry is simple (like a box or a single bottom surface), you can use a single file.

Alan

phsieh2005 May 19, 2010 22:37

Hi, Zymon,

I do not use enGrid. In stead, I use cgx (www.calculix.de). Type the following command to load the stl file into cgx:
cgx -stl filename.stl

then, do "plot e all". this will display all the elements.
For inlet, type "qadd inlet", then, select all the triangles that belong to the inlet patch. repeat the same for the other patches interested.

For each patch, after selecting them into the proper name, you have to do
comp inlet do
comp inlet do

This will put the nodes into the inlet patch set (repeat the same for all the patches). Then, export each patch using
send inlet stl

This will save all the triangles you selected into inlet patch to inlet.stl
repeat the same for all the patches.

Now that you have each patch in each file, you might want to edit each stl and add, for example, "inlet" to the first line after solid so that snappyHexMesh knows the name.

Hope this helps.

Pei

Zymon May 20, 2010 03:18

Ah, thanks Pei! I am gonna try it today. My solution for yesterday was that I set the surrounding box for snappy tight to my modell (btw. I have an inner flow), so that it touches the inlet and outlet boundaries. This does work for my simple model at the moment, but when it gets complex this won't be the perfect solution, I guess. So I'll try it with your software.

elvis May 20, 2010 12:06

Hello,

what about using discretizer http://www.discretizer.org/
It has two programms discretizer_setup.sh discretizer.sh

what you need to master your snappyhexmesh stuff is discretizer_setup.sh
looks like http://www.discretizer.org/files/boxdialog.jpg

But I'm wondering why don't you ask your engrid concernd questions on
http://engits.eu/phpBB3/ there is a forum for engrid.

But maybe you should contact Oliver Gloth user "ogloth" in this forum
he is the "Spiritus Rector" of engrid :)
see http://www.cfd-online.com/Forums/ope...generator.html

elvis

Zymon May 20, 2010 14:17

Hey, thanks for your advices. Btw. what Meshing-Tool do you take? Snappy works ok, but the problem with the edges is quite annoying. Engrid and NETGEN doesn't produce the desired results at the moment. Tomorrow I'll try your discretizer tool.

elvis May 20, 2010 15:31

Quote:

Originally Posted by Zymon (Post 259590)
Hey, thanks for your advices. Btw. what Meshing-Tool do you take? Snappy works ok, but the problem with the edges is quite annoying. Engrid and NETGEN doesn't produce the desired results at the moment. Tomorrow I'll try your discretizer tool.

Do not underestimate SnappyHexMesh (SHM)!
Well it depends on what you are going to simulate.
But SHM is the underlying technology for a commercial meshing tool
ICON FOAMpro. (I am not affiliated with ICON).
snappyhexmesh is a joint development of icon and opencfd
If creating a snappyhexmeshdict (that creates great results) would be that obvious. Why do people pay money for Consultancy?

Engrid has its merits as well (I am not affiliated with Engits).
But the Spiritus Rector of Engrid makes his living thru Consultancy, besides getting some funding by ESA.

So take some time to dig into learning how to master Engrid/SHMdict, or take some money to get Consultancy.

If you read carefully Stuff related to meshing on http://www.opensourcecfd.com this leads in the direction what is missing in your SHMdict

elvis

ogloth May 21, 2010 03:11

Hello,

it appears as if I should write a comment ;-)

It is true that consultancy is a core source of income for enGits. But we are not really looking for customers that just want user support for enGrid, although we would provide that if asked for. What we do is either customised developments or "complete" CFD consultancy using enGrid and OpenFOAM. With complete consultancy I mean we help our customers to get the task done themselves. Obviously there are issues sometimes (e.g. bugs in enGrid) and those we address quickly in order to meet the commercial deadlines.

Generally we are quite happy to give support on the forum. This is, of course, free of charge. Since enGits is a small company it is not always possible to answer quickly, because sometimes commercial projects are pressing.

Now to your actual meshing problem: If you want you can send me your geometry together with a description on what kind of mesh you would like to have and I'll have a go at it. Ideally, as mentioned above, you would do that on the enGrid forum (http://engits.eu/forum).

Regards,
Oliver

P.S. I am affiliated with enGits ... ;-)

Zymon May 21, 2010 08:52

5 Attachment(s)
Thanks a lot for your support Oliver. I am working on my diploma thesis and so I should really learn all the meshing stuff an do it on my own. Right now I just work on a quite simple model I made to get into meshing and OpenFOAM. Later on I'll get the complex model and I hope that I'll can apply my experiences then. The model right now is 3D, but actually I did it 2D and lenghtened it in the Z-direction. So there are quite a lot sharp edges and I have problems with snappy to get rid of it. So I also try to do it with enGrid.

I attached some pictures of my work untill now:

The first picture shows my original surface mesh, not decend enough for enGrid. So I created a better surface mesh with NETGEN. This can be seen in picture 2 and 3 (3D view). NETGENE produces partly too big meshes and other parts are refined too much. Is it possible to refine parts of the mesh? The max-mesh size option in the Meshing Options does not work at all. Picture 4 shows a slice of the grid (detailed around the orifice). It does look quite ok, but with 400k cells too fine, in my opinion. CheckMesh says all right, despite the number of severly non-orthogonal faces is 371. Due to my sharp edges I can't use the divide prismatic boundary layer tool, otherwise I get highly skew faces and the ckeckMesh fails. Picture 5 shows a fast potentialFoam simulation and the whole grid. You can see that at the parts where NETGEN didn't work that well (upper and lower parts of the chamber, see picture 3), the volumemesh is very bad too. Do you know a better surface mesher than NETGEN (or one with a better documentation)?

(Pictures in next comment, I can upload just 5 pics)
I also did a mesh with snappy what can be seen in picture 6. CheckMesh says everything is ok. But the result of the simulation (picture 7) is not satisfying. I did the refinement of the region with the distance mode. I think the lack in quality of the simulation is due to a missing grading of the mesh quality around the orifice. So the interpolation of the results at the nodes does not work properly. Is there an opportunity for grading between the defined levels in snappy? And is the quality of the surface mesh important for snappy anyway?

I also have some questions concerning enGrid:
- What boundaries should I select for the 'create prismatic boundary layers'? Just the inlet, outlet or all walls? I guess it is all walls and so I did it.
- What does 'total badness' mean? It doesn't sound positive and the number is very high what concerns me a bit.
- When I click 'fix surface triangulation' the program crashs. A usual bug or a problem with my mesh?

Sorry for so much text and so many questions. Nobody around me has any experiences with meshing or CFD simulations. So I am quite on my own except your support. Btw. the OpenFOAM export of enGrid works perfectly, well done!

Zymon May 21, 2010 08:54

2 Attachment(s)
The rest of the pictures.

ogloth May 21, 2010 10:16

Zymon,

Quote:

Originally Posted by Zymon (Post 259728)
The first picture shows my original surface mesh, not decend enough for enGrid. So I created a better surface mesh with NETGEN. This can be seen in picture 2 and 3 (3D view). NETGENE produces partly too big meshes and other parts are refined too much. Is it possible to refine parts of the mesh? The max-mesh size option in the Meshing Options does not work at all. Picture 4 shows a slice of the grid (detailed around the orifice). It does look quite ok, but with 400k cells too fine, in my opinion. CheckMesh says all right, despite the number of severly non-orthogonal faces is 371. Due to my sharp edges I can't use the divide prismatic boundary layer tool, otherwise I get highly skew faces and the ckeckMesh fails. Picture 5 shows a fast potentialFoam simulation and the whole grid. You can see that at the parts where NETGEN didn't work that well (upper and lower parts of the chamber, see picture 3), the volumemesh is very bad too. Do you know a better surface mesher than NETGEN (or one with a better documentation)?

Well, what is better or worse is usually a personal preference. I have used Gmsh and NETGEN as surface meshers for enGrid and usually I got better control with Gmsh. Having said that, enGrid has its own surface mesher now. If you have a discrete geometry (e.g. STL file), you can import that into enGrid and do all meshing tasks within enGrid. Blender is a nice open-source tool to create such a discrete geometry. If you have to rely on STEP or IGES CAD files, you will have to first convert the file. You can also load an existing surface mesh into enGrid and improve it further; this option, however, can be a bit slow sometimes because the search algorithm for the surface projection is not the best (will improve).

Skewness cannot be avoided for sharp corners and high aspect ratios -- simply impossible. But it possibly doesn't have a big impact on your computation. My advice would be to ignore skewness errors in the boundary layer.

Quote:

Originally Posted by Zymon (Post 259728)
- What boundaries should I select for the 'create prismatic boundary layers'? Just the inlet, outlet or all walls? I guess it is all walls and so I did it.

correct!

Quote:

Originally Posted by Zymon (Post 259728)
- What does 'total badness' mean? It doesn't sound positive and the number is very high what concerns me a bit.

That is just NETGEN's output piped into the window. To be honest, I don't know myself. It is some kind of quality measure for the tetras -- simply ignore it.

Quote:

Originally Posted by Zymon (Post 259728)
- When I click 'fix surface triangulation' the program crashs. A usual bug or a problem with my mesh?

Both ;-) it should not crash, but it also indicates (possibly) a problem in your surface mesh.

Quote:

Originally Posted by Zymon (Post 259728)
Sorry for so much text and so many questions. Nobody around me has any experiences with meshing or CFD simulations. So I am quite on my own except your support. Btw. the OpenFOAM export of enGrid works perfectly, well done!

Thanks!

Sorry about the lack of documentation ... it will improve, honestly ... ;-)

Regards,
Oliver

elvis May 21, 2010 11:26

Quote:

If you have to rely on STEP or IGES CAD files, you will have to first convert the file.
In my opinion Salome http://www.salome-platform.org/ can do the job of converting STEP and IGES -> STL for you.
Ofcourse it can do a lot more, as it has a meshing section (based on Netgen and gmsh or commercial plugins) and some more stuff.
http://www.caelinux.org/wiki/index.p...ELinux_2007.29 for an impression

also very helpful might be meshlab http://meshlab.sourceforge.net/
import:PLY, STL, OFF, OBJ, 3DS, COLLADA, PTX, V3D, PTS, APTS, XYZ, GTS, TRI, ASC, X3D, X3DV, VRML, ALN
export:PLY, STL, OFF, OBJ, 3DS, COLLADA, VRML, DXF, GTS, U3D, IDTF, X3D

elvis

Zymon May 21, 2010 11:49

Yeah, thanks. I have already heard about SALOME. I'll install it this weekend. At this company the geometry is defined by an own format. We think about writing an exporter to the .stl format, because the format is quite simple and well supported by OpenFOAM and the meshing tools. Is there a possibility to import .stl files to SALOME in order to change the geometry if required (or a converter to a supported format)?

So, what do you think about my mesh, is it ok?

edit: I have already installed Meshlab. Is one of the export formats readable by SALOME?

philippose May 21, 2010 17:55

5 Attachment(s)
Hello there,

I was looking through your posts on this thread, and was interested to see that Netgen and Engrid seem to be the centre of discussion :-)! So I thought I would put in a post from my side too :-)!

The geometry that you are trying to simulate looks cool.... :-)!

I was basically an "end-user" of Netgen till about 2 years ago, when I decided to actually take part in the development of Netgen too..... I must say, that I have not seen a mesher which is more robust and faster than Netgen in the Open-Source universe for automated meshing.

Again here too, the main problem why people face difficulties is the extreme lack of Documentation, and I would love to change that (and have been doing so, however at a very slow pace), except for the fact that my normal "day" job eats up most of my time and energy.

Anyway, coming to the point of control over the mesh generation in Netgen..... There are a couple of points to notice, which may not be apparent...:

1. When using OCC geometry, the meshing option STL/STEP/IGES - close edges has an inverse effect.... the smaller the number, the finer the mesh near edges which are close to each other.... however, when you select a coarser mesh setting in "Mesh Granularity", it automatically makes this number smaller...... which is a bug which has not yet been corrected (shall do it as soon as possible).

2. The Maximum and Minimum Mesh size settings do work quite well..... However, the values which you change in the GUI are the actual maximum and minimum edge lengths (in millimetre) of the elements.... Hence, if the topology of your geometry causes Netgen to automatically select a smaller mesh size than the currently selected maximum mesh size, you will not see any changes when you vary the maximum mesh size, unless you vary it to a value smaller than the largest automatic value determined by Netgen.

3. If you are using one of the later versions of Netgen (if I remember right, ver 4.9.11 upwards), you can colourize the generated mesh based on the local mesh size. This option can be enabled in the "View -> Viewing Options... -> Mesh" tab, by checking "Colored Meshsize visualization". Using this mode, you can easily see what minimum and maximum mesh sizes Netgen is using, and then you can modify the size constraints based on that. (Note: After selecting this option and clicking on "Done", you need to Double-Click somewhere in the graphics view to update the mesh display)

4. If you want a more uniform mesh, set a small value (smallest value in the GUI is 0.1) for the mesh-size grading option, move the slider to a large value and remove the tick for the option - STL/IGES/STEP - Close edges

5. If you close the gap between the Minimum and Maximum mesh size limits after performing option 4, you can get a mesh almost completely uniform.

6. Now for the cool bit..... I strongly suggest that you try the option of using a mesh size file. You can use the mesh size file to limit the mesh size at very specific locations by explicitly limiting the size at points or along lines. I have created a small excel program in which I put in the diagonally opposite (x,y,z) co-ordinates of a Cuboid, along with a resolution, and the maximum mesh size within this cuboid. I then generate a point cloud and limit the mesh size at each of those points within the cuboid using VBA (Visual Basic for Applications). By adding multiple such cuboids (or other forms) into one MSZ file, you can dictate exactly how the mesh has to look....... When using a Mesh size file, the size limitation specified by the mesh size file at a point has the highest priority, and overrides all other automatically determined mesh sizes.

7. And finally, if required, you can directly export from Netgen into OpenFOAM by selecting "OpenFOAM 1.5+ Format" under the Export Filetype option, and exporting the mesh generated using the Export Mesh... option both of which can be found under the "File" menu.


Here are some screenshots of some of the points I mentioned above. If you (or anyone else for that matter) requires more assistance, I would be glad to try and help.

If you need more details regarding the Mesh size file, let me know...

Hope this helps.....

Have a nice weekend!

Philippose

phsieh2005 May 21, 2010 23:00

Hi, philippose,

Your post is very helpful! I was quite confused about some of the settings you mentioned.

Quite some time ago, you mentioned about calling netgen as library from OpenFOAM. Is there anything happening in this area? I believe that this will be quite helpful for dynamic mesh cases (and Fluid-structure interaction cases).

Pei

Zymon May 22, 2010 05:33

Hi Philippose,

Wow, thanks a lot, this is very helpful. This weekend I'll deal with the theoretical part of CFD, but next week, when I am back at the company, I'll try all your suggested points. I'll most certainly come up with some more questions.

Right now I have two concerns: After the meshing of the surface Netgen automatically detects and defines boundaries. In the left chamber of my model I just want the upper part of the right, upper curvature to be defined as the outlet, but Netgen defines the whole curvature as one boundary. In enGrid you can set a feature angle when setting boundary codes. With a small angle (0.2 degrees) it works fine at this boundary. Is there something comparable in Netgen? Or can I select certain triangles and assign them to a boundary group (e.g. outlet)? This would be most appreciated, but I haven't found such an option yet. My second concern relates to the export to the OpenFOAM Format, you also mentioned. I tried this, but it doesn't save anything. After chosing a directory and saving there aren't any files in the directory. I just tried this twice, maybe the next time it works. But maybe it is a known bug.

A documentation would be really great. This is indeed a problem of Netgen. I have no doubt that this tool is very powerful, but when you don't know how to use it, there is no point in it.

philippose May 22, 2010 08:49

Hello again :-)!

Great that I was able to clarify some doubts (and possibly wake up some more :-)!)....

For your new questions.....

1. By default, Netgen assigns the number of the underlying face of the geometry as the boundary condition number for the triangles of the generated surface mesh. If Netgen is applying a common boundary number to the entire right side curvature, it would imply that the geometry of the entire curvature has been created as one continuous surface without an edge between the curved part, and the straight part (which you want to define as an output).

As of now, there is no way of selecting individual surface triangles and manually assigning a boundary condition number to them....

So.... possible solutions...:

1a. Explicitly create a break in that surface separating the part you want to define as an output so that it is identified as a separate surface directly in the software you use the create your geometry.

1b. Netgen also has another method of applying boundary numbers..... based on the colour of the underlying surface.... but even that will technically only work if you have two separate surfaces, because you cannot apply multiple colours on one surface.

Its always difficult to come to a decision as to what features are expected to be provided by the meshing tool, and what features can be assumed to be a part of the geometry generation phase.


2. As for the OpenFOAM Export from Netgen...... I just tried the export feature using Netgen-4.9.13 in both, Windows and Linux, and it worked fine.... Basically, you need to select a folder, and within this folder, Netgen creates a folder structure "constant -> polyMesh". The individual files (boundary, owner, neighbour, points, faces) are then written into the subfolder "polyMesh"


Have a great weekend ahead!

Philippose

elvis May 22, 2010 10:13

Quote:

Originally Posted by Zymon (Post 259758)
Yeah, thanks. I have already heard about SALOME. I'll install it this weekend. At this company the geometry is defined by an own format. We think about writing an exporter to the .stl format, because the format is quite simple and well supported by OpenFOAM and the meshing tools. Is there a possibility to import .stl files to SALOME in order to change the geometry if required (or a converter to a supported format)?

So, what do you think about my mesh, is it ok?

edit: I have already installed Meshlab. Is one of the export formats readable by SALOME?

Salome
Geometrie Import
Brep Boundary Representation (more or less the Standard Salome file format)
IGES
STEP
ACIS .sat

Geometrie Export
Brep Boundary Representation (more or less the Standard Salome file format)
IGES
STEP
ACIS .sat
and STL (binary and Ascii)

Import Meshing
DAT-file
UNV-file
MED-file

Export Meshing
DAT-file
UNV-file
MED-file
and STL

elvis

Zymon May 22, 2010 11:37

Ah, ok, so do you know a STL to IGES, STEP or ACIS converter? A quick research revealed that this is not that easy. The 3D Data expert (http://www.deskartes.com/data%20mani...a%20expert.htm) should work, despite I have not tried it. But I don't know yet if I have to change the geometry anyway. And I still think that STL is a good format to start with.

elvis May 23, 2010 05:49

Quote:

Originally Posted by Zymon (Post 259836)
Ah, ok, so do you know a STL to IGES, STEP or ACIS converter?

I do not know if it reaaly works, because if have no experience with freecad
http://sourceforge.net/apps/mediawik...itle=Main_Page

but if the statement is correct
Import/export to standard formats such as STEP, IGES, OBJ, DXF or SVG
(but never tried it)

then I would use meshlab to convert STL -> OBJ, and after that
Freecad to convert OBJ -> STEP, IGES

salome and freecad use both OpenCasCade http://www.opencascade.org/

What does the file format you have to convert look like?
Is it taken from some inhouse simulation software that is based on sttructured or unstrucktured dataformat? maybe you should also take a look at VTK
It has many reader or programmable filter => very stable and useful stuff

elvis


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