2.3. Subroutines for Modifying and Monitoring Existing Elements

2.3.1. Subroutine userou (Storing User-Provided Element Output)

*deck,userou                      USERDISTRIB
      subroutine userou (elem,iout,nbsvr,bsvr,nnrsvr,nrsvr,npsvr,psvr,
     x ncsvr,csvr,nusvr,usvr,nnode,nodes,xyz,vol,leng,time,
     x timinc,nutot,utot,maxdat,numdat,udbdat)
c
c *** primary function:    store user supplied element output
c                           in nmisc record
c
c         in order to activate this user programmable feature,
c         the user must enter the usrcal command.
c
c
c         *** Copyright ANSYS.  All Rights Reserved.
c         *** ansys, inc.
c *** Notice - This file contains ANSYS Confidential information ***
c
c             this routine is called by almost every element
c             the data is stored on the nmisc record.
c             warning:  other data may be stored between the
c                       documented data and this data.
c             in order to see the actual information on the nmisc
c              record, insert the command:
c                  dblist,elp,elnum1,elnum2,elinc,11
c                       where elnum1 = the first element
c                             elnum2 = the last element
c                             elinc  = the element increment number
c              after a set command in post1.
c
c  input arguments:
c   variable (typ,siz,intent)       description
c    elem    (int,sc,in)           - element number
c    iout    (int,sc,in)           - output unit number
c    nbsvr   (int,sc,in)           - number of basic element variables
c    bsvr    (dp,ar(nbsvr),in)     - basic element variables
c    nnrsvr  (int,sc,in)           - number of nonlinear element variables
c    nrsvr   (dp,ar(nnrsvr),in)    - nonlinear element variables
c    npsvr   (int,sc,in)           - number of plasticity element variables
c    psvr    (dp,ar(npsvr),in)     - plasticity element variables
c    ncsvr   (int,sc,in)           - number of creep element variables
c    csvr    (dp,ar(ncsvr),in)     - creep element variables
c    nusvr   (int,sc,in)           - number of user-supplied element variables
c                                         (= nstv on the nsvr command)
c    usvr    (dp,ar(nusvr),in)     - user-supplied element variables
c    nnode   (int,sc,in)           - number of nodes
c    nodes   (int,ar(nnode),in)    - node numbers
c    xyz     (dp,ar(6,nnode),in)   - nodal coordinates and rotations (virgin)
c    vol     (dp,sc,in)            - element volume (or area if 2-d)
c    leng    (dp,sc,in)            - element length (beams,spars,etc)
c    time    (dp,sc,in)            - current time
c    timinc  (dp,sc,in)            - current sub step time increment
c    nutot   (int,sc,in)           - length of dof solution vector utot
c    utot    (dp,ar(nutot),in)     - solution vector
c    maxdat  (int,sc,in)           - size of user output array (3 x nnode)
c                                     for contact element it is equale to nusvr
c                                     but it dode not exceed 120
c
c  output arguments:
c   variable (typ,siz,intent)       description
c    numdat  (int,sc,out)          - number of user output items in array udbdat
c                                      (maximum size of numdat is ielc(NMNMUP)
c                                      which is usually three times the number
c                                      of nodes.
c                                      For contact elements CONTA171-178,it 
c                                      should be equal or less than NSTV
c                                      on nsvr command). It cannot exceed 120.
c    udbdat  (dp,ar(maxdat),out)   - user output items to be placed at the end
c                                    of the nmisc record
c

2.3.2. Subroutine useran (Modifying Orientation of Material Properties)

*deck,useran                      USERDISTRIB
      subroutine useran  (vn,vref,elem,thick,xyzctr,bsangl)
c     user written routine to modify orientation of material properties
c     and stresses ***************************
c       applicable to: shell43,63,93,99, solid64
c        accessed by keyopt
c
c         *** Copyright ANSYS.  All Rights Reserved.
c         *** ansys, inc.
c *** Notice - This file contains ANSYS Confidential information ***
c
c **** warning *** do not change any arguments other than bsangl.
c                  if you do, your results are probably wrong.
c
c  input(do not change)---
c     vn       = vector normal to element
c     vref     = unit vector orienting element, essentially edge i-j
c     elem     = element number
c     thick    = total thickness of element at this point (see note below)
c     xyzctr = location of element centroid or integration point
c
c  output---
c     bsangl = output from this subroutine.  it represents the angle(s)
c              between vref and the desired orientation.  it may have
c              the default orientation coming in to useran.
c                This will be combined with the angles derived from
c                the ESYS command.
c           use 1 angle for 2-d elements and shells
c           use 3 angles for 3-d solids
c

2.3.3. Subroutine userrc (Performing User Operations on COMBIN37 Parameters)

*deck,userrc                      USERDISTRIB
      subroutine userrc (elem,ireal,type,nusvr,usvr,parm,parmld,
     x c1,c2,c3,c4,fcon)
c     primary function: user operation on parameter for combin37
c      accessed with keyopt(9) = 1
c
c         *** Copyright ANSYS.  All Rights Reserved.
c         *** ansys, inc.
c *** Notice - This file contains ANSYS Confidential information ***
c
c  input arguments:
c   variable (typ,siz,intent)       description
c    elem    (int,sc,in)           - element number
c    ireal    (int,sc,in)          - element real constant number
c    type    (int,sc,in)           - element type number
c    nusvr   (int,sc,in)           - number of user-supplied element variables
c                                     (input with the NSVR command)
c    usvr    (dp,ar(nusvr),inout)  - user-supplied element variables
c    parm    (dp,sc,in)            - current value of the paramater
c    parmld  (dp,sc,in)            - value of the parameter at previous time ste
c    c1      (dp,sc,in)            - real constant c1
c    c2      (dp,sc,in)            - real constant c2
c    c3      (dp,sc,in)            - real constant c3
c    c4      (dp,sc,in)            - real constant c4
c
c  output arguments:
c   variable (typ,siz,intent)       description
c    usvr    (dp,ar(nusvr),inout)  - user-supplied element variables
c                                     may be sent .rst file with usereo
c    fcon    (dp,sc,out)           - result of calculation
c
c     either c1 or c3 must be nonzero for this logic to be accessed,
c

2.3.4. Subroutine UElMatx (Accessing Element Matrices and Load Vectors)

*deck,UElMatx                      USERDISTRIB
      subroutine UElMatx (elem,nr,ls,zs,zsc,uelm,ielc,nodes,
     x                    ElDofEachNode,elmdat,xyzang,lenu)

c primary function:    User routine to access element matrices and load vectors.
c                      Needs to have USRCAL,UELMATX to be accessed.
c                      Called after the call to the element routine and
c                       before the solver.
c                      May be used to monitor and/or modify the element matrices
c                                                        and load vectors.

c         *** Copyright ANSYS.  All Rights Reserved.
c         *** ansys, inc.

c     typ=int,dp,log,chr,dcp   siz=sc,ar(n)   intent=in,out,inout

c  input arguments:
c     variable (typ,siz,intent)        description
c     elem     (int,sc,in)          - User element number
c     nr       (int,sc,in)          - number of rows in element matrix
c     ls       (int,ar(nr),in)      - Dof Index vector for this element matrix
c     zs       (dp,ar(nr,nr,*),inout)- K,M,C,SS,KCPLX matrices for this element
c     zsc      (dp,ar(nr,2),inout)  - Element load vector and N-R correction vec
c     uelm     (dp,ar(nr,5),in)     - Nodal displacements for this element
c     ielc     (int,ar(*),in)       - Element type characteristics
c     nodes    (int,ar(*),in)       - Nodes for this element
c     ElDofEachNode (int,ar(nr),in) - list of dofs for each node in Global
c     elmdat   (int,ar(10),in)      - Element data for this element
c     xyzang   (dp,ar(6,*),in)      - X,Y,Z,THXY,THYZ,THZX for each element node
c     lenu     (int,sc,in)          - Length of global displacement vector

c  output arguments:
c     zs       (dp,ar(nr,nr,4),inout)- K,M,C,SS matrices for this element
c     zsc      (dp,ar(nr,2),inout)  - Element load vector and N-R correction vec
c      WARNING:  any CHANGES to these (or any other) arguments will have a direc
c      impact on the solution, possibly giving meaningless results.  The normal
c      usage of this routine is simply monitor what is happening.


2.3.5. Subroutine uthick (Getting User-Defined Initial Thickness)


*deck,uthick                      USERDISTRIB
      SUBROUTINE uthick (elemId, elemType, matId, realId,
     $                   numDomIntPts, curCoords, thickness)
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c
c     *** primary function: get the user defined thickness
c
c         *** Copyright ANSYS.  All Rights Reserved.
c         *** ansys, inc.
c
c     input arguments
c     ===============
c     Variable        (type,sz,i/o)  description
c      elemId         (int,sc,i)     element number
c      elemType       (int,sc,i)     element TYPE (181 etc.)
c      matId          (int,sc,i)     material number
c      realId         (int,sc,i)     real constant set number
c      numDomIntPts   (int,sc,i)     number of integration points
c      curCoords      (dp,ar(3,numDomIntPts),i)
c                                    current coordinates
c
c     output arguments
c     ================
c      thickness      (dp,ar(3,numDomIntPts),o)
c                                    thickness at the integration points
c
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c
c --- parameters
c

2.3.6. Subroutine uflex (Calculating Flexibility Factors for PIPE288 and PIPE289)

*deck,uflex                      USERDISTRIB
      subroutine uflex (elemId,pressInt,pressExt,ex,pois,  sflex,twten)
c *** primary function:   to (re)compute the flexibility factors 
c                           for pipe288 and pipe289
c                         this is accessed by inputting the axial flexibility factor
c                           as -10.
c *** secondary functions: none
c
c *** Notice - This file contains ANSYS Confidential information ***
c
c         *** Copyright ANSYS.  All Rights Reserved.
c         *** ansys, inc.
c
c     typ=int,dp,log,chr,dcp   siz=sc,ar(n)   intent=in,out,inout
c
c     input arguments:
c  elemId      (int,sc,in) - element number
c  pressInt  (dp,ar(2),in) - internal pressures at end nodes
c  pressExt  (dp,ar(2),in) - external pressures at end nodes
c                                      Pressures include hydrostatatic but
c                                       not hydrodynamic effects.
c  ex           (dp,sc,in) - Young's Modulus
c  pois         (dp,sc,in) - Poisson's ratio
c  sflex  (dp,ar(6),inout) - input flexibility factors
c                              (axial, bending about element z, 
c                               bending about element y, twist, y shear, z shear)
c  twten     (dp,sc,inout) - twist-tension factor
c
c     output arguments:
c  sflex  (dp,ar(6),inout) - output flexibility factors
c                              (axial, bending about element z, 
c                               bending about element y, twist, y shear, z shear)
c  twten     (dp,sc,inout) - twist-tension factor
c

2.3.7. Subroutine UTimeInc (Overriding the Program-Determined Time Step)

This subroutine allows you to create a user-defined time step to override the one determined by the program. Activate the subroutine via the USRCAL,UTIMEINC command.

*deck,UTimeInc                      USERDISTRIB
      subroutine UTimeInc (deltmin,deltmax,delt)

c primary function:    User routine to override the program determined time step
c                      Needs to have USRCAL,UTIMEINC to be accessed.
c                      Called after the program determined the next time step
c                        increment (AUTOTS,ON only)

c         *** Copyright ANSYS.  All Rights Reserved.
c         *** ansys, inc.

c  input arguments:
c     deltmin  (int,dp,in)    - minimum time step size (user input)
c     deltmax  (int,dp,in)    - maximum time step size (user input)
c     delt     (int,dp,inout) - on input, the value determined by the program

c  output arguments:
c     delt     (int,dp,inout) - on output, the value you have determined


2.3.8. Subroutine UCnvrg (Overriding the Program-Determined Convergence)

This subroutine allows you to create user-defined convergence checking and to override the convergence determined by the program. Activate the subroutine via the USRCAL,UCNVRG command.

*deck,UCnvrg                      USERDISTRIB
      subroutine UCnvrg (ConvergenceType,ConvergenceFlag)

c primary function:    User routine to perform custom convergence checking and
c                        override the program-determined convergence
c                      Needs to have USRCAL,UCNVRG to be accessed.
c                      Called after the program convergence checks.

c         *** Copyright ANSYS.  All Rights Reserved.
c         *** ansys, inc.

c  input arguments:
c     ConvergenceType  (int,sc,in)    - type of convergence to be checked
c                                         1, nonlinear element (called after
c                                            element matrix formation)
c                                         2, force convergence (called after
c                                            element matrix formation)
c                                         3, displacement convergence (called after
c                                            equation solution)
c     ConvergenceFlag  (int,sc,inout) - on input, the value the program determined
c                                       for this Type
c                                         0, not converged
c                                         1, converged

c  output arguments:
c     ConvergenceFlag  (int,sc,inout) - on output, the value the you have determined
c                                       for this Type
c                                         0, not converged
c                                         1, converged

c     Note: For overall convergence, all 3 Types must be converged. Not all
c           Types are evaluated (dependent on CNVTOL input and program defaults)