!*************************************************************************************!
! TITLE: CFVR0822 - Combination module test
! SUBTITLE: Example to check the combinations utility
!
! DESCRIPTION: This example checks the functionality of the combinations module.
! DESCRIPTION:
! DESCRIPTION: It checks the following:
! DESCRIPTION:
! DESCRIPTION: - Results handle on SOLID45 elements.
! DESCRIPTION:
! DESCRIPTION: - Date handle with unsorted numeration (elements, load steps...)
! DESCRIPTION:
! DESCRIPTION:
! DESCRIPTION: The model is a two elements block model, each element is 1.00m * 1.50m * 1.00m.
! DESCRIPTION: All the nodes on one side are restrained (no movement is allowed).
! DESCRIPTION:
! DESCRIPTION: The load cases are:
! DESCRIPTION:
! DESCRIPTION: - Load Step 1, Sub Step 1: Imposed movement in X direction on a corner (node 30) of 1 meter.
! DESCRIPTION:
! DESCRIPTION: - Load Step 2, Sub Step 1: Imposed movement in Y direction on a corner (node 30) of 1 meter.
! DESCRIPTION:
! DESCRIPTION: No Civil materials have been used in this example,
! DESCRIPTION: only ANSYS results will be checked.
! DESCRIPTION:
! DESCRIPTION:
! DESCRIPTION: The target for the combinations is:
! DESCRIPTION:
! DESCRIPTION: - Target 45; Maximum stress in X direction
! DESCRIPTION:
! DESCRIPTION:
! DESCRIPTION: The combination rule defined is:
! DESCRIPTION:
! DESCRIPTION: - Combination rule 10: ADDITION: H1+H2
! DESCRIPTION:
!
! ELEMENT TYPE: Solid45
! MODULES:
! UNITS: SI
! KEYWORD1: Combinations
!*************************************************************************************!
  FINISH
  ~CFCLEAR,,1 
 AnsLic='ansys'

  NomFile='CFVR0822'
  /TITLE, %NomFile%, Combination module test with SOLID45
! ---------------------------------------------------------------------------------
! Model definition and solve
! ---------------------------------------------------------------------------------
/PREP7
! Materials
  MP,EX,5,3E6
  MP,NUXY,5,0.2
! Element types
  ET,2,SOLID45
! Nodes
  N,10,0.0,0.0
  N,20,1.0,0.0
  N,30,2.0,0.0
  N,40,0.0,1.5
  N,50,1.0,1.5
  N,60,2.0,1.5
  N,110,0.0,0.0,1.0
  N,120,1.0,0.0,1.0
  N,130,2.0,0.0,1.0
  N,140,0.0,1.5,1.0
  N,150,1.0,1.5,1.0
  N,160,2.0,1.5,1.0
! Elements
  MAT,5
  TYPE,2
  EN,100, 10, 20, 50, 40, 110, 120, 150, 140
  EN,200, 20, 30, 60, 50, 120, 130, 160, 150
! Boundary conditions
  D,10,ALL
  D,110,ALL
  D,40,ALL
  D,140,ALL
! Initial hypothesis solve
  /SOLU
  ! Hypothesis 1:
    /TITLE, Hypothesis 1
    OUTRES,ALL,ALL
    D,30,UX,1
    SOLVE
    DDELE,30,ALL
  ! Hypothesis 2:
    /TITLE, Hypothesis 2
    OUTRES,ALL,ALL
    D,30,UY,1
    SOLVE
    DDELE,30,ALL

/POST1
! ---------------------------------------------------------------------------------
! Read correct data from simple hypothesis
! ---------------------------------------------------------------------------------
  Dat=12 ! Number of data to check
  RES=
  *DIM,RES,,Dat,2
! Load data of each simple hypothesis
  ! Hypothesis 1
    SET,1,1
    *GET,RES( 1,1),NODE,30,S,X
    *GET,RES( 2,1),NODE,30,S,Y
    *GET,RES( 3,1),NODE,30,S,Z
    *GET,RES( 4,1),NODE,30,S,XY
    *GET,RES( 5,1),NODE,30,S,YZ
    *GET,RES( 6,1),NODE,30,S,XZ
    *GET,RES( 7,1),NODE,30,EPEL,X
    *GET,RES( 8,1),NODE,30,EPEL,Y
    *GET,RES( 9,1),NODE,30,EPEL,Z
    *GET,RES(10,1),NODE,30,EPEL,XY
    *GET,RES(11,1),NODE,30,EPEL,YZ
    *GET,RES(12,1),NODE,30,EPEL,XZ
  ! Hypothesis 2
    SET,2,1
    *GET,RES( 1,2),NODE,30,S,X
    *GET,RES( 2,2),NODE,30,S,Y
    *GET,RES( 3,2),NODE,30,S,Z
    *GET,RES( 4,2),NODE,30,S,XY
    *GET,RES( 5,2),NODE,30,S,YZ
    *GET,RES( 6,2),NODE,30,S,XZ
    *GET,RES( 7,2),NODE,30,EPEL,X
    *GET,RES( 8,2),NODE,30,EPEL,Y
    *GET,RES( 9,2),NODE,30,EPEL,Z
    *GET,RES(10,2),NODE,30,EPEL,XY
    *GET,RES(11,2),NODE,30,EPEL,YZ
    *GET,RES(12,2),NODE,30,EPEL,XZ

! ---------------------------------------------------------------------------------
! Definition and solving of combinations
! ---------------------------------------------------------------------------------
! Reset combinations module
  ~CMBCLR
! Targets definition
  ~TRGDEF,45,SOLID,S,X,MAX
! Combinations definition
  ! Combination 10: ADDITION [H1+H2]
      ~CMBDEF, 10,ADD,2
      ~STSTDEF,10,1,LSTEP,1, ,2,1,1
      ~STSTCFT,10, ,1.00
! Combine
  ~COMBINE

!--------------------------------------------------------------------------------------
! DATA CHECK
!--------------------------------------------------------------------------------------
! Data comparison number
  NComp = 12
  NComp_ch = 0

! Marix dim.
  *DIM,LABEL,CHAR,Ncomp,1
  *DIM,VALUE,,Ncomp,3
  *DIM,TOLER,,Ncomp,2

! Labels
!--------------------------------------------------------------------------------------
  *DO,I,1,NComp
    LABEL(I) ='TEST%I%'
  *ENDDO

! Correct values
!--------------------------------------------------------------------------------------
  *DO,I,1,NComp
    VALUE(I,1)=RES(I,1)+RES(I,2)
  *ENDDO

! Obtained values
!--------------------------------------------------------------------------------------
! Point to combined data
  ~CMBDAT,2
  ~CFSET,,10,45
  *GET,VALUE( 1,2),NODE,30,S,X
  *GET,VALUE( 2,2),NODE,30,S,Y
  *GET,VALUE( 3,2),NODE,30,S,Z
  *GET,VALUE( 4,2),NODE,30,S,XY
  *GET,VALUE( 5,2),NODE,30,S,YZ
  *GET,VALUE( 6,2),NODE,30,S,XZ
  *GET,VALUE( 7,2),NODE,30,EPEL,X
  *GET,VALUE( 8,2),NODE,30,EPEL,Y
  *GET,VALUE( 9,2),NODE,30,EPEL,Z
  *GET,VALUE(10,2),NODE,30,EPEL,XY
  *GET,VALUE(11,2),NODE,30,EPEL,YZ
  *GET,VALUE(12,2),NODE,30,EPEL,XZ

! Warning and error tolerances
  TOLER( 1, 1)= 1E-01   $   TOLER( 1, 2)= 1E-00
  TOLER( 2, 1)= 1E-02   $   TOLER( 2, 2)= 1E-01
  TOLER( 3, 1)= 1E-02   $   TOLER( 3, 2)= 1E-01
  TOLER( 4, 1)= 1E-02   $   TOLER( 4, 2)= 1E-01
  TOLER( 5, 1)= 1E-02   $   TOLER( 5, 2)= 1E-01
  TOLER( 6, 1)= 1E-02   $   TOLER( 6, 2)= 1E-01
  TOLER( 7, 1)= 1E-09   $   TOLER( 7, 2)= 1E-08
  TOLER( 8, 1)= 1E-09   $   TOLER( 8, 2)= 1E-08
  TOLER( 9, 1)= 1E-10   $   TOLER( 9, 2)= 1E-09
  TOLER(10, 1)= 1E-10   $   TOLER(10, 2)= 1E-09
  TOLER(11, 1)= 1E-09   $   TOLER(11, 2)= 1E-08
  TOLER(12, 1)= 1E-09   $   TOLER(12, 2)= 1E-08

!--------------------------------------------------------------------------------------
! Results comparison
!--------------------------------------------------------------------------------------
  COMPARA.MAC
