/out,stitch3d,out
/gopr
*msg,info
 stitch3d macro 11/23/2001
!STITCHES THE ROTOR AND STATOR TOGETHER for skewed periodic models
!taken from stitch6.mac
!
!    Assumes 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
!
immed
csys,1
cmsel,,stator
esel,r,mat,,1                  !    10/31/94
esel,r,real,,6                 !    10/31/94
nsle
nsel,r,loc,z,arg1-.0001,arg1+.0001
*get,_stthmx,node,,mxloc,y
*get,_stthmn,node,,mnloc,y
*get,_strdmn,node,,mnloc,x
*get,_strdmx,node,,mxloc,x
_strtol=(_strdmx-_strdmn)/100
cm,c_s1,node
cmsel,,rotor
esel,r,real,,5                 !    10/31/94
nsle                           !    10/31/94
nsel,r,loc,z,arg1-.0001,arg1+.0001
*get,_rtthmx,node,,mxloc,y
*get,_rtthmn,node,,mnloc,y
*get,_rdrmx,node,,mxloc,x
*get,_rdrmn,node,,mnloc,x
_rdtol=(_rdrmx-_rdrmn)/1000      !    10/31/94

_ohnang=_stthmx-_rtthmx
_perang=_stthmx-_stthmn

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


cmsel,,rotor
nsel,r,ext   !  7/19/97
nsel,r,loc,x,_rdrmx-_rdtol,_rdrmx+_rdtol
nsel,r,loc,z,arg1-.0001,arg1+.0001
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
*else
 nsel,r,loc,y,_stthmn+.0000001,_rtthmn-.01         !  11/10/94
*endif
csys,1
cm,_ohn,node
/com,before the _ohn node shift
dsys,1
nlis
dsys
shpp,off
ngen,2,,all,,,0,-_perang*_t_bsgn

cmsel,,stator
esel,r,real,,6
nsle
nsel,r,loc,z,arg1-.0001,arg1+.0001
esln
esel,r,real,,6
cm,_cestat,elem  !  elements on the stator side
cmsel,,_cerotor  !  nodes on the rotor side
ceintf,.1
cmsel,,_ohn
csys,1
ngen,2,,all,,,0,_perang*_t_bsgn
dsys,1
/com, after the node shift to the original position
nlis
dsys
/pbc,ce,1
alls
/gopr
/out