OpenFOAM/C3/Generating-Mesh-using-snappyHexMesh/English

From Script | Spoken-Tutorial
Revision as of 11:59, 11 July 2014 by Nancyvarkey (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Tutorial: Generating mesh using snappyHexMesh in OpenFOAM.


Script and Narration: Chaitrali Ghodke.


Keywords: Import STL file, background hex mesh, snappyHexMeshDict.


Visual Cue
Narration
Slide 1 Hello and welcome to the spoken tutorial on generating mesh using snappyHexMesh in OpenFOAM.
Slide 2 : Learning Objectives


In this tutorial we will learn to
  • Generate mesh using snappyHexMesh utility
  • Simulate temperature distribution of a flange.


Slide 3: Pre-requisite As a pre-requisite,
  • You should know parameters in snappyHexMeshDict to generate mesh.
  • For more details, refer the tutorial on introduction to snappyHexMesh in OpenFOAM.


Slide 4:

System Requirement

To record this tutorial, I am using
  • Ubuntu Linux Operating system version 12.04.
  • OpenFOAM version 2.2.2
  • ParaView version 3.12.0


Slide 5:


We are solving an existing case of flange from

laplacianFoam in basic directory.


laplacianFoam solver solves simple laplace equations.

Click on home >> OpenFoam-2.2.2 Now let us go to home folder and click on OpenFoam-2.2.2 folder.
Click on tutorials You will see tutorials.


Click on it.

Click on mesh Then click on mesh folder.
Click on snappyHexMesh You will see the snappyHexMesh folder.


Click on it

Right click >> Create new folder >> flange_1 In this folder, create a new folder by name flange_1.

Right click >> Create New Folder >> flange_1.

Go back to tutorials >> basic folder Now let's go back two levels.
Double-click on basic folder Open the basic folder.
Double-click on laplacianFoam You will see laplacianFoam folder.


Click on it.

Double-click on flange You will see flange case.


Click on it to open the folder.

Select 0, constant and system folders Copy the three folders 0, constant and system.
Go back to mesh >> snappyHexMesh >> flange_1 folder Now let us go three levels back.
Paste them there Paste the copied folders inside the flange_1 folder.
Go back to snappyHexMesh >> flange folder Now let us go one level back.
Double-click flange folder Click on flange folder.
Double-click on system You will see constant and system folders.


Click on system folder.

Select snappyHexMeshDict and surfaceFeatureExtractDict Copy snappyHexMeshDict and surfaceFeatureExtractDict from this folder.
Go back to snappyHexMesh >> flange_1 folder Now let us go two levels back.
Paste them there Paste these two files inside the system directory of flange_1 folder.
Right click >> Create new folder >> triSurface Now let us go one level back.

Click on constant folder.

In this, create a folder by name triSurface.

Go back to tutorials >> resources >> geometry folder Now let us go four levels back.
Double-click on resources Open the resources folder.
Double-click on geometry You will see geometry folder.


Now, open the geometry folder.

Double-click flange.stl.gz file In this, you will see flange.stl.gz file.


Extract this file.

Go to tutorials >> mesh >> snappyHexMesh >> flange_1 >> constant >> triSurface Give the path of triSurface folder in constant directory of flange_1 folder.
Now close this.
Ctrl+Alt+t simultaneously


cd OpenFOAM-2.2.2/tutorials/mesh/snappyHexMesh/flange_1

Open command terminal and enter the path for flange_1 as shown.

Type cd OpenFOAM-2.2.2/tutorials/mesh/snappyHexMesh/flange_1

Type ls Now type ls and press Enter.
Type cd constant There are three folders 0, constant and system.


Type cd space constant and press Enter.

Type ls Now type ls and press Enter.
Type cd polymesh You will see the polymesh and triSurface folders.


Type cd space polymesh and press Enter.

Type ls Now type ls and press Enter.
Type gedit blockMeshDict You can see the blockMeshDict file.


To view the contents of the file, type gedit blockMeshDict

and press Enter.

This will open up the blockMeshDict file.


This file contains co-ordinates for hex mesh and boundary patches.

Close blockMeshDict


Type cd ..

Type cd ..

Now close this and in the command terminal type

cd (space) .. (dot) (dot) and press Enter.


Again type cd (space) .. (dot) (dot) and press Enter.

Type cd system Now type cd space system and press Enter.
Type ls Now type ls and press Enter.


You can see the surfaceFeatureExtractDict file.

Type

gedit surfaceFeatureExtractDict

To view the contents of the file, type

gedit surfaceFeatureExtractDict

and press Enter.


(Note that F, E and D here are capital)

Open surfaceFeatureExtractDict This will open up the surfaceFeatureExtractDict file.


This file contains the information about geometry’s feature edges.


The included angle is taken as 150.

Close surfaceFeatureExtractDict Now close this.
Type gedit snappyHexMeshDict


In command terminal type

gedit snappyHexMeshDict

and press Enter.

(Note that H, M and D here are capital)

Open snappyHexMeshDict This will open up the snappyHexMeshDict file.


This file contains all the instructions about snappyHexMesh.

Give the geometry name In snappyHexMeshDict I have already made some changes.


I have named flange.stl same as that of STL file, which is in the constant/trisurface directory.

Give the file name for explicit feature edge refinement. For Explicit feature edge refinement in castellatedMeshControls, I have given the file name flange.eMesh.


This file is obtained by surfaceFeatureExtract utility.


The remaining details in the snappyHexMesh have changed as per requirements.

Type cd .. Now close this and in command terminal, type

cd (space) .. (dot) (dot) and press Enter.

Type cd 0 Type cd space 0 and press Enter.
Type ls Type ls and press Enter.


You can see the T file.

Type gedit T Now type gedit space T and press Enter.
This will open up the T file.


You will see the initial conditions for every patch.

Now, we have to give initial conditions for all patches of flange.
Copy the conditions Copy the initial conditions for patch 1 and paste it after patch 4 in the same file T.
Type flange_ Now type flange_ before this patch 1.
Give initial conditions for all patches of flange.

Save file T >> close

Similarly, we can do this for patch 2, 3 and 4.

Save this T file and close it.

Type cd .. And in the command terminal type cd (space) .. (dot) (dot)

and press Enter.

On the terminal >> type blockMesh Now, we need to mesh the geometry.

For that in command terminal, type blockMesh and press Enter.


Meshing is done.

Run surfaceFeatureExtract


Now type surfaceFeatureExtract and press Enter.


(Note that F and E here are capital.)


Surface feature extraction is done.

Type snappyHexMesh -overwrite Now type snappyHexMesh -(dash) overwrite and press Enter.
- (dash) overwrite command will prevent copying the files from the last time folders.
If not, the resulting meshes will be inside the next time folders, possibly the folders 1, 2 and 3.
Meshing will take some time.

<<PAUSE>>

Now meshing is completed.

For simulating temperature distribution, we are using laplacianFoam solver.
Type laplacianFoam In the command terminal type laplacianFoam and press Enter.


(Note that F here is capital.)


Iterations running will be seen in the terminal window.

Type paraFoam Once solving is completed, type paraFoam and press Enter to view the geometry and the results.


This will open up the Paraview window.

Click on Apply button On the left hand side of Paraview window, click on Apply.


The geometry can be seen here.

Check the box for T >> Click on Apply button Scroll down the properties panel of the object inspector menu.

Check the box for T in the volume fields and click on Apply.

In the drop down menu change from solid color to T Now go to the top of Active variable control drop down menu.


Change from solid color to capital T, which is the initial condition for the flange.

Click on the play button Now on the top of the Paraview window, you can see the VCR controls.


Click on the Play button.


Now this is the final result for temperature distribution of a flange.

Toggle on the color legend Toggle on the color legend by clicking on top left of the Active variable control menu.

This is the colour legend for temperature T.


<PAUSE>

Now let me get back to the slides.

Slide 6 : Assignment This brings us to the end of the tutorial.

As an assignment,

Change some parameters in the snappyHexMeshDict:

  • Refinement parameters
  • locationInMesh co-ordinates
  • snapControls, etc.

You can also change the temperature in the 0 folder and view the results in Paraview.

Slide 7 : Summary


In this tutorial we learnt :
  • To generate mesh by snappyHexMesh utility in OpenFoam.
  • Simulate temperature distribution of a flange.


Slide 8 :

About Spoken tutorials

Watch the video available at this URL:

http://spoken-tutorial.org/What_is_a_Spoken_Tutorial

It summarizes the Spoken Tutorial project.

If you do not have good bandwidth, you can download and watch it.

Slide 9:

About Spoken tutorials

The Spoken Tutorial Project Team

-Conducts workshops using spoken tutorials

-Gives certificates to those who pass an online test

-For more details, please write to

contact@spoken-tutorial.org

Slide 10: Acknowledgement


Spoken Tutorials are part of Talk to a Teacher project,

It is supported by National Mission on Education through ICT, MHRD, Government of India.

More information on the same is available at following URL link http://spoken-tutorial.org/NMEICT-Intro

About the contributor This is Chaitrali Ghodke from IIT BOMBAY signing off.

Thanks for joining.

Contributors and Content Editors

Chaitralighodke, Nancyvarkey