Hi,
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[3000], cell_2[102]
Kindly let me know.
Thank you.
Assign gids to two different cell types
Moderator: hines

 Posts: 70
 Joined: Wed Jan 18, 2012 12:25 am
 Location: University of Pavia

 Site Admin
 Posts: 5795
 Joined: Wed May 18, 2005 4:50 pm
 Location: Yale University School of Medicine
 Contact:
Re: Assign gids to two different cell types
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..M1, where the number of cells in any class m is n_m. Then the total number of cells is SUM over m=0..M1 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..m1 of n_j) to (1 + SUM over j=0..m of n_j)
Define the series of partial sums for j=0..M1 to be
sum_0 = n_0  1
sum_1 = sum_0 + n_1
sum_j = sum_j1 + 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.
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..M1, where the number of cells in any class m is n_m. Then the total number of cells is SUM over m=0..M1 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..m1 of n_j) to (1 + SUM over j=0..m of n_j)
Define the series of partial sums for j=0..M1 to be
sum_0 = n_0  1
sum_1 = sum_0 + n_1
sum_j = sum_j1 + 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.