The output of element and node information is sometimes crucial for secondary development, such as when making localized modifications to node coordinates during random defect application.
In Workbench, there are two methods to output the complete element and node information of a model:
- Using APDL commands: However, this method requires submitting the solution every time to execute the inserted APDL commands. It can be cumbersome to format and debug the output, especially when combining characters and data. In practice, it is less efficient.
- Inserting Python code: By leveraging the code functionality supported by Workbench, you can quickly execute the code without the need to understand the complex syntax of APDL. Moreover, you have the freedom to define the output format. It only requires a few simple steps. Let me explain briefly.
In the Mechanical interface, you can open the code input interface by clicking “Scripting” under the Automation tab. Once opened, you can use WB’s API functions on the right side to perform the required operations.
For detailed API usage, students can refer to ANSYS’ comprehensive help documentation. Here, I will focus on explaining how to output element and node information.
The information regarding elements and nodes can be found in the MeshData under the API function “Analyses”. To output the relevant information, you need to access the MeshData.
After the meshing is completed, use the following code to access the MeshData:
MeshData contains a wealth of information about meshing, such as element IDs, element counts, and node-related information. Our goal is to extract the node IDs of each element and all the node coordinate information, and write them to a file.
First, write the function code to output the node information contained in each element. The approach is as follows:
- Retrieve all element information from MeshData.
- Iterate through the elements to obtain the node information for each element.
- Iterate through the elements again to output the element ID and corresponding node IDs.
After running the code, you will find the output text file in the specified folder.
Next, we will output the coordinate information for each node. The approach is similar: iterate through the nodes, retrieve the node information, and output the node coordinates.
After running the code, you will find the output text file in the specified folder.
In addition to obtaining results without running the solver, Python code can also be assembled into a button and placed in the menu bar. This way, when opening any model, you can simply click the button to use the functionality. For example, here we will create a button named “Get_EleNode” and place it in the WB menu.
Open the button editor, fill in the relevant information, primarily the name and button icon.
Good Luck!
暂无评论内容