OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
BoxCornerDomain.h
Go to the documentation of this file.
1 //
2 // Class BoxCornerDomain
3 // :FIXME: add brief description
4 //
5 // Copyright (c) 2008, Yves Ineichen, ETH Zürich,
6 // 2013 - 2015, Tülin Kaman, Paul Scherrer Institut, Villigen PSI, Switzerland
7 // 2017 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
8 // All rights reserved
9 //
10 // Implemented as part of the master thesis
11 // "A Parallel Multigrid Solver for Beam Dynamics"
12 // and the paper
13 // "A fast parallel Poisson solver on irregular domains applied to beam dynamics simulations"
14 // (https://doi.org/10.1016/j.jcp.2010.02.022)
15 //
16 // This file is part of OPAL.
17 //
18 // OPAL is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
25 //
26 #ifndef BOXCORNER_DOMAIN_H
27 #define BOXCORNER_DOMAIN_H
28 
29 #include <map>
30 #include <string>
31 #include <utility>
32 
33 #include "Solvers/RegularDomain.h"
34 
35 /*
36 
37  A and B are the half aperture of the box
38 
39  / (A,B)
40  /
41  /
42  /
43  L1 /
44 ------------ --------------+ (-A,B)
45  | L2 | |
46  C| | |
47  |------| | /
48  ..... | /
49 (0,0)---.......-----------------+ /
50  ..... | /
51  z | /
52  | | /
53 --------------------------------+/ (-A,-B)
54 
55  Length_m
56 
57 Test in which of the 3 parts of the geometry we are in.
58 
59  if((z < L1) || (z > (L1 + L2)))
60  b = B;
61  else
62  b = B-C;
63 
64 
65 A = getXRangeMax()
66 B = getYRangeMax()
67 L1 = getZRangeMin()
68 L2 = getZRangeMax() - getZRangeMin
69 */
70 
72 
73 public:
82  BoxCornerDomain(double A, double B, double C,
83  double L1, double L2, IntVector_t nr, Vector_t hr,
84  std::string interpl);
86 
88  inline double getB(double z) const {
89  if((z < getZRangeMin()) || (z > getZRangeMax()))
90  return getYRangeMax();
91  else
92  return getYRangeMax() - C_m;
93  }
94 
96  inline bool isInside(int x, int y, int z) const {
97  const double xx = (x - (nr_m[0] - 1) / 2.0) * hr_m[0];
98  const double yy = (y - (nr_m[1] - 1) / 2.0) * hr_m[1];
99  const double b = getB(z * hr_m[2]);
100  return (xx < getXRangeMax() && yy < b && z >= 0 && z < nr_m[2]);
101  }
102 
103  void compute(Vector_t hr, NDIndex<3> localId);
104 
105 private:
106 
107  //XXX: since the Y coorindate is dependent on the Z value we need (int,
108  //int) -> intersection. To simplify things (for now) we use the same
109  //structure for X...
112  typedef std::multimap< std::pair<int, int>, double > BoxCornerPointList;
113 
116 
119 
121  double actBMin_m;
122 
123  double actBMax_m;
124 
126  double C_m;
127 
128  inline double getXIntersection(double cx, int /*z*/) const {
129  return (cx < 0) ? getXRangeMin() : getXRangeMax();
130  }
131 
132  inline double getYIntersection(double cy, int z) const {
133  return (cy < 0) ? getYRangeMin() : getB(z * hr_m[2]);
134  }
135 
137  inline int toCoordIdx(int x, int y, int z) const {
138  return (z * nr_m[1] + y) * nr_m[0] + x;
139  }
140 
142  int indexAccess(int x, int y, int z) const {
143  return idxMap_m.at(toCoordIdx(x, y, z));
144  }
145 
146  int coordAccess(int idx) const {
147  return coordMap_m.at(idx);
148  }
149 
151  void linearInterpolation(int x, int y, int z, StencilValue_t& value,
152  double &scaleFactor) const override;
153 
154  void quadraticInterpolation(int x, int y, int z, StencilValue_t& value,
155  double &scaleFactor) const override;
156 
157 };
158 
159 #endif
const int nr
Definition: ClassicRandom.h:24
int coordAccess(int idx) const
BoxCornerPointList IntersectYDir
all intersection points with grid lines in Y direction
std::multimap< std::pair< int, int >, double > BoxCornerPointList
double C_m
height of the corner
BoxCornerPointList IntersectXDir
all intersection points with grid lines in X direction
void compute(Vector_t hr, NDIndex< 3 > localId)
void linearInterpolation(int x, int y, int z, StencilValue_t &value, double &scaleFactor) const override
different interpolation methods for boundary points
void quadraticInterpolation(int x, int y, int z, StencilValue_t &value, double &scaleFactor) const override
BoxCornerDomain(double A, double B, double C, double L1, double L2, IntVector_t nr, Vector_t hr, std::string interpl)
bool isInside(int x, int y, int z) const
queries if a given (x,y,z) coordinate lies inside the domain
double actBMin_m
because the geometry can change in the y direction
int indexAccess(int x, int y, int z) const
conversion from (x,y,z) to index on the 3D grid
double getB(double z) const
as a function of z, determine the height (B) of the geometry
double getXIntersection(double cx, int) const
double getYIntersection(double cy, int z) const
int toCoordIdx(int x, int y, int z) const
conversion from (x,y,z) to index in xyz plane
IntVector_t nr_m
number of mesh points in each direction
std::map< int, int > coordMap_m
mapping idx -> (x,y,z)
double getXRangeMax() const
double getYRangeMax() const
double getZRangeMin() const
double getXRangeMin() const
std::map< int, int > idxMap_m
mapping (x,y,z) -> idx
double getYRangeMin() const
Vector_t hr_m
mesh-spacings in each direction
Stencil< double > StencilValue_t
double getZRangeMax() const