index_builder2

PURPOSE ^

INDEX_BUILDER - ???

SYNOPSIS ^

function f=index_builder(index,node_on_icefront,element_on_icefront)

DESCRIPTION ^

INDEX_BUILDER - ???

   Usage:
      f=index_builder(index,node_on_icefront,element_on_icefront)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function f=index_builder(index,node_on_icefront,element_on_icefront)
0002 %INDEX_BUILDER - ???
0003 %
0004 %   Usage:
0005 %      f=index_builder(index,node_on_icefront,element_on_icefront)
0006 
0007 index_icefront=[];
0008 nel=length(index);
0009 problematic_elements=[];
0010 for n=1:nel
0011     
0012    if element_on_icefront(n)
0013       if (node_on_icefront(index(n,1)) & node_on_icefront(index(n,2)) & node_on_icefront(index(n,3))),
0014          problematic_elements=[problematic_elements
0015             n];
0016        else,
0017       
0018         if (node_on_icefront(index(n,1)) & node_on_icefront(index(n,2)))
0019             index_icefront=[index_icefront
0020             index(n,1) index(n,2)];
0021         end
0022 
0023         if (node_on_icefront(index(n,2)) & node_on_icefront(index(n,3)))
0024            index_icefront=[index_icefront
0025             index(n,2) index(n,3)];
0026         end
0027         if (node_on_icefront(index(n,3)) & node_on_icefront(index(n,1)) & ...
0028                             (1-node_on_icefront(index(n,2))))
0029            index_icefront=[index_icefront
0030             index(n,3) index(n,1)];
0031         end
0032        end
0033     end
0034 end
0035 
0036 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
0037 %we deal with the problematic elements
0038 type_prob_elem=zeros(length(problematic_elements),1);
0039 position=zeros(length(problematic_elements),3);
0040 for i=1:length(problematic_elements),
0041    for n=1:3,
0042       a=length(find(index_icefront == index(problematic_elements(i),n)));
0043       if a>=1, position(i,n)=1;
0044       else position(i,n)=0;
0045       end
0046       
0047    end
0048        a=length(find(position(i,:)));
0049       type_prob_elem(i)=a(1);
0050 end
0051 
0052 %we begin with the type_prob_elem =2
0053 index_front_spec=[];
0054 pos=find(type_prob_elem ==2);
0055 for j=1:length(pos),
0056    el=problematic_elements(pos(j));
0057    pos2=find(position(pos(j),:)==0);
0058    switch pos2,
0059    case 1,
0060       index_front_spec=[index_front_spec
0061          index(el,1) index(el,2)
0062       index(el,3) index(el,1)];
0063    case 2,
0064       index_front_spec=[index_front_spec
0065          index(el,2) index(el,3)
0066       index(el,1) index(el,2)];
0067    case 3,
0068       index_front_spec=[index_front_spec
0069          index(el,3) index(el,1)
0070       index(el,2) index(el,3)];
0071    end   
0072 end
0073 
0074 %now the type_prob_elem=1
0075 pos=find(type_prob_elem==1);
0076 for n=1:length(pos),
0077 el=problematic_elements(pos(n));
0078 
0079 pos2=find(position(pos(n),:)==0);
0080 for m=1:length(pos2),
0081    a=length(find(index_front_spec==index(el,pos2(m))));
0082    if a>=1,
0083       position(pos(n),pos2(m))=1;
0084    end
0085 end
0086 
0087 pos2=find(position(pos(n),:)==0);
0088 switch pos2,
0089    case 1,
0090       index_front_spec=[index_front_spec
0091          index(el,1) index(el,2)
0092       index(el,3) index(el,1)];
0093    case 2,
0094       index_front_spec=[index_front_spec
0095          index(el,2) index(el,3)
0096       index(el,1) index(el,2)];
0097    case 3,
0098       index_front_spec=[index_front_spec
0099          index(el,3) index(el,1)
0100       index(el,2) index(el,3)];
0101 end   
0102 end
0103    
0104    
0105 %now the type_prob_elem=0
0106 pos=find(type_prob_elem==0);
0107 for n=1:length(pos),
0108 el=problematic_elements(pos(n));
0109 
0110 pos2=find(position(pos(n),:)==0);
0111 for m=1:length(pos2),
0112    a=length(find(index_front_spec==index(el,pos2(m))));
0113    if a>=1,
0114       position(pos(n),pos2(m))=1;
0115    end
0116 end
0117 
0118 pos2=find(position(pos(n),:)==0);
0119 switch pos2,
0120    case 1,
0121       index_front_spec=[index_front_spec
0122          index(el,1) index(el,2)
0123       index(el,3) index(el,1)];
0124    case 2,
0125       index_front_spec=[index_front_spec
0126          index(el,2) index(el,3)
0127       index(el,1) index(el,2)];
0128    case 3,
0129       index_front_spec=[index_front_spec
0130          index(el,3) index(el,1)
0131       index(el,2) index(el,3)];
0132 end   
0133 end
0134 
0135 %now we have to eliminate the lines that appear in the index_front_spec and that are inner lines to the mesh
0136 flag_elim=zeros(length(index_front_spec),1);
0137 for n=1:length(index_front_spec),
0138    a=length(find_line(index,index_front_spec(n,:)));
0139    if a>=2,
0140       flag_elim(n)=1;
0141    end
0142 end
0143 index_front_spec=erase_lines(index_front_spec,flag_elim);
0144    
0145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55
0146 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
0147 
0148    
0149    index_icefront=[index_icefront
0150       index_front_spec];
0151    
0152 f=index_icefront;
0153    
0154    
0155

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