How do I divide a volume to smaller ones in a meshed geometry?

I have a meshed rectangular cube with following dimension 1*1*3 (meters). it includes 24000 cubic cells . I made a secondary mesh in which every 64 cells make a new cubic mesh (larger meshes). Also I have coordination of all 24000 cell centers and some other parameters like pressure and velocity in every single cell in xls, txt and dat formats. I need to put evrey 64 cells (which are besides each others) together in a regular order and make larger meshes to average those data in the bigger cells. There will be 24000/64 = 375 meshes.
In other word, how can I divide a meshed volume like a cube to smaller ones so that the same numbers of cells locate in every smaller cubes, so called averaging in geometry!
Here I wrote a code and it gives 5*5*15 matix which is correct but the values are not true!
load as2.dat; PP = as2;
lx = 4; ly = 4; lz = 4;
PPP = zeros(2,2,2);
Lx = linspace(0 , 4 , lx+1); Ly = linspace(0 , 4 , ly+1); Lz = linspace(0 , 4 , lz+1);
for i = 0:3;
for j = 0:3;
for k = 0:3;
PPP(floor(i/4)+1 , floor(j/4)+1 , floor(k/4)+1)=
mean(mean(PP(:,4).(...
(PP(:,1) < Lx(i+2)) & (PP(:,1) >= Lx(i+1))& ...
(PP(:,2) < Ly(j+2)) & (PP(:,2) >= Ly(j+1))& ...
(PP(:,3) < Lz(k+2)) & (PP(:,3) >= Lz(k+1))),2));
end
end
end
PPP
I really appreciate if you help me,
Omid

Answers (0)

Asked:

on 7 May 2013

Community Treasure Hunt

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

Start Hunting!