PROGRAM SET27STAX3D
C=======================================================================
C         THREE DIMENSIONAL DATA GENERATING PROGRAM FOR STATICX.FOR
C    PROJECT NAME: EIGENVALUE
C    BOUNDARY CONDITIONS
C            LEFT END : EITHER FIXED OR FREE
C            RIGHT END: FREE
C            ALL OTHERS: NO NORMAL FOECE, NO SHEAR FORCE
C    DOMAIN: RECTANGULAR
C    ELEMENT: 27-NODED ISOPARAMETRIC HEXA 3D PARABOLIC ELEMENT
C    DOMAIN DISCRETIZATION: ONE-SIZE ELEMENTS 
C     EIJI FUKUMORI DECEMBER 9, 2010
C=======================================================================
      IMPLICIT REAL*8 ( A-H , O-Z )
      PARAMETER ( ND=27, MXE=220000, MXN=4000000, MXB=200000 )
      PARAMETER (YOUNG=205.D9,POISSON=0.3D0, DENSITY=7860.D0,
     * TLX = 100.D0    , TLY = 2.D0   , TLZ = 2.D0   ,   
     * NEX = 100       , NEY = 2      , NEZ = 2          )
C=======================================================================
      DIMENSION NODEX(MXE,ND), 
     * XCOORD(MXN), YCOORD(MXN) ,ZCOORD(MXN),
     * IBNDFX(MXB), IBNDFY(MXB) ,IBNDFZ(MXB)
      CHARACTER INPFILE*13,EXFILE*3
      LOGICAL YES, RSTRAINT
C=======================================================================
      DATA INPFILE / 'EIGN3D27S.DAT' /
C=======================================================================
      F(X) = X 
      G(X) = X
C=======================================================================
      WRITE (*,*) 'ND =', ND
      DX=TLX/(2*NEX)
      DY=TLY/(2*NEY)
      DZ=TLZ/(2*NEZ)
      NDX = 2*NEX+1
      NDY = 2*NEY+1  
      NDZ = 2*NEZ+1 
C=======================================================================
C      NEZ: NEMBER OF VERTICAL   ELEMENTS
C      NEY: NEMBER OF DEPTH      ELEMENTS
C      NEX: NEMBER OF HORIZONTAL ELEMENTS
C=======================================================================
C--------- EIGRNVALUE PARAMETER
C--------- DELTA = SHIFT PARAMETER THAT MUST BE > 0.
C--------- NEIGEN = NUMBER OF EIGRNVALUES TO BE EVALUATED
C------- IF THERE ARE SOME DIRICHLET BOUNDARIES, RSTRAINT = .TRUE.
C------- IF NO NODE IS GROUNDED, RSTRAINT = .FALSE.
C------- RSTRAINT = .FALSE. IF FREE MOTION.
C------- RSTRAINT = .TRUE.  IF SOME NODES ARE FIXED.
      DELTA    = 1.D-2
      NEIGEN   = 30
      RSTRAINT = .FALSE.
C=======================================================================
      WRITE (*,*) INPFILE
      WRITE (*,*)'DENSITY OF SOLID = ',DENSITY
      WRITE (*,*)'YOUNG MODULUS    = ',YOUNG
      WRITE (*,*)'POISSON RATIO    = ',POISSON
      WRITE (*,*)'DELTA    =', DELTA
      WRITE (*,*)'NEIGEN   =', NEIGEN
      WRITE (*,*)'RSTRAINT =', RSTRAINT
C=======================================================================
C                    ELEMENT CREATION
      NE = 0
      DO I = 1 , NEX
      DO J = 1 , NEZ
      DO K = 1 , NEY
      NE = NE + 1
      IF ( NE .GT. MXE ) STOP 'NE > MXE'
C------- BOTTOM FLOOR
      NODEX(NE,1)  = (I-1)*NDY*NDZ*2 + (J-1)*NDY*2 + (K-1)*2 + 1
      NODEX(NE,2)  = NODEX(NE,1) + NDY*NDZ
      NODEX(NE,3)  = NODEX(NE,2) + NDY*NDZ
      NODEX(NE,4)  = NODEX(NE,3) + 1
      NODEX(NE,5)  = NODEX(NE,4) + 1
      NODEX(NE,8)  = NODEX(NE,1) + 1
      NODEX(NE,7)  = NODEX(NE,8) + 1
      NODEX(NE,9)  = NODEX(NE,2) + 1
      NODEX(NE,6)  = NODEX(NE,9) + 1
C------- MIDIUM FLOOR
      NODEX(NE,10) = NODEX(NE,1) + NDY
      NODEX(NE,17) = NODEX(NE,10) + 1
      NODEX(NE,16) = NODEX(NE,17) + 1
      NODEX(NE,11) = NODEX(NE,10) + NDY*NDZ
      NODEX(NE,18) = NODEX(NE,11) + 1
      NODEX(NE,15) = NODEX(NE,18) + 1
      NODEX(NE,12) = NODEX(NE,11) + NDY*NDZ
      NODEX(NE,13) = NODEX(NE,12) + 1
      NODEX(NE,14) = NODEX(NE,13) + 1
C------- TOP FLOOR
      NODEX(NE,19) = NODEX(NE,10) + NDY
      NODEX(NE,26) = NODEX(NE,19) + 1
      NODEX(NE,25) = NODEX(NE,26) + 1
      NODEX(NE,20) = NODEX(NE,19) + NDY*NDZ
      NODEX(NE,27) = NODEX(NE,20) + 1
      NODEX(NE,24) = NODEX(NE,27) + 1
      NODEX(NE,21) = NODEX(NE,20) + NDY*NDZ
      NODEX(NE,22) = NODEX(NE,21) + 1
      NODEX(NE,23) = NODEX(NE,22) + 1
      END DO
      END DO
      END DO
      WRITE (*,*) 'NUMBER OF ELEMENTS =', NE
      CALL BANDWID ( MXE , ND , NE , NODEX , NBW )
C=======================================================================
C--------0---------0---------0---------0---------0---------0---------0--
C                 NODAL COORDINATE CREATION
      NNODE = 0
      DO I = 1 , NDX
      DO K = 1 , NDZ
      DO J = 1 , NDY
      NNODE = NNODE + 1
      IF ( NNODE .GT. MXN ) STOP 'NNODE > MXN'
      XCOORD(NNODE) = (I-1)*DX
      YCOORD(NNODE) = (J-1)*DY
      ZCOORD(NNODE) = (K-1)*DZ
      END DO
      END DO
      END DO
      WRITE (*,*) 'NUMBER OF NODAL POINTS =', NNODE
C=======================================================================
C                    BOUNDARY CONDITIONS
C==== FIRST FIND
C--------- NAVIER EQUATIONS
C------- IF THERE ARE SOME DIRICHLET BOUNDARIES, RSTRAINT = .TRUE.
C------- IF NO NODE IS GROUNDED, RSTRAINT = .FALSE.
      NBFX = 0
      NBFY = 0
      NBFZ = 0
      IF ( RSTRAINT ) THEN
C-----------------------------------------------
C--------- X DIRECTION ON FACE -X
      DO K = 1 , NDZ
      DO J = 1 , NDY
C
      NBFX = NBFX + 1
      IBNDFX(NBFX) = J + (K-1)*NDY
C
      NBFY = NBFY + 1
      IBNDFY(NBFY) = J + (K-1)*NDY
C
      NBFZ = NBFZ + 1
      IBNDFZ(NBFZ) = J + (K-1)*NDY
C
      END DO
      END DO
      END IF
C-----------------------------------------------
      WRITE(*,*) 'NUMBER OF DIRICHLET BOUNDARY CONDITIONS IN X=',NBFX
      WRITE(*,*) 'NUMBER OF DIRICHLET BOUNDARY CONDITIONS IN Y=',NBFY
      WRITE(*,*) 'NUMBER OF DIRICHLET BOUNDARY CONDITIONS IN Z=',NBFZ
C=======================================================================
C                         DATA FILE INQUIRY
      EXFILE = 'NEW'
      INQUIRE ( FILE = INPFILE, EXIST = YES )
      IF ( YES ) EXFILE='OLD'
C=======================================================================
C                     CREATING DATA FILES
C---------- PARAMETERS
      OPEN ( 1, FILE=INPFILE, STATUS = EXFILE )
      WRITE(1,*) DELTA, NEIGEN 
      WRITE(1,*) DENSITY, YOUNG, POISSON
C---------- ELEMENTS
      WRITE(1,*) NE
      DO I = 1 , NE
      WRITE (1,*) I, (NODEX(I,J), J = 1 , ND )
      END DO
C---------- COORDINATES OF NONAL POINTS
      WRITE(1,*) NNODE
      DO I = 1 , NNODE
      WRITE(1,*) I,XCOORD(I), YCOORD(I), ZCOORD(I)
      END DO
C---------- DIRICHLET TYPE BOUNDARY CONDITIONS
      WRITE(1,*) NBFX
       IF ( NBFX .GT. 0 ) THEN
         DO I = 1 , NBFX 
         WRITE (1,*) IBNDFX(I)
         END DO
       END IF
      WRITE(1,*) NBFY
       IF ( NBFY .GT. 0 ) THEN
         DO  I = 1 , NBFY 
         WRITE (1,*) IBNDFY(I)
         END DO
       END IF
      WRITE(1,*) NBFZ
       IF ( NBFZ .GT. 0 ) THEN
         DO  I = 1 , NBFZ 
         WRITE (1,*) IBNDFZ(I)
         END DO
       END IF
C=======================================================================
C---------- FINAL
      CLOSE (1)
C=======================================================================
      IF ( ND .EQ.  8 ) INTEPT=2
      IF ( ND .EQ. 27 ) INTEPT=3
C------ CREATION OF PARAMETER FILE TO BE USED IN INCLUDE STATEMENT
      OPEN ( 1, FILE='PARAM.DAT', STATUS='UNKNOWN' )
      WRITE (1,*) '      PARAMETER ( ND=',ND,' )'
      WRITE (1,*) '      PARAMETER ( INTEPT=',INTEPT,' )'
      WRITE (1,*) '      PARAMETER ( MXE=',NE,' )'
      WRITE (1,*) '      PARAMETER ( MXN=',NNODE,' )'
      WRITE (1,*) '      PARAMETER ( MXW=',NBW,' )'
      WRITE (1,*) '      PARAMETER ( MXENGN=',NEIGEN,' )'
      WRITE (1,*) '      PARAMETER ( MXB=',NBFX+NBFY+NBFZ,' )'
      CLOSE (1)
C=======================================================================
      STOP 'NORMAL TERMINATION'
      END
C
C
      SUBROUTINE BANDWID ( MXE , ND , NE , NODEX , NBW )
      DIMENSION NODEX(MXE,ND)
      NBW = 0
      DO I = 1 , NE
      DO J = 1 , ND-1
      DO K = J+1 , ND
      NBW = MAX0 ( NBW , IABS(NODEX(I,J)-NODEX(I,K)) )
      END DO
      END DO
      END DO
      NBW = NBW + 1
      WRITE (*,*) 'HALH BANDWIDTH =', NBW
      RETURN
      END