From: yiannis p on
Hello guys
I have been working with this for some time now and I have decided that I am on a dead end.
I have a set of data exported from FLUENT CFD software. It is unsorted and consists of the cartesian coordinated x, y, z, and a number of variables.
I want to perform surface integration on a number of variables say v with respect to x and y values.

I know the I can do single integration using either TRAPZ or SIMPS but how do I do that for unsorted data? Then how would I do the double integration?

Any help will be greatly appreciated

Thank you,
Yiannis
From: John D'Errico on
In article <1885804.1209993542372.JavaMail.jakarta(a)nitrogen.mathforum.org>, yiannis p <yiannis000(a)hotmail.com> wrote:

> Hello guys
> I have been working with this for some time now and I have decided that I am
> on a dead end.
> I have a set of data exported from FLUENT CFD software. It is unsorted and
> consists of the cartesian coordinated x, y, z, and a number of variables.
> I want to perform surface integration on a number of variables say v with
> respect to x and y values.
>
> I know the I can do single integration using either TRAPZ or SIMPS but how do
> I do that for unsorted data? Then how would I do the double integration?
>
> Any help will be greatly appreciated
>
> Thank you,
> Yiannis

You need to have a triangulation over the
set of (x,y) pairs. Use delaunay to do
this. Then use my tessquad to perform the
integration. It is on the file exchange.

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=9991&objectType=FILE

HTH,
John


--
The best material model of a cat is another, or preferably the same, cat.
A. Rosenblueth, Philosophy of Science, 1945

Those who can't laugh at themselves leave the job to others.
Anonymous
From: yiannis p on
Thank you John for your help.

However I have been trying for a day now to understand what to do and it is kind of hard since I am fairly new to matlab.
Could you please expand some more on how to use the simplexquad.m file and how to alter my data.

thank you in advance
Yiannis
From: John D'Errico on
yiannis p <yiannis000(a)hotmail.com> wrote in message
<31523928.1210174130186.JavaMail.jakarta(a)nitrogen.mathforum.org>...
> Thank you John for your help.
>
> However I have been trying for a day now to understand what to do and it
is kind of hard since I am fairly new to matlab.
> Could you please expand some more on how to use the simplexquad.m file
and how to alter my data.
>
> thank you in advance
> Yiannis

If you have a function that you can evaluate
at any location, then tessquad will do it
simply. I'll build a list of points on the unit
square. I'll make sure the list includes the
corners of the square to give a valid test
where we know the exact answer.

xy = [rand(100,2);[0 0;0 1;1 0;1 1]];
tri = delaunayn(xy);
fun = @(xy) prod(xy,2);

% We know the integral of x*y over the unit
% square [0,1]X[0,1]. It is just 0.25.

tessquad(@(xy) prod(xy,2),2,xy,tri)
ans =
0.25

% If you have only the fixed values at the points
% in xy, then tessquad does not do this. Its
% not that nasty though. Lets first choose a
% finer sampling, since this integration will not
% be as accurate.

xy = [rand(10000,2);[0 0;0 1;1 0;1 1]];
tri = delaunayn(xy);
z = fun(xy);

% Compute the areas of each triangle in tri.
A = abs((xy(tri(:,2),1)-xy(tri(:,1),1)).*(xy(tri(:,3),2)-xy(tri(:,1),2)) - ...
(xy(tri(:,3),1)-xy(tri(:,1),1)).*(xy(tri(:,2),2)-xy(tri(:,1),2)))/2;

avez = z(tri(:,1)) + z(tri(:,2)) + z(tri(:,3));
integral = sum(A.* avez/3)

format long g
integral = sum(A.* avez/3)
integral =
0.250000050745763

John
 | 
Pages: 1
Prev: fmincon query
Next: fft sign?