! ANSYS $RCSfile: CYCGEN.MAC,v $
! Modified on $Date: 2010-11-14 13:40:31 -0500 (Sun, 14 Nov 2010) $ 
! Source ID = $Revision: 435640 $
!  -------------------------------------------------------------------------
!       This macro generates the doubled geometry for the solution of 
!       a cyclic symmetry modal analysis. (See also CYCSOL).
!       This macro is designed to solve an eigenvalue problem
!       for a sector of a model that is cyclic symmetric.
!
!       **** This macro runs within PREP7 ****
!
!       Proper execution of this macro requires the following:
!
!           1. The geometry is defined in the global cylindrical system
!           2. the basic sector database is active
!               nodes, elements, coupling, and internal CE are defined
!
!       Use this macro as follows:
!
!            CYCGEN, ['LOAD']
!
!       The LOAD option generates constraints, nodal forces, pressures,
!        nodal temperatures, and element temperatures for the repeated
!        sector.
!  -------------------------------------------------------------------------
_kpr = wrinqr(1),NOPR
/NOPR                     ! Supress printout

!   check for rel.6.0 CYCLIC command
*get,_cs_num_sect,comm,,cycsym_com,,int,2
*if,_cs_num_sect,gt,1,then
   _modcyc = 0
   *msg,warning
       The CYLIC cmd has been used for cyclic symmetry. CYCGEN is ignored
*else
   _ntot=ndinqr(0,14)        ! max node number defined
   *if,_ntot,le,0,then
      *msg,error
           ABORT  - no nodes in basic sector
   *endif
   
   _etot=elmiqr(0,14)        ! max element number defined
   *if,_etot,le,0,then
      *msg,error
           ABORT  - no elements in basic sector
   *endif

   CYGEN                               ! Generate duplicate geometry

   numcmp,cp                           ! Compress couplings
   numcmp,ce                           ! Compress constraint eqns.
   _cpbase = cpinqr(0,14)              ! Remember number of base sector CP 
   _cebase = ceinqr(0,14)              ! Remember number of base sector CE 
   cpsgen,2,_ntot,all                  ! Generate internal couplings
   cesgen,2,_ntot,all                  ! Generate internal constraint eqns.

   arg1 = upcase(arg1)                 ! Upper case arg1
   *if,arg1,eq,'LOAD',then
      sbctran                          ! Transfer solid model loads
      fgen, 2,_ntot,1,_ntot            ! Generate nodal forces
      dgen, 2,_ntot,1,_ntot            ! Generate constraints
      epgen,2,_etot,1,_etot,,all       ! Generate pressures
      tgen, 2,_ntot,1,_ntot            ! Generate nodal temperatures
      tegen,2,_etot,1,_etot            ! Generate element temperatures
   *endif

   _ntot=
   _etot=
   _modcyc = 1
   *msg,warning
    The CYCGEN cmd used. In case CYCLIC cmd is desired please issue CYCLIC,UNDOUBLE
*endif

*get,enmax,elem,,num,max
numstr,elem,enmax+1
*set,enmax

*if,_kpr,eq,0,then
   _kpr=
*else
   _kpr=
   /GO
*endif
!  -------------------------------------------------------------------------
