PartitioningVector

PURPOSE ^

PARTITIONINGVECTOR - build the partitioning vector

SYNOPSIS ^

function [part tpart]=PartitioningVector(md,grids);

DESCRIPTION ^

PARTITIONINGVECTOR - build the partitioning vector

   Return a partitioning vector, and its transpose. The partitioning vector
   part shows how each dof is distributed. tpart allows from a partitioned dof to go back
   to its original position on the grid list.

   Usage:
      [part tpart]=PartitioningVector(md,grids)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [part tpart]=PartitioningVector(md,grids);
0002 %PARTITIONINGVECTOR - build the partitioning vector
0003 %
0004 %   Return a partitioning vector, and its transpose. The partitioning vector
0005 %   part shows how each dof is distributed. tpart allows from a partitioned dof to go back
0006 %   to its original position on the grid list.
0007 %
0008 %   Usage:
0009 %      [part tpart]=PartitioningVector(md,grids)
0010 
0011 global cluster
0012 
0013 if ~cluster,
0014     part=1:1:md.numberofgrids;
0015     tpart=1:1:md.numberofgrids;
0016 else
0017     part=zeros(md.numberofgrids,1);
0018     %First deal with non border grids.
0019 
0020     %How many grids for each lab?
0021     count=0;
0022     for i=1:md.numberofgrids,
0023         if ((~isempty(grids(i).grid)) & (grids(i).grid.border==0)),
0024             count=count+1;
0025         end
0026     end
0027 
0028     %broacast
0029     labcounts=gcat(count);
0030 
0031     %create offset into partition vector
0032     offset=0;
0033     for i=1:(labindex-1),
0034         offset=offset+labcounts(i);
0035     end
0036 
0037     %create partition vector
0038     for i=1:md.numberofgrids,
0039         if ((~isempty(grids(i).grid)) & (grids(i).grid.border==0)),
0040             offset=offset+1;
0041             part(offset)=i;
0042         end
0043     end
0044 
0045     part=gplus(part);
0046 
0047     %deal with border grids
0048     count=gplus(count);
0049     for i=1:md.numberofgrids,
0050         if ((~isempty(grids(i).grid)) & (grids(i).grid.border==1)),
0051             count=count+1;
0052             part(count)=i;
0053         end
0054     end
0055 
0056     %Build tpart:
0057     tpart=zeros(md.numberofgrids,1);
0058     for i=1:md.numberofgrids,
0059         tpart(part(i))=i;
0060     end
0061 end
0062 
0063 end %end function

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003