Encyclopaedia Index

Part 1. BFC-grid-generation tutorial

Contents

  1. PIL variables and commands involved
  2. Setting grid dimension
  3. Setting grid coordinates directly
  4. (Old commands for generating BFC grid)
  5. Shaping grids by copying and transforming
  6. Matching grids and sub-grids to frames
  7. Viewing and checking grids

PIL variables and commands involved in BFC grid generation

  1. Switch to BFC grid BFC=T Set the grid type to BFC
  2. Set grid dimension GSET(D,...) Set Grid Dimension
  3. Set coordinates directly
  4. Set grid by transformation
  5. Set grid by matching frames
  6. Tools for checking grid

Definition GSET(D

GSET(D,...)

Set the Grid Dimension

This command sets the initial BFC grid with the specified number of cells and the reference grid extent in each direction. It also sets the number of regions in each direction to 1, with uniform grid distribution.The optional reference extents are useful mainly for graphical monitoring of grid settings. Note that 'number of cells' here means the number of subdivisions in a certain direction, which is one less than the number of grid lines.

If dx, dy and dz are omitted, the default extent of 1 meter is set to each direction.


Format:  GSET(D,ni,nj,nk[,dx,dy,dz])

ni -- Integer value or expression, for the total number of cells in I direction. NX will be set to this value. nj -- Integer value or expression, for the total number of cells in J direction. NY will be set to this value. nk -- Integer value or expression, for the total number of cells in K direction. NZ will be set to this value.

dx -- Real value or expression, reference extent in X direction. XULAST will be set to this value. dy -- Real value or expression, reference extent in Y direction. YVLAST will be set to this value. dz -- Real value or expression, reference extent in Z direction. ZWLAST will be set to this value.

Examples

GSET(D

Example 1:
Setting initial grid in a 1-meter-cube box, with NX=5 NY=3 and NZ=8

BFC=T GSET(D,5,3,8)

Note that the last 3 arguments have been omitted

Example 2:
Setting initial grid in a box with:
XULAST=0.2 YVLAST=1.0 ZWLAST=2.0 NX=1 NY=5 NZ=20

This is a 2-D grid

BFC=T
GSET(D,1,5,20,0.2,1.0,2.0)

Here the last 3 arguments are supplied.

Note that the statements


  NX=1; NY=5;NZ=20;XULAST=0.2;YVLAST=1.0;ZWLAST=2.0
  BFC=T
  GSET(D,NX,NY,NZ,XULAST,YVLAST,ZWLAST)
would have the same effect, and may be easier to modify.

Definition

XC,YC,ZC

XC Array to store X coordinates of grid corners YC Array to store Y coordinates of grid corners ZC Array to store Z coordinates of grid corners

After BFC=T and GSET(D,...), XC, YC and ZC arrays will contain the coordinate values for a total number (NX+1)x(NY+1)x(NZ+1) of grid corners. As XC, YC and ZC are PIL arrays, their values can be modified by normal PIL assignment statements.

Format: XC(I,J,K)=... YC(I,J,K)=... ZC(I,J,K)=...

For XC(I,J,K),YC(I,J,K), ZC(I,J,K), The array dimensions are

I from 1 to NX+1 J from 1 to NY+1 K from 1 to NZ+1

Assignments may be effected by :

Examples of setting XC,YC,ZC now follow

Example 1:
Change coordinates for two grid-corner points


 BFC=T
 GSET(D,1,5,20,0.2,1.0,2.0)
 YC(2,6,11,1)=1.5; ZC(2,6,11,1)=0.8
 YC(2,6,12,1)=1.5; ZC(2,6,12,1)=0.85

Example 2:
Use XC,YC,ZC to build grid in a cylinder, by means of nested DO loops



 REAL(RR,AA,ZPWR,PI); PI=3.1416
 NX=10;         NY=5;        NZ=5
 XULAST=2.*PI;  YVLAST=0.5;  ZWLAST=2.0; ZPWR=1.0
 
 BFC=T
 GSET(D,NX,NY,NZ,XULAST,YVLAST,ZWLAST)
 +  DO KK=1,NZ+1
 +  DO JJ=1,NY+1
 +  DO II=1,NX+1
 +    RR=YVLAST*(JJ-1)/NY
 +    AA=XULAST*(II-1)/NX
 +    XC(II,JJ,KK)=RR*COS(AA)
 +    YC(II,JJ,KK)=RR*SIN(AA)
 +    ZC(II,JJ,KK)=ZWLAST*((KK-1)/NZ)**ZPWR
 +  ENDDO
 +  ENDDO
 +  ENDDO

Note that this is not the most economical formulation, even though it is the easiest to understand. For economy, the value of RR should be calculated once for each JJ; the COS and SIN terms should be evaluated only once for each II.

Changing the value of ZPWR can make the ZC distribution non-uniform.

Older (than GSET) commands for generating BFC grids

The following commands are still valid: SETPT, SETLIN, DOMAIN and MAGIC

Examples of the use of these commands are to be found in the input-file library of the BFC Option, for example case 459, 515, 517 and 519


GSET(C,....: Function and syntax

GSET(C,...) means 'Copy Grid'

This command copies to plane 2 the grid on plane 1 by means of shifting or rotating. The dimensions of the original mesh and the final one, in terms of I, J, K, must be the same.

The format to shift the grid is: GSET(C,pln2,F,pln1[,i1,i2,i3,i4],+,dx,dy,dz[,INC,pwr]) It may include the intermediate meshes


         GSET(C,pln2,F,pln1[,i1,i2,i3,i4],RX,ang,y0,z0[,INC,pwr])
         GSET(C,pln2,F,pln1[,i1,i2,i3,i4],RY,ang,x0,z0[,INC,pwr])
         GSET(C,pln2,F,pln1[,i1,i2,i3,i4],RZ,ang,x0,y0[,INC,pwr])
           rotate grid mesh about axis in X or Y or Z direction

pln1 -- The original grid plane, an expression which combines the grid plane direction and number. For example, I1 means the first I plane , J15 means the 15th J plane, K21 means the 21st plane in K direction. pln2 -- The final grid plane and number, in the same form as pln1.

i1,i2,i3,i4 -- The mesh limits on the grid plane. According to the grid plane direction, they are:


     grid plane direction       i1          i2          i3          i4

     I               MIN_J_CELL  MAX_J_CELL  MIN_K_CELL  MAX_K_CELL
     J               MIN_I_CELL, MAX_I_CELL, MIN_K_CELL, MAX_K_CELL
     K               MIN_I_CELL, MAX_I_CELL, MIN_J_CELL, MAX_J_CELL

dx,dy,dz -- The displacement of the final mesh from the original one in the three coordinate directions.

pwr -- When internal grid planes are included, this is the distribution power for the internal grid planes, in the same format as in GSET(L,...). When shifting grid planes, pwr sets the distrbution in terms of the distance; when rotating, it sets the distribution of angles.

ang -- Rotating angle in radians. Rotating direction obeys right hand convention. The positive direction is: for RX, from +Y to +Z; for RY, from +Z to +X; for RZ, from +X to +Y.

x0 -- the X position of the rotation axis. y0 -- the Y position of the rotation axis. z0 -- the Z position of the rotation axis.

GSET(C,... Example 1:
Rotate grid plane to form Polar-like grid

     
 BFC=T
 GSET(D,1,5,20,0.2,1.0,2.0)
 GSET(C,I2,F,I1,RZ,-0.2,0.0,0.0)
Here:

GSET(C,... Example 2:
The first GSET(C causes expansion; the second GSET(C causes rotation.


 BFC=T
 GSET(D,1,5,20,0.2,1.0,2.0)
 GSET(C,J6,F,J1,1,1,5,8,+,0.0,1.5,0.0,INC,1.5)
 GSET(C,K21,F,K11,RX,3.1416/2,-1.0,1.0,INC,1.0)

Here:

GSET(T,....: Function and syntax

GSET(T,...) means "provide transitions between grid planes"

This command is used to make a smooth transition from a grid mesh of one shape to another of a different shape. A linear interpolation is used. The two grid meshes must have the same dimensions in terms of I, J and K.

Format: GSET(T,pln2,F,pln1[,i1,i2,i3,i4],pwr)

pln1 -- The first grid plane and number pln2 -- The last grid plane and number

i1,i2,i3,i4 -- The grid mesh limits, as in the table in GSET(C,...).

pwr -- The distribution power for the transition, definition as in GSET(L,...).

Examples GSET(T

Example: The first GSET(T smoothes the left hand part, The second GSET(T straightens the bottom part of the rotated body.


         BFC=T
         GSET(D,1,5,20,0.2,1.0,2.0)
         GSET(C,J6,F,J1,1,1,5,8,+,0.0,1.5,0.0,INC,1.5)
         GSET(C,K21,F,K11,RX,3.1416/2,-1.0,1.0,INC,1.0)

GSET(T,K5,F,K1,1.0) GSET(T,K21,F,K11,1,1,1,2,1.0)

Fig d8

Definition

GSET(B

GSET(B,...) Set Internal Grid Points of a Block

This command performs interpolation for the internal grid coordinates of a block. The block can either be two dimensional or three dimensional. The interpolation method string is the same as in GSET(M,...).

Format: GSET(B,i1,i2,j1,j2,k1,k2,style)


         i1     --  The first I cell in the block
         i2     --  The last I cell in the block
         j1     --  The first J cell in the block
         j2     --  The last J cell in the block
         k1     --  The first K cell in the block
         k2     --  The last K cell in the block

style -- The interpolation method string

Examples GSET(B

Example: GSET(B sets the internal coordinates with Laplace solver and makes the grid as orthogonal as possible. A part of the whole grid plane (K from 11 to NZ) is considered.


         BFC=T
         GSET(D,1,5,20,0.2,1.0,2.0)
         GSET(C,J6,F,J1,1,1,5,8,+,0.0,1.5,0.0,INC,1.5)
         GSET(C,K21,F,K11,RX,3.1416/2,-1.0,1.0,INC,1.0)
         GSET(T,K5,F,K1,1.0)
         GSET(T,K21,F,K11,1,1,1,2,1.0)

GSET(B,1,NX,1,NY,11,NZ,LAP10)

Fig d9

Definition

GSET(P

GSET(P,...) Set a Point

This command defines a point in three-dimensional space. The coordinates are in metres. Up to 50 such points can be defined. If the named point has already been defined, this command will move the point.

Format: GSET(P,pnam,xp,yp,zp)

pnam -- Name of the point, up to four characters xp,yp,zp -- location of the point

Example: Set two points A and B in the 3-D space:


         GSET(P,A,-1.0,0.0,0.0)
         GSET(P,B,1.0,1.0,0.0)

Fig d10

Definition

GSET(L

GSET(L,...) Set a Line

This command defines a line as one of three types: a straight line, an arc, or a curve. The line is named 'lnam' by this command. A line must start at one named point and end at another. Up to 50 lines can be defined. A line can have up to 100 segments which will later be used to form grid cells. If the named line has already been defined, this command will modify the line.

Format: GSET(L,lnam,pnm1,pnm2,nseg[,powr]) ---- a straight line GSET(L,lnam,pnm1,pnm2,nseg,powr,ARC,arcx,arcy,arcz) --- a line on an arc GSET(L,lnam,pnm1,pnm2,nseg,powrCRVcvnm) -- a line on a curve lnam -- Name of the LINE, a string of up to four characters, the first of which must be alpha-numeric.

pnm1 -- Name of the POINT where the LINE starts. pnm2 -- Name of the POINT where the LINE ends. nseg -- Number of segments on the line, integer value or integer expression, in the range from 1 to 100. powr -- Distribution power string. This can be one of four types, eg: 1.0 Equally spaced; [Default] 0.8 Power law with power of 0.8; -1.5 Backward power law with power of 1.5; S2.0 Symmetric power law with power of 2.0 arcx,arcy,arcz -- The coordinates of an extra point to form an arc. The extra point and the two named points must not lie on a straight line, otherwise an arc can not be formed. cvnm -- Name of a CURVE which the line follows. The named curve must have already been defined by GSET(V,...).

Examples GSET(L

Straight line, uniform distribution GSET(L,L1,A,B,10)

Fig d11

Line on an arc GSET(L,L4,A,B,10,1.0,ARC,0.0,1.0,0.0)

Fig d12

Straight line, power law GSET(L,L2,A,B,10,1.5)

Fig d13

Straight line, symmetric power law GSET(L,L3,A,B,10,S1.5)

Fig d14

Definition

GSET(V

GSET(V,...) Set a Curve

This command defines a curve. A curve must start from one named point and end at another. The curve must be given a name, which will be used when defining a LINE. Up to 10 curves can be defined, each with up to 50 points. To define a curve named CV1, first use GSET(V,CV1,S,...) , then enter GSET(V,xvc,yvc,zvc) for each internal point, and finally, use GSET(V,CV1,E,...) to end the curve. To use the CURVE for defining a LINE, see GSET(L,...). A linear curve is formed by straight lines from one point to another; a spline curve will pass through all the defined points with continuity of gradient and curvature.

Format: GSET(V,vnam,S,pnm1,SPLINE[,svx,svy,svz]) start a spline curve GSET(V,xvc,yvc,zvc) set a point along the curve GSET(V,vnam,E,pnm2[,evx,evy,evz]) end a spline curve

vnam -- Name of the CURVE, a string of up to four characters, the first of which must be alpha-numeric.

pnm1 -- Name of the POINT where the CURVE starts. pnm2 -- Name of the POINT where the CURVE ends.

svx, svy, svz -- Vector components of the initial direction for spline curve. ( This sets the boundary condition of the spline curve solver.) evx, evy, evz -- Vector components of the ending direction for the spline curve (for setting the boundary condition of the spline curve solver).

xvc, yvc, zvc -- Coordinate data for the curve to follow.

Examples

GSET(V

Define spline curve CC


Start at point A with zero curvature boundary condition
  GSET(V,CC,S,A,SPLINE)
The curve goes throuth the following fixed points:
  GSET(V,-0.5,-0.5,0.0)
  GSET(V,0.0,0.8,0.0)
It ends towards point B in a direction (1.0,0.0,0.0) (+X direction)
  GSET(V,CC,E,B,1.0,0.0,0.0)

Use the curve to define a line

GSET(L,LV,A,B,30,1.0CRVCC)

Fig d15

Definition

GSET(F

GSET(F,...) Set a Frame

This command defines a FRAME which will be used for holding a grid mesh. Up to 20 frames can be defined. A frame must have four corners, each marked by a named POINT. The corner points must be linked by existing lines, or by a number of contiguous lines passing through intermediate named points. The total number of subdivisions on opposing edges of the frame must be equal.

In graphics mode (eg using the VIEW command), the frame name and extent (in terms of number of cells) is displayed to assist the user in determining the overall grid dimensions, and the grid plane limits when matching frames to grid planes.

Format: GSET(F,fnam,p1,m1,p2,m2,p3,m3,p4,m4)

fnam -- Name of the FRAME, a string of up to four characters, the first of which must be alpha-numeric.

p1 -- Name of the first corner POINT. p2 -- Name of the second corner POINT. p3 -- Name of the third corner POINT. p4 -- Name of the fourth corner POINT.

m1 -- List of intermediate points between the first and second corner points (listed in the direction from the first corner point to the second one). m2 -- List of intermediate points between the second and third corner points (listed in the direction from the second corner point to the third one). m3 -- List of intermediate points between the third and fourth corner points (listed in the direction from the third corner point to the fourth one). m4 -- List of intermediate points between the fourth and first corner points (listed in the direction from the fourth corner point to the first one).

If there are two or more intermediate points, they must be separated by a dot '.' in the list, ie P5.P6 if P5 and P6 are the names of intermediate points. When there is no intermediate point, use a hyphen, -, instead.

Examples

GSET(F

Examples:


     The simplest frame FR1 is constructed by 4 points and 4 lines.
        GSET(F,F1,A,-,B,-,C,-,D,-)
     More complecated frames FR2 and FR3 are constructed by
            more points and lines.
        GSET(F,F2, B, E.F, G, -, H, -, C, -)
        GSET(F,F3, D, C,   H, K, I, -, J, -)

Fig d16

Definition

GSET(M

GSET(M,...) Match a Grid Mesh

This command matches a section of grid mesh to a frame. This section of the grid must be the same size as the frame in terms of grid cell numbers. The origin of the mesh is defined by (i1,j1,k1), and its orientation is defined by the 'direc' string. In the 'direc' string, the two directions can neither be the same nor be opposites, ie +I+I and -K+K are not valid, but +I+J, -K+I or +J-I are valid.

See entries MAGIC, SLIDW, SLIDE, SLIDS, SLIDN, SLIDL, SLIDH for more information on interpolation methods.

Before GSET(M, the grid dimension must have already been defined by GSET(D.

Format: GSET(M,fnam,direc,i1,j1,k1[,style]) fnam -- Name of the frame to which a grid mesh will be matched. direc -- A string of four characters which shows the directions of grid lines to be matched to the frame edges. The first two characters can be one of: +I, -I, +J, -J, +K, -K which sets the direction for the frame edge from corner point 1 to corner point 2. The last two characters can also be one of the above six options and set the direction for the frame edge from corner point 2 to corner point 3.

i1,j1,k1 -- The index for the grid corner which is to be matched to the first corner POINT of the named frame. style -- The interpolation method for matching the grid, with the following options, for example: TRANS trans-finite interpolation LAP5 Laplace solver with 5 iterations LAP14.FFTFTF Laplace solver with 14 iterations, FFTFTF is the string to control the sliding boundary conditions. The order is: SLIDW, SLIDE, SLIDS, SLIDN, SLIDL, SLIDH. So the string above sets the SOUTH and LOW boundaries as sliding ones.

Examples

GSET(M

Frame F3 is matched to a part of the grid plane using Laplace solver with 20 iterations and the HIGH boundary is 'sliding'.


GSET(D,1,18,15)
GSET(M,F1,+J+K,1,1,1)
GSET(M,F2,+J+K,1,11,1)
GSET(M,F3,+J+K,1,1,7,LAP20.FFFFFT)

Fig d16

Definition

GSET(I

GSET(I)

Clear GridGen Elements

This command clears all the grid-generation elements, ie it sets the number of points, lines, curves and frames to zero. The grid which has already been set will not be affected. After this command has been issued, previous names for points, lines, etc can be re-used.

Format: GSET(I)

Examples

GSET(I

GSET(I) clears points, lines and frames.

Fig d17
TOOLS

Tools to check grid

SEEPTS Print out grid corner coordinates Format: SEEPTS(i1,i2,j1,j2,k1,k2)

VIEW Use full screen to show grid Format: VIEW VIEW(I or J or K, Number of plane)

GRDCHK Check grid orthogonality Format: GRDCHK(I or J or K, Number of plane)

JJS