Clear Filters
Clear Filters

Finite Element post-processing

7 views (last 30 days)
Edward
Edward on 14 Nov 2011
Dear All,
I'm finding solution to a FE post-processing problem. I got a file of output data for a 2D FE analysis, with data saved in the following format:
x1 y1 T1
x2 y2 T2
x3 y3 T3
..........
I need to find all the nodes in a specified area within the domain analysed, say, all the nodes boxed by a small rectangular. The coordinates at the centre of the box is known, and the area of the box is know as well. What kind of algorithms or Matlab functions could I use to achieve it?
Thanks in advance.
Edward
  1 Comment
David Young
David Young on 14 Nov 2011
It probably wasn't a good idea to have "finite element" in the title and in the tags. I nearly didn't look at your question because it's a long time since I did anything with finite element modelling, but in fact finite elements are irrelevant to the actual question you asked. You could remove the tag (along with post-processing) at least, to reduce noise.

Sign in to comment.

Answers (1)

David Young
David Young on 14 Nov 2011
You can read the data from the file into a matrix with either dlmread or textscan. The documentation for these has examples and explanation.
Assuming you've read your data into a vector with a value in each element, in the order you give in your question, you can then proceed as follows. Since you only know the centre and the area of the box, I'll assume it's a square, otherwise there isn't enough information.
data = 100*rand(1, 150); % dummy data - real is read from file
xcentre = 30; % parameters of square - centre and area
ycentre = 10;
area = 1000;
% get limits of square from centre and area
square_half_size = sqrt(area)/2;
xmin = xcentre - square_half_size;
xmax = xcentre + square_half_size;
ymin = ycentre - square_half_size;
ymax = ycentre + square_half_size;
% split up data
data_matrix = reshape(data, 3, []); % first row is x, second y, third T
x = data_matrix(1, :);
y = data_matrix(2, :);
T = data_matrix(3, :);
% find numbers of rows for which x and y lie within square
wanted = x > xmin & x < xmax & y > ymin & y < ymax;
% select only the data you want
x_selected = x(wanted);
y_selected = y(wanted);
T_selected = T(wanted);
% or, keeping them together in one matrix
data_selected = data_matrix(:, wanted);
The key to understanding this code is the line with "x > xmin & ..." in it. Look at how the code builds up to making that logical expression work, then look at what is done with it. If you are not clear about the last part you may need to read about logical indexing in the documentation.
  2 Comments
David Young
David Young on 14 Nov 2011
I see you've edited the question and changed the format of the data from a 1 x 3N vector to a N x 3 matrix, since I answered. However, this should make little difference to my answer, except that you may not need to reshape step, though you may need to transpose the matrix or exchange rows and columns in my code.
David Young
David Young on 14 Nov 2011
Or maybe Walter formatted it for you. But anyway, same result.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!