1
/* This software was developed by Bruce Hendrickson and Robert Leland *
2
* at Sandia National Laboratories under US Department of Energy *
3
* contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
10
/* Make coarse graph vertex coordinates be center-of-mass of their */
11
/* fine graph constituents. */
13
void makeccoords(graph, cnvtxs, cv2v_ptrs, cv2v_vals,
14
igeom, coords, ccoords)
15
struct vtx_data **graph; /* array of vtx data for graph */
16
int cnvtxs; /* number of vertices in coarse graph */
17
int igeom; /* dimensions of geometric data */
18
int *cv2v_ptrs; /* vtxs corresponding to each cvtx */
19
int *cv2v_vals; /* indices into cv2v_vals */
20
float **coords; /* coordinates for vertices */
21
float **ccoords; /* coordinates for coarsened vertices */
23
double mass; /* total mass of merged vertices */
24
float *cptr; /* loops through ccoords */
25
int cvtx; /* coarse graph vertex */
26
int vtx; /* vertex being merged */
27
int i, j; /* loop counters */
29
for (i = 0; i < igeom; i++) {
30
ccoords[i] = cptr = smalloc((cnvtxs + 1) * sizeof(float));
31
for (cvtx = cnvtxs; cvtx; cvtx--) {
36
for (cvtx = 1; cvtx <= cnvtxs; cvtx++) {
38
for (j = cv2v_ptrs[cvtx]; j < cv2v_ptrs[cvtx + 1]; j++) {
40
mass += graph[vtx]->vwgt;
41
ccoords[0][cvtx] += graph[vtx]->vwgt * coords[0][vtx];
43
ccoords[0][cvtx] /= mass;
46
else if (igeom == 2) {
47
for (cvtx = 1; cvtx <= cnvtxs; cvtx++) {
49
for (j = cv2v_ptrs[cvtx]; j < cv2v_ptrs[cvtx + 1]; j++) {
51
mass += graph[vtx]->vwgt;
52
ccoords[0][cvtx] += graph[vtx]->vwgt * coords[0][vtx];
53
ccoords[1][cvtx] += graph[vtx]->vwgt * coords[1][vtx];
55
ccoords[0][cvtx] /= mass;
56
ccoords[1][cvtx] /= mass;
60
for (cvtx = 1; cvtx <= cnvtxs; cvtx++) {
62
for (j = cv2v_ptrs[cvtx]; j < cv2v_ptrs[cvtx + 1]; j++) {
64
mass += graph[vtx]->vwgt;
65
ccoords[0][cvtx] += graph[vtx]->vwgt * coords[0][vtx];
66
ccoords[1][cvtx] += graph[vtx]->vwgt * coords[1][vtx];
67
ccoords[2][cvtx] += graph[vtx]->vwgt * coords[2][vtx];
69
ccoords[0][cvtx] /= mass;
70
ccoords[1][cvtx] /= mass;
71
ccoords[2][cvtx] /= mass;