!*************************************************************************************!
! TITLE: CFVR5203 - Redefinition of the support beam using ~CFLSWRT
! SUBTITLE:
!
! DESCRIPTION: A prestressed beam is subjected to several load states.
! DESCRIPTION: The model is a fixed-pinned beam with a length of 15 m.
! DESCRIPTION:
! DESCRIPTION: The beam is made of C16/20 concrete.
! DESCRIPTION:
! DESCRIPTION: The cross section is a rectangular concrete one, 1 x 0.5, which has top and botto,
! DESCRIPTION: reinforcement of S400 steel, with 40 mm for geometrical cover and 28 mm of diameter.
! DESCRIPTION:
! DESCRIPTION: The load states are:
! DESCRIPTION:
! DESCRIPTION: - Load state 1: Self weight
! DESCRIPTION:
! DESCRIPTION: - Load state 2: Prestressing forces
! DESCRIPTION:
! DESCRIPTION: - Load state 3: Self weight and Prestressing forces
! DESCRIPTION:
! DESCRIPTION: - Load state 4: Self weight + Modified Prestressing
! DESCRIPTION:
! DESCRIPTION: - Load state 5: Self weight + Modified Prestressing and tendon deactivated.
! DESCRIPTION:
! DESCRIPTION: The aim of the example is to redefine the support beam using ~CFLSWRT command.
! DESCRIPTION:
! DESCRIPTION: This example is based on "Prestressed concrete,
! DESCRIPTION: a fundamental approach", 4<sup>th</sup> edition, page 16.
!
! ELEMENT TYPE: BEAM44
! MODULES: PRSC
! UNITS: SI
! KEYWORD1: Beam
! KEYWORD2: Tendon
! KEYWORD3: Cross Section
! KEYWORD4: Prestressed Concrete
!
!*************************************************************************************!
   FINISH
   ~CFCLEAR,,1
   NomFile='CFVR5203'
   /TITLE, CFVR5203 ,Redefinition of the support beam using ~CFLSWRT

! -------------------------------------------------------------------------------------
! Initial data
! -------------------------------------------------------------------------------------
! CivilFEM SETUP
  ~UNITS,SI
  ~CODESEL,,EC2-91,EC2-91
  ~CFACTIV,PRSC,Y

! Preprocessor
  /PREP7

! Material Definition
  ~CFMP,1,LIB,CONCRETE,EC2,C16/20
  ~CFMP,2,LIB,REINF,CEB,S400
  ~CFMP,3,LIB,PREST,ASTMA416,Gr250

! Element Type Definition
  ET,1,Beam44

! Cross-section definition
  ~CSECDMS,1,REC,1,1 ,0.5,0 ,0 ,0 ,0 ,0 ,0 ,1 ,2
! Beam & Shell property
  ~BMSHPRO,1,BEAM,1,1,,,44,1,1,,Beam 1

! Model Construction
  k,1
  k,2,15
  l,1,2
  dk,1,ux,0,,,uy,uz,rotx
  dk,2,uy,0,,,uz
  h_elems = 4
  medcut = h_elems+1
  endcut   = h_elems*2+1
  lesize,all,,,h_elems*2
  lmesh,all

! Support beam construction
  area = 0.001
  c_diameter = 0.15
  ~SBBMDEF

  ~PCEPDEF,1,       1,     0,0
  ~PCEPDEF,2,  medcut,-0.400,0
  ~PCEPDEF,3,  endcut,     0,0

  ~PCPPDEF,1,       1,     0,0
  ~PCPPDEF,3,  endcut,     0,0

  Papp = 862207

  ~PCTNDEF,1,3,area,c_diameter,Papp ,Papp ,0
  ~PCTNMDF,1,EADD,1.
  ~PCTNMDF,1,EADD,2.
  ~PCTNMDF,1,EADD,3.
  ~PCTNMDF,1,PADD,1.
  ~PCTNMDF,1,PADD,3.
  ~PCTNMDF,1,METHOD,1
  ~PCTNMDF,1,EPAROUT,1,0
  ~PCTNMDF,1,EPARIN,2,0
  ~PCLOSS,10000000,0,0,0.8,


 /SOLU
  ACEL,,9.81
  ~CFLSWRT              ! LS 1: Self weight

  ACEL,
  ~PCPL               ! Prestressing forces
  ~CFLSWRT              ! LS 2: Prestressing

  ~PCDEL              ! Prestressing forces delete
  ACEL,,9.81
  ~PCPL               ! Prestressing forces
  ~CFLSWRT              ! LS 3: SW + Prestressing

 ~PCDEL              ! Prestressing forces delete
 ~PCTNMDF,1,P0MAX,7000
 ~PCPL               ! Prestressing forces
 ~CFLSWRT              ! LS 4: SW + Prestressing modify

 ~PCTNMDF,1,ACTIVE,0
 ~CFLSWRT              ! LS 5: SW + Prestressing modify and tendon deactivated.

 LSSOLVE,1,5,1


!-----------------------------------------------------------------
! DATA CHECK
!-----------------------------------------------------------------
! Data comparison number
  NComp = 14
  NComp_ch = 0

! Matrix 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 values
  VALUE( 1,1) = 1
  VALUE( 2,1) = 2
  VALUE( 3,1) = 0.39137E+08
  VALUE( 4,1) = 0.10420E+09
  VALUE( 5,1) = 0.
  VALUE( 6,1) = 0.78000E+08
  VALUE( 7,1) = 0.71160E+08
  VALUE( 8,1) = 0.
  VALUE( 9,1) = 9
  VALUE(10,1) = 0.78000E+08
  VALUE(11,1) = 0.71160E+08
  VALUE(12,1) = 4
  VALUE(13,1) = 2
  VALUE(14,1) =-0.106666

! Labels
  LABEL( 1) ='TEST1'
  LABEL( 2) ='TEST2'
  LABEL( 3) ='TEST3'
  LABEL( 4) ='TEST4'
  LABEL( 5) ='TEST5'
  LABEL( 6) ='TEST6'
  LABEL( 7) ='TEST7'
  LABEL( 8) ='TEST8'
  LABEL( 9) ='TEST9'
  LABEL(10) ='TEST10'
  LABEL(11) ='TEST11'
  LABEL(12) ='TEST12'
  LABEL(13) ='TEST13'
  LABEL(14) ='TEST14'

! Warning and error tolerances
  TOLER( 1, 1)= 1E-5       $   TOLER( 1, 2)= 1E-5
  TOLER( 2, 1)= 1E-5       $   TOLER( 2, 2)= 1E-5
  TOLER( 3, 1)= 1E4        $   TOLER( 3, 2)= 1E4
  TOLER( 4, 1)= 1E6        $   TOLER( 4, 2)= 1E6
  TOLER( 5, 1)= 1E-5       $   TOLER( 5, 2)= 1E-5
  TOLER( 6, 1)= 1E4        $   TOLER( 6, 2)= 1E4
  TOLER( 7, 1)= 1E4        $   TOLER( 7, 2)= 1E4
  TOLER( 8, 1)= 1E-5       $   TOLER( 8, 2)= 1E-5
  TOLER( 9, 1)= 1E-5       $   TOLER( 9, 2)= 1E-5
  TOLER(10, 1)= 1E4        $   TOLER(10, 2)= 1E4
  TOLER(11, 1)= 1E4        $   TOLER(11, 2)= 1E4
  TOLER(12, 1)= 1E-5       $   TOLER(12, 2)= 1E-5
  TOLER(13, 1)= 1E-5       $   TOLER(13, 2)= 1E-5
  TOLER(14, 1)= 1E-5       $   TOLER(14, 2)= 1E-5

/POST1
~CFSET,,2
~CFGET,VALUE( 1,2),PRSCONC,,TENDON,COUNT
~CFGET,VALUE( 2,2),PRSCONC,,TENDON,PNPTS,,1
~CFGET,VALUE( 3,2),PRSCONC,,TENDON,LOSS,,1,3,1
~CFGET,VALUE( 4,2),PRSCONC,,TENDON,LOSS,,1,4,2
~CFGET,VALUE( 5,2),PRSCONC,,TENDON,LOSS,,1,5,3

~CFSET,,3
~CFGET,VALUE( 6,2),PRSCONC,,TENDON,LOSS,,1,3,4
~CFGET,VALUE( 7,2),PRSCONC,,TENDON,LOSS,,1,4,5
~CFGET,VALUE( 8,2),PRSCONC,,TENDON,LOSS,,1,5,6

~CFSET,,4
~CFGET,VALUE( 9,2),PRSCONC,,CUT,COUNT
~CFGET,VALUE(10,2),PRSCONC,,CUT,LOSS ,,5,1,4
~CFGET,VALUE(11,2),PRSCONC,,CUT,LOSS ,,6,1,5

~CFSET,,5
~CFGET,VALUE(12,2),PRSCONC,,NODE,CUT, ,5
~CFGET,VALUE(13,2),PRSCONC,,PPOINT,COUNT
~CFGET,VALUE(14,2),PRSCONC,,EPOINT,SLOPE, ,1

!--------------------------------------------------------------------------------------
! Results comparison
!--------------------------------------------------------------------------------------
  COMPARA.MAC
