!*****************************************************************************************************!
! TITLE: CFVR5103 -   Bridge Stretch: Long Clothoid
! SUBTITLE:
!
! DESCRIPTION: The example is a bridge with the following geometry:
! DESCRIPTION:
! DESCRIPTION: Plan View
! DESCRIPTION:
! DESCRIPTION: - Clothoid: From MP 0 (radius = 0) to MP 1000 (radius = 10).
! DESCRIPTION:
! DESCRIPTION: Elevation View
! DESCRIPTION:
! DESCRIPTION: - Straight line: From MP 0 to MP 1000 (0% slope).
! DESCRIPTION:
! DESCRIPTION: The aim of the example is to verify the geometry of a bridge.
!
! ELEMENT TYPE: NONE
! MODULES: NLBR
! UNITS: SI
! KEYWORD1: Bridges
!
!*************************************************************************************!

  FINISH
  ~CFCLEAR,,1
  ~CFACTIV,NLBR,Y
  NomFile='CFVR5103'
  /TITLE, %NomFile%, Bridge Stretch: Long Clothoid

! -------------------------------------------------------------------------------------
! Initial data
! -------------------------------------------------------------------------------------
! CivilFEM SETUP
  ~UNITS,SI
  ~CODESEL,EC3-92,EHE,,,EC8-94

/PREP7
Length = 1000
radius = 10
step   = 10
~brinip,1
~braddpl,  0,Length,   0, radius   ! Clothoid
~braddel,  0,Length ,

~BRSKTCH, step

!--------------------------------------------------------------------------------------
! DATA CHECK
!--------------------------------------------------------------------------------------
! Data comparison number
  NComp    = Length/step - 2
  NComp_ch = 1

! Marix dim.
  *DIM,LABEL,CHAR,Ncomp,1
  *DIM,LABEL_CH,CHAR,Ncomp_ch,1
  *DIM,VALUE,,Ncomp,3
  *DIM,VALUE_CH,CHAR,Ncomp_ch,3
  *DIM,TOLER,,Ncomp,2

! Correct data, Labels, obtained data
!--------------------------------------------------------------------------------------
  ~CFGET,PARA,BRIDGE,,STRETCH,PLANT,PARAM,1
*DO,i,1,NComp
   VALUE( i,1) =  1
   LABEL( i)  = 'KP%i+1%'
*ENDDO

*DO,i,2,NComp+1,1
   *get,ax,KP,i-1,LOC,X
   *get,ay,KP,i-1,LOC,Y
   *get,bx,KP,i  ,LOC,X
   *get,by,KP,i  ,LOC,Y
   *get,cx,KP,i+1,LOC,X
   *get,cy,KP,i+1,LOC,Y
   r1x = (bx - ax)/2
   r1y = (by - ay)/2
   r2x = (cx - bx)/2
   r2y = (cy - by)/2
   prodi = r1x*r2x + r1y*r2y
   modi  = sqrt(r1x**2 + r1y**2)
   cosalfa = prodi/modi**2
   alfa  = ACOS(cosalfa)
   beta = (ACOS(-1)-alfa)/2
   kappa = COS(beta)/modi
   ! s = A**2 * Kappa
   VALUE(i-1,2) = step*(i-1)/kappa/PARA**2
*ENDDO

! Warning and error tolerances
  *DO,II,1,NComp
    TOLER(II, 1)= 4E-2
    TOLER(II, 2)= 4E-2
  *ENDDO
  TOLER(  1,1) = 8E-2   $  TOLER(  1,2) = 8E-2
  TOLER( 37,1) = 6E-2   $  TOLER( 37,2) = 6E-2

!--------------------------------------------------------------------------------------
! Results comparison
!--------------------------------------------------------------------------------------
  COMPARA.MAC
