본문 바로가기

카테고리 없음

Openfoam Create Patch Tutorial

5.3 Mesh generation with the blockMesh utility This section describes the mesh generation utility, blockMesh, supplied with OpenFOAM. The blockMesh utility creates parametric meshes with grading and curved edges.The mesh is generated from a dictionary file named blockMeshDict located in the system (or constant/polyMesh) directory of a case. BlockMesh reads this dictionary, generates the mesh and writes out the mesh data to points and faces, cells and boundary files in the same directory.The principle behind blockMesh is to decompose the domain geometry into a set of 1 or more three dimensional, hexahedral blocks. Edges of the blocks can be straight lines, arcs or splines.

The mesh is ostensibly specified as a number of cells in each direction of the block, sufficient information for blockMesh to generate the mesh data.Each block of the geometry is defined by 8 vertices, one at each corner of a hexahedron. The vertices are written in a list so that each vertex can be accessed using its label, remembering that OpenFOAM always uses the C convention that the first element of the list has label ‘0’. An example block is shown in Figure with each vertex numbered according to the list. The edge connecting vertices 1 and 5 is curved to remind the reader that curved edges can be specified in blockMesh.It is possible to generate blocks with less than 8 vertices by collapsing one or more pairs of vertices on top of each other, as described in section.Each block has a local coordinate system that must be right-handed.

Table 5.1: Keywords used in blockMeshDict.5.3.1 Writing a blockMeshDict fileThe blockMeshDict file is a dictionary using keywords described below. convertToMeters: scaling factor for the vertex coordinates, e.g. 0.001 scales to mm. vertices: list of vertex coordinates, see section. edges: used to describe curved geometry, see section. block: ordered list of vertex labels and mesh size, see section.

boundary: sub-dictionary of boundary patches, see section. mergePatchPairs: list of patches to be merged, see section.The convertToMeters keyword specifies a scaling factor by which all vertex coordinates in the mesh description are multiplied. Vertices(( 0 0 0 ) // vertex number 0( 1 0 0.1) // vertex number 1( 1.1 1 0.1) // vertex number 2( 0 1 0.1) // vertex number 3(-0.1 -0.1 1 ) // vertex number 4( 1.3 0 1.2) // vertex number 5( 1.4 1.1 1.3) // vertex number 6( 0 1 1.1) // vertex number 7); 5.3.1.2 The edgesEach edge joining 2 vertex points is assumed to be straight by default. However any edge may be specified to be curved by entries in a list named edges. The list is optional; if the geometry contains no curved edges, it may be omitted.Each entry for a curved edge begins with a keyword specifying the type of curve from those listed in Table.

Table 5.2: Edge types available in the blockMeshDict dictionary.The keyword is then followed by the labels of the 2 vertices that the edge connects. Following that, interpolation points must be specified through which the edge passes. For a arc, a single interpolation point is required, which the circular arc will intersect. For spline, polyLine and BSpline, a list of interpolation points is required.

The line edge is directly equivalent to the option executed by default, and requires no interpolation points. Note that there is no need to use the line edge but it is included for completeness. For our example block in Figure we specify an arc edge connecting vertices 1 and 5 as follows through the interpolation point. Blocks(hex (0 1 2 3 4 5 6 7) // vertex numbers(10 10 10) // numbers of cells in each directionsimpleGrading (1 2 3) // cell expansion ratios); The definition of each block is as follows: Vertex numbering The first entry is the shape identifier of the block, as defined in the $FOAM ETC-6/cellModels file. The shape is always hex since the blocks are always hexahedra. There follows a list of vertex numbers, ordered in the manner described on page.

Openfoam tutorial pdf

Number of cells The second entry gives the number of cells in each of the and directions for that block. Cell expansion ratios The third entry gives the cell expansion ratios for each direction in the block.

The expansion ratio enables the mesh to be graded, or refined, in specified directions. The ratio is that of the width of the end cell along one edge of a block to the width of the start cell along that edge, as shown in Figure. Each of the following keywords specify one of two types of grading specification available in blockMesh. SimpleGrading The simple description specifies uniform expansions in the local, and directions respectively with only 3 expansion ratios, e.g.simpleGrading (1 2 3) edgeGrading The full cell expansion description gives a ratio for each edge of the block, numbered according to the scheme shown in Figure with the arrows representing the direction from first cellto last cell e.g.edgeGrading (1 1 1 1 2 2 2 2 3 3 3 3)This means the ratio of cell widths along edges 0-3 is 1, along edges 4-7 is 2 and along 8-11 is 3 and is directly equivalent to the simpleGrading example given above.

Figure 5.5: Mesh grading along a block edge5.3.1.4 Multi-grading of a block Using a single expansion ratio to describe mesh grading permits only “one-way” grading within a mesh block. In some cases, it reduces complexity and effort to be able to control grading within separate divisions of a single block, rather than have to define several blocks with one grading per block. For example, to mesh a channel with two opposing walls and grade the mesh towards the walls requires three regions: two with grading to the wall with one in the middle without grading.OpenFOAM v2.4+ includes multi-grading functionality that can divide a block in an given direction and apply different grading within each division. This multi-grading is specified by replacing any single value expansion ratio in the grading specification of the block, e.g.

“ 1”, “ 2”, “ 3” in. Blocks(hex (0 1 2 3 4 5 6 7) (100 300 100)simpleGrading (1 2 3););We will present multi-grading for the following example:.

split the block into 3 divisions in the -direction, representing 20%, 60% and 20% of the block length;. include 30% of the total cells in the y-direction (300) in each divisions 1 and 3 and the remaining 40% in division 2;. apply 1:4 expansion in divisions 1 and 3, and zero expansion in division 2.We can specify this by replacing the -direction expansion ratio “ 2” in the example above with the following. Blocks(hex (0 1 2 3 4 5 6 7) (100 300 100)simpleGrading(1 // x-direction expansion ratio((0.2 0.3 4) // 20% y-dir, 30% cells, expansion = 4(0.6 0.4 1) // 60% y-dir, 40% cells, expansion = 1(0.2 0.3 0.25) // 20% y-dir, 30% cells, expansion = 0.25 (1/4))3 // z-direction expansion ratio));Both the fraction of the block and the fraction of the cells are normalized automatically.

They can be specified as percentages, fractions, absolute lengths, etc. And do not need to sum to 100, 1, etc. The example above can be specified using percentages, e.g. Blocks(hex (0 1 2 3 4 5 6 7) (100 300 100)simpleGrading(1((20 30 4) // 20%, 30%.(60 40 1)(20 30 0.25))3)); 5.3.1.5 The boundaryThe boundary of the mesh is given in a list named boundary. The boundary is broken into patches (regions), where each patch in the list has its name as the keyword, which is the choice of the user, although we recommend something that conveniently identifies the patch, e.g. Inlet; the name is used as an identifier for setting boundary conditions in the field data files. The patch information is then contained in sub-dictionary with:.

type: the patch type, either a generic patch on which some boundary conditions are applied or a particular geometric condition, as listed in section;. faces: a list of block faces that make up the patch and whose name is the choice of the user, although we recommend something that conveniently identifies the patch, e.g. Inlet; the name is used as an identifier for setting boundary conditions in the field data files.blockMesh collects faces from any boundary patch that is omitted from the boundary list and assigns them to a default patch named defaultFaces of type empty. This means that for a 2 dimensional geometry, the user has the option to omit block faces lying in the 2D plane, knowing that they will be collected into an empty patch as required.Returning to the example block in Figure, if it has an inlet on the left face, an output on the right face and the four other faces are walls then the patches could be defined as follows. MergePatchPairs(( ) // merge patch pair 0( ) // merge patch pair 1) The pairs of patches are interpreted such that the first patch becomes the master and the second becomes the slave. Figure 5.6: Merging overlapping patchesThe consequence is that the original geometry of the slave patch will not necessarily be completely preserved during merging. Therefore in a case, say, where a cylindrical block is being connected to a larger block, it would be wise to the assign the master patch to the cylinder, so that its cylindrical shape is correctly preserved.

There are some additional recommendations to ensure successful merge procedures:. in 2 dimensional geometries, the size of the cells in the third dimension, i.e. Out of the 2D plane, should be similar to the width/height of cells in the 2D plane;. it is inadvisable to merge a patch twice, i.e.

Include it twice in mergePatchPairs;. where a patch to be merged shares a common edge with another patch to be merged, both should be declared as a master patch.5.3.3 Projection of vertices, edges and faces blockMesh can be configured to create body fitted meshes using projection of vertices, edges and/or faces onto specified geometry. The functionality can be used to mesh spherical and cylindrical geometries such as pipes and vessels conveniently. The user can specify within the blockMeshDict file within an optional geometry dictionary with the same format as used in the snappyHexMeshDict file.

For example to specify a cylinder using the built in geometric type the user could configure with the following. Vertices(name v0 project (-1 -0.1 -1) (cylinder)name v1 project ( 1 -0.1 -1) (cylinder).);edges(project v0 v1 (cylinder).);When a name is provided for a given entity, it can be used to replace the index. In the example about, rather than specify the edge using vertex indices 0 and 1, the names v0 and v1 are used. 5.3.5 Creating blocks with fewer than 8 verticesIt is possible to collapse one or more pair(s) of vertices onto each other in order to create a block with fewer than 8 vertices. The most common example of collapsing vertices is when creating a 6-sided wedge shaped block for 2-dimensional axi-symmetric cases that use the wedge patch type described in section.

The process is best illustrated by using a simplified version of our example block shown in Figure. Let us say we wished to create a wedge shaped block by collapsing vertex 7 onto 4 and 6 onto 5. This is simply done by exchanging the vertex number 7 by 4 and 6 by 5 respectively so that the block numbering would become. Figure 5.7: Creating a wedge shaped block with 6 verticesThe same applies to the patches with the main consideration that the block face containing the collapsed vertices, previously (4 5 6 7) now becomes (4 5 5 4). This is a block face of zero area which creates a patch with no faces in the polyMesh, as the user can see in a boundary file for such a case.

The patch should be specified as empty in the blockMeshDict and the boundary condition for any fields should consequently be empty also. 5.3.6 Running blockMeshAs described in section, the following can be executed at the command line to run blockMesh for a case in the directory.

5.2 BoundariesIn this section we discuss the way in which boundaries are treated in OpenFOAM. The subject of boundaries is quite complex because their role in modelling is not simply that of a geometric entity but an integral part of the solution and numerics through boundary conditions or inter-boundary ‘connections’. A discussion of boundaries sits uncomfortably between a discussion on meshes, fields, discretisation, computational processing etc.We first need to consider that, for the purpose of applying boundary conditions, a boundary is generally broken up into a set of patches. One patch may include one or more enclosed areas of the boundary surface which do not necessarily need to be physically connected. A type is assigned to every patch as part of the mesh description, as part of the boundary file described in section.

It describes the type of patch in terms of geometry or a data ‘communication link’. An example boundary file is shown below for a sonicFoam case.

A type entry is clearly included for every patch ( inlet, outlet, etc. ), with types assigned that include patch, symmetryPlane and empty. Figure 5.3: Axi-symmetric geometry using the wedge patch type.5.2.1 Geometric (constraint) patch typesThe main geometric types available in OpenFOAM are summarised below.

This is not a complete list; for all types see $FOAM SRC/finiteVolume/fields/fvPatchFields/constraint. patch: generic type containing no geometric or topological information about the mesh, e.g.

Used for an inlet or an outlet. wall: for patch that coincides with a solid wall, required for some physical modelling, e.g. Wall functions in turbulence modelling. symmetryPlane: for a planar patch which is a symmetry plane. symmetry: for any (non-planar) patch which uses the symmetry plane (slip) condition. empty: for solutions in in 2 (or 1) dimensions (2D/1D), the type used on each patch whose plane is normal to the 3rd (and 2nd) dimension for which no solution is required. wedge: for 2 dimensional axi-symmetric cases, e.g.

A cylinder, the geometry is specified as a wedge of small angle ( e.g. FoamInfo totalPressure In the following sections we will highlight some particular important, commonly used boundary conditions. 5.2.3.1 The inlet/outlet conditionThe inletOutlet condition is one derived from mixed, which switches between zeroGradient when the fluid flows out of the domain at a patch face, and fixedValue, when the fluid is flowing into the domain.

Openfoam Create Patch Tutorial For Beginners

For inflow, the inlet value is specified by an inletValue entry. A good example of its use can be seen in the damBreak tutorial, where it is applied to the phase fraction on the upper atmosphere boundary. Where there is outflow, the condition is well posed, where there is inflow, the phase fraction is fixed with a value of 0, corresponding to 100% air.

Utilities

How To Use Openfoam

Find $FOAM SRC/finiteVolume/fields/fvPatchFields -type f xargs grep -l Function1 xargs dirname sort -u They include conditions such as uniformFixedValue, which is a fixedValue condition which applies a single value which is a function of time through a uniformValue keyword entry.The Function1 is specified by a keyword following the uniformValue entry, followed by parameters that relate to the particular function.