Basilisk source code (http://basilisk.fr/src/)

root / src / utils.i

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
%{
  struct _interpolate {
    scalar v;
    double x, y, z;
  };
  extern double interpolate (struct _interpolate p);
%}

%inline %{
  typedef struct {
    double avg, rms, max, area;
  } norm;
  extern norm normf (scalar f);

  typedef struct {
    double min, max, sum, stddev, area;
  } stats;
  extern stats statsf (scalar f);

  extern void vorticity (const vector u, scalar omega);
%}

%apply (double * IN_ARRAY1, int DIM1) {(double * x, int len1)};
%apply (double * ARGOUT_ARRAY1, int DIM1) {(double * val, int len)};
%inline %{
  void _interpolate1D (scalar v, double * x, int len1, double * val, int len) {
    int i;
    for (i = 0; i < len; i++) {
      struct _interpolate p = {v, 0.9999999999*x[i]};
      val[i] = interpolate (p);
    }
  }
%}

%apply (double * IN_ARRAY2, int DIM1, int DIM2) {
  (double * x, int len3, int len4),
  (double * y, int len5, int len6)
}
%apply (double * INPLACE_ARRAY2, int DIM1, int DIM2) {
  (double * val, int len1, int len2)
}
%inline %{
  void _interpolate2D (scalar v, 
                       double * x, int len3, int len4,
                       double * y, int len5, int len6,
                       double * val, int len1, int len2) {
    int i;
    for (i = 0; i < len1*len2; i++) {
      struct _interpolate p = {v, 0.9999999999*x[i], 0.9999999999*y[i]};
      val[i] = interpolate (p);
    }
  }
%}