Exporting image-generated geometry in matlab to FEA compatible format

조회 수: 3 (최근 30일)
Sebastián Fernández
Sebastián Fernández 2024년 8월 6일
편집: Precise Simulation 2024년 12월 22일
  • Hello, I am doing an undergraduate thesis, and I like to implement MATLAB in some of the analysis.
  • The query is, how to export a file generated as an image in a code, to a format compatible with FEA (Finite element analysis).
  • The goal is to find the temperature profile in this slag pot geometry, which is a truncated cone.
  • So, once having the compatible geometry I can use matlab pdegplot and some commands related to find the temperature profile.
  • The code was generated by AI (Claude).
% Dibujo tronco de cono en 3D. Luego, obtener el perfil de temperatura y
% modelamiento de pérdida de calor mediante el uso de ecuaciones
% diferenciales.
% Parámetros del problema
R1 = 1.155; % Semi-eje mayor de la elipse menor (m)
R2 = 2.082; % Semi-eje mayor de la elipse mayor (m)
b1 = 1.549; % Semi-eje menor de la elipse mayor (m)
b2 = 0.838; % Semi-eje menor de la elipse menor (m)
h = 2.921; % Altura del tronco de cono (m)
theta = linspace(0, 2*pi, 100); % Ángulo para las elipses
% Coordenadas para la elipse menor (base inferior)
x1 = R1 * cos(theta);
y1 = b2 * sin(theta);
z1 = zeros(size(theta));
% Coordenadas para la elipse mayor (base superior)
x2 = R2 * cos(theta);
y2 = b1 * sin(theta);
z2 = h * ones(size(theta));
% Superficie lateral del tronco de cono
[Theta, Z] = meshgrid(theta, linspace(0, h, 100));
R = (R2 - R1) / h * Z + R1;
B = (b1 - b2) / h * Z + b2;
X = R .* cos(Theta);
Y = B .* sin(Theta);
% Graficar el tronco de cono
figure;
hold on;
surf(X, Y, Z, 'EdgeColor', 'none', 'FaceAlpha', 0.7); % Superficie lateral
fill3(x1, y1, z1, 'r'); % Base inferior
fill3(x2, y2, z2, 'b'); % Base superior
xlabel('X (m)');
ylabel('Y (m)');
zlabel('Z (m)');
title('Tronco de Cono con Bases Elípticas');
axis equal;
grid on;
hold off;
  댓글 수: 2
dpb
dpb 2024년 8월 6일
% Dibujo tronco de cono en 3D. Luego, obtener el perfil de temperatura y
% modelamiento de pérdida de calor mediante el uso de ecuaciones
% diferenciales.
% Parámetros del problema
R1 = 1.155; % Semi-eje mayor de la elipse menor (m)
R2 = 2.082; % Semi-eje mayor de la elipse mayor (m)
b1 = 1.549; % Semi-eje menor de la elipse mayor (m)
b2 = 0.838; % Semi-eje menor de la elipse menor (m)
h = 2.921; % Altura del tronco de cono (m)
theta = linspace(0, 2*pi, 100); % Ángulo para las elipses
% Coordenadas para la elipse menor (base inferior)
x1 = R1 * cos(theta);
y1 = b2 * sin(theta);
z1 = zeros(size(theta));
% Coordenadas para la elipse mayor (base superior)
x2 = R2 * cos(theta);
y2 = b1 * sin(theta);
z2 = h * ones(size(theta));
% Superficie lateral del tronco de cono
[Theta, Z] = meshgrid(theta, linspace(0, h, 100));
R = (R2 - R1) / h * Z + R1;
B = (b1 - b2) / h * Z + b2;
X = R .* cos(Theta);
Y = B .* sin(Theta);
% Graficar el tronco de cono
figure;
hold on;
surf(X, Y, Z, 'EdgeColor', 'none', 'FaceAlpha', 0.7); % Superficie lateral
fill3(x1, y1, z1, 'r'); % Base inferior
fill3(x2, y2, z2, 'b'); % Base superior
xlabel('X (m)');
ylabel('Y (m)');
zlabel('Z (m)');
title('Tronco de Cono con Bases Elípticas');
axis equal;
grid on;
hold off;
view([-37.5 30]) % lets look at a 3D view
ans = 'orthographic'
For FEA modeling, you need the mesh coordinates and connectivity. Is your intent to export to an external FEA code like Ansys for the computation or do it all in MATLAB? There's generateMesh in the PDE Toolbox and some examples
Precise Simulation
Precise Simulation 2024년 12월 22일
편집: Precise Simulation 2024년 12월 22일
If it is just a cone, you can also create both the CAD geometry and FEA volume mesh with the FEATool Matlab toolbox https://featool.com/doc/geom#:~:text=cone

댓글을 달려면 로그인하십시오.

답변 (1개)

Rahul
Rahul 2024년 8월 7일
According to my understanding you wish to export the values generated by your code to an format conmpatible with FEA.
From the code provided by you, you can consider exporting your values to an '.stl' file which is a common format for FEA.
In addition to the code provided by you, you can do the following steps:
% Convert surface data to patch data
[F, V] = surf2patch(X, Y, Z, 'triangles');
% Create a triangulation object
TR = triangulation(F, V);
% Write the triangulation data to an STL file
stlwrite(TR, 'truncated_cone.stl');
Here the 'surf2patch' function is used to convert the surface data (X, Y, Z) into a patch structure returning Faces(F) and Vectices(V) of the object.
The 'triangulation' function takes the Faces(F) and Vertices(V) and creates a traingulation object (TR) which can be used to define geometry of the obejcts.
The 'stlwrite' function takes the 'triangulation' object (TR) and writes it's geometrical structure in a '.stl' format.
You can refer to the following documentations to know more about these functions:
Hope this helps! Thanks.

카테고리

Help CenterFile Exchange에서 General PDEs에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by