source: trunk/anuga_work/anuga_cuda/src/anuga_HMPP/update.c @ 9329

Last change on this file since 9329 was 9017, checked in by steve, 12 years ago

Adding in Zhe (John) Weng's anuga_cuda code as obtained from googlecode https://code.google.com/p/anuga-cuda

File size: 1.4 KB
Line 
1// from quantity_ext.c
2#include "hmpp_fun.h"
3
4
5
6#ifdef USING_LOCAL_DIRECTIVES
7#pragma hmpp update codelet, target=CUDA args[*].transfer=atcall
8#endif
9void update(
10        int N,
11        double timestep,
12        double centroid_values[N],
13        double explicit_update[N],
14        double semi_implicit_update[N])
15{
16    int k;
17    double denominator, x;
18
19
20    // Divide semi_implicit update by conserved quantity
21    #pragma hmppcg gridify(k), &
22    #pragma hmppcg & private(denominator, x), &
23    #pragma hmppcg & global(timestep, centroid_values, explicit_update, &
24    #pragma hmppcg & semi_implicit_update)
25    for (k=0; k<N; k++) {
26        x = centroid_values[k];
27        if (x == 0.0) {
28            semi_implicit_update[k] = 0.0;
29        } else {
30            semi_implicit_update[k] /= x;
31        }
32    //}
33
34
35    // Explicit updates
36    //for (k=0; k<N; k++) {
37        centroid_values[k] += timestep*explicit_update[k];
38    //}
39
40
41
42    // Semi implicit updates
43    //for (k=0; k<N; k++) {
44        denominator = 1.0 - timestep*semi_implicit_update[k];
45        if (denominator <= 0.0) {
46        // FIXME: can't pass, since inter-iterations dependency
47//            return;
48        } else {
49            //Update conserved_quantities from semi implicit updates
50            centroid_values[k] /= denominator;
51        }
52    }
53
54    // Reset semi_implicit_update here ready for next time step
55    //memset(semi_implicit_update, 0, N*sizeof(double));
56}
57
58
Note: See TracBrowser for help on using the repository browser.