BuildGridSets

PURPOSE ^

BUILDGRIDSETS - build the different grid sets

SYNOPSIS ^

function BuildGridSets(grids,constraints)

DESCRIPTION ^

BUILDGRIDSETS - build the different grid sets

   Several grid sets are needed to solve the finite element problem
   o the gset table of degrees of freedom contains 
     all the degrees of freedom for each grid (6)
   o the sset table of degrees of freedom contains 
     all the degrees of freedom that are spcd
   o the fset table of degrees of freedom contains 
     all the degrees of freedom that are free (gset-sset)
   o the fset table of degrees of freedom contains 
     all the degrees of freedom that linked (2d-3d junction for example)

   Usage:
      BuildGridSets(grids,constraints)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function BuildGridSets(grids,constraints)
0002 %BUILDGRIDSETS - build the different grid sets
0003 %
0004 %   Several grid sets are needed to solve the finite element problem
0005 %   o the gset table of degrees of freedom contains
0006 %     all the degrees of freedom for each grid (6)
0007 %   o the sset table of degrees of freedom contains
0008 %     all the degrees of freedom that are spcd
0009 %   o the fset table of degrees of freedom contains
0010 %     all the degrees of freedom that are free (gset-sset)
0011 %   o the fset table of degrees of freedom contains
0012 %     all the degrees of freedom that linked (2d-3d junction for example)
0013 %
0014 %   Usage:
0015 %      BuildGridSets(grids,constraints)
0016 
0017 global cluster
0018 global gridset
0019 
0020 mset=zeros(getdofcount(grids),1);
0021 nset=zeros(getdofcount(grids),1);
0022 sset=zeros(getdofcount(grids),1);
0023 fset=zeros(getdofcount(grids),1);
0024 
0025 %First build mutually exclusive m and n sets
0026 %see NastranRgbDoc documentation in theoryguide directory.
0027 nset(:)=1; %everyone is in the n set, except if it is the leading dof of an rgb.
0028 for i=1:length(constraints)
0029     constraint=constraints(i).constraint;
0030     if strcmpi(constraint.type,'rgb'),
0031         grid1=constraint.grid1;
0032         grid2=constraint.grid2;
0033         dof=constraint.dof;
0034         dof1=grids(grid1).grid.doflist(dof);
0035         dof2=grids(grid2).grid.doflist(dof);
0036         if (mset(dof1)==1),
0037             %this dof is already in the mset!
0038             if mset(dof2)==1,
0039                 %ok, we have identical rgbs, do nothing
0040             else
0041                 mset(dof2)=1;
0042                 nset(dof2)=0;
0043             end
0044         else
0045             mset(dof1)=1;
0046             nset(dof1)=0;
0047         end
0048     end
0049 end
0050 
0051 %Build gridset table of degrees of freedom -> s degrees (the ones that are constrained with an spc -> s for spc)
0052 %the f degrees of freedom (the rest, called f set -> f for free)
0053 for i=1:length(grids),
0054     grid=grids(i).grid;
0055 
0056     if isempty(grid),continue;end;
0057 
0058     if ~cluster,
0059         %if dof 1 is spc'ed, put it in the sset, otherwise, in the fset
0060         if ~isempty(findstr(grid.gridset,'1')), sset(grid.doflist(1))=1; else fset(grid.doflist(1))=1; end
0061         if ~isempty(findstr(grid.gridset,'2')), sset(grid.doflist(2))=1; else fset(grid.doflist(2))=1; end
0062         if ~isempty(findstr(grid.gridset,'3')), sset(grid.doflist(3))=1; else fset(grid.doflist(3))=1; end
0063         if ~isempty(findstr(grid.gridset,'4')), sset(grid.doflist(4))=1; else fset(grid.doflist(4))=1; end
0064         if ~isempty(findstr(grid.gridset,'5')), sset(grid.doflist(5))=1; else fset(grid.doflist(5))=1; end
0065         if ~isempty(findstr(grid.gridset,'6')), sset(grid.doflist(6))=1; else fset(grid.doflist(6))=1; end
0066     else
0067         %same thing, except that if the grid is a border grid, we only carry out the inclusion on lab 1
0068         if grid.border==1,
0069             if labindex==1,
0070                 if ~isempty(findstr(grid.gridset,'1')), sset(grid.doflist(1))=1; else fset(grid.doflist(1))=1; end
0071                 if ~isempty(findstr(grid.gridset,'2')), sset(grid.doflist(2))=1; else fset(grid.doflist(2))=1; end
0072                 if ~isempty(findstr(grid.gridset,'3')), sset(grid.doflist(3))=1; else fset(grid.doflist(3))=1; end
0073                 if ~isempty(findstr(grid.gridset,'4')), sset(grid.doflist(4))=1; else fset(grid.doflist(4))=1; end
0074                 if ~isempty(findstr(grid.gridset,'5')), sset(grid.doflist(5))=1; else fset(grid.doflist(5))=1; end
0075                 if ~isempty(findstr(grid.gridset,'6')), sset(grid.doflist(6))=1; else fset(grid.doflist(6))=1; end
0076             end
0077         else
0078             if ~isempty(findstr(grid.gridset,'1')), sset(grid.doflist(1))=1; else fset(grid.doflist(1))=1; end
0079             if ~isempty(findstr(grid.gridset,'2')), sset(grid.doflist(2))=1; else fset(grid.doflist(2))=1; end
0080             if ~isempty(findstr(grid.gridset,'3')), sset(grid.doflist(3))=1; else fset(grid.doflist(3))=1; end
0081             if ~isempty(findstr(grid.gridset,'4')), sset(grid.doflist(4))=1; else fset(grid.doflist(4))=1; end
0082             if ~isempty(findstr(grid.gridset,'5')), sset(grid.doflist(5))=1; else fset(grid.doflist(5))=1; end
0083             if ~isempty(findstr(grid.gridset,'6')), sset(grid.doflist(6))=1; else fset(grid.doflist(6))=1; end
0084         end
0085     end
0086 end
0087 
0088 
0089 if cluster,
0090     error('Not cool, broke it!');
0091     sset=gplus(sset);
0092     fset=gplus(fset);
0093 end
0094 
0095 %First build mset vector
0096 
0097 %m and n set are mutually exclusive! For now, we assume no spc is on an mpc!
0098 pos=find(mset);
0099 fset(pos)=0;
0100 sset(pos)=0;
0101 nset(pos)=0;
0102 
0103 gridset.pv_m=pos; 
0104 gridset.msize=length(pos);
0105 
0106 pos=find(nset);
0107 gridset.pv_n=pos;
0108 gridset.nsize=length(pos);
0109 
0110 
0111 %now, n set splits into s and f set
0112 n_sset=sset(gridset.pv_n);
0113 n_fset=fset(gridset.pv_n);
0114 
0115 pos=find(n_sset);
0116 gridset.pv_s=pos;
0117 gridset.ssize=length(pos);
0118 
0119 pos=find(n_fset);
0120 gridset.pv_f=pos; 
0121 gridset.fsize=length(pos);
0122 
0123 
0124 gridset.gsize=gridset.msize+gridset.nsize; %no need for flags, as all dofs belong to the g set
0125 
0126 
0127 
0128 end

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