*deck,usersw       USERDISTRIB  parallel                                pck dc
      subroutine usersw (option,elem,intpt,mat,proptb,ncomp,epswel,
     x epel,e,nuxy,fluen,dfluen,tem,dtem,toffst,timvll,timvnc,usvr)
c
c *** primary function:   allow users to write their own swelling laws.
c                           this logic is accessed with c72 = 10
c *** secondary function:    demonstrate the use of user-written swelling laws
c
c
c         *** Copyright ANSYS.  All Rights Reserved.
c         *** ansys, inc.
c *** Notice - This file contains ANSYS Confidential information ***
c
c  input arguments:
c     option   (int,sc,in)       swelling option
c     elem     (int,sc,in)       element number (label)
c     intpt    (int,sc,in)       element integration point number
c     mat      (int,sc,in)       material reference number
c     proptb   (dp,ar(*),in)     nonlinear material table (tb commands)
c     ncomp    (int,sc,in)       number of strain components (=1, 4, or 6)
c                                   1 - truss or beam elements
c                                   4 - 2-d solids and pipe elements
c                                   6 - 3-d solids and most shells
c     epswel   (dp,sc,inout)     total accumulated swelling strain
c                                     before this substep
c     epel     (dp,ar(ncomp),inout) elastic strain
c     e        (dp,sc,in)        elastic modulus
c     nuxy     (dp,sc,in)        poisson'S RATIO
c     fluen    (dp,sc,in)        total fluence (bf or bfe commands)
c     dfluen   (dp,sc,in)        increment in fluence for this substep
c     tem      (dp,sc,in)        temperature (bf or bfe commands)
c     dtem     (dp,sc,in)        increment in temperature for this substep
c     toffst   (dp,sc,in)        offset of temperature scale from absolute zero
c                                               (toffst command)
c     timvll   (dp,sc,in)        time at the end of this substep
c     timvnc   (dp,sc,in)        the increment of time this substep
c     usvr     (dp,ar(*),inout)  user-defined state variables(optional)
c
c   output arguments:
c     epswel   (dp,sc,inout)     total accumulated swelling strain
c                                     after this substep
c     epel     (dp,ar(ncomp),inout) elastic strain adjusted
c                                                 for swelling increment
c     usvr     (dp,ar(*),inout)  updated user-defined state variables
c
#include "impcom.inc"


       external erhandler

#include "stepcm.inc"
      integer option,elem,intpt,mat,ncomp
      double precision  proptb(*),epswel,epel(ncomp),e,nuxy,
     x  fluen,dfluen,tem,dtem,toffst,timvll,timvnc,usvr(*),
     x  delswl,eptot(3)
c
c
c         the following conditions are checked before this routine is called
c            proptb(67) and proptb(68) are not both zero
c            fluen and dfluen are both positive
c            (temp + toffst) is .gt. zero
c            proptb(72) = 10 to activate user swelling option
c
c    *** the normal usage of the routine is for isotropic materials
c
c   *** customer should remove the below warning when making any changes ***
      if (kfstps .eq. 1) then
c
         if (intpt .eq. 1)
     Xcall erhandler('usersw',5000,2,
     x 'ANSYS,INC.-supplied version of coding for USERSW has been used.'
     x ,0.0d0,' ')
c

      endif
c
c   *** customer should remove the below dummy logic when making any changes ***
c     **** dummy logic to use unused variables ****
      delswl = option+elem+mat+ncomp
      delswl = epel(1)+e+nuxy+(tem+dtem+toffst)+(timvll-timvnc)+dfluen
      usvr(1) = usvr(1)
c
      eptot(1) = epel(1) + epswel
      if (ncomp .gt. 1) then
         eptot(2) = epel(2) + epswel
         eptot(3) = epel(3) + epswel
      endif
c
c         ******* begin sample law ****************************
c     *** swelling strain is a power function of fluence
c     *** epswl = proptb(67)*f**proptb(68)
c     *** let delswl = d(epswel)/d(fluen)
      delswl = proptb(67)*proptb(68)*fluen**(proptb(68) - 1.0d0)
c         ******* end sample law
c
c     *** the next executable statement is true for all laws
c     *** epswel(i) = epswel(i-1) + (d(epswel)/d(fluen))*dfluen
c     *** where i is the iteration counter
      epswel = epswel + delswl*dfluen
c
      epel(1) = eptot(1) - epswel
      if (ncomp .gt. 1) then
         epel(2) = eptot(2) - epswel
         epel(3) = eptot(3) - epswel
      endif
      return
      end
