! Copyright (c) 2000-2013 Autodesk, Inc.  All Rights Reserved. This
! software is protected by United States and International Law, including
! copyrights, trademarks, patents and pending patents.  Copying, duplication,
! reproduction, or Distribution is strictly prohibited.

! Provided here are explicit interfaces to routines exported
! from Helius:MCT for use by user subroutines

MODULE HELIUS_MATERIALS
    INTEGER, PARAMETER :: HANDLE = INT_PTR_KIND()
    
    INTERFACE
        !
        ! Generic subroutines
        !
        SUBROUTINE HELIUS_ERR(ERRMSG, ERRTYPE)
            CHARACTER(LEN=*), INTENT(IN) :: ERRMSG
            INTEGER, INTENT(IN) :: ERRTYPE
        ENDSUBROUTINE
        
        SUBROUTINE FEA_JOBNAME(JNAME)
            CHARACTER(LEN=240), INTENT(OUT) :: JNAME
        ENDSUBROUTINE FEA_JOBNAME

        SUBROUTINE FEA_JOBDIR(JDIR)
            CHARACTER(LEN=240), INTENT(OUT) :: JDIR
        ENDSUBROUTINE FEA_JOBDIR

        !
        ! Subroutines for unis (2 constituents)
        !
        SUBROUTINE HELIUS2_NAME(HMAT, CMNAME)
            INTEGER(INT_PTR_KIND()), INTENT(IN) :: HMAT
            CHARACTER(LEN=80), INTENT(OUT) :: CMNAME
        ENDSUBROUTINE
        
        SUBROUTINE HELIUS2_STRENGTH(HPROP, STRENGTH)
            INTEGER(INT_PTR_KIND()), INTENT(IN) :: HPROP
            REAL(8), INTENT(OUT) :: STRENGTH(6)
        ENDSUBROUTINE            
        
        SUBROUTINE HELIUS2_ELASTIC(HMAT, HPROP, ELASTIC)
            INTEGER(INT_PTR_KIND()), INTENT(IN) :: HMAT, HPROP
            REAL(8), INTENT(OUT) :: ELASTIC(12,3)
        ENDSUBROUTINE
        
        SUBROUTINE HELIUS2_MICROSTRUCTURE(HMAT, HPROP, FVF)
            INTEGER(INT_PTR_KIND()), INTENT(IN) :: HMAT, HPROP
            REAL(8), INTENT(OUT) :: FVF
        ENDSUBROUTINE
        
        SUBROUTINE HELIUS2_DMGINI_MCT(HMAT, HPROP, STSM, STSF, FI, SR)
            INTEGER(INT_PTR_KIND()), INTENT(IN) :: HMAT, HPROP
            REAL(8), INTENT(IN) :: STSM(6), STSF(6)
            REAL(8), INTENT(OUT) :: FI(2), SR(2)
        ENDSUBROUTINE
        
        !
        ! Subroutines for plain weaves (3 constituents)
        !
        SUBROUTINE HELIUS3_NAME(HMAT, CMNAME)
            INTEGER(INT_PTR_KIND()), INTENT(IN) :: HMAT
            CHARACTER(LEN=80), INTENT(OUT) :: CMNAME
        ENDSUBROUTINE
        
        SUBROUTINE HELIUS3_STRENGTH(HPROP, STRENGTH, KNEE)
            INTEGER(INT_PTR_KIND()), INTENT(IN) :: HPROP
            REAL(8), INTENT(OUT) :: STRENGTH(7), KNEE(3)
        ENDSUBROUTINE            
        
        SUBROUTINE HELIUS3_ELASTIC(HMAT, HPROP, ELASTIC)
            INTEGER(INT_PTR_KIND()), INTENT(IN) :: HMAT, HPROP
            REAL(8), INTENT(OUT) :: ELASTIC(12,8)
        ENDSUBROUTINE
        
        SUBROUTINE HELIUS3_MICROSTRUCTURE(HMAT, HPROP, BVF, FVF)
            INTEGER(INT_PTR_KIND()), INTENT(IN) :: HMAT, HPROP
            REAL(8), INTENT(OUT) :: BVF(2), FVF(2)
        ENDSUBROUTINE
        
        !
        ! Micromechanics subroutines
        !
        SUBROUTINE HELIUS_MICROMECHANICS_HEXPACK(ELASTIC_C, ELASTIC_F, ELASTIC_M, FVF, FVF_FEA)
            REAL(8), INTENT(IN) :: ELASTIC_F(12), ELASTIC_M(12), FVF
            REAL(8), INTENT(OUT) :: ELASTIC_C(12), FVF_FEA
        ENDSUBROUTINE
        
    ENDINTERFACE
    
ENDMODULE HELIUS_MATERIALS

MODULE HELIUS
    USE HELIUS_MATERIALS
ENDMODULE HELIUS
