开发者

In ansys, get array of all real property numbers being used

开发者 https://www.devze.com 2023-01-26 16:06 出处:网络
Using ANSYS APDL, I\'m looking for a quick and computationally inexpensive way to get all the current real numbers used in the model. Something like

Using ANSYS APDL, I'm looking for a quick and computationally inexpensive way to get all the current real numbers used in the model. Something like

*vget,real_numbers...

The best I can come up with is

! Get a list of all element types
*get,elemCount,elem,,count      
elemReals= $ *vget,elemReals,elem,,attr,real !Get list of elements real numbers

*get,maxReal,rcon,,num,max
realMas开发者_如何学运维k= $ *dim,realMask,array,maxReal
*vfill,realMask,data,0.0

!Create Mask Of Real Numbers and number of real of real numbers
realCount = 0
*do,i,1,elemCount,
   *if,realMask(elemReals(i)),eq,0,then
    realMask(elemReals(i)) = 1
    realCount = realCount + 1
 *endif
*enddo

!Fill out real number array
realNumbers = $ *dim,realNumbers,array,realCount
realIndex = 1
*do,i,1,maxReal,
 *if,realMask(i),eq,1,then
    realNumbers(realIndex) = i
    realIndex = realIndex + 1
 *endif
*enddo

It works, but the if your real numbers are spaced very far apart it ends up looping through a bunch of zeros in the real mask...

-Ben


I guess it's a bit late for the answer but I would try to loop through all REAL constants as Nastza suggests, select all elements with that real and list it in the array if the number is > 0. May or may not be faster. Would have to be tested.

*GET,mymaxvariable,RCON,0,NUM,MAX ! The maximum real constant set number defined
    *DO,i,1,mymaxvariable,1
      ESEL,NONE
      ESEL,S,REAL,,i        ! Select elements with current real number
      ecount = 0
      *GET,ecount,ELEM,  0, COUNT
      *IF,ecount,GT,0,then
      ! Process here, at this point, variable i is one of the real constant present (and activively used) in model
        /COM,real: %i%, elm. count: %ecount%
      *ENDIF
    *ENDDO

Took about 2 seconds on (rather small) model with 2000 constant sets. If needed to write out the results to a text file I suggest to write an array first and then write to a file all at once, otherwise the speed rapidly decreases :)


*GET,mymaxvariable,RCON,0,NUM,MAX ! The maximum real constant set number defined
*DO,i,1,mymaxvariable,1
  j=1
  *GET,myvariable,RCON,i,CONST,j  ! Value of real constant number "j" in set "i"
*ENDDO
0

精彩评论

暂无评论...
验证码 换一张
取 消