OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
ArbitraryDomain.h
Go to the documentation of this file.
1//
2// Class ArbitraryDomain
3// Interface to iterative solver and boundary geometry
4// for space charge calculation
5//
6// Copyright (c) 2008, Yves Ineichen, ETH Zürich,
7// 2013 - 2015, Tülin Kaman, Paul Scherrer Institut, Villigen PSI, Switzerland
8// 2016, Daniel Winklehner, Massachusetts Institute of Technology
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 ARBITRARY_DOMAIN_H
29#define ARBITRARY_DOMAIN_H
30
31#include <mpi.h>
32#include <hdf5.h>
33#include "H5hut.h"
34
35#include <map>
36#include <string>
37#include <tuple>
38#include <vector>
39#include "IrregularDomain.h"
40
42
44
45public:
47 std::string interpl);
48
50
52 bool isInside(int idx, int idy, int idz) const override {
53 return isInsideMap_m.at(toCoordIdx(idx, idy, idz));
54 }
55
56 // calculates intersection with rotated and shifted geometry
57 void compute(Vector_t hr, NDIndex<3> localId) override;
58
59private:
61
65 typedef std::multimap< std::tuple<int, int, int>, double > PointList_t;
66
69
72
75
76 // Here we store the number of nodes in a xy layer for a given z coordinate
77 std::map<int, int> numXY_m;
78
79 // Mapping all cells that are inside the geometry
80 std::map<int, bool> isInsideMap_m;
81
83
84 // Conversion from (x,y,z) to index in xyz plane
85 int toCoordIdx(int idx, int idy, int idz) const {
86 return (idz * nr_m[1] + idy) * nr_m[0] + idx;
87 }
88
89 // Conversion from (x,y,z) to index on the 3D grid
90 int indexAccess(int x, int y, int z) const override {
91 return idxMap_m.at(toCoordIdx(x, y, z));
92 }
93
94 int coordAccess(int idx) const override {
95 return coordMap_m.at(idx);
96 }
97
98 // Different interpolation methods for boundary points
99 void constantInterpolation(int idx, int idy, int idz, StencilValue_t& value,
100 double &scaleFactor) const override;
101
102 void linearInterpolation(int idx, int idy, int idz, StencilValue_t& value,
103 double &scaleFactor) const override;
104};
105
106#endif
const int nr
Definition: ClassicRandom.h:24
bool isInside(int idx, int idy, int idz) const override
queries if a given (x,y,z) coordinate lies inside the domain
PointList_t intersectHiY_m
all intersection points with gridlines in Y direction
std::map< int, bool > isInsideMap_m
void linearInterpolation(int idx, int idy, int idz, StencilValue_t &value, double &scaleFactor) const override
PointList_t intersectLoZ_m
BoundaryGeometry * bgeom_m
int indexAccess(int x, int y, int z) const override
Vector_t globalInsideP0_m
int toCoordIdx(int idx, int idy, int idz) const
PointList_t intersectHiZ_m
all intersection points with gridlines in Z direction
std::map< int, int > numXY_m
PointList_t intersectHiX_m
all intersection points with gridlines in X direction
PointList_t intersectLoX_m
void compute(Vector_t hr, NDIndex< 3 > localId) override
ArbitraryDomain(BoundaryGeometry *bgeom, IntVector_t nr, Vector_t hr, std::string interpl)
int coordAccess(int idx) const override
void constantInterpolation(int idx, int idy, int idz, StencilValue_t &value, double &scaleFactor) const override
different interpolation methods for boundary points
std::multimap< std::tuple< int, int, int >, double > PointList_t
PointList_t intersectLoY_m
IntVector_t nr_m
number of mesh points in each direction
std::map< int, int > coordMap_m
mapping idx -> (x,y,z)
std::map< int, int > idxMap_m
mapping (x,y,z) -> idx
Stencil< double > StencilValue_t