### 7.6.2. Access to All Elements in a Part

The following code loops over all Unstructured Parts in a model and defines the value of user variable VAR01 to be the impedance of the material for all Parts containing volume elements.

          USE mdpart
          USE mdvar_all
          USE mdsolv

          IMPLICIT NONE

          INTEGER(INT4) :: NPART, N, NEL, NINST

          DO NPART = 1, NUM_PARTS
            PART => PARTS(NPART)%P
            IF (PART%ELEM_CLASS/=ICLASS_VOLUME) CYCLE ! SKIP NON-SOLID ELEMENTS

            ! LOOP OVER ELEMENTS IN PART
            DO N = 1, PART%NUMELM
              NEL = PART%ELEMENT_LIST(N) ! OBTAIN GLOBAL INTERNAL INDEX IF ELEMENT

              ! COPY ELEMENT VARIABLES INTO LOCAL VARIABLE VECTOR
              NINST = 0
              CALL GET_ELEM_VAR(NEL,NINST)

              ! CALCULATE IMPEDANCE
              RVL(IVR_VAR01) = RVL(IVR_DENSITY)*RVL(IVR_SOUNDSPEED)

              ! COPY UPDATED LOCAL ELEMENT DATA BACK TO MAIN STORAGE
              CALL PUT_ELEM_VAR(NEL,NINST)

            END DO ! END LOOP ON ELEMENTS
          END DO ! END LOOP ON PARTS

Release 18.2 - © ANSYS, Inc. All rights reserved.