How can I create FEA colour plots?

Hi Everyone,
I have an array of dataset containing X,Y coordinates and their corresponding FEA results (Von Mises, Displacement, Strain).
What is the easiest way to plot this data on coloured contour plots?
Thank you for your help.

3 Comments

J. Alex Lee
J. Alex Lee on 7 Mar 2020
Edited: J. Alex Lee on 7 Mar 2020
do you have connectivity information?
If not, you can maybe use the triangulate function within matlab to generate it first, and maybe there are ways to plot such results.
otherwise you can try to use a scatteredInterpolant to find values on a regular grid of positions, then use a contour() or contourf()
Can you be a bit more specific?
I have tried to fiddle with the commands you recommended but I couldn't work out how to create the plot.
Please show your attempts. Attach the data

Sign in to comment.

Answers (1)

Assuning that you have a planar rectangular geometry and coordinates and results are stored in vectors x, y and vonMises, you can use the following code:
% x - vector of x coordinates
% y - vector of y coordinates
% vonMises - nodal von Mises stress
n = 50; % number of levels
contourf(x, y, vonMises, n);
xlim([min(x) max(x)]);
ylim([min(y) max(y)]);
xlabel("X coordinate")
ylabel("Y coordinate")
bar = colorbar;
title(bar, "Von Mises stress")
If your geometry is not rectangular, then you also need some information about connections between individual nodes as J. Alex Lee has already noted.

10 Comments

Tamas Lanci
Tamas Lanci on 3 Apr 2020
Edited: Tamas Lanci on 3 Apr 2020
This is my FE model that I am trying to visalize in Matlab:
This is a fraction of the dataset that I am using:
Do you still think ContourF function is the applicable in this case?
  • Do you still think ContourF function is the applicable in this case?
Didn't you stil try?
And why your elements have only two points each instead of four?
Do you still think ContourF function is the applicable in this case?
Definitely yes!
You can take full advantage of a fact that contourf does not fill areas with NaN values. The idea comes from this Matlab answer.
In your case, you need to create ghost nodes in the hollow area. The following code should do the trick.
% Import input data
% x - vector of x coordinates
% y - vector of y coordinates
% vonMises - nodal von Mises stress
% Create "ghost points"
r = 10; % radius of the hollow area
% I am assunming that the centre of the area is in x = 0, y = 0.
pts = 60; % number of the ghost points
phi = linspace(0, 2*pi, pts + 1)';
ptsX = 0.999 * r * cos(phi(1:end-1));
ptsY = 0.999 * r * sin(phi(1:end-1));
% Add the ghost points to your input data
x = [x; ptsX]; % I am assuming that x is a column vector
y = [y; ptsY];
vonMises = [vonMises; nan(size(ptsX))];
% Plot countour diagram
n = 50; % number of levels
contourf(x, y, vonMises, n);
xlim([min(x) max(x)]);
ylim([min(y) max(y)]);
xlabel("X coordinate")
ylabel("Y coordinate")
bar = colorbar;
title(bar, "Von Mises stress")
Alternatively, you can use your input data and just draw a white circle in the hollow area.
EDIT: Typo corrected.
I am sorry. I wasn't clear in the beginning. I would like this to work for any sort of shape and not only for the one I shared above.
Well, you can easily generate the ghost points in any desired area.
If you need a higher degree of automation, you can use scatteredInterpolant, which has been already mentioned by J. Alex Lee. If you set "ExtrapolationMethod" parameter to "none", areas outside of the convex hull of your points are omitted automatically. Unfortunately, this solution does not recognise hollow areas inside the convex hull.
% Import input data
% x - vector of x coordinates
% y - vector of y coordinates
% vonMises - nodal von Mises stress
% Generate interpolant
F = scatteredInterpolant(x, y, vonMises, 'natural', 'none');
% Generate query nodes
dx = (max(x) - min(x)) / 1000;
dy = (max(y) - min(y)) / 1000;
[xq, yq] = meshgrid(min(x):dx:max(x), min(y):dy:max(y));
% Visualise data
vq = F(xq, yq);
surface(xq, yq, vq);
shading interp
view(2)
Lubos Smolik
Lubos Smolik on 3 Apr 2020
Edited: Lubos Smolik on 3 Apr 2020
And why your elements have only two points each instead of four?
@Darova Results are probably in interpolation points and not in nodes.
Before going down this rabit hole of post-processing the excel data (which I would imagine in general is hard to do), I guess we should ask OP if they have access to the actual FE results from which the full elemental connectivity information can be extracted. It's also not clear why matlab needs to be the platform of choice to do the visualization if this is the case?
Integration point to be precise ( I made a mistake when I exported the data)
Yes, I have access to the FE results.
I wrote a code which overlays the FE results on the DIC calculates difference between them for validation purposes.
The reason I am using X,Y coordinates for the nodes is that I neet to match the format of the DIC results.
I would like to validate my code as much as possible. Therefore, I think the "scatteredInterpolant" method is the way to go.
I managed to create the object earlier but I don't really know where to go from there to create the plot.
Can you give me a little bit of guidence on that, please?
Thank you for everybody's help.
I used the TriScatteredInterp method with the ghost nodes as suggested:
clear all
clc
M=readmatrix("DIC_PLATE_COPY.csv");
%Mu=M(1:2:end,:);
px=(M(:,1));
py=(M(:,2));
pz=(M(:,10));
r = 6; % radius of the hollow area
% I am assunming that the centre of the area is in x = 0, y = 0.
pts = 500; % number of the ghost points
phi = linspace(0, 2*pi, pts + 1)';
ptsX = 0.999 * r * cos(phi(1:end-1));
ptsY = 0.999 * r * sin(phi(1:end-1));
% Add the ghost points to your input data
px = [px; ptsX]; % I am assuming that x is a column vector
py = [py; ptsY];
pz = [pz; nan(size(ptsX))];
x=linspace(min(px(:,1)),max(px(:,1)),1000);
y=linspace(min(py(:,1)),max(py(:,1)),1000);
[X,Y]=meshgrid(x,y);
F=TriScatteredInterp(px(:,1),py(:,1),pz(:,1));
[M c]=contourf(X,Y,F(X,Y),40,'LineColor','none');
daspect([1 1 1])
colormap(jet)
colorbar

Sign in to comment.

Categories

Products

Asked:

on 6 Mar 2020

Edited:

on 16 Apr 2020

Community Treasure Hunt

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

Start Hunting!