!*************************************************************************************!
! TITLE: CFVR3702 - Initial stresses on 3D Model
! SUBTITLE: Initial stresses on a 3D Model with irregular mesh.
!
! DESCRIPTION: A plane model is used to analyze the results obtained when applying
! DESCRIPTION: initial stresses and gravity on a 3D model with an irregular mesh.
! DESCRIPTION:
!
! ELEMENT TYPE: SOLID95
! MODULES: GETC
! UNITS: SI
! KEYWORD1: Geotechnics
!*************************************************************************************!
  FINISH
  ~CFCLEAR,,1
  ~CFACTIV,GETC,Y

  NomFile='CFVR3702'
  /TITLE, %NomFile%, Initial stresses. 3D Model.

! -------------------------------------------------------------------------------------
! Initial data
! -------------------------------------------------------------------------------------
! CivilFEM SETUP
  ~UNITS,SI
  ~CODESEL,EC3-92,EC2-91,,,EC8-94

/PREP7
! 1. Element types
! --------------------------------------------------
ET,1,SOLID95

! 2. Materials
! --------------------------------------------------
~CFMP,2,LIB,ROCK,,Lydite
~CFMP,2,DatGen,GAM,,17000

! 3. Model
! --------------------------------------------------
 h = 30   ! Height.
 c = 90   ! Width.
 b = 90   ! Base thickness.
 Ndiv = 5 ! Number of divisions.

esize,,Ndiv
BLOCK,0,b,0,c,0,h

! Mesh.
TYPE,1
MAT,2
VMESH,1

NSEL,s,LOC,x,0
NSEL,a,LOC,x,b
D,all,ux,0
NSEL,s,LOC,y,0
NSEL,a,LOC,y,c
D,all,uy,0
NSEL,s,LOC,z,0
D,all,all
NSEL,all
ESEL,all

! 4. Solution
! --------------------------------------------------
/SOLU
~TIS,cfvr3702,ist,-z
ISFILE,READ,cfvr3702,ist
ACEL,,,9.81
SOLVE

! 5. Delete created files.
! --------------------------------------------------
/DELETE,cfvr3702,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.15149E6 $  *GET,VALUE( 1,2),NODE,  1,S,X
   VALUE( 2,1) = -0.15149E6 $  *GET,VALUE( 2,2),NODE,  1,S,Y
   VALUE( 3,1) = -0.51017E6 $  *GET,VALUE( 3,2),NODE,  1,S,Z
   VALUE( 4,1) = -0.15149E6 $  *GET,VALUE( 4,2),NODE, 30,S,X
   VALUE( 5,1) = -0.15149E6 $  *GET,VALUE( 5,2),NODE, 30,S,Y
   VALUE( 6,1) = -0.51017E6 $  *GET,VALUE( 6,2),NODE, 30,S,Z
   VALUE( 7,1) =  0         $  *GET,VALUE( 7,2),NODE,110,S,X
   VALUE( 8,1) =  0         $  *GET,VALUE( 8,2),NODE,110,S,Y
   VALUE( 9,1) =  0         $  *GET,VALUE( 9,2),NODE,110,S,Z
   VALUE(10,1) = -0.89660E5 $  *GET,VALUE(10,2),NODE,430,S,X
   VALUE(11,1) = -0.89660E5 $  *GET,VALUE(11,2),NODE,430,S,Y
   VALUE(12,1) = -0.30610E6 $  *GET,VALUE(12,2),NODE,430,S,Z

!  Note:
!    the computed values #7 and #8 should be same order of magnitude than #9
!    (Sx = Sy = Ko*Sz), however due to the mesh density are significantly different.
!     Increasing the density of the mesh that difference would be reduced (all stresses
!     would approach zero)

! Warning and error tolerances
  *DO,II,1,12
    TOLER(II,1) = 1E4
    TOLER(II,2) = 1E4
  *ENDDO

! -------------------------------------------------------------------------------------
! Results comparison
! -------------------------------------------------------------------------------------
  COMPARA.MAC
