Line data Source code
1 : //
2 : // Class RegionLayout
3 : // RegionLayout stores a partitioned set of NDRegion objects, to represent
4 : // the parallel layout of an encompassing NDRegion. It also contains
5 : // functions to find the subsets of the NDRegion partitions which intersect
6 : // or touch a given NDRegion. It is similar to FieldLayout, with the
7 : // following changes:
8 : // 1. It uses NDRegion instead of NDIndex, so it is templated on the position
9 : // data type (although it can be constructed with an NDIndex and a Mesh
10 : // as well);
11 : // 2. It does not contain any consideration for guard cells;
12 : // 3. It can store not only the partitioned domain, but periodic copies of
13 : // the partitioned domain for use by particle periodic boundary conditions
14 : // 4. It also keeps a list of FieldLayoutUser's, so that it can notify them
15 : // when the internal FieldLayout here is reparitioned or otherwise changed.
16 : //
17 : // If this is constructed with a FieldLayout, it stores a pointer to it
18 : // so that if we must repartition the copy of the FieldLayout that
19 : // is stored here, we will end up repartitioning all the registered Fields.
20 : //
21 : #ifndef IPPL_REGION_LAYOUT_H
22 : #define IPPL_REGION_LAYOUT_H
23 :
24 : #include <array>
25 :
26 : #include "Types/ViewTypes.h"
27 :
28 : #include "Utility/TypeUtils.h"
29 :
30 : #include "Region/NDRegion.h"
31 :
32 : namespace ippl {
33 : namespace detail {
34 :
35 : template <typename T, unsigned Dim, class Mesh, class... Properties>
36 : class RegionLayout {
37 : template <typename... Props>
38 : using base_type = RegionLayout<T, Dim, Mesh, Props...>;
39 :
40 : public:
41 : using NDRegion_t = NDRegion<T, Dim>;
42 : using view_type = typename ViewType<NDRegion_t, 1, Properties...>::view_type;
43 : using host_mirror_type = typename view_type::host_mirror_type;
44 :
45 : using uniform_type = typename CreateUniformType<base_type, view_type>::type;
46 :
47 : // Default constructor. To make this class actually work, the user
48 : // will have to later call 'changeDomain' to set the proper Domain
49 : // and get a new partitioning.
50 : RegionLayout();
51 :
52 : // Constructor which takes a FieldLayout and a MeshType
53 : // This one compares the domain of the FieldLayout and the domain of
54 : // the MeshType to determine the centering of the index space.
55 : RegionLayout(const FieldLayout<Dim>&, const Mesh&);
56 :
57 72 : ~RegionLayout() = default;
58 :
59 84 : const NDRegion_t& getDomain() const { return region_m; }
60 :
61 : const view_type getdLocalRegions() const;
62 :
63 : const host_mirror_type gethLocalRegions() const;
64 :
65 : void write(std::ostream& = std::cout) const;
66 :
67 : void changeDomain(const FieldLayout<Dim>&, const Mesh& mesh); // previously private...
68 :
69 : private:
70 : NDRegion_t convertNDIndex(const NDIndex<Dim>&, const Mesh& mesh) const;
71 : void fillRegions(const FieldLayout<Dim>&, const Mesh& mesh);
72 :
73 : //! Offset from 'normal' Index space to 'Mesh' Index space
74 : std::array<int, Dim> indexOffset_m;
75 :
76 : //! Offset needed between centering of Index space and Mesh points
77 : std::array<bool, Dim> centerOffset_m;
78 :
79 : NDRegion_t region_m;
80 :
81 : //! local regions (device view)
82 : view_type dLocalRegions_m;
83 :
84 : //! local regions (host mirror view)
85 : host_mirror_type hLocalRegions_m;
86 :
87 : view_type subdomains_m;
88 : };
89 :
90 : template <typename T, unsigned Dim, class Mesh>
91 : std::ostream& operator<<(std::ostream&, const RegionLayout<T, Dim, Mesh>&);
92 :
93 : } // namespace detail
94 : } // namespace ippl
95 :
96 : #include "Region/RegionLayout.hpp"
97 :
98 : #endif
|