Contents
1 Aim
Create an axisymetric mesh with blockMesh and setup the case for simpleFoam.
2 Mesh description:
The simulation domain is a cylindrical pipe with diameter 0.19 m and length 1.1 m. To reduce computational effort, mesh is created as 2D axi-symmetrical. The density of the mesh is 300 cells in axial and 19 in radial direction. Schematically the drawing of the mesh is shown on the picture. "X","Y","Z" - coordinates, 0-5 points in blockMesh description.
3 Writing blockMeshDict
3.1 How to get points 1,4,5,2 ?
The wedge has angle = 5 deg. To calculate the points we need half of expressed in radians. Let Python to do the job:
$ python Python 2.4.4 (#1, May 30 2008, 12:21:58) [GCC 4.1.2 (Gentoo 4.1.2 p1.1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import math >>> 0.19/2.0*math.cos(math.pi*2.5/180) 0.094909581050276498 >>> 0.19/2.0*math.sin(math.pi*2.5/180) 0.0041438417997069201 >>>
First value (0.0949) corresponds to x and second (0.00414) to y.
Point 1 is (0.0949 0.00414 0)
Point 4 is (0.0949 -0.00414 0)
Point 2 is (0.0949 0.00414 1.1)
Point 5 is (0.0949 -0.00414 1.1)
3.2 blockMeshDict
FoamFile { version 2.0; format ascii; root ""; case ""; instance ""; local ""; class dictionary; object blockMeshDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // convertToMeters 1; vertices ( (0 0 0) (0.0949 0.00414 0) (0.0949 0.00414 1.1) (0 0 1.1) (0.0949 -0.00414 0) (0.0949 -0.00414 1.1) ); blocks ( hex (0 4 1 0 3 5 2 3) (19 1 300) simpleGrading (1 1 1) ); edges ( ); boundary ( front { type wedge; faces ( (0 1 2 3) ); } back { type wedge; faces ( (0 3 5 4) ); } tankWall { type wall; faces ( (1 4 5 2) ); } inlet { type patch; faces ( (0 4 1 0) ); } outlet { type patch; faces ( (3 5 2 3) ); } axis { type empty; faces ( (0 3 3 0) ); } ); mergePatchPairs ( );
3.3 Run a blockMesh
mkdir -p ax/constant/polyMesh touch axiWiki/constant/polyMesh/blockMeshDict emacs axiWiki/constant/polyMesh/blockMeshDict
Copy/paste the blockMeshDict from section above and save changes.
Now you have to write controlDict otherwise you will get an error when doing blockMesh:
--> FOAM FATAL IO ERROR : cannot open file file: /home/rafal/OpenFOAM/rafal-1.4.1/trunk/run/axiWiki/system/controlDict at line 0. From function regIOobject::readStream(const word&) in file db/regIOobject/regIOobjectRead.C at line 66. FOAM exiting
Lets steal it from standard tutorial file for simpleFoam case pitzDaily. It is not so important at this stage.
mkdir axiWiki/system
cat $FOAM_RUN/tutorials/simpleFoam/pitzDaily/system/controlDict > axiWiki/system/controlDict
In later versions of OpenFOAM (i.e. 2.2.0), this path has to be modified slightly:
cat $FOAM_RUN/tutorials/incompressible/simpleFoam/pitzDaily/system/controlDict > axiWiki/system/controlDict
Now you can run blockMesh.
/*---------------------------------------------------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 1.4.1 | | \\ / A nd | Web: http://www.openfoam.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ Exec : blockMesh . axiWiki Date : Jun 18 2008 Time : 13:09:31 Host : tux PID : 8950 Root : /home/rafal/OpenFOAM/rafal-1.4.1/trunk/run Case : axiWiki Nprocs : 1 Create time Reading block mesh description dictionary Creating block mesh Creating blockCorners Creating curved edges Creating blocks Creating patches Creating block mesh topology Default patch type set to empty Check block mesh topology Basic statistics Number of internal faces : 0 Number of boundary faces : 6 Number of defined boundary faces : 6 Number of undefined boundary faces : 0 Checking patch -> block consistency Creating block offsets Creating merge list . Creating points Creating cells Creating patches Creating mesh from block mesh Default patch type set to empty Creating merge patch pairs Writing polyMesh end
Now you have to remove some things by hand to finish with mesh.
emacs axiWiki/constant/polyMesh/boundary
and change number of boundary fields from 6 to 5 and delete the bit below from the file
axis { type empty; nFaces 0; startFace 22819; }
4 Lets see the mesh in paraFoam
To see the mesh in paraFoam we need fvSchemes and fvSolution in system directory. Lets steal it from the same case like above.
cat $FOAM_RUN/tutorials/simpleFoam/pitzDaily/system/fvSolution > axiWiki/system/fvSolution cat $FOAM_RUN/tutorials/simpleFoam/pitzDaily/system/fvSchemes > axiWiki/system/fvSchemes
Now we should be able to see the mesh in paraFoam
paraFoam . axiWiki
5 Using Gmsh to Make an Axisymmetric Mesh
This section assumes you know your way in Gmsh and you have used gmshToFoam (2D_Mesh_Tutorial_using_GMSH) before
1. Make a 2D sketch of your problem
2. Rotate the sketch -2.5° in radian (-0.04363323129985824)
3. Extrude (revolve) 5° in radian (0.08726646259971647)
4. save mesh
5. Type
$ gmshToFoam yormesh.msh
6. Go to the boundary file and change the front and back patches to a wedge BC (also do not forget to remove the default faces and reduce number of total patches by one)
7. Change your initial conditions (assign wedge BC to wedge patches)
- ) --El Safti 13:13, 22 September 2011 (CEST)
6 Using Other Software for Pre-Processing
To use other software for pre-processing, you'll have to create your mesh exactly as you would do for a 2D (e.g. plane strain) case, i.e. only one cell thick 3D mesh. You need to have a patch that will be the axis (or the nearest to it if the geometry is hollow) and a single patch that points to the front and back faces of the geometry (wedge patches). Afterwards, transform your geometry to OpenFOAM as you do normally with mesh conversion utilities. Use the utility makeAxialMesh (Contrib_MakeAxialMesh) to edit the position of nodes. The command should look like:
$ makeAxialMesh -axis axisPatchName -wedge wedgePatchName [-offset 5]
The offset is an option that translates the axis away from the axis patch making a hole in the geometry. Note that makeAxialMesh works also for meshes generated by blockMesh. Next you need to use the collapseEdges utility (something like):
$ collapseEdges 0.00001 5
Search CFD-online forum for the proper use of collapseEdges if it gave you trouble. Update this section if you had a better understanding of it.--El Safti 21:25, 22 September 2011 (CEST)
7 Disclaimer:
On this page appeared as a 20 minutes work. It can therefore contain some mistakes. This is probably not a proper way to do the axisymetric mesh, but the one that worked for me. If you have any comments, feel free to modify the case.
--Rafalzietara 12:24, 18 June 2008 (CEST)