Retrieve and export contact pressure results using APDL Commands object

Nikos Kallitsis
Nikos Kallitsis Member, Employee Posts: 36
10 Comments 5 Likes First Anniversary Ansys Employee
✭✭✭✭
edited June 2023 in Structures

How can I export contact pressure results using APDL commands in Mechanical?

Tagged:

Comments

  • Nikos Kallitsis
    Nikos Kallitsis Member, Employee Posts: 36
    10 Comments 5 Likes First Anniversary Ansys Employee
    ✭✭✭✭

    You can export contact pressure results using APDL commands following these steps:

    1. Insert an APDL Commands object to the contact you want to extract results for. Assign a parameter to the contact type by issuing: myContact = cid.
    2. Make sure you have enabled the .db output: Analysis Settings -> Analysis Data Management -> Save MAPDL db
    3. Insert an APDL Commands object in the solution with the following script:
    !Select nodes in contact area
    !-----------------------------
    RESUME !Resume .db
    SET, LAST !Read results
    ESEL, S, TYPE, , myContact !Select elements of contact type
    NSLE, S, CORNER !Select all nodes associated with above elements
    
    !Export contact pressure results
    !-------------------------------
    *GET, nodeCount, NODE, , COUNT !Total number of nodes
    *VGET, nodeList, NODE, , NLIST !List of nodes
    *DIM, contPresArray, ARRAY, nodeCount, 5 !Create 2D array
    
    *DO, node_iter, 1, nodeCount !Iterate over each node
    *SET, contPresArray(node_iter,1), nodeList(node_iter) !Populate 1st column with nodeID
    *GET, contPresArray(node_iter,2), NODE, contPresArray(node_iter,1), LOC, X !Populate 2nd column with Node X-Location
    *GET, contPresArray(node_iter,3), NODE, contPresArray(node_iter,1), LOC, Y !Populate 3rd column with Node Y-Location
    *GET, contPresArray(node_iter,4), NODE, contPresArray(node_iter,1), LOC, Z !Populate 4th column with Node Z-Location
    *GET, contPresArray(node_iter,5), NODE, contPresArray(node_iter,1), CONT, PRES !Populate 5th column with Contact Pressure
    *ENDDO
    
    *CFOPEN, %_wb_userfiles_dir(1)%Pressure_Export_APDL, txt !Create/Open txt file for export
    *VWRITE, 'NodeID', ',', 'LocX', ',', 'LocY', ',', 'LocZ', ',', 'Pressure' !Write titles
    (A6, A1, A4, A1, A4, A1, A4, A1, A8)
    *VWRITE, contPresArray(1,1), ',', contPresArray(1,2), ',', contPresArray(1,3), ',', contPresArray(1,4), ',', contPresArray(1,5) !Write results
    (F8.0, A1, F10.3, A1, F10.3, A1, F10.3, A1, F10.3)
    *CFCLOS !Close file
    

    A text file will be created in the User Files directory named Pressure_Export_APDL.txt.