Difference between revisions of "Main ContribExamples/AxiSymmetric"
Rafalzietara (Talk | contribs) (→Mesh description:) |
(→How to get points 1,4,5,2 ?: \apha to <math>\alpha</math>) |
||
(14 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
== Aim == | == Aim == | ||
− | Create an axisymetric mesh with blockMesh | + | Create an axisymetric mesh with blockMesh and setup the case for simpleFoam. |
+ | |||
== Mesh description: == | == 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. | |
− | is shown on the picture. "X","Y","Z" - coordinates, 0-5 points in blockMesh description. | + | |
[[Image:AxiSymetricMeshDrawingSchematicBlockMeshPoints.v.1.0.svg]] | [[Image:AxiSymetricMeshDrawingSchematicBlockMeshPoints.v.1.0.svg]] | ||
Line 9: | Line 9: | ||
== Writing blockMeshDict == | == Writing blockMeshDict == | ||
=== How to get points 1,4,5,2 ?=== | === How to get points 1,4,5,2 ?=== | ||
− | The wedge has angle | + | The wedge has angle <math>\alpha</math> = 5 deg. To calculate the points we need half of <math>\alpha</math> expressed in radians. |
Let Python to do the job: | Let Python to do the job: | ||
<Python> | <Python> | ||
− | + | $ python | |
+ | |||
Python 2.4.4 (#1, May 30 2008, 12:21:58) | Python 2.4.4 (#1, May 30 2008, 12:21:58) | ||
[GCC 4.1.2 (Gentoo 4.1.2 p1.1)] on linux2 | [GCC 4.1.2 (Gentoo 4.1.2 p1.1)] on linux2 | ||
Type "help", "copyright", "credits" or "license" for more information. | Type "help", "copyright", "credits" or "license" for more information. | ||
>>> import math | >>> import math | ||
− | >>> 0.19*math. | + | >>> 0.19/2.0*math.cos(math.pi*2.5/180) |
− | 0. | + | 0.094909581050276498 |
− | >>> 0.19*math. | + | >>> 0.19/2.0*math.sin(math.pi*2.5/180) |
− | 0. | + | 0.0041438417997069201 |
>>> | >>> | ||
</Python> | </Python> | ||
− | First value (0. | + | First value (0.0949) corresponds to x and second (0.00414) to y. |
− | Point 1 is (0. | + | Point 1 is (0.0949 0.00414 0) |
− | Point 4 is (0. | + | Point 4 is (0.0949 -0.00414 0) |
− | Point 2 is (0. | + | Point 2 is (0.0949 0.00414 1.1) |
− | Point 5 is (0. | + | Point 5 is (0.0949 -0.00414 1.1) |
=== blockMeshDict === | === blockMeshDict === | ||
Line 58: | Line 59: | ||
( | ( | ||
(0 0 0) | (0 0 0) | ||
− | (0. | + | (0.0949 0.00414 0) |
− | (0. | + | (0.0949 0.00414 1.1) |
− | (0 1.1 | + | (0 0 1.1) |
− | (0. | + | (0.0949 -0.00414 0) |
− | (0. | + | (0.0949 -0.00414 1.1) |
); | ); | ||
− | |||
blocks | blocks | ||
( | ( | ||
− | hex (0 | + | hex (0 4 1 0 3 5 2 3) (19 1 300) simpleGrading (1 1 1) |
); | ); | ||
Line 75: | Line 75: | ||
); | ); | ||
− | + | 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) | ||
+ | ); | ||
+ | } | ||
); | ); | ||
Line 109: | Line 133: | ||
=== Run a blockMesh === | === Run a blockMesh === | ||
− | <bash> | + | <bash> |
− | mkdir | + | mkdir -p ax/constant/polyMesh |
touch axiWiki/constant/polyMesh/blockMeshDict | touch axiWiki/constant/polyMesh/blockMeshDict | ||
emacs axiWiki/constant/polyMesh/blockMeshDict | emacs axiWiki/constant/polyMesh/blockMeshDict | ||
</bash> | </bash> | ||
− | + | Copy/paste the blockMeshDict from section above and save changes. | |
+ | |||
+ | |||
− | Now you have to write controlDict otherwise you will get | + | Now you have to write controlDict otherwise you will get an error when doing blockMesh: |
<bash> | <bash> | ||
--> FOAM FATAL IO ERROR : cannot open file | --> FOAM FATAL IO ERROR : cannot open file | ||
− | file: /home/rafal/ | + | file: /home/rafal/OpenFOAM/rafal-1.4.1/trunk/run/axiWiki/system/controlDict at line 0. |
From function regIOobject::readStream(const word&) | From function regIOobject::readStream(const word&) | ||
Line 127: | Line 153: | ||
FOAM exiting | FOAM exiting | ||
</bash> | </bash> | ||
− | Lets | + | Lets steal it from standard tutorial file for simpleFoam |
+ | case pitzDaily. It is not so important at this stage. | ||
<bash> | <bash> | ||
mkdir axiWiki/system | mkdir axiWiki/system | ||
− | cat $FOAM_RUN/tutorials/ | + | cat $FOAM_RUN/tutorials/simpleFoam/pitzDaily/system/controlDict > axiWiki/system/controlDict |
</bash> | </bash> | ||
+ | In later versions of OpenFOAM (i.e. 2.2.0), this path has to be modified slightly: | ||
+ | <bash> | ||
+ | cat $FOAM_RUN/tutorials/incompressible/simpleFoam/pitzDaily/system/controlDict > axiWiki/system/controlDict | ||
+ | </bash> | ||
+ | |||
Now you can run blockMesh. | Now you can run blockMesh. | ||
<bash> | <bash> | ||
− | + | /*---------------------------------------------------------------------------*\ | |
+ | | ========= | | | ||
+ | | \\ / 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 | Exec : blockMesh . axiWiki | ||
Date : Jun 18 2008 | Date : Jun 18 2008 | ||
− | Time : | + | Time : 13:09:31 |
Host : tux | Host : tux | ||
− | PID : | + | PID : 8950 |
− | Root : /home/rafal/ | + | Root : /home/rafal/OpenFOAM/rafal-1.4.1/trunk/run |
Case : axiWiki | Case : axiWiki | ||
Nprocs : 1 | Nprocs : 1 | ||
Line 160: | Line 198: | ||
Creating block mesh topology | Creating block mesh topology | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Default patch type set to empty | Default patch type set to empty | ||
Line 222: | Line 236: | ||
emacs axiWiki/constant/polyMesh/boundary | emacs axiWiki/constant/polyMesh/boundary | ||
</bash> | </bash> | ||
− | and change number of fields from 6 to 5 and delete the bit from the file | + | and change number of boundary fields from 6 to 5 and delete the bit below from the file |
<cpp> | <cpp> | ||
axis | axis | ||
Line 232: | Line 246: | ||
</cpp> | </cpp> | ||
− | == Lets see the mesh == | + | == Lets see the mesh in paraFoam == |
− | To see the mesh in paraFoam we need fvSchemes in system directory. | + | To see the mesh in paraFoam we need fvSchemes and fvSolution in system directory. |
− | Lets | + | Lets steal it from the same case like above. |
<bash> | <bash> | ||
− | + | cat $FOAM_RUN/tutorials/simpleFoam/pitzDaily/system/fvSolution > axiWiki/system/fvSolution | |
+ | cat $FOAM_RUN/tutorials/simpleFoam/pitzDaily/system/fvSchemes > axiWiki/system/fvSchemes | ||
</bash> | </bash> | ||
Now we should be able to see the mesh in paraFoam | Now we should be able to see the mesh in paraFoam | ||
Line 242: | Line 257: | ||
paraFoam . axiWiki | paraFoam . axiWiki | ||
</bash> | </bash> | ||
+ | == 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 | ||
+ | |||
+ | <bash> | ||
+ | $ gmshToFoam yormesh.msh | ||
+ | </bash> | ||
+ | |||
+ | 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) | ||
+ | |||
+ | :) --[[User:El Safti|El Safti]] 13:13, 22 September 2011 (CEST) | ||
+ | |||
+ | |||
+ | == 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: | ||
+ | <bash> | ||
+ | $ makeAxialMesh -axis axisPatchName -wedge wedgePatchName [-offset 5] | ||
+ | </bash> | ||
+ | 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): | ||
+ | <bash> | ||
+ | $ collapseEdges 0.00001 5 | ||
+ | </bash> | ||
+ | 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.--[[User:El Safti|El Safti]] 21:25, 22 September 2011 (CEST) | ||
== Disclaimer: == | == Disclaimer: == |
Latest revision as of 11:14, 30 August 2016
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)