aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib/src/region.hh
blob: dcf618133deb837aa56504c19167664928c92abc (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#ifndef REGION_HH
#define REGION_HH

#include <iostream>

#include "defs.hh"
#include "bbox.hh"
#include "vect.hh"



// Region description
struct region_t {
  ibbox  extent;                            // extent
  b2vect outer_boundaries;                  // outer boundaries
  int    map;                               // map to which this
                                            // region belongs
  int    processor;                         // processor number
};



bool operator== (region_t const & a, region_t const & b);
inline
bool operator!= (region_t const & a, region_t const & b)
{
  return not (a == b);
}



inline size_t memoryof (region_t const & reg)
{
  return
    memoryof (reg.extent) +
    memoryof (reg.outer_boundaries) +
    memoryof (reg.map) +
    memoryof (reg.processor);
}

istream & operator>> (istream & is, region_t       & reg);
ostream & operator<< (ostream & os, region_t const & reg);



// A pseudoregion is almost a region; it is a bbox that lives on a
// certain processor.  Pseudoregions are a compact way to store
// information about what processors needs to send data to what other
// processor during synchronisation or regridding.
struct pseudoregion_t {
  ibbox extent;
  int processor;
  pseudoregion_t ()
  {
  }
  pseudoregion_t (ibbox const & extent_, int const processor_)
    : extent (extent_), processor (processor_)
  {
  }
};

inline size_t memoryof (pseudoregion_t const & p)
{
  return
    memoryof (p.extent) +
    memoryof (p.processor);
}

ostream & operator<< (ostream & os, pseudoregion_t const & p);

struct sendrecv_pseudoregion_t {
  pseudoregion_t send, recv;
  sendrecv_pseudoregion_t ()
  {
  }
  sendrecv_pseudoregion_t (ibbox const & send_extent, int const send_processor,
                           ibbox const & recv_extent, int const recv_processor)
    : send (pseudoregion_t (send_extent, send_processor)),
      recv (pseudoregion_t (recv_extent, recv_processor))
  {
  }
};

inline size_t memoryof (sendrecv_pseudoregion_t const & srp)
{
  return memoryof (srp.send) + memoryof (srp.recv);
}

ostream & operator<< (ostream & os, sendrecv_pseudoregion_t const & srp);



#endif // #ifndef REGION_HH