~chaffra/+junk/trilinos

« back to all changes in this revision

Viewing changes to packages/zoltan/src/util/converters_for_JPDC_adaptive_mesh_experiments/exo2chaco/chaco/coarsen/makeccoords.c

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme, Christophe Prud'homme, Johannes Ring
  • Date: 2009-12-13 12:53:22 UTC
  • mfrom: (5.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20091213125322-in0nrdjc55deqsw9
Tags: 10.0.3.dfsg-1
[Christophe Prud'homme]
* New upstream release

[Johannes Ring]
* debian/patches/libname.patch: Add prefix 'libtrilinos_' to all
  libraries. 
* debian/patches/soname.patch: Add soversion to libraries.
* debian/watch: Update download URL.
* debian/control:
  - Remove python-numeric from Build-Depends (virtual package).
  - Remove automake and autotools from Build-Depends and add cmake to
    reflect switch to CMake.
  - Add python-support to Build-Depends.
* debian/rules: 
  - Cleanup and updates for switch to CMake.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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. */
 
4
 
 
5
#include <stdio.h>
 
6
#include "defs.h"
 
7
#include "structs.h"
 
8
#include "smalloc.h"
 
9
 
 
10
/* Make coarse graph vertex coordinates be center-of-mass of their */
 
11
/* fine graph constituents. */
 
12
 
 
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 */
 
22
{
 
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 */
 
28
 
 
29
    for (i = 0; i < igeom; i++) {
 
30
        ccoords[i] = cptr = smalloc((cnvtxs + 1) * sizeof(float));
 
31
        for (cvtx = cnvtxs; cvtx; cvtx--) {
 
32
            *(++cptr) = 0;
 
33
        }
 
34
    }
 
35
    if (igeom == 1) {
 
36
        for (cvtx = 1; cvtx <= cnvtxs; cvtx++) {
 
37
            mass = 0;
 
38
            for (j = cv2v_ptrs[cvtx]; j < cv2v_ptrs[cvtx + 1]; j++) {
 
39
                vtx = cv2v_vals[j];
 
40
                mass += graph[vtx]->vwgt;
 
41
                ccoords[0][cvtx] += graph[vtx]->vwgt * coords[0][vtx];
 
42
            }
 
43
            ccoords[0][cvtx] /= mass;
 
44
        }
 
45
    }
 
46
    else if (igeom == 2) {
 
47
        for (cvtx = 1; cvtx <= cnvtxs; cvtx++) {
 
48
            mass = 0;
 
49
            for (j = cv2v_ptrs[cvtx]; j < cv2v_ptrs[cvtx + 1]; j++) {
 
50
                vtx = cv2v_vals[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];
 
54
            }
 
55
            ccoords[0][cvtx] /= mass;
 
56
            ccoords[1][cvtx] /= mass;
 
57
        }
 
58
    }
 
59
    else if (igeom > 2) {
 
60
        for (cvtx = 1; cvtx <= cnvtxs; cvtx++) {
 
61
            mass = 0;
 
62
            for (j = cv2v_ptrs[cvtx]; j < cv2v_ptrs[cvtx + 1]; j++) {
 
63
                vtx = cv2v_vals[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];
 
68
            }
 
69
            ccoords[0][cvtx] /= mass;
 
70
            ccoords[1][cvtx] /= mass;
 
71
            ccoords[2][cvtx] /= mass;
 
72
        }
 
73
    }
 
74
}