aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetRegrid2/src/indexing.hh
blob: ac07fd5ba575fbff5ac33b2018e3c1877fdad996 (plain)
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
#ifndef INDEXING_HH
#define INDEXING_HH

#include <cassert>

#include <cctk.h>



namespace CarpetRegrid2 {
  
  // Get indexing information for a vector grid array
  void
  getvectorindex2 (cGH const * cctkGH,
                   char const * groupname,
                   int * lsh);
  
  
  
  static inline
  int
  index2 (int const * const lsh,
          int const i,
          int const j)
  {
    assert (lsh);
    assert (lsh[0] >= 0);
    assert (lsh[1] >= 0);
    assert (i >= 0 and i < lsh[0]);
    assert (j >= 0 and j < lsh[1]);
    return i + lsh[0] * j;
  }
  
} // namespace CarpetRegrid2

#endif // #ifndef INDEXING_HH