Page 1 of 1
Assign gids to two different cell types
Posted: Thu Sep 05, 2013 9:14 am
How to assign gids to two different cell types? Because, when I use for (i=pc.id; i<$1;i+=pc.nhost), it cannot set same gid for two different cells.
Are there any examples available on this type of problem? In my case, two cell types exist: cell_1, cell_2
Kindly let me know.
Re: Assign gids to two different cell types
Posted: Thu Sep 05, 2013 11:13 am
Here's a simple strategy that should work if a single for loop is used to spawn all cells:
Decide in advance how many cells of each class are needed. Inside the for loop that spawns all cells, test the loop index i to determine which class should be created. Elaborating slightly, suppose there are M cell classes whose indices are m = 0..M-1, where the number of cells in any class m is n_m. Then the total number of cells is SUM over m=0..M-1 of n_m, and
class 0 cells have gids that range from 0 to n_0 - 1
class 1 cells have gids that range from n_0 to n_0 + n_1 - 1
class m cells, where 0<m<M, have gids that range from (SUM over j=0..m-1 of n_j) to (-1 + SUM over j=0..m of n_j)
Define the series of partial sums for j=0..M-1 to be
sum_0 = n_0 - 1
sum_1 = sum_0 + n_1
sum_j = sum_j-1 + n_j
sum_j is the maximum gid that will be assigned to a cell of class j.
So on each pass through the for loop, compare i against the partial sums to determine which class should be spawned. If the partial sums are contained in a Vector, the Vector class's indwhere will be useful for this.