source: soft/giet_vm/applications/ocean/laplacalc.c @ 799

Last change on this file since 799 was 799, checked in by alain, 8 years ago

Introducing a port of ocean application without macros.

File size: 3.8 KB
Line 
1/*************************************************************************/
2/*                                                                       */
3/*  Copyright (c) 1994 Stanford University                               */
4/*                                                                       */
5/*  All rights reserved.                                                 */
6/*                                                                       */
7/*  Permission is given to use, copy, and modify this software for any   */
8/*  non-commercial purpose as long as this copyright notice is not       */
9/*  removed.  All other uses, including redistribution in whole or in    */
10/*  part, are forbidden without prior written permission.                */
11/*                                                                       */
12/*  This software is provided with absolutely no warranty and no         */
13/*  support.                                                             */
14/*                                                                       */
15/*************************************************************************/
16
17/* Performs the laplacian calculation for a subblock */
18
19#include "decs.h"
20
21///////////////////////////
22void laplacalc( long procid, 
23                double ****x, 
24                double ****z, 
25                long psiindex, 
26                long firstrow, 
27                long lastrow, 
28                long firstcol, 
29                long lastcol )
30{
31    long iindex;
32    long indexp1;
33    long indexm1;
34    long ip1;
35    long im1;
36    long i;
37    long j;
38    double **t2a;
39    double **t2b;
40    double *t1a;
41    double *t1b;
42    double *t1c;
43    double *t1d;
44
45    t2a = (double **) x[procid][psiindex];
46    j = gps[procid]->neighbors[UP];
47    if (j != -1) 
48    {
49        t1a = (double *) t2a[0];
50        t1b = (double *) x[j][psiindex][im - 2];
51        for (i = 1; i <= lastcol; i++) 
52        {
53            t1a[i] = t1b[i];
54        }
55    }
56    j = gps[procid]->neighbors[DOWN];
57    if (j != -1) 
58    {
59        t1a = (double *) t2a[im - 1];
60        t1b = (double *) x[j][psiindex][1];
61        for (i = 1; i <= lastcol; i++) 
62        {
63            t1a[i] = t1b[i];
64        }
65    }
66    j = gps[procid]->neighbors[LEFT];
67    if (j != -1) {
68        t2b = (double **) x[j][psiindex];
69        for (i = 1; i <= lastrow; i++) 
70        {
71            t2a[i][0] = t2b[i][jm - 2];
72        }
73    }
74    j = gps[procid]->neighbors[RIGHT];
75    if (j != -1) {
76        t2b = (double **) x[j][psiindex];
77        for (i = 1; i <= lastrow; i++) {
78            t2a[i][jm - 1] = t2b[i][1];
79        }
80    }
81
82    t2a = (double **) x[procid][psiindex];
83    t2b = (double **) z[procid][psiindex];
84    for (i = firstrow; i <= lastrow; i++) 
85    {
86        ip1 = i + 1;
87        im1 = i - 1;
88        t1a = (double *) t2a[i];
89        t1b = (double *) t2b[i];
90        t1c = (double *) t2a[ip1];
91        t1d = (double *) t2a[im1];
92        for (iindex = firstcol; iindex <= lastcol; iindex++) 
93        {
94            indexp1 = iindex + 1;
95            indexm1 = iindex - 1;
96            t1b[iindex] = factlap * (t1c[iindex] + 
97                          t1d[iindex] + t1a[indexp1] + t1a[indexm1] - 4. * t1a[iindex]);
98        }
99    }
100
101    if (gps[procid]->neighbors[UP] == -1) 
102    {
103        t1b = (double *) t2b[0];
104        for (j = firstcol; j <= lastcol; j++) 
105        {
106            t1b[j] = 0.0;
107        }
108    }
109    if (gps[procid]->neighbors[DOWN] == -1) 
110    {
111        t1b = (double *) t2b[im - 1];
112        for (j = firstcol; j <= lastcol; j++) 
113        {
114            t1b[j] = 0.0;
115        }
116    }
117    if (gps[procid]->neighbors[LEFT] == -1) 
118    {
119        for (j = firstrow; j <= lastrow; j++) 
120        {
121            t2b[j][0] = 0.0;
122        }
123    }
124    if (gps[procid]->neighbors[RIGHT] == -1) 
125    {
126        for (j = firstrow; j <= lastrow; j++) 
127        {
128            t2b[j][jm - 1] = 0.0;
129        }
130    }
131
132}
Note: See TracBrowser for help on using the repository browser.