aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib/src/region.hh
blob: 66037bdc78831f17e14349565f1fc0ffdf99a26b (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#ifndef REGION_HH
#define REGION_HH

#include <iostream>
#include <vector>

#include "defs.hh"
#include "bbox.hh"
#include "fulltree.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
  ipfulltree * processors;       // processor decomposition
  
  region_t ();
  region_t (region_t const & a);
  region_t & operator= (region_t const & a);
  ~region_t ();
  
  bool invariant () const;
};



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);
}



void
combine_regions (vector<region_t> const & oldregs,
                 vector<region_t> & newregs);



size_t memoryof (region_t const & reg);

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 belongs to a
// certain component.  Pseudoregions are a compact way to store
// information about what components needs to send data to what other
// components during synchronisation or regridding.
struct pseudoregion_t {
  ibbox extent;
  int component;
  pseudoregion_t ()
  {
  }
  pseudoregion_t (ibbox const & extent_, int const component_)
    : extent (extent_), component (component_)
  {
  }
};

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

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

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_component,
                           ibbox const & recv_extent,  int const recv_component)
    : send (pseudoregion_t (send_extent, send_component)),
      recv (pseudoregion_t (recv_extent, recv_component))
  {
  }
};

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