OpenFOAM, like any other CFD package that uses the finite volume method, needs a mesh on which to solve the NS equations.
There are a lot of tools to make meshes these days, free or commercial.
Today I will focus on one of the tools provided with OpenFOAM: the blockMesh; this is mainly a dictionary in which the user types in vertices, edges, blocks and settings for the mesh and afterwards defines the boundary conditions.
That is the blockMesh is a CAD tool as much as is a meshing tool (the old school mesher). I will explain as condensed as possible, using the example of the forwardStep case (this can be found in the tutorials/compressible/sonicFoam/laminar).
That is the blockMesh is a CAD tool as much as is a meshing tool (the old school mesher). I will explain as condensed as possible, using the example of the forwardStep case (this can be found in the tutorials/compressible/sonicFoam/laminar).
The dictionary contains: the header, convertToMeters, vertices, blocks, edges, boundary and mergePatchPairs.
I will take each command and explain what it does:
header: this is a default for all dictionaries in OpenFOAM.
I will take each command and explain what it does:
header: this is a default for all dictionaries in OpenFOAM.
vertices: type in a list of points by Cartesian coordinates; keep in mind that the order of the points is important, as OpenFOAM will count the first point as vertex 0, the second as vertex 1 and so on.
convertToMeters: OpenFOAM uses the SI units for computing, therefore the coordinates must be typed in meters; this command helps us with the unit conversion, that is we don't need to make the conversion; leave this value 1 if the coordinates are in meters; change it to 0.001 if the coordinates are in millimeters; change it to 0.0254 if the coordinates are in inches and so on.
blocks: defines 6 faced volumes (command hex) using the before created vertices as corners; the order in which the points must be typed is shown in the following picture.
This picture gives even more information: when introducing the corner vertices, OpenFOAM sets by default a number and an orientation for each of the block's edges; as a rule, the edges that are in the direction of x axis, have the orientation of the x axis and are numbered by right hand rule (x axis direction is the thumb); the x axis edges are counted first, then the y axis and finally the z axis edges.
Returning to the problem at hand, the three blocks created look as in the following:
After the definition of corners, a list of three numbers is given; this list says how many cells to be created in each direction for the block; keep in mind that the number of cells must match between blocks; in the z direction we create a single cell because we want this to be a 2D grid.
This picture gives even more information: when introducing the corner vertices, OpenFOAM sets by default a number and an orientation for each of the block's edges; as a rule, the edges that are in the direction of x axis, have the orientation of the x axis and are numbered by right hand rule (x axis direction is the thumb); the x axis edges are counted first, then the y axis and finally the z axis edges.
Returning to the problem at hand, the three blocks created look as in the following:
After the definition of corners, a list of three numbers is given; this list says how many cells to be created in each direction for the block; keep in mind that the number of cells must match between blocks; in the z direction we create a single cell because we want this to be a 2D grid.
And finally, the last command specifies the aspect ration of the grid; that is the ratio of the cell size in that direction between the last and the first cell; we will change this later in order to create different meshes.
edges: defines the way that the edges would be created; if this is left empty, the edges are created by defaults as straight lines.
edges: defines the way that the edges would be created; if this is left empty, the edges are created by defaults as straight lines.
boundary: this command defines the boundary conditions for the mesh; using the below picture, the red face is the inlet, the green is the outlet, yellow are defined as symmetry and the gray is a no slip wall; in the blockMeshDict defined by the corresponding faces; keep in mind that the order of vertices to define the face is given again by the right hand rule (the thumb must be in the direction of the face normal - which is always pointing outside the block).
With the shown commands in the blockMeshDict, the following mesh is created:
From this point if we change the simpleGrading to (0.5 0.5 1) (2 0.5 1) (2 2 1), the following mesh is created:
With simpleGrading to (0.25 0.25 1) (4 0.25 1) (4 4 1), the following mesh is created:
With simpleGrading to (0.125 0.125 1) (8 0.125 1) (8 8 1), the following mesh is created:
And finally double-ing the cell number in all direction (except z direction) and th simpleGrading to (0.5 0.5 1) (2 0.5 1) (2 2 1), the following mesh is created:
This case was run with some nonphysical input values for velocity, temperature and pressure; in the following are shown the results for the first and last mesh:
Velocity:
Temperature:
Pressure:
Even if the results have no physical significance, it can be seen that there is a big difference in the solution based on which mesh is used.
If you have any questions or suggestion, please a comment below.
From this point if we change the simpleGrading to (0.5 0.5 1) (2 0.5 1) (2 2 1), the following mesh is created:
With simpleGrading to (0.25 0.25 1) (4 0.25 1) (4 4 1), the following mesh is created:
With simpleGrading to (0.125 0.125 1) (8 0.125 1) (8 8 1), the following mesh is created:
And finally double-ing the cell number in all direction (except z direction) and th simpleGrading to (0.5 0.5 1) (2 0.5 1) (2 2 1), the following mesh is created:
This case was run with some nonphysical input values for velocity, temperature and pressure; in the following are shown the results for the first and last mesh:
Velocity:
Temperature:
Pressure:
Even if the results have no physical significance, it can be seen that there is a big difference in the solution based on which mesh is used.
If you have any questions or suggestion, please a comment below.
0 comments:
Post a Comment