aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetRegrid2/src/boundary.hh
blob: 00e2ede2167470826c5e6fdc37c5325ac6e37cba (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#ifndef BOUNDARY_HH
#define BOUNDARY_HH

#include <defs.hh>
#include <gh.hh>
#include <vect.hh>

#include <ostream>



namespace CarpetRegrid2 {
  
  
  
  // Convert a coordinate location to an index location.  For cell
  // centring, shift upwards.
  ivect
  rpos2ipos (rvect const & rpos,
             rvect const & origin, rvect const & scale,
             gh const & hh, int const rl);
  
  // Convert a coordinate location to an index location, rounding in
  // the opposite manner as rpos2ipos.  For cell centring, shift
  // downwards instead of upwards.
  ivect
  rpos2ipos1 (rvect const & rpos,
              rvect const & origin, rvect const & scale,
              gh const & hh, int const rl);
  
  // Convert an index location to a coordinate location
  rvect
  ipos2rpos (ivect const & ipos,
             rvect const & origin, rvect const & scale,
             gh const & hh, int const rl);
  
  // Convert an index bbox to a coordinate bbox
  rbbox
  ibbox2rbbox (ibbox const & ib,
               rvect const & origin, rvect const & scale,
               gh const & hh, int const rl);
  
  
  
  // Snap (enlarge) a bbox to the next coarser level, if desired
  ibbox
  snap_ibbox (ibbox const & ib,
              gh const & hh, int const rl);
  
  
  
  void
  get_boundary_specification (jjvect & nboundaryzones,
                              jjvect & is_internal,
                              jjvect & is_staggered,
                              jjvect & shiftout);
  
  void
  get_physical_boundary (rvect & physical_lower,
                         rvect & physical_upper,
                         rvect & spacing);
  
  void
  calculate_exterior_boundary (rvect const & physical_lower,
                               rvect const & physical_upper,
                               rvect       & exterior_lower,
                               rvect       & exterior_upper,
                               rvect const & spacing);
  
  
  
  // Location and description of the outer boundary
  struct domain_boundary {
    jjvect nboundaryzones, is_internal;
    jjvect is_staggered, shiftout;
    
    b2vect boundary_staggering_mismatch;
    
    rvect physical_lower, physical_upper;
    rvect spacing;
    
    rvect exterior_lower, exterior_upper;
    
    // The physical boundary
    rvect origin;
    rvect scale;
    
    // The location of the outermost grid points. For cell centring,
    // these are 1/2 grid spacing inside of the boundary.
    ivect physical_ilower, physical_iupper;
    
    domain_boundary (gh const& hh, dh const& dd);
  };
  
  struct level_boundary: public domain_boundary {
    rvect level_physical_lower;
    rvect level_physical_upper;
    rvect level_spacing;
    
    rvect level_exterior_lower, level_exterior_upper;
    
    // The location of the outermost grid points. For cell centring,
    // these are 1/2 grid spacing inside of the boundary.
    ivect level_physical_ilower;
    ivect level_physical_iupper;
    
    ivect level_exterior_ilower;
    ivect level_exterior_iupper;
    
    // The minimum necessary distance away from the outer boundary due
    // to buffer and ghost zones. This is e.g. the distance that the
    // lower boundary of a bbox has to have from the lower boundary.
    // This is in terms of grid points.
    i2vect min_bnd_dist_away;
    // The minimum necessary distance from the outer boundary due to
    // buffer and ghost zones. This is e.g. the distance that the
    // upper boundary of a bbox has to have from the lower boundary.
    // This is in terms of grid points.
    i2vect min_bnd_dist_incl;
    
    level_boundary (gh const& hh, dh const& dd, int rl);
  };
  
} // namespace CarpetRegrid2



ostream& operator<<(ostream& os, CarpetRegrid2::domain_boundary const& bnd);
ostream& operator<<(ostream& os, CarpetRegrid2::level_boundary const& bnd);



#endif  // #ifndef BOUNDARY_HH