HalfPeriodicBox.cpp
1 #include "HalfPeriodicBox.hpp"
2 #include "../../../misc/universal_error.hpp"
3 
4 std::pair<Vector2D, Vector2D> HalfPeriodicBox::getBoundaries(void) const
5 {
6  return std::pair<Vector2D, Vector2D>(Vector2D(_left, _down),
7  Vector2D(_right, _up));
8 }
9 
11 {
12  if(point.y<_down||point.y>_up)
13  return true;
14  return false;
15 }
16 
17 HalfPeriodicBox::HalfPeriodicBox(double left, double right,double up, double down)
18  :_left(left),_right(right),_up(up),_down(down)
19 {
20  if(left>=right||down>=up)
21  throw UniversalError("Invalid values for grid boundaries");
22 }
23 
25 {
26  return HalfPeriodic;
27 }
28 
30 {
31  if(dir==Left)
32  return _left;
33  else if(dir==Right)
34  return _right;
35  else if(dir==Up)
36  return _up;
37  else if(dir==Down)
38  return _down;
39  else
40  throw UniversalError("Unknown direction");
41 }
42 
43 bool HalfPeriodicBox::AreWeReflective(Edge const& edge) const
44 {
45  double length=edge.GetLength();
46  // Are we periodic or reflective?
47  if(fabs((edge.vertices.first.y-edge.vertices.second.y))<1e-5*length)
48  if(fabs(edge.vertices.first.y-_up)<1e-5*length
49  ||fabs(edge.vertices.first.y-_down)<1e-5*length)
50  return true;
51  else
52  return false;
53  else
54  return false;
55 }
Directions
Directions of boundaries of the computational domain.
Container for error reports.
double GetGridBoundary(Directions dir) const
Returns the boundary coordinate.
Interface between two cells.
Definition: Edge.hpp:13
double y
Component in the y direction.
Definition: geometry.hpp:48
bool PointIsReflective(Vector2D const &point) const
Checks if the point is a reflected point outside the domain.
BoundaryType
Type of boundary.
bool AreWeReflective(Edge const &edge) const
Return wheter an edge is reflective or not.
std::pair< Vector2D, Vector2D > vertices
Points at the ends of the edge.
Definition: Edge.hpp:18
BoundaryType GetBoundaryType(void) const
Returns the boundary type.
Square box outer boundary conditions with two sides reflective and two periodic. The x direction is t...
HalfPeriodicBox(double left, double right, double up, double down)
Class constructor.
2D Mathematical vector
Definition: geometry.hpp:15
double GetLength(void) const
Returns the length of the edge.
Definition: Edge.cpp:26
std::pair< Vector2D, Vector2D > getBoundaries(void) const
Returns the lower left and upper right corners.