program tiler_2d ! !******************************************************************************* ! !! TILER_2D coordinates the PostScript details and runs the test. ! ! ! Reference: ! ! W N Gordon and Charles A Hall, ! Construction of Curvilinear Coordinate Systems and Application to ! Mesh Generation, ! International Journal of Numerical Methods in Engineering, ! Volume 7, pages 461-477, 1973. ! ! Joe Thompson, Bharat Soni, Nigel Weatherill, ! Handbook of Grid Generation, ! CRC Press, ! 1999. ! ! Discussion: ! ! This program also requires the PS_WRITE routines to run. ! ! Modified: ! ! 01 July 1999 ! ! Author: ! ! John Burkardt ! implicit none ! character ( len = 80 ) fileps integer ierror integer iunit real xmax real xmin real ymax real ymin ! write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TILER_2D' write ( *, '(a)' ) ' Create a PostScript image of a 2D tiling.' iunit = 1 fileps = 'tiler_2d.ps' call ps_file_open ( fileps, iunit, ierror ) if ( ierror /= 0 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TILER_2D' write ( *, '(a,i6)' ) ' File creation error ', ierror stop end if xmin = -5.0E+00 ymin = 0.0E+00 xmax = 5.0E+00 ymax = 5.0E+00 call ps_file_head ( fileps, xmax, xmin, ymax, ymin ) call ps_page_head call box_tiler_2d ( iunit ) call ps_page_tail call ps_file_tail call ps_file_close ( iunit ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TILER_2D' write ( *, '(a)' ) ' Normal end of execution.' stop end subroutine box_tiler_2d ( iunit ) ! !******************************************************************************* ! !! BOX_TILER_2D selects one sub-box at a time to be tiled. ! ! ! Reference: ! ! W N Gordon and Charles A Hall, ! Construction of Curvilinear Coordinate Systems and Application to ! Mesh Generation, ! International Journal of Numerical Methods in Engineering, ! Volume 7, pages 461-477, 1973. ! ! Joe Thompson, Bharat Soni, Nigel Weatherill, ! Handbook of Grid Generation, ! CRC Press, ! 1999. ! ! Modified: ! ! 27 August 1999 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, integer IUNIT, the FORTRAN unit number associated with the ! PostScript output file. ! implicit none ! integer i integer iunit integer j integer, parameter :: NI = 6 integer, parameter :: NJ = 3 real u0 real u1 real, parameter :: UMAX = 30.0E+00 real, parameter :: UMIN = 150.0E+00 real v0 real v1 real, parameter :: VMAX = 5.0E+00 real, parameter :: VMIN = 1.0E+00 ! ! Draw the region: ! ! Draw the items with horizontal index I: ! do i = 1, NI u0 = ( real ( NI + 1 - i ) * UMIN + real ( i - 1 ) * UMAX ) / real ( NI ) u1 = ( real ( NI - i ) * UMIN + real ( i ) * UMAX ) / real ( NI ) ! ! Draw the items with vertical index J: ! do j = 1, NJ v0 = ( real ( NJ + 1 - j ) * VMIN + real ( j - 1 ) * VMAX ) / real ( NJ ) v1 = ( real ( NJ - j ) * VMIN + real ( j ) * VMAX ) / real ( NJ ) ! ! Now that we have specified a subregion, "draw" the lines associated ! with the tile. ! call sub_box_tiler_2d ( UMIN, VMIN, UMAX, VMAX, u0, v0, u1, v1 ) end do end do return end subroutine sub_box_tiler_2d ( UMIN, VMIN, UMAX, VMAX, u0, v0, u1, v1 ) ! !******************************************************************************* ! !! SUB_BOX_TILER_2D "tiles" a sub-box with the given pattern. ! ! ! Reference: ! ! W N Gordon and Charles A Hall, ! Construction of Curvilinear Coordinate Systems and Application to ! Mesh Generation, ! International Journal of Numerical Methods in Engineering, ! Volume 7, pages 461-477, 1973. ! ! Joe Thompson, Bharat Soni, Nigel Weatherill, ! Handbook of Grid Generation, ! CRC Press, ! 1999. ! ! Modified: ! ! 27 August 1999 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, real UMIN, VMIN, UMAX, VMAX, the minimum and maximum values ! of U and V. ! ! Input, real U0, V0, U1, V1, the (U,V) coordinates of the opposite ! corners of the sub-box. ! implicit none ! integer, parameter :: NPOINT = 11 ! integer i real r real r_tab(NPOINT) real, parameter :: R0 = 0.0E+00 real, parameter :: R1 = 1.0E+00 real, parameter :: S0 = 0.0E+00 real, parameter :: S1 = 1.0E+00 real u real u0 real u1 real UMAX real UMIN real s real s_tab(NPOINT) real v real v0 real v1 real VMAX real VMIN real x(NPOINT) real x00 real x01 real x0v real x10 real x11 real x1v real xu0 real xu1 real y(NPOINT) real y00 real y01 real y0v real y10 real y11 real y1v real yu0 real yu1 ! ! Here is a sequence of points in (R,S) coordinate (between 0 and 1) ! which describe the "tile" that is to be drawn within each sub-box. ! r_tab(1) = 0.3E+00 s_tab(1) = 0.2E+00 r_tab(2) = 0.3E+00 s_tab(2) = 0.8E+00 r_tab(3) = 0.4E+00 s_tab(3) = 0.79E+00 r_tab(4) = 0.5E+00 s_tab(4) = 0.78E+00 r_tab(5) = 0.55E+00 s_tab(5) = 0.75E+00 r_tab(6) = 0.6E+00 s_tab(6) = 0.65E+00 r_tab(7) = 0.55E+00 s_tab(7) = 0.55E+00 r_tab(8) = 0.5E+00 s_tab(8) = 0.42E+00 r_tab(9) = 0.4E+00 s_tab(9) = 0.41E+00 r_tab(10) = 0.3E+00 s_tab(10) = 0.4E+00 r_tab(11) = 0.6E+00 s_tab(11) = 0.2E+00 ! ! Evaluate the (X,Y) coordinates of the corner (U,V) values. ! call boundary_2d ( UMIN, VMIN, UMAX, VMAX, UMIN, VMIN, x00, y00 ) call boundary_2d ( UMIN, VMIN, UMAX, VMAX, UMIN, VMAX, x01, y01 ) call boundary_2d ( UMIN, VMIN, UMAX, VMAX, UMAX, VMIN, x10, y10 ) call boundary_2d ( UMIN, VMIN, UMAX, VMAX, UMAX, VMAX, x11, y11 ) do i = 1, NPOINT ! ! Get the point (R,S) in the tile. ! r = r_tab(i) s = s_tab(i) ! ! Get the corresponding point (U,V) in the rectangular space. ! u = ( ( r1 - r ) * u0 + ( r - r0 ) * u1 ) / ( r1 - r0 ) v = ( ( s1 - s ) * v0 + ( s - s0 ) * v1 ) / ( s1 - s0 ) ! ! Evaluate (X,Y) at (U,0), (U,1), (0,V), (1,V). ! call boundary_2d ( UMIN, VMIN, UMAX, VMAX, u, VMIN, xu0, yu0 ) call boundary_2d ( UMIN, VMIN, UMAX, VMAX, u, VMAX, xu1, yu1 ) call boundary_2d ( UMIN, VMIN, UMAX, VMAX, UMIN, v, x0v, y0v ) call boundary_2d ( UMIN, VMIN, UMAX, VMAX, UMAX, v, x1v, y1v ) ! ! Get the corresponding point (X,Y) in the warped space. ! x(i) = ( - x00 * ( UMAX - u ) * ( VMAX - v ) & + x0v * ( UMAX - u ) * ( VMAX - VMIN ) & - x01 * ( UMAX - u ) * ( v - VMIN ) & + xu0 * ( UMAX - UMIN ) * ( VMAX - v ) & + xu1 * ( UMAX - UMIN ) * ( v - VMIN ) & - x10 * ( u - UMIN ) * ( VMAX - v ) & + x1v * ( u - UMIN ) * ( VMAX - VMIN ) & - x11 * ( u - UMIN ) * ( v - VMIN ) ) & / ( ( UMAX - UMIN ) * ( VMAX - VMIN ) ) y(i) = ( - y00 * ( UMAX - u ) * ( VMAX - v ) & + y0v * ( UMAX - u ) * ( VMAX - VMIN ) & - y01 * ( UMAX - u ) * ( v - VMIN ) & + yu0 * ( UMAX - UMIN ) * ( VMAX - v ) & + yu1 * ( UMAX - UMIN ) * ( v - VMIN ) & - y10 * ( u - UMIN ) * ( VMAX - v ) & + y1v * ( u - UMIN ) * ( VMAX - VMIN ) & - y11 * ( u - UMIN ) * ( v - VMIN ) ) & / ( ( UMAX - UMIN ) * ( VMAX - VMIN ) ) end do call ps_line ( NPOINT, x, y ) return end subroutine boundary_2d ( UMIN, VMIN, UMAX, VMAX, u, v, x, y ) ! !******************************************************************************* ! !! BOUNDARY_2D maps a point (U,V) to its corresponding (X,Y) coordinates. ! ! ! Discussion: ! ! The routine is only called to evaluate the (X,Y) coordinates of ! a point (U,V) which lies on the boundary. That is, one of ! U and V will always be a maximum or minimum value. ! ! Reference: ! ! W N Gordon and Charles A Hall, ! Construction of Curvilinear Coordinate Systems and Application to ! Mesh Generation, ! International Journal of Numerical Methods in Engineering, ! Volume 7, pages 461-477, 1973. ! ! Joe Thompson, Bharat Soni, Nigel Weatherill, ! Handbook of Grid Generation, ! CRC Press, ! 1999. ! ! Modified: ! ! 01 July 1999 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, real UMIN, VMIN, UMAX, VMAX, the minimum and maximum values ! of U and V. ! ! Input, real U, V, the (U,V) coordinates of a point that lies on the ! boundary of the region. ! ! Output, real X, Y, the (X,Y) coordinates of the image of the point. ! implicit none ! real, parameter :: DEG2RAD = 3.14159265E+00 / 180.0E+00 real UMAX real UMIN real VMAX real VMIN real theta real u real v real v2 real x real y theta = u * DEG2RAD if ( u == UMIN ) then x = v * cos ( theta ) y = v * sin ( theta ) else if ( u == UMAX ) then x = v * cos ( theta ) y = v * sin ( theta ) else if ( v == VMIN ) then x = v * cos ( theta ) y = v * sin ( theta ) else if ( v == VMAX ) then v2 = v + sin ( 3.0E+00 * theta ) x = v2 * cos ( theta ) y = v2 * sin ( theta ) else write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'BOUNDARY_2D - Fatal error!' stop end if return end