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 with local refinement of ONE STLfile (https://www.cfd-online.com/Forums/openfoam-meshing/61483-snappyhexmesh-local-refinement-one-stlfile.html)

wolle1982 February 18, 2009 07:46

SnappyHexMesh with local refinement of ONE STLfile
 
Hallo all,

while using the great Tool snappyHexMesh one can quickly get too many cells. But if some level of refinement is required in only some special regions of the geometry, e.g. an airfoil nose, there is the possibility to let snappyHexMesh refine those special regions separately.

http://www.cfd-online.com/OpenFOAM_D...es/1/11255.jpg

Here's a little manual how to do so.

1. Create geometry in CAD Programm and split into so many region as different refinement levels are required. Export each File as separate STL file.

2. Copy-Paste single STL files into one STL file. In my example the file is names Input.stl. Inside the Input.stl file you have to name the different regions. Look at attached file-example. Regions named "NumberOne" and "NumberTwo".
http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif Input.stl

3. In snappyHexMeshDict one has to define the regions as region and give the patches names (here: "shpere" and "ellipse"). See attached snappyHexMeshDict.

4. Under refinementSurfaces one now can define the separat refinement level for both regions ("NumberOne" and "NumberTwo"). See attached snappyHexMeshDict.

5. Under addLayerControls one can now define the separate layers to be added to the defined patches ("sphere" and "ellipse"). See attached snappyHexMeshDict.
http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif snappyHexMeshDict

6. Doing sHM eather
a) as usual:
- blockMesh
- snappyHexMesh

or

b) in parallel computing
- blockMesh
- decomposePar
- foamJob -p -s snappyHexMesh
- reconstructParMesh -mergeTol 1e-06 -time 1
- reconstructParMesh -mergeTol 1e-06 -time 2
- reconstructParMesh -mergeTol 1e-06 -time 3

with the (very common) attached decomposeParDict.
http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif decomposeParDict

As results you get a meshed surface with separate local refined regions which safes a lot of cells to compute.

Step one: Refining in different local refinementlevels
http://www.cfd-online.com/OpenFOAM_D...es/1/11256.jpg

Step two: Snapping to the surface
http://www.cfd-online.com/OpenFOAM_D...es/1/11257.jpg

Step three: Building boundary layer by adding structured cells to surface
http://www.cfd-online.com/OpenFOAM_D...es/1/11258.jpg

Notice: To view the single patches in paraView, you have to load in the given patches (as usual). Then change something in the markement of the patches (e.g. take away the inlet-patch) and update view, now you can see the defined single patches.

Notice: a different refinement level on the surface means that neighbour bounary layers have pourly a different thickness.

Notice: the triangle Cells are only a display mistake by paraView. In reality they are hexes and polyhexes. See picture

http://www.cfd-online.com/OpenFOAM_D...es/1/11259.jpg


Have fun with it!
Wolfgang

wolle1982 February 23, 2009 13:16

Add-on "Forces": To get the
 
Add-on "Forces":

To get the attacking Forces on the whole geometry use "forces"-function in controlDict (see other threads) and define patches separated with a sinlge blank:

functions
(
forces
{
type forces;
functionObjectLibs ("libforces.so");
patches (sphere ellipse);
rhoInf 1.225;
CofR (0.25 0 0);
}
);

The function simply sums all the forces of the multiple patches.

openfoam_user June 26, 2009 02:57

Hi Wolfgang,

till now I have never used SnappyHexMesh. I would like to try it with your case. Could you provide me with your STL geometry ?

One problem is that SHM does not respect sharp edges. Do you know if it will be improved into the next release ?

Best Regards,

Stephane Sanchi.

wolle1982 June 26, 2009 08:46

Hi Stephane,

I have no idea, if sHM will be improved in the next version. I'm only user, no programmer.

No, the STL-File is too large. But you can create your own one. Take a CAD Program and export as STL File.

If you don't have a CAD Program, you also can use Salome to create simple volumes. after creating the geometry in salome, mesh the surface with a triangle-only surface grid. that will be able to be exported as a STL file.

greetings

santos June 26, 2009 09:23

Hi,

You can export your mesh to STL directly from the 'Geometry' module of Salome, no need to create a mesh.

Regards,
Jose Santos

Novi March 17, 2011 02:56

Help Please
 
Hi, Your post regarding localize refinement using snappyHexMesh is very helpful. But I can't open the file that you attach. Is is possible to post the codes again?

Thank you :)

bigbang July 16, 2011 10:34

Great example. Thank you.

I'm just getting starting with openFoam and this is a good addition to the motorBike tutorial.

giuli@ October 20, 2011 03:31

Hi Wolgfang,
thank you for your post, you enlightened me :)

I am meshing a car, which geometry is composed by 10 parts. The local surface refinement works; however, sHM meshes also inside the volume of the car. If I mesh the car as one part, this problem does not occur. I guess ( :confused: ), the locationInMesh point doesn't see the geometry as a whole, when it is specified as an assembly of parts, and therefore all the cells are visible.

Did you have the same problem, or it actually removed the cells inside your volume?
Do you have any idea how to solve this?

Thank you and regards,
giuli@

PS: anybody with similar experience is welcome to comment :)

giuli@ October 20, 2011 03:58

Hi everybody,
I guess I found the problem (posted by me just above) - I think that it is just a matter of how close the parts of the geometry are. With a very coarse surface mesh (not refined enough to see eventual gaps among the parts) the volume mesh inside the car is removed!

cheers,

gg

michaelb December 15, 2011 05:52

Hi Giulia,

have you tried the ADMesh program yet?
https://sites.google.com/a/varlog.com/www/admesh-htm
I'm particularly thinking of the "-f" option which may help filling the gaps in between two solids. The sHM shouldn't mesh the inside of your solid anymore and you would be able to reach the required refinement.

Best,


Michael

giuli@ December 15, 2011 08:58

Hi Micheal,
thank you very much for your suggestion. I will try this program soon!

regards,

giuli@

hhh February 1, 2012 12:04

synappy hex mesh
 
Dear foamers,
i have problem in snappy hex mesh, i have cad model in stl format,how i solve in open foam,
1.how to import
2.how to create outer domain
3.how to mesh the model
4.how to set boundary condition,for my i consider to create domain to set
inlet velocity ,pressure outlet and remaining face is symmetry wall is cad model
5.how to run
i am begineer please give idea for to this problem

michaelb February 1, 2012 12:14

Hi hhh,

have you had a look at this tutorial ? :
http://www.hydroniumion.de/general/s...mesh-tutorial/
and this pdf ? :http://www.ats4i.com.br/en/publications/files/SnappyHexMesh_1stOpenFoamBRAZIL_linux.pdf

This might be a good starting point. Beyond that if you've any further questions I'm afraid I won't be able to help you since I'm also a beginner.

Cheers,

Michael

hhh February 2, 2012 00:34

snappy hex mesh
 
Dear michal,
thanks for response,its really useful for beginners, i hopes i get some idea to learn snappyhexmesh.




Warm Regards,
hhh

soonic March 24, 2012 16:33

starter
 
http://www.cfd-online.com/Forums/ope...ost351265.html

I wrote a how to split the stl to several regions, if somebody will need it )like me) to start this tutorial.

thanks for your tutorial.

sivakumar August 23, 2013 10:49

3 Attachment(s)
Hi There,
I am trying to use sHM utility, for that I have created .stl file.

* I have single STL file see fig1, the coloured one is the STL file, grey colour is blockMesh Box.

* For the same geometry I have done Meshing with 3 volumes (inlet volume, fan volume, outlet volume) using Gambit.

* For sHM I exported it as one STL.
* Is it necessary to split the STL file in to many STL???

* I haven’t edit the STL file, but I used the STL face names in sHM.

STL file is

solid FACE.24
facet normal -0.922423 -0.386182 -0.000000
outer loop
vertex -0.215172 0.740366 6.000000
vertex -0.215172 0.740366 4.230000
vertex -0.160542 0.609881 6.000000
endloop
endfacet
................................
...............................
facet normal -0.922423 -0.386182 -0.000000
outer loop
vertex -0.087704 0.435900 1.870000
vertex -0.087704 0.435900 0.100000
vertex -0.033074 0.305414 0.100000
endloop
endfacet
endsolid FACE.24

solid FACE.23
facet normal 0.000000 0.000000 1.000000
outer loop
vertex 0.354461 0.684669 6.000000
vertex 0.337417 0.693227 6.000000
vertex 0.345089 0.611537 6.000000
endloop

..................................
..................................

facet normal 0.000000 0.000000 1.000000
outer loop
vertex -0.039209 0.398857 6.000000
vertex -0.072195 0.398857 6.000000
vertex -0.039209 0.320068 6.000000
endloop
endfacet
endsolid FACE.23

sHMDict is:

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

geometry
{
fanGeo.stl
{
type triSurfaceMesh;
regions
{
FACE.24
{
name inlet;
}

FACE.23
{
name outlet;
}
}

* I have generated the blockMesh with 3 volume as follows

convertToMeters 1;

vertices
(
(-0.4 0.2 -1.5)
(0.4 0.2 -1.5)
(0.4 0.8 -1.5)
(-0.4 0.8 -1.5)
(-0.4 0.2 -0.1)
(0.4 0.2 -0.1)
(0.4 0.8 -0.1)
(-0.4 0.8 -0.1)
(-0.4 0.2 0.2)
(0.4 0.2 0.2)
(0.4 0.8 0.2)
(-0.4 0.8 0.2)
(-0.4 0.2 6)
(0.4 0.2 6)
(0.4 0.8 6)
(-0.4 0.8 6)
);

blocks
(
hex (0 1 2 3 4 5 6 7) (15 15 50) simpleGrading (1 1 1)

hex (4 5 6 7 8 9 10 11)
fan
(15 15 10) simpleGrading (1 1 1)

hex (8 9 10 11 12 13 14 15) (15 15 100) simpleGrading (1 1 1)

);

edges
(
);


boundary
(
inlet
{
type patch;
faces
(
(0 3 2 1)
);
}

outlet
{
type patch;
faces
(
(12 13 14 15)
);
}

center0
{
type wall;
faces
(
(0 1 5 4)
);
}

fan
{
type wall;
faces
(
(4 5 9 8)
);
}

center1
{
type wall;
faces
(
(8 9 13 12)
);
}

ILR0
{
type cyclic;
neighbourPatch ILR1;
faces
(
(0 4 7 3)
);
}

ILR1
{
type cyclic;
neighbourPatch ILR0;
faces
(
(1 5 6 2)
);
}

CLR0
{
type cyclic;
neighbourPatch CLR1;
faces
(
(4 8 11 7)
);
}

CLR1
{
type cyclic;
neighbourPatch CLR0;
faces
(
(5 9 10 6)
);
}

OLR0
{
type cyclic;
neighbourPatch OLR1;
faces
(
(8 12 15 11)
);
}

OLR1
{
type cyclic;
neighbourPatch OLR0;
faces
(
(9 13 14 10)
);
}

top0
{
type wall;
faces
(
(3 7 6 2)
);
}

top2
{
type wall;
faces
(
(11 15 14 10)
);
}

top1
{
type wall;
faces
(
(7 11 10 6)
);
}

);

mergePatchPairs
(
);

after that I executed snappyHexMesh, its not all removing the unwanted region. I am confused.

But if I work with one hex block in the blockMesh it is working fine, but I not able to define the patches.

please help me to get rid of this problem


Thanks,
Sivakumar

sivakumar August 23, 2013 12:12

Hi there,
Sorry for the post, its working fine.

the problem was in the sHMDict

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

geometry
{
fanGeo.stl
{
type triSurfaceMesh;
name fanGeo; // I included this, that was the problem.
regions
{
FACE.24
{
name OLR0;
}

FACE.23
{
name outlet;
}

FACE.25
{
name top2;
}


Thanks,
Sivakumar

ashishmagar600 July 28, 2017 07:35

Hello, everyone.

I don't know if this is the right thread to ask (I am sorry), guess this thread gives info about sHM, that's why. I was just figuring out how to define or control the size of the grid inside the refinement box. Actually, I needed this to verify independence of the grid, but I don't really know how a certain level will give me a grid size I want.

thanks in anticipation

otaolafr May 1, 2020 05:09

Quote:

Originally Posted by ashishmagar600 (Post 658737)
Hello, everyone.

I don't know if this is the right thread to ask (I am sorry), guess this thread gives info about sHM, that's why. I was just figuring out how to define or control the size of the grid inside the refinement box. Actually, I needed this to verify independence of the grid, but I don't really know how a certain level will give me a grid size I want.

thanks in anticipation

hello! i would go with doing the simulation and use mapFields to use the last t output as input for a smaller grid and repeat it :) hope it helps

otaolafr May 1, 2020 05:19

hello,
I am looking at this method of introducing STLs and I find it really simple instead of what I am doing at the moment, but I am having a big issue. the STL is not watertight after doing the cat of the files. I am sure that the original ones were watertight as they were a solid in my CAD file. here is an image of the model, note that all the faces in the same color I exported in a single stl (so in total i have: red, blue, yellow and with blue stls) (the withe bluish in the first and end lines of the squares are an error from the image only and not a superposition of the faces or anything related.)
https://i.ibb.co/T1mm3xR/Image1.png

I think that maybe the issue comes from the red and blue stls that are composed of several surfaces that are not connected between each other?. I would really appreciate any help.
best regards, franco


All times are GMT -4. The time now is 15:59.