Ansys Learning Forum › Forums › Discuss Simulation › General Mechanical › How to compute the gap between surface in each direction? › Reply To: How to compute the gap between surface in each direction?
There is some possibility to do this with APDL, but it gets involved. You can’t get element normal at nodes for the contact elements. So you would have to look up the contact type in the APDL element reference:
https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/corp/v231/en/ans_elem/Hlp_E_LIBRARY.html
For example, if contact side is scoped to a face in a 3D analysis, this uses CONTA174:
Different scoping type (edge, vertex) and different analysis dimension (2D) will use different contact type: contact 172-178. Check the ds.dat in the solution directory to see what kind of contact element it used (ET command in the contact definition). You use UPCOORD to set nodes to deformed locations and use *GET to get the locations of the corner node of interest. Or get displacement and undeformed node locations using *GET and add instead of the UPCOORD command. Use the CONTA174 node location schematic for IJKLMNOP to get 2 adjacent midside node, and then *GET to get the locations. Compute vectors, then cross product to get normal vector. This will not be the exact normal vector at the node since contacts can have curvature, but it will be the nearest normal measured from linear assumptions to midside nodes. The *GET will be getting preprocessing values, so this works with CSYS. You can use CSYS,0 to make sure you are reporting the locations in the global coordinate system. In the CONTA174 reference, you can find the output quantities. Near the end you can find the GGAP (geometric gap) in the NMSIC table for each corner node.
You can use *GET to get the NMISC values. Assuming this value is in the direction of the normal vector you computed at the node earlier, you can then compute the projection of this value into the 3 global coordinate system axes.
Of course, your APDL code would need to loop over selected elements, and then loop over each corner node of each element to do this (in order of IJKL, so you know how each is connected to MNOP). You can use *CFOPEN to open a file for writing, and use *VWRITE to write each line. Use *CFCLOS when done. This will create a space or comma delimited file depending on what characters you insert. You can open this file in Excel. Your APDL script would also need to average midside node gap values from the corner nodes. For each midside node, you would need to compute the normal vector from 2 vectors you compute from the locations of its 2 adjacent corner nodes. Check for linear case.