! ANSYS $RCSfile: D2D3INTF.MAC,v $
! Modified on $Date: 2010-11-14 13:40:31 -0500 (Sun, 14 Nov 2010) $ 
! Source ID = $Revision: 435640 $
!  -------------------------------------------------------------------------
!       This macro is designed to write the constraint equations connecting
!       a two-dimensional axisymmetric model to a three dimensional model.
!
!       **** This macro runs within PREP7 ****
!
!       Proper execution of this macro requires the following:
!
!           1. The axisymmetric model is in the x-y plane, with the 
!              radius along the positive x axis.
!           2. The three dimensional model is generated such that the
!              y axis is the axis of the geometry.  This may be done
!              using the LOCAL,11,1, 0,0,0, 0,-90,0 command.
!
!       Use this macro as follows:
!
!            modcyc,'D2ELEM','D3NODE',CSYS
!
!                 where: D2ELEM - Element component of 2d elements at bdry 
!                        D3NODE = Node component of 3d nodes to attach
!                        CSYS   - Coordinate system for 3d cylinderical
!      
!       Side effects:
!            A file 'scratch' is created in the current directory.
!            The active coordinate system is set to 0
!            All nodes and elements are selected
!  -------------------------------------------------------------------------

_nerror = 0

*get,_nmax,COMP,arg1,TYPE
*if,_nmax,ne,2,then
    *msg,error
        ABORT - D2ELEM is not defined or not an element component 
    _nerror = _nerror + 1
*endif
!  -------------------------------------------------------------------------

*get,_nmax,COMP,arg2,TYPE
*if,_nmax,ne,1,then
    *msg,error
        ABORT - D3NODE is not defined or not a node component 
    _nerror = _nerror + 1
*endif
!  -------------------------------------------------------------------------

*if,arg3,lt,11,then
   *msg,error
           ABORT  - Cylinderical system required for 3d model
   _nerror = _nerror + 1
*endif
!  -------------------------------------------------------------------------

*if,_nerror,eq,0,then
   _nmax = ndinqr(0,14)            ! get maximum node number
   ngen,2,_nmax,all                ! create duplicate set of nodes
   csys,arg3                       ! set to the 3d cylinderical system
   nsel,s,node,,1,_nmax            ! select the original nodes
   /out,scratch                    ! put shape warning messages on scratch file
   shpp,warn                       ! make element shape errors non-fatal
   nmod,all,,0,                    ! compress all nodes to x-y plane
   /out                            ! return output to normal
   csys,0                          ! reset coordinate system to global
   cmsel,s,arg2                    ! select nodes on 3d side
   cmsel,s,arg1                    ! select elements on 2d side
   ceintf                          ! generate constraint equations
   nall                            ! select all nodes
   eall                            ! select all elements
   ngen,2,-_nmax,_nmax+1,2*_nmax   ! restore original node positions
   ndel,_nmax+1,2*_nmax            ! delete the duplicate set of nodes
   numcmp,node,truncate            ! reset maximum node number
   *get,_dof,active,,dof,max       ! get number of active dof
   *if,_dof,ge,3,then              ! check for structural problem
      cmsel,s,arg2                 ! select 3d nodes
      csys,11                      ! set coordinate system to 3d cyl
      /out,scratch                 ! put warning messages on scratch file
      nrotat,all                   ! rotate all nodes at boundary
      /out                         ! return output to normal
      d,all,uz                     ! set all uz to 0.0 at boundary
      csys,0                       ! reset coordinate system to global
      nall                         ! select all nodes
   *endif                          ! end of structural test
   _dof=                           ! remove parameter
*endif

_nerror=                           ! remove parameters
_nmax=
