


SPCGRIDS - spc the grids
Go through the grids and figure out which are spcd
Usage:
[grids,y_g]=SpcGrids(grids,constraints)

0001 function [grids,y_g]=SpcGrids(grids,constraints) 0002 %SPCGRIDS - spc the grids 0003 % 0004 % Go through the grids and figure out which are spcd 0005 % 0006 % Usage: 0007 % [grids,y_g]=SpcGrids(grids,constraints) 0008 0009 global cluster 0010 0011 %initialize y_g, vector of constraint values in the g-set: 0012 y_g=sparse(getdofcount(grids),1); 0013 0014 if cluster, 0015 y_g_border=sparse(getdofcount(grids),1); 0016 end 0017 0018 %Go through constraints and add constraint on gridset list of corresponding grid 0019 for i=1:length(constraints), 0020 0021 constraint=constraints(i).constraint; 0022 if strcmpi(constraint.type,'spc'), 0023 constraint_grid=grids(constraint.grid).grid; 0024 0025 %On the cluster, grids are partitioned across cpus, but constraints are replicated across cpus. So 0026 %grids pointed to by certain constraints might not exist on the local cpu. In this case, skip the 0027 %constraint operations. 0028 if cluster & isempty(constraint_grid), 0029 continue; 0030 end 0031 0032 %for the constrained grid, add the correct degree of freedom in the gridset list 0033 constraint_grid.gridset=[constraint_grid.gridset num2str(constraint.dof)]; %concatenate two strings 0034 0035 %plug modified grid back into grids dataset. 0036 grids(constraint.grid).grid=constraint_grid; 0037 0038 %plug value of constraint in corresponding constraint vector y_g 0039 dof=constraint_grid.doflist(constraint.dof); 0040 if ~cluster, 0041 y_g(dof)=constraint.value; 0042 else 0043 %for cluster, we add to y_g only if grid does not belong to border (we don't want to add constraint.value several times for each cpu). 0044 if constraint_grid.border~=1, 0045 y_g(dof)=constraint.value; 0046 else 0047 y_g_border(dof)=constraint.value; 0048 end 0049 end 0050 end 0051 end 0052 0053 if cluster, 0054 %Add all the y_g from all the cpus 0055 y_g=gplus(y_g); 0056 %y_g_border is the same on all cpus, plug it into y_g 0057 y_g=y_g+y_g_border; 0058 end