OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
EllipticDomain.h
Go to the documentation of this file.
1 //
2 // Class EllipticDomain
3 // This class provides an elliptic beam pipe. The mesh adapts to the bunch size
4 // in the longitudinal direction. At the intersection of the mesh with the
5 // beam pipe, three stencil interpolation methods are available.
6 //
7 // Copyright (c) 2008, Yves Ineichen, ETH Zürich,
8 // 2013 - 2015, Tülin Kaman, Paul Scherrer Institut, Villigen PSI, Switzerland
9 // 2017 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
10 // All rights reserved
11 //
12 // Implemented as part of the master thesis
13 // "A Parallel Multigrid Solver for Beam Dynamics"
14 // and the paper
15 // "A fast parallel Poisson solver on irregular domains applied to beam dynamics simulations"
16 // (https://doi.org/10.1016/j.jcp.2010.02.022)
17 //
18 // This file is part of OPAL.
19 //
20 // OPAL is free software: you can redistribute it and/or modify
21 // it under the terms of the GNU General Public License as published by
22 // the Free Software Foundation, either version 3 of the License, or
23 // (at your option) any later version.
24 //
25 // You should have received a copy of the GNU General Public License
26 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
27 //
28 #ifndef ELLIPTICAL_DOMAIN_H
29 #define ELLIPTICAL_DOMAIN_H
30 
31 #include <vector>
32 #include <map>
33 #include <string>
34 #include <cmath>
35 #include "Solvers/RegularDomain.h"
38 
39 class EllipticDomain : public RegularDomain {
40 
41 public:
43  Vector_t hr, std::string interpl);
44 
46 
48  bool isInside(int x, int y, int z) const {
49  double xx = getXRangeMin() + hr_m[0] * (x + 0.5);
50  double yy = getYRangeMin() + hr_m[1] * (y + 0.5);
51 
52  bool isInsideEllipse = (xx * xx / (getXRangeMax() * getXRangeMax()) +
53  yy * yy / (getYRangeMax() * getYRangeMax()) < 1);
54 
55  return (isInsideEllipse && z >= 0 && z < nr_m[2]);
56  }
57 
59  void compute(Vector_t hr, NDIndex<3> localId);
60 
61 private:
62 
65  typedef std::multimap<int, double> EllipticPointList_t;
66 
69 
72 
74  int toCoordIdx(int x, int y) const { return y * nr_m[0] + x; }
75 
77  int indexAccess(int x, int y, int z) const {
78  return idxMap_m.at(toCoordIdx(x, y)) + z * getNumXY();
79  }
80 
81  int coordAccess(int idx) const {
82  int ixy = idx % getNumXY();
83  return coordMap_m.at(ixy);
84  }
85 
87  void linearInterpolation(int x, int y, int z, StencilValue_t& value,
88  double &scaleFactor) const override;
89 
90  void quadraticInterpolation(int x, int y, int z, StencilValue_t& value,
91  double &scaleFactor) const override;
92 };
93 
94 #endif //#ifdef ELLIPTICAL_DOMAIN_H
const int nr
Definition: ClassicRandom.h:24
int coordAccess(int idx) const
void compute(Vector_t hr, NDIndex< 3 > localId)
calculates intersection
std::multimap< int, double > EllipticPointList_t
int indexAccess(int x, int y, int z) const
conversion from (x,y,z) to index on the 3D grid
int toCoordIdx(int x, int y) const
conversion from (x,y) to index in xy plane
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
EllipticPointList_t intersectYDir_m
all intersection points with grid lines in Y direction
bool isInside(int x, int y, int z) const
queries if a given (x,y,z) coordinate lies inside the domain
EllipticPointList_t intersectXDir_m
all intersection points with grid lines in X direction
EllipticDomain(BoundaryGeometry *bgeom, IntVector_t nr, Vector_t hr, std::string interpl)
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 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
int getNumXY() const override
Definition: RegularDomain.h:32