| 1 |
/* |
| 2 |
* Copyright(C) 1999-2020 National Technology & Engineering Solutions |
| 3 |
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 4 |
* NTESS, the U.S. Government retains certain rights in this software. |
| 5 |
* |
| 6 |
* See packages/seacas/LICENSE for details |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "smalloc.h" // for smalloc |
| 10 |
#include "structs.h" // for bilist, vtx_data |
| 11 |
#include <stdio.h> // for NULL |
| 12 |
|
| 13 |
void make_bndy_list(struct vtx_data **graph, /* data structure for graph */ |
| 14 |
struct bilist *movelist, /* list of vtxs to be moved */ |
| 15 |
struct bilist ****buckets, /* array of lists for bucket sort */ |
| 16 |
struct bilist **listspace, /* list data structure for each vertex */ |
| 17 |
int *sets, /* processor each vertex is assigned to */ |
| 18 |
int nsets, /* number of sets divided into */ |
| 19 |
int *bspace, /* list of active vertices for bucketsort */ |
| 20 |
int **tops, /* top of each set of buckets */ |
| 21 |
int **bndy_list /* list of boundary vertices returned */ |
| 22 |
) |
| 23 |
{ |
| 24 |
struct bilist *bptr; /* loops through bspace */ |
| 25 |
int vtx; /* vertex that was moved */ |
| 26 |
int set; /* set a vertex is in */ |
| 27 |
int list_length; /* number of active vertices */ |
| 28 |
int bndy_length; /* number of vertices actually on boundary */ |
| 29 |
int size; /* array spacing */ |
| 30 |
int i, j, k; /* loop counters */ |
| 31 |
|
| 32 |
/* First push all the moved vertices onto list, so they can be flagged. */ |
| 33 |
/* They've already been removed from buckets, so want to avoid them. */ |
| 34 |
size = (int)(&(listspace[0][1]) - &(listspace[0][0])); |
| 35 |
bptr = movelist; |
| 36 |
list_length = 0; |
| 37 |
while (bptr != NULL) { |
| 38 |
vtx = ((int)(bptr - listspace[0])) / size; |
| 39 |
bspace[list_length++] = vtx; |
| 40 |
bptr = bptr->next; |
| 41 |
} |
| 42 |
|
| 43 |
/* Now get all the vertices still in the bucket lists. */ |
| 44 |
for (k = tops[0][1]; k >= 0; k--) { |
| 45 |
bptr = buckets[0][1][k]; |
| 46 |
while (bptr != NULL) { |
| 47 |
vtx = ((int)(bptr - listspace[0])) / size; |
| 48 |
bspace[list_length++] = vtx; |
| 49 |
bptr = bptr->next; |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
for (i = 1; i < nsets; i++) { |
| 54 |
for (k = tops[i][0]; k >= 0; k--) { |
| 55 |
bptr = buckets[i][0][k]; |
| 56 |
while (bptr != NULL) { |
| 57 |
vtx = ((int)(bptr - listspace[0])) / size; |
| 58 |
bspace[list_length++] = vtx; |
| 59 |
bptr = bptr->next; |
| 60 |
} |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
/* Now that list is constructed, go reconstruct all the set numbers. */ |
| 65 |
bndy_length = 0; |
| 66 |
for (i = 0; i < list_length; i++) { |
| 67 |
vtx = bspace[i]; |
| 68 |
set = sets[vtx]; |
| 69 |
for (j = 1; j < graph[vtx]->nedges; j++) { |
| 70 |
if (sets[graph[vtx]->edges[j]] != set) { |
| 71 |
bspace[bndy_length++] = vtx; |
| 72 |
break; |
| 73 |
} |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
/* Finally, copy boundary vertices into boundary list. */ |
| 78 |
*bndy_list = smalloc((bndy_length + 1) * sizeof(int)); |
| 79 |
for (i = 0; i < bndy_length; i++) { |
| 80 |
(*bndy_list)[i] = bspace[i]; |
| 81 |
} |
| 82 |
(*bndy_list)[bndy_length] = 0; |
| 83 |
} |