Overview
Comment: | Reordered algorithms as follows: bond end coordinates associate port labels with bonds (port_bond) associate bonds with components unsorted list of bonds on each component (components) interpret strokes and setup the causality of the bonds (bonds) expand vector ports & add new bonds and connections sort bonds on each component according to the labels -- two ports default included here. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | origin/master | trunk |
Files: | files | file ages | folders |
SHA3-256: |
d75632f734fcab6485bfa8b870ec551b |
User & Date: | gawthrop@users.sourceforge.net on 1997-08-14 11:01:42 |
Other Links: | branch diff | manifest | tags |
Context
1997-08-14
| ||
11:59:47 | Vector ports added!! check-in: 6847e1f089 user: gawthrop@users.sourceforge.net tags: origin/master, trunk | |
11:01:42 |
Reordered algorithms as follows: bond end coordinates associate port labels with bonds (port_bond) associate bonds with components unsorted list of bonds on each component (components) interpret strokes and setup the causality of the bonds (bonds) expand vector ports & add new bonds and connections sort bonds on each component according to the labels -- two ports default included here. check-in: d75632f734 user: gawthrop@users.sourceforge.net tags: origin/master, trunk | |
1997-08-09
| ||
14:42:39 | Added underscore to port regexp check-in: 7aafd38e0d user: gawthrop@users.sourceforge.net tags: origin/master, trunk | |
Changes
Modified mttroot/mtt/bin/trans/m/rbg2abg.m from [d8d4e1e6ac] to [0a2a4fa9dc].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | + + + + | function [bonds,components] = rbg2abg(name,rbonds,rstrokes,rcomponents,port_coord,port_name,infofile) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% Version control history % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% $Id$ % %% $Log$ % %% Revision 1.17 1997/08/09 11:31:16 peterg % %% Default two port list is [in;out] (or [out;in]) % %% Dont do global default if no ports labels. % %% % %% Revision 1.16 1997/08/07 16:12:36 peterg % %% Fixed sorting bug: now puts the jth component from the unsorted list % %% into the kth component of the sorted list .. not vice versa! % %% % %% Revision 1.15 1997/08/06 21:43:19 peterg % %% Corrected error in creating component list: the kth component of the % %% list is given by the jth component of the original list NOT vice |
︙ | |||
106 107 108 109 110 111 112 113 114 115 116 117 118 119 | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | + | other_end = which_end.*other_end_1 + (one-which_end).*other_end_2; arrow_vector = ( which_end.*other_end_2 + (one-which_end).*other_end_1 ) - ... arrow_end; % Locate the bond end nearest to each port % col 1 of port_near_bond contains a signed bond number (+ for arrow end) % col 2 of port_near_bond contains the corresponding port index port_bond = []; for i = 1:n_ports near_bond = adjbond(port_coord(i,1:2),arrow_end,other_end); [rows,cols]=size(near_bond); if rows>1 error(sprintf ... ("A port is near to more than one bond at coordinates %g,%g\n", ... port_coord(i,1)/scale, port_coord(i,2)/scale)); |
︙ | |||
129 130 131 132 133 134 135 | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | - - + + - - + + - - + - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - + - - + - - - - - - + - - - - - - + - - - - - - + - - - - + - - - - - - - - - - - - - - - + - - - - - + - - - - + - - - - - - - + | % Locate the components at the ends of each bond % col 1 of comp_near_bond contain the component nearest to the arrow end % col 2 of comp_near_bond contain the component nearest to the other end for i = 1:n_bonds comp_near_bond(i,:) = adjcomp(arrow_end(i,:),other_end(i,:),rcomponents); end; |
︙ | |||
314 315 316 317 318 319 320 321 322 323 324 325 | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | flow_side = stroke_direction*arrow_vector(j,:)'>0; causality(j,1+flow_side) = 2*which_end-1; end; end; end; bonds = causality; % Now expand vector ports [n_bonds,junk] = size(bonds); n_exp_ports=n_ports; exp_port_name=""; %exp_comps = []; for i=1:n_ports subport = split(port_name(i,:), ','); [n_subports,junk] = size(subport); exp_port_name = [exp_port_name; subport(1,:)]; if n_subports>1 mtt_info(port_name(i,:),infofile); % Check that there is a corresponding vector port at the other end of the % bond signed_bond_index = port_bond(i); [other_index,n_other] = getindex(port_bond,-signed_bond_index); if n_other == 1 other_port_name = port_name(other_index,:); mtt_info(other_port_name,infofile); else mtt_info(['Vector port ', port_name(i,:), ' has no matching port'], infofile); end; % Remove sign info. bond_index = abs(signed_bond_index); sig = sign(signed_bond_index); for j=2:n_subports mtt_info(subport(j,:),infofile); % Add a new name to give a non-vector list exp_port_name = [exp_port_name; subport(j,:)]; n_exp_ports = n_exp_ports+1; % Add one more bond to the list bonds = [bonds; bonds(bond_index,:)]; n_bonds = n_bonds + 1; % Add bond to the port_bond list port_bond = [port_bond; n_bonds]; % Add a new bond to the component at this end (taking note of the direction). comp_index = comp_near_bond(bond_index,1); components = add_bond(components, sig*n_bonds, comp_index); end; end; end; %Replace old list by new port_name = exp_port_name %Resize the lists [n_ports,junk] = size(port_name); port_name, components % Produce a list of bonds on each component (within this component) % - sorted if explicit port numbers for i = 1:n_components disp('-----------------'); %Get component type eval(['[comp_type, comp_name] = ', name, '_cmp(i)']); %Convert junction names if comp_type=='0' comp_type = 'zero'; end if comp_type=='1' comp_type = 'one'; end %Find the port list for this component if exist([comp_type, '_cause'])==0 eval(['[junk1,junk2,junk3,junk4,junk5,port_list]=', comp_type, '_rbg;']); else port_list=comp_ports(comp_type); end; % Find the (unsorted) bond list on this component signed_bond_list = nozeros(components(i,:)); n_comp_bonds = length(signed_bond_list); direction = sign(signed_bond_list); % Check that number of bonds on the component is the same as the number of % ports [n_comp_ports,m_comp_ports] = size(port_list); if (n_comp_ports~=n_comp_bonds) & ... ~(strcmp(comp_type,'zero')|strcmp(comp_type,'one')) message=sprintf('Component %s (%s) has %1.0f impinging bonds but has %1.0f ports', ... comp_name,comp_type,n_comp_bonds,n_comp_ports); mtt_info(message, infofile); end; unsorted_port_list=""; if n_ports>0 % then there are some named ports % so find those associated with the bonds on this component. k=0; for j = 1:n_comp_bonds b = signed_bond_list(j); % Find the port label on component end of bond (if any) [port_index,m] = getindex(port_bond,b); if m==1 k=k+1; unsorted_port_list(k,:) = port_name(port_index,:); end; end; else % just use that provided by the component % unsorted_port_list = port_list; % k = n_comp_bonds; k=0; end; %Either all ports or no ports should be labelled - write error %message if this is not so if (k~=0)&(k~=n_comp_bonds) mtt_info(['Component ', comp_name, ' (', comp_type, ') has wrong number of labels'], infofile); mtt_info(sprintf("\tit has %1.0f labels but should have 0 or %1.0f",k,n_comp_bonds), infofile); end; %Compute the number of labeled ports [n_unsorted_ports,m_unsorted_ports] = size(unsorted_port_list); if m_unsorted_ports==0 n_unsorted_ports = 0; end; n_unsorted_ports,n_comp_bonds % One port defaults: if (n_comp_bonds==1)&(n_unsorted_ports==0) if (direction(1)<0) & ~strcmp(comp_type,'SS') % Wrong way for default mtt_info(['One-port ', comp_name, ' (', comp_type, ') has the sign pointing the wrong way '], infofile); end; unsorted_port_list = port_list; end; %Two port defaults if (n_comp_bonds==2)&(n_unsorted_ports==0) if direction(1)==direction(2) % Wrong way for default mtt_info(['Two-port ', comp_name, ' (', comp_type, ') does not have though-pointing arrows'], infofile); end; if direction(1)==1 %in mtt_info([comp_name, ' in'],infofile); unsorted_port_list = ['in';'out']; else %reverse the order mtt_info([comp_name, ' out'],infofile); unsorted_port_list = ['out';'in']; end; end; % Recompute the number of unsorted ports [n_unsorted_ports,m_unsorted_ports] = size(unsorted_port_list); if m_unsorted_ports<2 n_unsorted_ports = 0; end; % Junctions or no lables(order of ports unimportant) if strcmp(comp_type,'zero')|strcmp(comp_type,'one') for j = 1:n_comp_bonds components(i,j) = signed_bond_list(j); end else %Order of ports is important unsorted_port_list, port_list if n_unsorted_ports==0 mtt_info(['Component ', comp_name, ' (', comp_type, ') has no labeled ports'], infofile); end; %Write out the signed bond list in the correct order for j = 1:n_comp_bonds name_k = unsorted_port_list(j,:); k = name_in_list(name_k, port_list); % Check that it only appears once in port list if length(k)>1 mtt_info(['Component ', comp_name, ' (', comp_type, ') has ports with the same name: ', name_k], infofile); end; %Check that it only appears one in the label list kk = name_in_list(name_k,unsorted_port_list); if length(kk)>1 mtt_info(['Component ', comp_name, ' (', comp_type, ') has multiple port labels: ', name_k], infofile); end; if k==0 mtt_info(['Component ', comp_name, ' (', comp_type, ') has an unrecognised port: ', name_k], infofile); else components(i,k) = signed_bond_list(j); end; end; end; end; fclose(fnum); |