有限元

编程入门 行业动态 更新时间:2024-10-28 20:31:21
有限元 - 三角网格中应力的绘图(Finite Element - Plotting with stresses in triangle mesh)

我正在制作程序,我需要绘制一些已分成许多三角形的区域。 我计算了每个节点/三角形每个角落的应变。 现在我需要用应变绘制三角形。

现在我有三种绘制三角形的方法。 但在其中一个中,我用每个三角形的平均角度应变填充。 我想要做的是......将应变放在角落,得到一个看起来像轮廓或轮廓的图。 - 我真的不明白他们是如何工作的。

谁能帮我?

clear; clc; TC = [ 1 2 3 ; 2 3 4 ] ; % Triangles node Connection. NC = [ 0,0 ; 0,1 ; 1,0 ; 1,1 ] ; % Node Coordinates. strain = [ 300 , 400 , 500 ; 400 , 500 , 600]; % Strains in each node.; [ne,np] = size(TC); % Just finding how many elements. element = zeros([3 2 ne]); % Creating a matrix for each element. % My first and second plot... for i=1:ne no1 = TC(i,1); no2 = TC(i,2); no3 = TC(i,3); element(:,:,i) = [ NC(no1,1),NC(no1,2); NC(no2,1),NC(no2,2); NC(no3,1),NC(no3,2);]; % Defining each element for each loop. % Node 1 Node 2 Node 3 xe = [element(1,1,i),element(2,1,i),element(3,1,i)]; % Defining coordinates to plot. ye = [element(1,2,i),element(2,2,i),element(3,2,i)]; subplot(3,1,1) plot([xe, xe(1)],[ye, ye(1)]) % ATTEMPT ONE % Only plotting the triangles. Using first value also last to close the triangle. xlim([-1 2]); ylim([-1 2]) hold on subplot(3,1,2) fill(xe,ye,mean(strain(i,:))) % ATTEMPT TWO % Fill triangles with average strain. hold on xlim([-1 2]); ylim([-1 2]) end % ATTEMPT 3 subplot(3,1,3) TR = triangulation(TC,NC); triplot(TR) hold on xlim([-1 2]); ylim([-1 2])

提前致谢。

I'm making program where I need to plot some area which has been split up in many triangles. I have calculated strains in each node / each corner of the triangle. Now I need to plot the triangle with the strains.

Now I have three ways of plotting the triangles. But in one of them I fill each triangle with the average of it's corners strains. What I want to do is... Put the strain on the corner and get a plot that looks like contour or contourf. - I don't really understand how they work.

Can anyone help me?

clear; clc; TC = [ 1 2 3 ; 2 3 4 ] ; % Triangles node Connection. NC = [ 0,0 ; 0,1 ; 1,0 ; 1,1 ] ; % Node Coordinates. strain = [ 300 , 400 , 500 ; 400 , 500 , 600]; % Strains in each node.; [ne,np] = size(TC); % Just finding how many elements. element = zeros([3 2 ne]); % Creating a matrix for each element. % My first and second plot... for i=1:ne no1 = TC(i,1); no2 = TC(i,2); no3 = TC(i,3); element(:,:,i) = [ NC(no1,1),NC(no1,2); NC(no2,1),NC(no2,2); NC(no3,1),NC(no3,2);]; % Defining each element for each loop. % Node 1 Node 2 Node 3 xe = [element(1,1,i),element(2,1,i),element(3,1,i)]; % Defining coordinates to plot. ye = [element(1,2,i),element(2,2,i),element(3,2,i)]; subplot(3,1,1) plot([xe, xe(1)],[ye, ye(1)]) % ATTEMPT ONE % Only plotting the triangles. Using first value also last to close the triangle. xlim([-1 2]); ylim([-1 2]) hold on subplot(3,1,2) fill(xe,ye,mean(strain(i,:))) % ATTEMPT TWO % Fill triangles with average strain. hold on xlim([-1 2]); ylim([-1 2]) end % ATTEMPT 3 subplot(3,1,3) TR = triangulation(TC,NC); triplot(TR) hold on xlim([-1 2]); ylim([-1 2])

Thanks in advance.

最满意答案

您可以使用fill功能来获得所需的阴影。 通过对您的应用程序进行一些自定义,我相信下面的代码可以正常工作,尽管如果for循环使程序运行速度过慢,可能会有一些向量化。

X = zeros(3,size(TC,1)); Y = zeros(3,size(TC,1)); C = zeros(3,size(TC,1)); for i = 1:size(TC,1) % for all triangle connection definitions for j = 1:3 % for all nodes in a triangle X(j,i) = NC(TC(i,j),1)'; % format X points Y(j,i) = NC(TC(i,j),2)'; % format Y points C(:,i) = strain(i,:)'; % format color based on strain value end end fill(X,Y,C)

结果:

在此处输入图像描述

您可能需要查看此文档以获取有关如何解释X,Y和C的更多详细信息

You can use the fill function to get the shading that you desire. With a little bit of customization for your application I believe the following code will work, although some vectorization may be in order if the for loop slows your program too much.

X = zeros(3,size(TC,1)); Y = zeros(3,size(TC,1)); C = zeros(3,size(TC,1)); for i = 1:size(TC,1) % for all triangle connection definitions for j = 1:3 % for all nodes in a triangle X(j,i) = NC(TC(i,j),1)'; % format X points Y(j,i) = NC(TC(i,j),2)'; % format Y points C(:,i) = strain(i,:)'; % format color based on strain value end end fill(X,Y,C)

The result:

enter image description here

You may want to check this documentation for further details on how X,Y and C are interpreted

更多推荐

本文发布于:2023-07-28 08:35:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1303074.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有限元

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!