SquareBox.cpp
1 #include "SquareBox.hpp"
2 #include "../../../misc/universal_error.hpp"
3 
4 bool SquareBox::PointIsReflective(Vector2D const& point)const
5 {
6  if(point.x<_left||point.x>_right)
7  return true;
8  if(point.y<_down||point.y>_up)
9  return true;
10  return false;
11 }
12 
13 bool SquareBox::AreWeReflective(Edge const& /*edge*/)const
14 {
15  return true;
16 }
17 
18 namespace {
19  void assert_directions(double left, double right,
20  double up, double down)
21  {
22  if(left>=right||down>=up)
23  throw UniversalError("Invalid values for grid boundaries");
24  }
25 }
26 
27 SquareBox::SquareBox(double left, double right,double up, double down):
28  _left(left),_right(right),_up(up),_down(down)
29 {
30  assert_directions(left,right,up,down);
31 }
32 
33 SquareBox::SquareBox(Vector2D const& bottom_left,
34  Vector2D const& top_right):
35  _left(bottom_left.x),
36  _right(top_right.x),
37  _up(top_right.y),
38  _down(bottom_left.y)
39 {
40  assert_directions(_left,_right,_up,_down);
41 }
42 
44 {
45  return Rectengular;
46 }
47 
49 {
50  if(dir==Left)
51  return _left;
52  else if(dir==Right)
53  return _right;
54  else if(dir==Up)
55  return _up;
56  else if(dir==Down)
57  return _down;
58  else
59  throw UniversalError("Unknown direction");
60 }
61 
62 pair<Vector2D, Vector2D> SquareBox::getBoundary(void) const
63 {
64  return pair<Vector2D,Vector2D>(Vector2D(_left,_down),
65  Vector2D(_right,_up));
66 }
67 
68 void SquareBox::SetBoundary(Vector2D const& ll, Vector2D const& ur)
69 {
70  _left = ll.x;
71  _right = ur.x;
72  _up = ur.y;
73  _down = ll.y;
74 }
75 
76 SquareBox::~SquareBox(void) {}
Directions
Directions of boundaries of the computational domain.
Square box outer boundary conditions.
Container for error reports.
pair< Vector2D, Vector2D > getBoundary(void) const
Returns the coordinates of the lower left and top right of the square frame.
Definition: SquareBox.cpp:62
Interface between two cells.
Definition: Edge.hpp:13
bool PointIsReflective(Vector2D const &point) const
Checks if the point is a reflected point outside the domain.
Definition: SquareBox.cpp:4
BoundaryType GetBoundaryType(void) const
Returns the boundary type.
Definition: SquareBox.cpp:43
double y
Component in the y direction.
Definition: geometry.hpp:48
BoundaryType
Type of boundary.
bool AreWeReflective(Edge const &edge) const
Return wheter an edge is reflective or not.
Definition: SquareBox.cpp:13
SquareBox(double left, double right, double up, double down)
Class constructor.
Definition: SquareBox.cpp:27
2D Mathematical vector
Definition: geometry.hpp:15
double x
Component in the x direction.
Definition: geometry.hpp:45
double GetGridBoundary(Directions dir) const
Returns the boundary coordinate.
Definition: SquareBox.cpp:48