/* $Header: /usr/home/sanjay/Feap/Elem/Ec/RCS/kine13.c,v 1.4 2000/01/28 20:32:11 sanjay Exp $*/

/* ul and shps defined as zero indexed */
/* These defines allow one to "declare" variable dimension arrays in C through the use of a
     passed in pointer plus dimensions.  The storage scheme can be either row major or column major.
     And the usage is looks like a FORTRAN syntax.  Here ul and shps are column major */

#define ul(dof,node,type)  (*(ulf+((type)*ndf*nel)+((node)*ndf)+dof))
#define shps(der,node)  (*(shpsf+((node)*3)+der))

void kine13(double *shpsf,
             double *ulf,
             int ndf, int nel,
             double eps[6], double deps[6]) {
/*
c-------------------------------------------------------------------
c      * * F E A P * * A Finite Element Analysis Program
c      Copyright (c) 1984-1994: Robert L. Taylor
c
c      C Language Example Element for FEAP
c      Copyright (c) 2000     : Sanjay Govindjee
c
c     Input:
c        shps(3,nel)      - shape functions plus derivatives (uses cover definition
c                           and shpsf pointer)
c        ul(ndf,nel,type) - Nodal displacements, and increments, etc
c                           (uses cover definition and ulf pointer)
c        nel              - No. nodes/element
c        ndf              - degrees of freedom per node
c
c     Output:
c        eps(6)      - strain vector
c        deps(6)     - incremental strain vector
c-------------------------------------------------------------------
*/
      int  i,k,l;

/*    Plane Strain strain tensor */

        for(i=0;i<6;i++) {
             eps[i]  = 0.0;
             deps[i] = 0.0;
        }

        for(k=0;k<nel;k++) {
            eps[0]  +=  ul(0,k,0) * shps(0,k);
            eps[1]  +=  ul(1,k,0) * shps(1,k);
            eps[3]  +=  ul(0,k,0) * shps(1,k)
                      + ul(1,k,0) * shps(0,k);
            deps[0] +=  ul(0,k,1) * shps(0,k);
            deps[1] +=  ul(1,k,1) * shps(1,k);
            deps[3] +=  ul(0,k,1) * shps(1,k)
                      + ul(1,k,1) * shps(0,k);
        }

}