Proto  3.2
Proto_MBBoundaryData.H
Go to the documentation of this file.
1 #pragma once
2 #ifndef _PROTO_MB_BOUNDARY_DATA_
3 #define _PROTO_MB_BOUNDARY_DATA__
4 
5 #include "Proto.H"
7 
8 namespace Proto
9 {
10  template<typename T, unsigned int C, MemType MEM>
12  {
14 
16  MBDisjointBoxLayout a_layout,
17  MBIndex a_localIndex,
18  MBIndex a_adjIndex,
19  Box a_localBox,
20  Box a_adjBox,
21  CoordPermutation a_adjToLocal,
22  Point a_ghost = Point::Zeros());
23 
24  inline void define(
25  MBDisjointBoxLayout a_layout,
26  MBIndex a_localIndex,
27  MBIndex a_adjIndex,
28  Box a_localBox,
29  Box a_adjBox,
30  CoordPermutation a_adjToLocal,
31  Point a_ghost = Point::Zeros());
32  inline Face localFace() const;
33  inline Face adjFace() const;
34  inline void fill(const BoxData<T, C, MEM>& a_data);
35 
36  inline Box localBox() const {return localData->box().grow(-localGhost);}
37  inline Box adjBox() const {return adjData->box().grow(-adjGhost);}
38 
39  inline void print();
40 
49  std::shared_ptr<BoxData<T, C, MEM>> localData;
50  std::shared_ptr<BoxData<T, C, MEM>> adjData;
51  };
52 
53  template<typename T, unsigned int C, MemType MEM>
55 
56  template<typename T, unsigned int C, MemType MEM>
58  MBDisjointBoxLayout a_layout,
59  MBIndex a_localIndex,
60  MBIndex a_adjIndex,
61  Box a_localBox,
62  Box a_adjBox,
63  CoordPermutation a_adjToLocal,
64  Point a_ghost)
65  {
66  define(a_layout, a_localIndex, a_adjIndex, a_localBox, a_adjBox, a_adjToLocal, a_ghost);
67  }
68 
69  template<typename T, unsigned int C, MemType MEM>
71  MBDisjointBoxLayout a_layout,
72  MBIndex a_localIndex,
73  MBIndex a_adjIndex,
74  Box a_localBox,
75  Box a_adjBox,
76  CoordPermutation a_adjToLocal,
77  Point a_ghost)
78  {
79  layout = a_layout;
80  localGhost = a_ghost;
81  localIndex = a_localIndex;
82  adjIndex = a_adjIndex;
83  Box localBox = a_localBox.grow(a_ghost);
84  localData = std::make_shared<BoxData<T, C, MEM>>(localBox, 7);
85  adjGhost = a_adjToLocal.inverse()(a_ghost).abs();
86  Box adjBox = a_adjBox.grow(adjGhost);
87  adjData = std::make_shared<BoxData<T, C, MEM>>(adjBox, 7);
88  adjToLocal = a_adjToLocal;
91  }
92 
93  template<typename T, unsigned int C, MemType MEM>
95  const BoxData<T, C, MEM>& a_data)
96  {
97  a_data.copyTo(*adjData);
98  adjData->copyTo(*localData, adjToLocal);
99  }
100 
101  template<typename T, unsigned int C, MemType MEM>
103  {
104  PROTO_ASSERT(localDir.codim() == 1,
105  "MBBoundaryData::localFace | Error: This boundary is not a codimension 1 face");
106  for (int ii = 0; ii < DIM; ii++)
107  {
108  if (localDir[ii] != 0)
109  {
110  return Face(ii, localDir[ii] < 0 ? Side::Lo : Side::Hi);
111  }
112  }
113  return Face(0,Side::Lo); // dummy return to suppress a compilation warning
114  }
115 
116  template<typename T, unsigned int C, MemType MEM>
118  {
119  PROTO_ASSERT(adjDir.codim() == 1,
120  "MBBoundaryData::localFace | Error: This boundary is not a codimension 1 face");
121  for (int ii = 0; ii < DIM; ii++)
122  {
123  if (adjDir[ii] != 0)
124  {
125  return Face(ii, adjDir[ii] < 0 ? Side::Lo : Side::Hi);
126  }
127  }
128  return Face(0,Side::Lo); // dummy return to suppress a compilation warning
129  }
130 
131  template<typename T, unsigned int C, MemType MEM>
133  {
134  pr_out() << " | localBoundary: " << localData->box();
135  pr_out() << " | adjBoundary: " << adjData->box() << std::endl;
136  }
137 } // end namespace Proto
138 #endif //end include guard
Point localDir
Definition: Proto_MBBoundaryData.H:44
MBIndex adjIndex
Definition: Proto_MBBoundaryData.H:43
Definition: Proto_Face.H:122
Point localGhost
Definition: Proto_MBBoundaryData.H:47
void copyTo(BoxData< T, C, MEM_DEST, D, E > &a_dest) const
Copy on Intersection.
Multidimensional Rectangular Array.
Definition: Proto_BoxData.H:314
Low side; normal is in negative coordinate direction.
Definition: Proto_Face.H:26
Defines discrete rotations in logically rectangular coordinate systems.
Definition: Proto_CoordPermutation.H:13
Point adjGhost
Definition: Proto_MBBoundaryData.H:48
Point adjDir
Definition: Proto_MBBoundaryData.H:45
std::shared_ptr< BoxData< T, C, MEM > > adjData
Definition: Proto_MBBoundaryData.H:50
CoordPermutation inverse() const
Compute and return the inverse Permutation.
Point connectivity(const MBPoint &patch_1, const MBPoint &patch_2) const
Definition: Proto_MBDisjointBoxLayout.H:247
An interval in DIM dimensional space.
Definition: Proto_Box.H:29
Box adjBox() const
Definition: Proto_MBBoundaryData.H:37
Face localFace() const
Definition: Proto_MBBoundaryData.H:102
CoordPermutation adjToLocal
Definition: Proto_MBBoundaryData.H:46
Box grow(int a_numpoints) const
Isotropic Grow Operation.
Definition: Proto_MBBoundaryData.H:11
Face adjFace() const
Definition: Proto_MBBoundaryData.H:117
#define PROTO_ASSERT(stmt, args...)
Definition: Proto_PAssert.H:48
void print()
Definition: Proto_MBBoundaryData.H:132
std::ostream & pr_out()
Use this in place of std::cout for program output.
void fill(const BoxData< T, C, MEM > &a_data)
Definition: Proto_MBBoundaryData.H:94
void define(MBDisjointBoxLayout a_layout, MBIndex a_localIndex, MBIndex a_adjIndex, Box a_localBox, Box a_adjBox, CoordPermutation a_adjToLocal, Point a_ghost=Point::Zeros())
Definition: Proto_MBBoundaryData.H:70
static ACCEL_DECORATION Point Zeros()
Get Zeros.
Definition: Proto_Array.H:17
MBDisjointBoxLayout layout
Definition: Proto_MBBoundaryData.H:41
Integer Valued Vector.
Definition: Proto_Point.H:24
Definition: Proto_MBDisjointBoxLayout.H:14
Box localBox() const
Definition: Proto_MBBoundaryData.H:36
MBIndex localIndex
Definition: Proto_MBBoundaryData.H:42
int codim() const
Query Codimension.
High side; normal is in the positive coordinate direction.
Definition: Proto_Face.H:27
MBBoundaryData()
Definition: Proto_MBBoundaryData.H:54