Dof

PURPOSE ^

DOF - assign the degrees of freedom to each grid

SYNOPSIS ^

function grids=Dof(grids)

DESCRIPTION ^

DOF - assign the degrees of freedom to each grid

   Establish the degrees of freedom that exist on each grid. For each grid, 
   we default to 6 degrees of freedom, 3 in translation and 3 in rotation (Nastran convention)
   When running serially, the dofs (degrees of freedom) are setup incrementaly,  6 for each grid. 
   In parallel, things are a bit more complex. We want grids belonging to the same partition to 
   be side by side in the global system matrices, to improve the sparsity pattern.  We also want 
   the border grids, grids that belong to several partitions, to be lumped at the end of the dof list. 

   Usage:
      grids=Dof(grids)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function grids=Dof(grids)
0002 %DOF - assign the degrees of freedom to each grid
0003 %
0004 %   Establish the degrees of freedom that exist on each grid. For each grid,
0005 %   we default to 6 degrees of freedom, 3 in translation and 3 in rotation (Nastran convention)
0006 %   When running serially, the dofs (degrees of freedom) are setup incrementaly,  6 for each grid.
0007 %   In parallel, things are a bit more complex. We want grids belonging to the same partition to
0008 %   be side by side in the global system matrices, to improve the sparsity pattern.  We also want
0009 %   the border grids, grids that belong to several partitions, to be lumped at the end of the dof list.
0010 %
0011 %   Usage:
0012 %      grids=Dof(grids)
0013 
0014 global cluster
0015 
0016 dofcount=length(grids)*6;
0017 
0018 if ~cluster,
0019     dof=1;
0020     for i=1:length(grids),
0021         grids(i).grid.doflist=dof:1:(dof+5);
0022         dof=dof+6;
0023     end
0024 else
0025     borderdof=1;
0026     dof=1;
0027     for i=1:length(grids),
0028         if ~isempty(grids(i).grid),
0029             if ~grids(i).grid.border,
0030                 grids(i).grid.doflist=dof:1:(dof+5);
0031                 dof=dof+6;
0032             else
0033                 grids(i).grid.doflist=borderdof:1:(borderdof+5);
0034                 borderdof=borderdof+6;
0035             end
0036         end
0037     end
0038     localdofcount=dof-1;
0039     localborderdofcount=borderdof-1;
0040 
0041     %Now, offset the border dofs so that they are lumped at the end of the dof list.
0042     for i=1:length(grids),
0043         if (~isempty(grids(i).grid) & grids(i).grid.border),
0044             grids(i).grid.doflist=grids(i).grid.doflist+dofcount-localborderdofcount;
0045         end
0046     end
0047 
0048     %Now, update the regular local grid dofs to account for other cpu grids.
0049     alldofcounts=gcat(localdofcount); %this array holds the dof count for all cpus.
0050     
0051     %Determine offset for all grid dofs
0052     dofoffset=sum(alldofcounts(1:labindex-1));
0053     
0054     %offset all grid dofs.
0055     for i=1:length(grids),
0056         if (~isempty(grids(i).grid) & ~grids(i).grid.border),
0057             grids(i).grid.doflist=grids(i).grid.doflist+dofoffset;
0058         end
0059     end
0060 end

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