-1

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 file

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

Roman Zh.
  • 985
  • 2
  • 6
  • 20
  • So what is the problem? There is no question in your post. – Roman Zh. Apr 14 '21 at 07:19
  • The question is how I can reconstruct a mesh with the data in the attached picture. – Mehrdad Saaedi Apr 14 '21 at 10:29
  • Reconstruct how? In Abaqus? On your screenshot, you already have part of the input file recognizable by Abaqus. – Roman Zh. Apr 14 '21 at 12:53
  • No not in Abaqus. I have the mesh in Abaqus. As I explained, I used the finite element data from Abaqus to train a machine learning model in Keras. The model is supposed to predict nodal displacements as Abaqus does. Now, I need to illustrate my ML displacement prediction in 3D, to visually compare it with my deformed model from FEA. That's why I used the "reconstruction" term for the mesh. – Mehrdad Saaedi Apr 14 '21 at 14:20
  • So, the question is "how to plot mesh in python"? Which means it is not really the abaqus-related question. Well, as you have access to Abaqus, the easiest way would be to create an orphan mesh from your predicted data. so you will compare two meshes visualized using the same "graphical environment" (Abaqus CAE in this case). Otherwise, use any plotting library like matplotlib, plotly or other solution which you can find by google it. – Roman Zh. Apr 14 '21 at 15:10

2 Answers2

0

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.

E.g. 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.

Nic
  • 56
  • 6
0

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):

enter image description here

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)
Iddo Hanniel
  • 1,636
  • 10
  • 18