/out,stitch6,out
/com,stitch6.mac    990716
!  Stitches the rotor and stator together.  (original from JTJacobs 7/94)
!  Rotor allowed to be moved in the -angular direction - 11/95.
!  Variable list at end of file.
!
!  No arguments. 
!
!  Assumptions:
!    -rotor is in "ROTOR" and stator is in "STATOR"
!    -air elements in gap on rotor side  :    REAL=5, MAT=1
!    -air elements in gap on stator side :    REAL=6, MAT=1
!
!  Macros used: none
!
!  Output:
!    stitch6.out
!

/gopr
*msg,info
 stitch6 macro 11/25/95

immed
csys,1
cmsel,,stator
esel,r,mat,,1                  !    10/31/94
esel,r,real,,6                 !    10/31/94
nsle
*get,_stthmx,node,,mxloc,y
*get,_stthmn,node,,mnloc,y
*get,_strdmn,node,,mnloc,x
*get,_strdmx,node,,mxloc,x
_strtol=(_strdmx-_strdmn)/100
cmsel,,rotor
esel,r,real,,5                 !    10/31/94
nsle                           !    10/31/94
*get,_rtthmx,node,,mxloc,y
*get,_rtthmn,node,,mnloc,y

cscir,21,1
csys,21
*get,_cthtmn1,node,,mnloc,y
*get,_cthtmx1,node,,mxloc,y
*if,_cthtmx1,gt,_cthtmx,then
  /com, swapping the angles
  _cthtmx=_cthtmx1
 *endif
*get,_rdrmx,node,,mxloc,x
*get,_rdrmn,node,,mnloc,x
_rdtol=(_rdrmx-_rdrmn)/1000      !    10/31/94

_ohnang=_stthmx-_cthtmx   !_rtthmx   7/21/00
_perang=_stthmx-_stthmn

_t_bsgn=1
*if,_ohnang,gt,0,then
 _t_bsgn=-1
 csys,1
*endif


cmsel,,rotor
nsel,r,ext   !  7/19/97
nsel,r,loc,x,_rdrmx-_rdtol,_rdrmx+_rdtol
cm,_cerotor,node
!   nsel,r,loc,y,_stthmx-.00001,_rtthmx+.01         !  11/03/94
*if,_t_bsgn,eq,1,then
 !nsel,r,loc,y,_stthmx+.0000001,_rtthmx+.01         !  11/10/94
 nsel,r,loc,y,_stthmx+.0000001,_cthtmx+.01          !  7/21/00
*else
 nsel,r,loc,y,_stthmn+.0000001,_rtthmn-.01         !  11/10/94
*endif
csys,1
cm,_ohn,node
shpp,off
ngen,2,,all,,,0,-_perang*_t_bsgn
cmsel,,stator
nsel,r,ext   !  7/19/97
nsel,r,loc,x,_strdmn-.01,_strdmn+_strtol
esln
nsle
cm,_cestfr,node
*get,_elmx,elem,,num,max
*get,_curreal,elem,_elmx,attr,real
cmsel,,stator
esel,r,real,,_curreal
cmsel,,_cerotor
cmsel,a,_cestfr
cedel,all,,,any
numc,ce
cmsel,,_cerotor
esel,r,real,,_curreal
ceintf,.1
cmsel,,_ohn
csys,1
ngen,2,,all,,,0,_perang*_t_bsgn
/pbc,ce,1
alls
/gopr
/out,stitch6,out,,append

!                    Variable List
!
! _stthmx  maximum azimuthal (theta) location of all stator-side air nodes
!          incomplete
!