OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
RectangularDomain.h
Go to the documentation of this file.
1//
2// Class RectangularDomain
3// This class provides a rectangular beam pipe. The mesh adapts to the bunch
4// in longitudinal direction.
5//
6// Copyright (c) 2008, Yves Ineichen, ETH Zürich,
7// 2013 - 2015, Tülin Kaman, Paul Scherrer Institut, Villigen PSI, Switzerland
8// 2017 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
9// All rights reserved
10//
11// Implemented as part of the master thesis
12// "A Parallel Multigrid Solver for Beam Dynamics"
13// and the paper
14// "A fast parallel Poisson solver on irregular domains applied to beam dynamics simulations"
15// (https://doi.org/10.1016/j.jcp.2010.02.022)
16//
17// This file is part of OPAL.
18//
19// OPAL is free software: you can redistribute it and/or modify
20// it under the terms of the GNU General Public License as published by
21// the Free Software Foundation, either version 3 of the License, or
22// (at your option) any later version.
23//
24// You should have received a copy of the GNU General Public License
25// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
26//
27#ifndef RECTANGULAR_DOMAIN_H
28#define RECTANGULAR_DOMAIN_H
29
30#include <vector>
31#include <string>
33
35
36public:
42 RectangularDomain(double a, double b, IntVector_t nr, Vector_t hr);
43
45 void compute(Vector_t hr, NDIndex<3> /*localId*/);
46
48 inline bool isInside(int x, int y, int /*z*/) const {
49 double xx = (x - (nr_m[0] - 1) / 2.0) * hr_m[0];
50 double yy = (y - (nr_m[1] - 1) / 2.0) * hr_m[1];
51 return (xx <= getXRangeMax() && yy < getYRangeMax());
52 }
53
54private:
56 int indexAccess(int x, int y, int z) const {
57 return y * nr_m[0] + x + z * getNumXY();
58 }
59
60 int coordAccess(int idx) const {
61 return idx % getNumXY();
62 }
63};
64
65#endif
66
const int nr
Definition: ClassicRandom.h:24
std::complex< double > a
IntVector_t nr_m
number of mesh points in each direction
double getXRangeMax() const
double getYRangeMax() const
Vector_t hr_m
mesh-spacings in each direction
RectangularDomain(double a, double b, IntVector_t nr, Vector_t hr)
bool isInside(int x, int y, int) const
queries if a given (x,y,z) coordinate lies inside the domain
int coordAccess(int idx) const
int indexAccess(int x, int y, int z) const
conversion from (x,y,z) to index on the 3D grid
void compute(Vector_t hr, NDIndex< 3 >)
calculates intersection with the beam pipe
int getNumXY() const override
Definition: RegularDomain.h:32