!===============================================
!             AREMCN90.MAC
!===============================================
!  Stan Kelley -- dv-1699 -- created June 2004
!   OBSOLETE AS OF FEB 2005 IN REV 10.0
!===============================================
! 
! 2-D rezoning contact pair restoration
!    - to be called after AREMESH and remeshing
!
/nopr

! save command blocking setting
*get,ar21,common,,REZONING,,int,9
remesh,cblock,off

! make sure in REMESH
*get,ar22,active,,routine
*if,ar22,ne,21,then
   /prep7
*endif

_maxln = lsinqr (0,14) > 1    ! maximum line number

! save info
cm,_lsave,line
cm,_nsave,node
*get,arg8,acti,,type
*get,arg9,acti,,real

! loop through lines

_itype1 = 0
_itype2 = 0
_jtype1 = 0
_jtype2 = 0

*do,_line,1,_maxln

   ! line must be selected
   *if,lsinqr(_line,1),ne,1,cycle

   ! line must have element divisions
   *if,lsinqr(_line,-8),lt,1,cycle

   ! line must have no associated elements
   *if,lsinqr(_line,-6),ne,0,cycle

   ! line must have been marked by rmsh2d2.mac
   _type1n1 = lsinqr (_line,-2)   ! stored as type
   *if,_type1n1,lt,1,cycle
   *if,_itype1,ne,_type1n1,then
      _itype1 = _type1n1
      _jtype1 = etyiqr (_itype1,-2)
      *if,_jtype1,lt,169,or,_jtype1,gt,172,cycle
   *endif
   _real1n1 = lsinqr (_line,-3)   ! stored as real
   *if,_real1n1,lt,1,cycle

   !  generate first set of elements
   lsel,,,,_line
   nsll,,1
   type,_type1n1
   real,_real1n1
   ar11 = elmiqr (0,12)
   esurf
   ar12 = elmiqr (0,12)
   *msg,info,ar12-ar11,_type1n1,_real1n1,_line
   %/ CREATED %I NEW CONTACT/TARGET ELEMENTS OF TYPE %I REAL %I ON LINE %I.
   cmsel,s,_lsave

   _type2n1 = lsinqr (_line,-15)  ! stored as sect
   *if,_type2n1,lt,1,then
      lsel,,,,_line
      latt
      cmsel,s,_lsave
      *cycle
   *endif
   *if,_itype1,ne,_type2n1,then
      _itype1 = _type2n1
      _jtype1 = etyiqr (_itype1,-2)
      *if,_jtype1,lt,169,or,_jtype1,gt,172,then
         lsel,,,,_line
         latt
         cmsel,s,_lsave
         *cycle
      *endif
   *endif
   _real2n1 = lsinqr (_line,-1)   ! stored as mat
   *if,_real2n1,lt,1,then
      lsel,,,,_line
      latt
      cmsel,s,_lsave
      *cycle
   *endif

   !  generate second set of elements
   lsel,,,,_line
   nsll,,1
   type,_type2n1
   real,_real2n1
   ar11 = elmiqr (0,12)
   esurf
   ar12 = elmiqr (0,12)
   *msg,info,ar12-ar11,_type2n1,_real2n1,_line
   %/ CREATED %I NEW CONTACT/TARGET ELEMENTS OF TYPE %I REAL %I ON LINE %I.
   latt
   cmsel,s,_lsave
*enddo

_call_aremeshcn = -1

! create elnewrzn
cm,_esave,elem
esel,,type,,_type
cm,elnewrznx,elem
cmsel,s,_esave
cmdel,_esave

! restore selected sets etc
cmsel,s,_lsave
cmdel,_lsave
cmsel,s,_nsave
cmdel,_nsave
type,arg8
real,arg9

! restore command blocking setting
*if,ar21,eq,1,then
   remesh,cblock,warn
*elseif,ar21,eq,2,then
   remesh,cblock,on
*endif

_line = $ _maxln = $ _cnodes1 = $ _cnodes2 = $ _itype1 = $ _itype2 =
_jtype1 = $ _jtype2 = $ _real1n1 = $ _real2n1 = $ _type1n1 = $ _type2n1 =
_type =
/gopr
