Feellgood
absorbing_ends.h
Go to the documentation of this file.
1 #ifndef ABSORBING_ENDS_H
2 #define ABSORBING_ENDS_H
3 
9 #include <algorithm>
10 #include <cmath>
11 #include <string>
12 #include <vector>
13 
14 #include "node.h"
15 
26  {
28  bool enable = false;
29 
31  Nodes::index axis = Nodes::IDX_Z;
32 
34  double length = 0;
35 
37  double alpha_max = 1;
38 
40  std::vector<std::string> regions;
41 
44  double lo = 0;
45 
48  double hi = 0;
49 
51  double alpha(const double alpha0, const double x) const
52  {
53  if (!enable)
54  { return alpha0; }
55  const double s = std::max(x - (hi - length), (lo + length) - x); // depth in the nearest zone
56  if (s <= 0)
57  { return alpha0; }
58  const double sn = std::sin(M_PI_2 * std::min(s / length, 1.0));
59  return alpha0 + (alpha_max - alpha0) * sn * sn;
60  }
61  };
62 
63 #endif
index
Definition: node.h:33
header to define struct Node
Definition: absorbing_ends.h:26
bool enable
Definition: absorbing_ends.h:28
double alpha_max
Definition: absorbing_ends.h:37
Nodes::index axis
Definition: absorbing_ends.h:31
double alpha(const double alpha0, const double x) const
Definition: absorbing_ends.h:51
std::vector< std::string > regions
Definition: absorbing_ends.h:40
double length
Definition: absorbing_ends.h:34
double lo
Definition: absorbing_ends.h:44
double hi
Definition: absorbing_ends.h:48