!   TITLE:  rotate_volm_msh.mac (MESH)
!
!
!           Created provision for using ROTASET array for multiple area
!           materials.
!
!           Surveyed code and deleted unnecessary and/or incorrect line
!           code. Removed provision for multipe area materials.
!
!   OBJECTIVE:
!
!   This sub-macro meshes a set of rotated volumes.
!
!
!   COMMAND SYNTAX:
!
!                         (1)     (2)     (3)      (4)     (5)    (6)   (7)
!       ROTATE_VOLM_MSH, actcs,  mstyp, mshdens, elmszovr, etpa, etpv, elmnl,
!
!                        elmxl, mtrl,  rl,  ecs,  radrot, varcang, ell
!                         (8)   (9)   (10)  (11)   (12)    (13)    (14)
!
!
!   ARGUMENTS:
!
!       (1) actcs = active coordinate system (need not be cylindrical) about
!                   whose Z-axis the volumes (and therefore the meshes) are
!                   revolved.
!
!   The remaining arguments are the arguments used in MSH_ALGORITHM.  See
!   MSH_ALGORITHM for a description of arguments 2-14.  Note that PERFLSZ,
!   PERFMSH, ATARGOV, and VOLSEL (in MSH_ALGORITHM) have pre-determined
!   values and are not at the discretion of the user.
!
!
!   DESCRIPTION:
!
!   The algorithm meshes a selected set of areas and sweeps the mesh through the
!   volumes revolved about the Z axis of the specified CS, ACTCS (argument 1).
!   (The axis of revolution must be the Z-axis of ACTCS.)
!
!   The selected areas must be a set of axisymmetric cross-sectional areas that,
!   when revolved, would rotate to create the volumes. Any cross-section may be
!   chosen from a 360-degree revolved set of volumes, where the revolved mesh
!   starts and ends with the same selected areas in the set.
!
!   If the volumes are partially revolved (i.e., revolved < 360 degrees, thereby
!   having different start and end areas), then either end area may be selected.
!
!   This macro is an extension of the MSH_ALGORITHM , enhancing the user meshing
!   capabilities to the special case of revolved volumes, thereby automating the
!   meshing process for volumes of revolution.
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
revcs__=arg1
a2_=arg2
b3_=arg3
c4_=arg4
e5_=arg5
f6_=arg6
g7_=arg7
h8_=arg8
i9_=arg9
j0_=ar10
k1_=ar11
n4_=ar12
o5_=ar13
p6_=ar14
!
*get,actvcs__,active,,csys
!
csys,revcs__                            ! active CS
clocal,csn+50,1,0,0,0,0,0,0
!
*if,i9_,eq,0,then
    i9_=1
*endif
!
entity_array,'a','rotaset_','array'     ! create array of selected areas
alimit_=ecount
!
*do,abcde__,1,alimit_,1                 ! iterate through area array
    *do,wxyz__,1,7200,1                 ! iterate through all volumes ( < 3600 )
        csys,csn+50
        !
        *if,wxyz__,eq,1,then                    ! If volume iteration = 1 then
            asel,s,area,,rotaset_(abcde__,1)
            vsla,r,0
            vol_cg
            !
            *do,defg__,1,num_vols,1
                csys,0
                k,,vcg_data(defg__,3),vcg_data(defg__,4),vcg_data(defg__,5)
                init_entity_num,1
            *enddo
            !
            csys,csn+50
            !
            *if,num_vols,gt,1,then
                k1__=km-1
                k2__=km
                !
                aloc1_=ky(k1__)
                aloc2_=ky(k2__)
                kdele,k1__,k2__,1
                !
                ang_convert,aloc1_,0,'aloc1_'
                ang_convert,aloc2_,0,'aloc2_'
                !
                *if,aloc1_,lt,aloc2_,then
                    target_sweep_area,rotaset_(abcde__,1),vcg_data(1,1)
                    v2bmsh_=vcg_data(1,1)
                *elseif,aloc2_,lt,aloc1_,then
                    target_sweep_area,rotaset_(abcde__,1),vcg_data(2,1)
                    v2bmsh_=vcg_data(2,1)
                *endif
            *elseif,num_vols,eq,1,then
                k1__=km
                !
                aloc1_=ky(k1__)
                kdele,k1__
                !
                target_sweep_area,rotaset_(abcde__,1),vcg_data(1,1)
                v2bmsh_=vcg_data(1,1)
            *endif
            !
            a2bmsh_=rotaset_(abcde__,1)
            pls_=1
            pmsh_=3
        *else
            pls_=0
            pmsh_=2
            !
            v_old_=v2bmsh_
            a2bmsh_=atarg_
            !
            asel,s,area,,a2bmsh_
            vsla,r,0
            vsel,u,volu,,v_old_
            get_max_entity
            !
            *if,vm,gt,0,then
                v2bmsh_=vm
                target_sweep_area,a2bmsh_,v2bmsh_
            *else
                *exit
            *endif
        *endif
        !
        asel,s,area,,a2bmsh_
        !
        !                     (1)      (2)     (3)     (4)      (5)       (6)
        !    MSH_ALGORITHM, perflsz, perfmsh, mstyp, mshdens, elmszovr, atargov,
        !
        !                   etpa, etpv, elmnl, elmxl, mtrl,  rl,  ecs, volsel,
        !                    (7)   (8)   (9)    (10)  (11)  (12)  (13)  (14)
        !
        !                   radrot, varcang, ell
        !                    (15)     (16)   (17)
        !
        !             (1)   (2)  (3) (4) (5)  (6)   (7) (8) (9) (10)(11)(12)(13) (14)   (15)(16)(17)
        msh_algorithm,pls_,pmsh_,a2_,b3_,c4_,atarg_,e5_,f6_,g7_,h8_,i9_,j0_,k1_,v2bmsh_,n4_,o5_,p6_
        !
        *if,atarg_,eq,rotaset_(abcde__,1),then
            *exit
        *endif
    *enddo
    !
    *if,assemble,eq,0,then
        init_entity_num
    *elseif,assemble,eq,1,then
        init_entity_num,1
    *endif
*enddo
!
csys,actvcs__
csdele,csn+50
!
eplot
!
*set,revcs__,
*set,actvcs__,
*set,aloc1_,
*set,aloc2_,
*set,pls_,
*set,pmsh_,
*set,a2_,
*set,b3_,
*set,c4_,
*set,e5_,
*set,f6_,
*set,g7_,
*set,h8_,
*set,i9_,
*set,j0_,
*set,k1_,
*set,n4_,
*set,o5_,
*set,p6_,
*set,abcde__,
*set,defg__,
*set,wxyz__,
*set,alimit_,
*set,a2bmsh_,
*set,v2bmsh_,
*set,rotaset_(1),
*set,vcg_data(1),
*set,atarg_,
*set,k1__,
*set,k2__,
*set,num_vols,
!
*if,prkey_,eq,1,then
    /go
*endif