!*************************************************************************************!
! TITLE: CFVR3701 - Initial stresses on 2D Model
! SUBTITLE: Initial stresses on a 2D Model with irregular mesh.
!
! DESCRIPTION: A plane model is used to analyze the results obtained when applying
! DESCRIPTION: initial stresses and gravity on a 2D model with an irregular mesh.
! DESCRIPTION:
!
! ELEMENT TYPE: PLANE42
! MODULES: GETC
! UNITS: SI
! KEYWORD1: Geotechnics
!*************************************************************************************!
  FINISH
  ~CFCLEAR,,1
  ~CFACTIV,GETC,Y
  NomFile='CFVR3701'
  /TITLE, %NomFile%, Initial stresses on 2D Model

! -------------------------------------------------------------------------------------
! Initial data
! -------------------------------------------------------------------------------------
! CivilFEM SETUP
  ~UNITS,SI
  ~CODESEL,EC3-92,EC2-91,,,EC8-94

/PREP7

! 1. Element types
! --------------------------------------------------
ET,1,PLANE42,,,2

! 2. Materials
! --------------------------------------------------
~CFMP,1,LIB,SOIL,,GC
~CFMP,1,DatGen,GAM,,10500

! 3. Model
! --------------------------------------------------
 h1 = -10 ! Base height.
 h2 = 20  ! Upper height.
 b = 40   ! Base thickness.
 Ndiv = 5 ! Number of divisions.

K,1,0,h1
K,2,b,h1
K,3,0,h1+(h2-h1)/NDiv
K,4,b,h1+(h2-h1)/NDiv
K,5,0,h2-h1
K,6,b,h2-h1

lsel,none
l,1,2
l,3,4
l,5,6
LESIZE, ALL,,,NDiv
lsel,none
l,1,3
l,2,4
LESIZE, ALL,,,1
lsel,none
l,3,5
l,4,6
LESIZE, ALL,,,NDiv-1
lsel,all

A,1,2,4,3
A,3,4,6,5
! Hard points.
HPTCREATE,AREA,2,,COORD,b/Ndiv/2,(h2-h1)/2,0
HPTCREATE,AREA,2,,COORD,3*b/Ndiv/2,(h2-h1)/2,0

! Mesh.
TYPE,1
MAT,1
AMESH,1,2
NSEL,s,LOC,x,0
NSEL,a,LOC,x,b
D,all,ux,0
NSEL,s,LOC,y,h1
D,all,all
NSEL,all
ESEL,all

EPLOT
/IMAGE, SAVE, %NomFile%,BMP

! 4. Solution
! --------------------------------------------------
/SOLU
~TIS,cfvr3701,ist,-y
ISFILE,READ,cfvr3701,ist
ACEL,,9.81
SOLVE

! 5. Delete created files.
! --------------------------------------------------
/DELETE,cfvr3701,ist

!--------------------------------------------------------------------------------------
! DATA CHECK
!--------------------------------------------------------------------------------------
! Data comparison number
  NComp    = 12
  NComp_ch = 0

! 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

! Labels
!--------------------------------------------------------------------------------------
  LABEL( 1)  = 'SX_1'
  LABEL( 2)  = 'SY_1'
  LABEL( 3)  = 'SZ_1'
  LABEL( 4)  = 'SX_2'
  LABEL( 5)  = 'SY_2'
  LABEL( 6)  = 'SZ_2'
  LABEL( 7)  = 'SX_3'
  LABEL( 8)  = 'SY_3'
  LABEL( 9)  = 'SZ_3'
  LABEL(10)  = 'SX_4'
  LABEL(11)  = 'SY_4'
  LABEL(12)  = 'SZ_4'

! Correct data, obtained data
!--------------------------------------------------------------------------------------
   VALUE( 1,1) = -0.1928E6 $  *GET,VALUE( 1,2),NODE, 1,S,X
   VALUE( 2,1) = -0.3856E6 $  *GET,VALUE( 2,2),NODE, 1,S,Y
   VALUE( 3,1) = -0.1928E6 $  *GET,VALUE( 3,2),NODE, 1,S,Z
   VALUE( 4,1) = -0.1944E6 $  *GET,VALUE( 4,2),NODE, 4,S,X
   VALUE( 5,1) = -0.3888E6 $  *GET,VALUE( 5,2),NODE, 4,S,Y
   VALUE( 6,1) = -0.1944E6 $  *GET,VALUE( 6,2),NODE, 4,S,Z
   VALUE( 7,1) = -0.1738E6 $  *GET,VALUE( 7,2),NODE,10,S,X
   VALUE( 8,1) = -0.3476E6 $  *GET,VALUE( 8,2),NODE,10,S,Y
   VALUE( 9,1) = -0.1738E6 $  *GET,VALUE( 9,2),NODE,10,S,Z
   VALUE(10,1) = -0.1338E6 $  *GET,VALUE(10,2),NODE,22,S,X
   VALUE(11,1) = -0.2676E6 $  *GET,VALUE(11,2),NODE,22,S,Y
   VALUE(12,1) = -0.1338E6 $  *GET,VALUE(12,2),NODE,22,S,Z

! Warning and error tolerances
  *DO,II,1,12
    TOLER(II,1) = 1E4
    TOLER(II,2) = 1E4
  *ENDDO

!--------------------------------------------------------------------------------------
! Results comparison
!--------------------------------------------------------------------------------------
  COMPARA.MAC
