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] Please help me, I am new to CFD and snappyHexMesh (https://www.cfd-online.com/Forums/openfoam-meshing/108005-please-help-me-i-am-new-cfd-snappyhexmesh.html)

ben1793 October 11, 2012 13:46

Please help me, I am new to CFD and snappyHexMesh
 
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.

ben1793 October 11, 2012 15:36

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?

Eloise October 12, 2012 03:50

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

ben1793 October 12, 2012 07:30

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.

Eloise October 12, 2012 07:48

Quote:

Originally Posted by ben1793 (Post 386258)
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 (Post 386258)
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 (Post 386258)
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 !

ben1793 October 13, 2012 08:18

Thank you for the reply.

ben1793 October 15, 2012 12:40

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?

Tobi October 16, 2012 03:06

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

elvis October 16, 2012 11:08

Quote:

Originally Posted by ben1793 (Post 386731)
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

ben1793 October 17, 2012 16:05

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.

wyldckat October 18, 2012 04:22

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

plucas October 18, 2012 09:10

Quote:

Originally Posted by ben1793 (Post 387180)
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.

Eloise October 18, 2012 09:46

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 (Post 387180)

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;
}


ben1793 October 18, 2012 12:35

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.

Eloise October 18, 2012 15:48

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

ben1793 October 18, 2012 16:50

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 :)


Tobi October 18, 2012 17:17

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

ben1793 October 19, 2012 04:00

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

Eloise October 19, 2012 04:11

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 (Post 387394)

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

ben1793 October 19, 2012 05:37

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.

Eloise October 19, 2012 08:00

Quote:

Originally Posted by ben1793 (Post 387471)
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?

See Tobi's answer... You can go from one time directory to another in the top right region of the paraView interface where you have a button that allow you going one time up or down.
Quote:

Originally Posted by Tobi (Post 387396)
Then open paraview and you can switch from 0 (backgroundmesh) to 1 (castellatedMesh) to 2 (snapped mesh) and so on.

Quote:

Originally Posted by ben1793 (Post 387471)
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.

In sHMD, you renamed your body as cara with the line
geometry { cara.stl { type triSurfaceMesh; name cara; }};
The system/controlDict file in the motorbike tutorial has the line
which should also appear in your controlDict
functions {#include "forceCoeffs"
}
It refers to the file forceCoeffs (that you must copy in your system directory) and you must change the patches name
from
patches ( "motorBike.*" ); to patches ( "cara.*" );


ben1793 October 19, 2012 09:04

Thank you for the help.

I have changed the name in the forceCoefs file and when I tried to run the simulation in paraFoam I did not get any results, not just that but I cant even get the options for u or p, so I went into the 0 folder and realised it was still under the name motorbike so I changed all the contents (in files such as p, u, k, omega) files from "motorBike_.*" to "cara.*" I had also tried "cara_.*" but still get the same problem, I cant change to velocity or pressure in para view and cant get any results, does anyone know what else I need to change?

plucas October 19, 2012 12:18

Quote:

Originally Posted by ben1793 (Post 387498)
Thank you for the help.

I have changed the name in the forceCoefs file and when I tried to run the simulation in paraFoam I did not get any results, not just that but I cant even get the options for u or p, so I went into the 0 folder and realised it was still under the name motorbike so I changed all the contents (in files such as p, u, k, omega) files from "motorBike_.*" to "cara.*" I had also tried "cara_.*" but still get the same problem, I cant change to velocity or pressure in para view and cant get any results, does anyone know what else I need to change?

Easiest thing to do would be to change you model name to motorBike. If that does not work, you have a different problem than just file names.

ben1793 October 19, 2012 14:45

Thank you for the help plucas.

I did as you said and changed the name to motorBike and also edited the snappyHexMesh but the same problem occurs, I will take you through what I did:

In the terminal I typed:

cp -r 0.org 0 > /dev/null 2>&1
blockMesh
snappyHexMesh
potentialFoam
simpleFoam
paraFoam

I then hit apply and changed to the number 2 on the top right corner so that I could view my STL geometry, but still no u or p options, I also checked numbers 1 and 0 and still couldn't find anything.

Eloise October 19, 2012 15:15

try this:
Code:

cp -r 0.org 0 > /dev/null 2>&1
blockMesh
snappyHexMesh
cp 3/polymesh/* constant/polymesh/
rm -r 1/ 2/ 3/
potentialFoam
simpleFoam
paraFoam

Eloïse

wyldckat October 19, 2012 15:19

Suggestion - replace these three lines:
Code:

snappyHexMesh
cp 3/polymesh/* constant/polymesh/
rm -r 1/ 2/ 3/

for this one:
Code:

snappyHexMesh -overwrite
;)

ben1793 October 19, 2012 16:49

Thank you :)

I have now got the p and u values but can not view my drag coefficient, on the motorbike tutorial it made a log.simpleFoam file automatically and listed all my drag coefficients but on this example there is no log so I made one separately and still no results, does anyone know how to view these results?

wyldckat October 20, 2012 16:40

Hi Ben,

If you are still using the same settings that are present in "system/controlDict" that the "motorBike" case is using, along with the included files it refers to, then you should have the following file present in your case:
Code:

forces/0/forceCoeffs.dat
To plot it... there are several options:
  • Open it in LibreOffice's Calc.
  • Plot using Gnuplot.
  • Convert the file to a CSV file and open it in ParaView.
Best regards,
Bruno

ben1793 October 21, 2012 08:22

Thank you for the reply wyldckat

I did as you said and found the file called forceCoefs.dat, I opened it and there was a HUGE list of coefficients for the drag but, they were all VERY high, ranging from 2800-1300 for the drag coefficient when I know it should only be around 0.2, why is this happening?



ben1793 October 22, 2012 16:40

Could anybody please tell me why I am getting such high drag coefficients even though I have not modified anything apart from the snappyHexMeshDict and the STL file in the motorbike tutorial?

Also, if possible could somebody please upload a STL file that the drag coefficient has already been tested on so that I could use it as a guide?

Thank you.

Eloise October 23, 2012 03:22

Hi Ben,

Think about the definition of a drag coefficient and go to read the file forceCoeffs. There might be some stuff you need to modify in there...

Regards,
Eloïse

ben1793 October 23, 2012 05:24

I have tried playing around with the forceCoefs and have also been reading up on the drag coefficient but can not fix the problem, still getting very high drag, I will make a separate thread for this question so that I can post all my code.

Thank you.

malaboss December 21, 2012 04:51

If you did not get any answer on that question :
you have to specify in controlDict a surface and a velocity to define the drag value. I think it is Aref and Umag. there are other variables such as the direction of the velocity.
What you found in the motor bike tutorial may not actually be applicable for your case.
Hope that helps.


All times are GMT -4. The time now is 06:03.