PROGRAM SETTRS4C
C=======================================================================
C                DATA GENERATING PROGRAM FOR torsion4q.for
C                        DOMAIN : TLX BY TLY  1/4 circle
C                          1/4 MODEL
C     DOMAIN SIZE: TLX BY TLY
C                         BOUNDARY CONDITIONS 
C        DIRICHLET: STRESS FUNCTION(S) ALONG THE OUTER BOUNDARY = 0
C          NEUMANN: DS/DN=0 ALONG THE SYMMETRY LINES
C           EIJI FUKUMORI NOVEMBER 28, 1995, NOV. 03, 2024
C=======================================================================
      IMPLICIT REAL*8 ( A-H , O-Z )
      PARAMETER ( ND=4, MXE=13400, MXN=13500, MXB=2300 )
CCCCCCCCC      PARAMETER (   TLX = 1.D0,   TLY =1.D0 )
C=======================================================================
      DIMENSION NODEX(MXE,ND),XCOORD(MXN),YCOORD(MXN),IBNDT(MXB),
     *          BVT(MXB), ITYPET(MXB)
C=======================================================================
C         NEY: NEMBER OF VERTICAL ELEMENTS (NUMBER OF NODES: NEY+1)
C         NEX: NEMBER OF HORIZONTAL ELEMENTS (NUMBER OF NODES: NEX+1)
C=======================================================================
      TLX = 1.094693879D0
      TLY = 1.094693879D0
      NEX = 10
      NEY = 10
C
      DX = TLX / NEX
      DY = TLY / NEY
      NDX=NEX+1
      NDY=NEY+1
      GM = 26538461.5384615D0
      THETA = 0.0000670055862315403D0
C=======================================================================
C                    ELEMENT CREATION
      NE = 0
      DO I = 1 , NEY
      DO J = 1 , NEX
      NE = NE + 1
      IF ( NE .GT. MXE ) STOP 'NE > MXE'
      NODEX(NE,1) = NDX*(I-1) + J
      NODEX(NE,2) = NODEX(NE,1) + 1
      NODEX(NE,3) = NODEX(NE,2) +NDX
      NODEX(NE,4) = NODEX(NE,1)+NDX
      END DO
      END DO
C=======================================================================
C                 NODAL COORDINATE CREATION
      NNODE = 0
      DO I = 1 , NDY
      DO J = 1 , NDX
      NNODE = NNODE + 1
      IF ( NNODE .GT. MXN ) STOP 'NNODE > MXN'
      NODE = NDX*(I-1) + J
      XCOORD(NODE) =  DX*(J-1)
      YCOORD(NODE) =  DY*(I-1)
      END DO
      END DO
C-------------------------- Circularization ----------------------------
      DO I = 1 , NNODE
      IF ( (XCOORD(I) .NE. 0.D0) ) THEN
      ANGLE = DATAN ( YCOORD(I)/XCOORD(I) )
      R = DMAX1 (XCOORD(I), YCOORD(I))
      XCOORD(I) = R*DCOS(ANGLE)
      YCOORD(I) = R*DSIN(ANGLE)
      END IF
      END DO
C=======================================================================
C                    BOUNDARY CONDITIONS
C--------- MOMENTUM EQUATIONS AND HEAT EQUATION
      NBT  = 0
C--------- FACE OF +Y AND -Y
C--------- -Y: NEUMANN PHI=0; NO INPUT DATA necessary
C--------- +Y: DIRICHLET
      DO J = 1 , NDX
      NBT = NBT + 1
      IBNDT(NBT) = NDY*(NDY-1) + J
      ITYPET(NBT) = 1
      BVT(NBT) = 0.D0
      END DO
C--------- FACE OF +X AND -X
C-------- -X: NEUMANN PHI=0; NO INPUT DATA necessary
C-------- +X DIRICHLET
      DO I = 1 , NEY
      NBT  = NBT  + 1
      IBNDT (NBT ) = NDX*I
      ITYPET(NBT) = 1
      BVT(NBT ) = 0.D0
      END DO
C=======================================================================
      WRITE (*,*) ' NUMBER OF ELEMENTS (NE) = ',NE
      WRITE (*,*) ' NUMBER OF NODAL POINTS (NNODE) = ',NNODE
C=======================================================================
      OPEN ( 1, FILE='ELEMENT4.OUT', STATUS = 'UNKNOWN' )
      DO IEL = 1 , NE
      DO J = 1 , ND
      NODE = NODEX(IEL,J)
      WRITE(1,*) XCOORD(NODE),YCOORD(NODE)
      END DO
      NODE = NODEX(IEL,1)
      WRITE(1,*) XCOORD(NODE),YCOORD(NODE)
      WRITE(1,*)
      END DO
      CLOSE (1)
C=======================================================================
C                     MAKING DATA FILES
C---------- 'PROJECT'.JNK
      IR = 1
      OPEN ( IR, FILE='TRS4DATA.DAT', STATUS='UNKNOWN' )
      WRITE (IR,*) GM, THETA
      WRITE (IR,*) NE
      DO IEL = 1 , NE
        WRITE (IR,*) IEL,(NODEX(IEL,J),J=1,ND)
      END DO
      WRITE (IR,*) NNODE
      DO NODE = 1 , NNODE
        WRITE (IR,*) NODE,XCOORD(NODE),YCOORD(NODE)
      END DO
      WRITE (IR,*) NBT
      DO I = 1 , NBT
        WRITE (IR,*) IBNDT(I), ITYPET(I), BVT(I)
      END DO
      CLOSE (1)
      STOP "NORMAL TERMINATION"
      END