简体   繁体   中英

How can I reconstruct a mesh in Python/Matlab from the nodes coordinates and their connectivity data existed in Abaqus inp file?

I am working on a machine learning model that predicts the displacements of the nodes in an object after applying a force. My model is trained with the data generated from FEM Abaqus and I want to reconstruct the mesh from the coordinates of the nodes, predicted by the ML model. So far, I have been able to recreate a representation with a plotly 3D scatter plot from the nodes coordinates but it is not a mesh. The data that I have exist in an Abaqus inp file and consist of the coordinates of the nodes as well as which nodes contributing to which elements (picture below). abaqus inp 文件

I would appreciate it if anyone can help me with the problem. Thank you.

Given that you have a tetrahedron Element as I can see from you.inp File you could use the so called delaunay triangulation. That is basically the method that is used for mesh generation with tetrahedrons. Point being is: It must not be the case that the two outcoming meshs are exactly the same. MATLAB has a builtin example of delaunay, take a look at that one. You could also try to read the connectivity table from Abaqus and use this one.

Eg MATLAB:

trimesh(T,x,y,z)

where T is the connectivity matrix (either read from abaqus or use delaunay-function) and x,y,z are the corresponding coordinates of the nodes.

For python there are possibilities like trimesh, I would expect that scipy also has some meshing capabilities.

If I understand correctly, you have a list of 3d tetrahedra that you want to visualize. In python you can do this using the following function (which is modified from my previous answer , see the explanation there).

def plot_tetra(ax, points, tetra_list):
    edges = collect_edges(tetra_list)
    x = np.array([])
    y = np.array([])
    z = np.array([])
    for (i,j) in edges:
        x = np.append(x, [points[i, 0], points[j, 0], np.nan])      
        y = np.append(y, [points[i, 1], points[j, 1], np.nan])      
        z = np.append(z, [points[i, 2], points[j, 2], np.nan])
    ax.plot3D(x, y, z, color='g', lw='0.1')

    ax.scatter(points[:,0], points[:,1], points[:,2], color='b')


def collect_edges(tetra_list):
    edges = set()
    for (i0, i1, i2, i3) in tetra_list:
        edges.add((i0,i1))
        edges.add((i0,i2))
        edges.add((i0,i3))
        edges.add((i1,i2))
        edges.add((i1,i3))
        edges.add((i2,i3))
    return edges

A possible result of calling this function with the code below is shown in the following figure (also taken from there):

在此处输入图像描述

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits import mplot3d

fig = plt.figure()
ax = plt.axes(projection='3d')
plot_tetra(ax, points, tetra_list)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM