CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Native Meshers: snappyHexMesh and Others

Please help me, I am new to CFD and snappyHexMesh

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree2Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   October 11, 2012, 13:46
Default Please help me, I am new to CFD and snappyHexMesh
  #1
Member
 
Ben
Join Date: Sep 2012
Posts: 40
Rep Power: 4
ben1793 is on a distinguished road
Hello

I have made a thread on the OpenFOAM sub-forum in the past about installation problems and turned it into my question thread but after a while I got told I would be better off making a new thread for my questions so here it is

EDIT: I have figured this question out after searching the forum for ages and finding a solution, but I will be asking many more questions soon.

Last edited by ben1793; October 11, 2012 at 14:42.
ben1793 is offline   Reply With Quote

Old   October 11, 2012, 15:36
Default
  #2
Member
 
Ben
Join Date: Sep 2012
Posts: 40
Rep Power: 4
ben1793 is on a distinguished road
I have a question now, I am using the motorbike tutorial as a guide and found this:

http://www.vespalabs.org/Projects/Ve...rbike_Tutorial

I have messed around on paraview for ages but cant get it anything like the view on the website, I want it so that I slice through the block (wind tunnel) so that I can actually see the flow over the motorbike while the motorbike itself stays as a solid surface, whenever I try use the slice tool it end up cutting through the bike also, is there anyway I only cut through the block?
ben1793 is offline   Reply With Quote

Old   October 12, 2012, 03:50
Default
  #3
Senior Member
 
Elo´se
Join Date: Jul 2012
Location: Trondheim, Norway
Posts: 103
Rep Power: 5
Eloise is on a distinguished road
Hi Ben,
You can try to open 2 objects in paraView: the internal flow field and the motorbike surface. If you use VTK format, then load both files. Otherwise, select both in the Object Inspector. Then, render the motorbike as a surface, and make a cut through the internal field.
You can also find many info in here:
http://www.paraview.org/paraview/hel...de%20v3.10.pdf
I hope this help.
regards,
Elo´se
Eloise is offline   Reply With Quote

Old   October 12, 2012, 07:30
Default
  #4
Member
 
Ben
Join Date: Sep 2012
Posts: 40
Rep Power: 4
ben1793 is on a distinguished road
Thank you for the reply Eloise.

Could you please tell me how to render the motorbike as a surface?

Also, I have been wondering, why is the motorbike tutorial under incompressible flows because the simulation is of a wind tunnel and that is a compressible flow.

If I changed the name of the file in the snappyHexMeshDict file for another stl file would the model in the wind tunnel change or would more things need to be modified, and also, where would I save the stl file?

I am sorry for asking such newbie questions but I have just started out with OpenFOAM and really don't know much about it.
ben1793 is offline   Reply With Quote

Old   October 12, 2012, 07:48
Default
  #5
Senior Member
 
Elo´se
Join Date: Jul 2012
Location: Trondheim, Norway
Posts: 103
Rep Power: 5
Eloise is on a distinguished road
Quote:
Originally Posted by ben1793 View Post
Could you please tell me how to render the motorbike as a surface?
Highlight the motorbike item in the pipeline Browser, and in the top toolbars change the rendering from "outline" to "surface". If you struggle with other basic features, go through a tutorial such as http://paraview.org/Wiki/The_ParaView_Tutorial

Quote:
Originally Posted by ben1793 View Post
Also, I have been wondering, why is the motorbike tutorial under incompressible flows because the simulation is of a wind tunnel and that is a compressible flow.
If it is low mach number, you can neglect compressibility effects.

Quote:
Originally Posted by ben1793 View Post
If I changed the name of the file in the snappyHexMeshDict file for another stl file would the model in the wind tunnel change or would more things need to be modified, and also, where would I save the stl file?
You have to replace the stl file located in constant/trisurface/ directory with your stl file. Your stl must be in ascii stl format (see description of the format on wikipedia) and must be of sufficiently good quality. Try it, you will probably run into some error messages, read them and browse on the forum to see if people had similar issue before.
Good luck !
Eloise is offline   Reply With Quote

Old   October 13, 2012, 08:18
Default
  #6
Member
 
Ben
Join Date: Sep 2012
Posts: 40
Rep Power: 4
ben1793 is on a distinguished road
Thank you for the reply.

Last edited by ben1793; October 15, 2012 at 12:42.
ben1793 is offline   Reply With Quote

Old   October 15, 2012, 12:40
Default
  #7
Member
 
Ben
Join Date: Sep 2012
Posts: 40
Rep Power: 4
ben1793 is on a distinguished road
Could anyone please tell me how to run the motorbike tutorial with a different stl model?

I have already converted my model to ASCII and placed it into the trisurface folder
I have also edited the snappyHexMeshDict on the top line and changed it from motorbike.obj to myfilename.obj
I meshed the geometry and used the ./Allrun command to run it and viewed it on paraview, the tunnel was there butmy stl geometry was not in the tunnel.

What have I done wrong?
ben1793 is offline   Reply With Quote

Old   October 16, 2012, 03:06
Default
  #8
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,086
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi ben,

have a look at the openfoamwiki http://openfoamwiki.net/index.php/SnappyHexMesh
There you can find some tutorials with sHM! After that it should be clear how to use it. Otherwise you can make a thread in the sHM section.

Regard Tobi
Tobi is offline   Reply With Quote

Old   October 16, 2012, 11:08
Default
  #9
Senior Member
 
Elvis
Join Date: Mar 2009
Location: Sindelfingen, Germany
Posts: 577
Blog Entries: 5
Rep Power: 13
elvis is on a distinguished road
Quote:
Originally Posted by ben1793 View Post
I have already converted my model to ASCII and placed it into the trisurface folder
I have also edited the snappyHexMeshDict on the top line and changed it from motorbike.obj to myfilename.obj
What have I done wrong?
At least you should write myfilename.stl for an STL-file in snappyHexMeshDict

I think HelxyOS is a great GUI and keeps one away from wrong file names.

You could sometimes get much better results when you use an myfilename.eMesh-file that
you get by using surfaceFeatureExtract command and include that myfilename.eMesh in snappyHexMeshDict as well
elvis is offline   Reply With Quote

Old   October 17, 2012, 16:05
Default
  #10
Member
 
Ben
Join Date: Sep 2012
Posts: 40
Rep Power: 4
ben1793 is on a distinguished road
Thank you for the replies, links have come in very handy. My main concern at the moment is not to get perfect results but it is just to get any results at all.

I have found a guide that told me a bit about creating code in the snappyHexMeshDict file so I copied the code and modified it and got the following:


FoamFile
{ version 2.0; format ascii; root ""; case ""; instance ""; local ""; class dictionary; object autoHexMeshDict; }

castellatedMesh true;
snap true;
addLayers true;

geometry
{ cara.stl { type triSurfaceMesh; name cara; } };

castellatedMeshControls
{ maxLocalCells 10000000; maxGlobalCells 2000000; minRefinementCells 0; nCellsBetweenLevels 1;

refinementSurfaces
{ cara { level (4 5); } } resolveFeatureAngle 30;

refinementRegions
{ cara { mode distance; levels ((0.1 5) (0.4 4) (1 2)); } }

locationInMesh (3.11 1.51 -1.1); }

snapControls
{ nSmoothPatch 3; tolerance 4.0; nSolveIter 30; nRelaxIter 5; }

addLayersControls
{ layers { cara_vcg { nSurfaceLayers 1; } } }


meshQualityControls
{
}


I try this and only my tunnel loads which is what is in the blockMeshDict, my STL file does not show, what have I done wrong?
Also, I did not modify anything in the refinement regions, the location mesh and dont really know what to put in the meshQualityControls, although I will modify the location in mesh once I have actually got the STL model to appear.

Last edited by ben1793; October 17, 2012 at 16:21.
ben1793 is offline   Reply With Quote

Old   October 18, 2012, 04:22
Default
  #11
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,301
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Greetings to all,

FYI: I've mode this thread to the snappyHexMesh sub-forum.

@ben1793: which tutorial are you following now?
Nonetheless, it would be best that you use OpenFOAM's own motorBike tutorial "mesh/snappyHexMesh/motorBike" and work from there.

And as already mentioned before, Helyx-OS would make your life a lot easier since you're new with snappyHexMesh

Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   October 18, 2012, 09:10
Default
  #12
Member
 
plucas's Avatar
 
Anonymous
Join Date: Dec 2011
Location: Everywhere
Posts: 75
Rep Power: 5
plucas is on a distinguished road
Quote:
Originally Posted by ben1793 View Post
I try this and only my tunnel loads which is what is in the blockMeshDict, my STL file does not show, what have I done wrong?
Also, I did not modify anything in the refinement regions, the location mesh and dont really know what to put in the meshQualityControls, although I will modify the location in mesh once I have actually got the STL model to appear.
It is not appearing because your snappyHexMesh is failing. One of the values in the snappyHexMesh file is causing problems creating the mesh and is terminating the process.
plucas is offline   Reply With Quote

Old   October 18, 2012, 09:46
Default
  #13
Senior Member
 
Elo´se
Join Date: Jul 2012
Location: Trondheim, Norway
Posts: 103
Rep Power: 5
Eloise is on a distinguished road
Try this one below...
I deactivated the layer insertion (You don't need that yet), and added some "default" values for mesh quality.
Use the command snappyHexMesh > log.snappyHexMesh and post the log file here so maybe we can help you to see where is the error
Regards,
Elo´se
Quote:
Originally Posted by ben1793 View Post

FoamFile
{ version 2.0; format ascii; root ""; case ""; instance ""; local ""; class dictionary; object autoHexMeshDict; }

castellatedMesh true;
snap true;
addLayers false;

geometry
{ cara.stl { type triSurfaceMesh; name cara; } };

castellatedMeshControls
{ maxLocalCells 10000000; maxGlobalCells 2000000; minRefinementCells 0; nCellsBetweenLevels 1;

refinementSurfaces
{ cara { level (4 5); } } resolveFeatureAngle 30;

refinementRegions
{ cara { mode distance; levels ((0.1 5) (0.4 4) (1 2)); } }

locationInMesh (3.11 1.51 -1.1); }

snapControls
{ nSmoothPatch 3; tolerance 4.0; nSolveIter 30; nRelaxIter 5; }

addLayersControls
{ layers { cara_vcg { nSurfaceLayers 1; } } }


meshQualityControls
{

maxNonOrtho 65;
maxBoundarySkewness 20;
maxInternalSkewness 4;
maxConcave 80;
minVol 1e-13;
minTetQuality 1e-30;
minTwist 0.02;
minDeterminant 0.001;
minFaceWeight 0.02;
minVolRatio 0.01;
}
plucas likes this.
Eloise is offline   Reply With Quote

Old   October 18, 2012, 12:35
Default
  #14
Member
 
Ben
Join Date: Sep 2012
Posts: 40
Rep Power: 4
ben1793 is on a distinguished road
Thank you for all the replies and I am sorry that I had posted this question on the wrong sub-forum.

Also, Thank you so much Eloise for taking the time to edit my code

I have used the command in the terminal and got the following error:

--> FOAM FATAL ERROR:
Cannot find file "points" in directory "polyMesh" in times 0 down to constant

From function Time::findInstance(const fileName&, const word&, const IOobject::readOption, const word&)
in file db/Time/findInstance.C at line 188.

FOAM exiting


I also did not mention, I had changed the size of the external mesh (wind tunnel) in the blockMeshDict file because when I had loaded the tunnel and STL files separately on para view I had noticed that the STL file was much larger in size than the tunnel, so I added two more 0's after every number in the initial part of the blockMeshDict to scale the tunnel by 100.
ben1793 is offline   Reply With Quote

Old   October 18, 2012, 15:48
Default
  #15
Senior Member
 
Elo´se
Join Date: Jul 2012
Location: Trondheim, Norway
Posts: 103
Rep Power: 5
Eloise is on a distinguished road
The file "points" in the polymesh directory is created by blockMesh. Have you run the blockMesh utility before snappyHexMesh?
Try the following steps:
1) copy the "AllClean" from motorbike tutorial to your case directory
2) run AllClean in your case directory
3) execute the following commands, one by one:
cp -r 0.org 0 > /dev/null 2>&1
blockMesh > log.blockMesh
=> Check in paraView if your windtunnel is as you expect and if your STL is where you want it to be. Play around with the bolckMeshDict until you reach that point.
snappyHexMesh > log.snappyHexMesh
=> Check the different meshs (times 0, 1 and 2) in paraView to see what was the effect of the castellate and snap steps

Regards,
Elo´se
Eloise is offline   Reply With Quote

Old   October 18, 2012, 16:50
Default
  #16
Member
 
Ben
Join Date: Sep 2012
Posts: 40
Rep Power: 4
ben1793 is on a distinguished road
I managed to do everything up till the last step and then a Error:


--> FOAM FATAL IO ERROR:
keyword mergeTolerance is undefined in dictionary "/home/ben/OpenFOAM/ben-2.1.1/run/motorBike/system/snappyHexMeshDict"

file: /home/ben/OpenFOAM/ben-2.1.1/run/motorBike/system/snappyHexMeshDict from line 20 to line 56.

From function dictionary::lookupEntry(const word&, bool, bool) const
in file db/dictionary/dictionary.C at line 400.

FOAM exiting

I think I have fixed the mergeTolerance problem by coppying it from another example but now have the following error:

--> FOAM FATAL IO ERROR:
keyword features is undefined in dictionary "/home/ben/OpenFOAM/ben-2.1.1/run/motorBike/system/snappyHexMeshDict::castellatedMeshControls"

file: /home/ben/OpenFOAM/ben-2.1.1/run/motorBike/system/snappyHexMeshDict::castellatedMeshControls from line 28 to line 36.

From function dictionary::lookupEntry(const word&, bool, bool) const
in file db/dictionary/dictionary.C at line 400.

FOAM exiting


Here is what is inside my snappyHexMeshDict under castellatedMeshControl:

castellatedMeshControls
{ maxLocalCells 10000000; maxGlobalCells 2000000; minRefinementCells 0; nCellsBetweenLevels 1;



When I used the command you told me to use, it created a new folder called 0, what is the difference between 0 and 0.org?

Is the main reason for creating a log just to see if there is any errors?

Thank you


Last edited by ben1793; October 18, 2012 at 17:06.
ben1793 is offline   Reply With Quote

Old   October 18, 2012, 17:17
Default
  #17
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,086
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Its the latest entry in your sHMDict:

Code:
// Advanced

// Flags for optional output
// 0 : only write final meshes
// 1 : write intermediate meshes
// 2 : write volScalarField with cellLevel for postprocessing
// 4 : write current intersections as .obj files
debug 0;


// Merge tolerance. Is fraction of overall bounding box of initial mesh.
// Note: the write tolerance needs to be higher than this.
mergeTolerance 1e-6;
Just set

Code:
mergeTolerance 1e-6;
into your file.


Differences between 0 and 0.org are that in 0.org your variables (U,T,p...) are and in the folder 0 is your castellatedMesh.
If you have the folder 0.org copyed to 0 with
Code:
cp -r 0.org 0
you ll get a new timestep "1" to your case. In that case is the castellatedMesh
in timestep 2 is your snapped mesh
in timestep 3 is your addedLayer mesh (if you use it).

If you set
Code:
writeTimestep    100;
into your controlDict

you ll get the folders

100
200
300

and so no.


Build an empty folder 0 befor running sHM.
Then open paraview and you can switch from 0 (backgroundmesh) to 1 (castellatedMesh) to 2 (snapped mesh) and so on.


Tobi

Tobi
Tobi is offline   Reply With Quote

Old   October 19, 2012, 04:00
Default
  #18
Member
 
Ben
Join Date: Sep 2012
Posts: 40
Rep Power: 4
ben1793 is on a distinguished road
Thank you for replying Toby and also thank you for answering my questions and clearing things up for me

I have added the code to my snappyHexMeshDict and got the same error when I tried to compile it in the terminal:

--> FOAM FATAL IO ERROR:
keyword features is undefined in dictionary "/home/ben/OpenFOAM/ben-2.1.1/run/motorBike/system/snappyHexMeshDict::castellatedMeshControls"

file: /home/ben/OpenFOAM/ben-2.1.1/run/motorBike/system/snappyHexMeshDict::castellatedMeshControls from line 28 to line 36.

From function dictionary::lookupEntry(const word&, bool, bool) const
in file db/dictionary/dictionary.C at line 400.

FOAM exiting
ben1793 is offline   Reply With Quote

Old   October 19, 2012, 04:11
Default
  #19
Senior Member
 
Elo´se
Join Date: Jul 2012
Location: Trondheim, Norway
Posts: 103
Rep Power: 5
Eloise is on a distinguished road
If you read the message, it tells you that it misses "features" in castellatedMeshControls. Look at the sHMD in the motorbike totuorial and you will see that there is a line with "feature" which does not exist in your sHMD
Add this:
Quote:
Originally Posted by ben1793 View Post

castellatedMeshControls
{ maxLocalCells 10000000; maxGlobalCells 2000000; minRefinementCells 0; nCellsBetweenLevels 1; features();

Next error message you get, try to read it carefully and compare your file to a tutorial file to see if anything is missing

Regards,
Elo´se
Eloise is offline   Reply With Quote

Old   October 19, 2012, 05:37
Default
  #20
Member
 
Ben
Join Date: Sep 2012
Posts: 40
Rep Power: 4
ben1793 is on a distinguished road
Thank you Eloise.

I had done as you said and continued changing the snappyHexMeshDict whenever an error came up and finally got it so that no errors come up, but now I have a new problem.
I used the commands you said which created the 0 folder and then used the blockMesh > log.blockMesh and then snappyHexMesh > log.snappyHexMesh and after that used paraFoam, when I went into paraFoam I can see my part under the mesh parts in the pipeline browser, it is right at the bottom under all my other patch's and its called cara_vcg - Patch, when I click apply to view my geometry the cara_vcg vanishes and I am left with just the patch's for my tunnel.

EDIT: I have fixed it, I just ticked the skip zero time box, what does this do?

Also, I have executed the command potentialFoam and simpleFoam as I did on the motorBike tutorial in the past and I did not get a log for simpleFoam so I did it again but this time did simpleFoam > log.simpleFoam, I now have the log but can not view the information I need which is the drag coefficient, I could do this on the motorbike tutorial but for some reason it does not work on here.

Last edited by ben1793; October 19, 2012 at 05:54.
ben1793 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
snappyHexMesh not refining surfaces Hydro1004 OpenFOAM 3 August 29, 2012 11:56
Some problems about using snappyHexMesh xiaow_g OpenFOAM Native Meshers: snappyHexMesh and Others 1 April 13, 2012 05:56
snappyHexMesh won't work - zeros everywhere! sc298 OpenFOAM Native Meshers: snappyHexMesh and Others 2 March 27, 2011 21:11
SnappyHexMesh samiam1000 OpenFOAM 0 October 5, 2009 10:32
Problem with snappyHexMesh samiam1000 OpenFOAM 0 October 3, 2009 05:08


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