NDDEM
Boundaries.h
Go to the documentation of this file.
1 #include <iostream>
2 #include <fstream>
3 
4 #ifndef BOUNDARIES_H
5 #define BOUNDARIES_H
6 
7 template <int d>
8 class Boundary {
9 public:
12  // would be nice as aliases, but too hard
13  double vel ;
15  double radius ;
16 
17  // not aliases ...
18  int axis ;
19  std::vector<double> center = std::vector<double>(d,0) ;
20  std::vector<double> omega = std::vector<double>(d*(d-1)/2,0) ;
21 
22  template <class Archive>
23  void serialize(Archive &ar) {
25  }
26 
27  //============================================================================
28  std::vector<double> as_vector()
29  {
30  std::vector<double> res ;
31  switch (Type)
32  {
33  case WallType::PBC :
34  return {xmin, xmax, delta, static_cast<double>(Type)} ;
35  case WallType::PBC_LE :
36  return {xmin, xmax, delta, static_cast<double>(Type), vel} ;
37  case WallType::WALL:
38  return {xmin, xmax, delta, static_cast<double>(Type)} ;
39  case WallType::MOVINGWALL :
40  return {xmin, xmax, delta, static_cast<double>(Type), velmin, velmax} ;
41  case WallType::SPHERE:
42  res = {radius, radius*radius, 0, static_cast<double>(Type) } ;
43  res.insert(res.end(), center.begin(), center.end()) ;
44  return res ;
46  res = {radius, radius*radius, 0, static_cast<double>(Type) } ;
47  res.insert(res.end(), center.begin(), center.end()) ;
48  res.insert(res.end(), omega.begin(), omega.end()) ;
49  return res ;
51  return {radius, radius*radius, 0, static_cast<double>(Type) } ;
53  return {radius, radius*radius, 0, static_cast<double>(Type) } ;
54  case WallType::ELLIPSE:
55  return {semiaxisx, semiaxisy, 0, static_cast<double>(Type), centerx, centery} ;
57  return {0, 0, 0, static_cast<double>(Type)} ;
58  default:
59  printf("ERR Incorrect wall reading, unknown wall.\n") ;
60  }
61 
62  }
63 
64  int read_line (std::istream &in)
65  {
66  switch (Type)
67  {
68  case WallType::PBC :
69  case WallType::PBC_LE :
70  case WallType::WALL:
71  case WallType::MOVINGWALL :
72  in >> xmin >> xmax ;
73  delta = xmax - xmin ;
74  break ;
75  case WallType::SPHERE:
79  in >> radius ;
80  break ;
81  case WallType::ELLIPSE:
82  assert((d==2)) ;
83  in >> semiaxisx >> semiaxisy;
84  break ;
86  default:
87  printf("ERR Incorrect wall reading, unknown wall.\n") ;
88  }
89  switch (Type)
90  {
92  case WallType::HEMISPHERE :
93  in >> axis ;
94  break ;
95  case WallType::PBC_LE :
96  in >> vel ;
97  displacement = 0;
98  break ;
100  in >> velmin >> velmax ;
101  break ;
102  case WallType::ELLIPSE:
103  in >> centerx >> centery ;
104  break ;
105  case WallType::PBC:
106  case WallType::SPHERE:
108  case WallType::WALL:
109  case WallType::UNDEFINED:
110  break ;
111 
112  }
113  switch (Type)
114  {
115  case WallType::SPHERE:
118  for (int dd =0 ; dd<d ; dd++)
119  in >> center[dd] ;
120  break ;
121  case WallType::PBC:
122  case WallType::PBC_LE:
123  case WallType::WALL:
124  case WallType::MOVINGWALL :
126  case WallType::ELLIPSE:
127  case WallType::UNDEFINED:
128  break ;
129 
130  }
132  for (int i=0; i<d*(d-1)/2 ; i++)
133  in >> omega[i] ;
134 
135  return 0 ;
136  }
137 
140 
141 } ;
142 
143 
144 
145 
146 
147 #endif
Definition: Boundaries.h:8
double semiaxisx
Definition: Boundaries.h:14
std::vector< double > as_vector()
Definition: Boundaries.h:28
void serialize(Archive &ar)
Definition: Boundaries.h:23
double vel
Definition: Boundaries.h:13
double semiaxisy
Definition: Boundaries.h:14
double xmin
Definition: Boundaries.h:11
int axis
Definition: Boundaries.h:18
WallType Type
Definition: Boundaries.h:10
double displacement
Definition: Boundaries.h:11
std::vector< double > center
Definition: Boundaries.h:19
bool is_sphere()
Definition: Boundaries.h:138
double radius
Definition: Boundaries.h:15
std::vector< double > omega
Definition: Boundaries.h:20
double velmin
Definition: Boundaries.h:11
double velmax
Definition: Boundaries.h:11
double centery
Definition: Boundaries.h:14
bool is_periodic()
Definition: Boundaries.h:139
double xmax
Definition: Boundaries.h:11
double centerx
Definition: Boundaries.h:14
int read_line(std::istream &in)
Definition: Boundaries.h:64
double delta
Definition: Boundaries.h:11
WallType
Definition: Typedefs.h:23
@ ROTATINGSPHERE
uint d
Type
Type of JSON value.
Definition: rapidjson.h:644