OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
Domain_icells_cart_unit_test.cu
1
2#define BOOST_TEST_DYN_LINK
3#include <boost/test/unit_test.hpp>
4#include "Space/Shape/Box.hpp"
5#include "Decomposition/Domain_icells_cart.hpp"
6#include "VCluster/VCluster.hpp"
7#include "VTKWriter/VTKWriter.hpp"
8#include "Grid/iterators/grid_skin_iterator.hpp"
9
10BOOST_AUTO_TEST_SUITE( domain_icells_cart )
11
12BOOST_AUTO_TEST_CASE( domain_icells_use )
13{
14#if 0
15
17
19
20 Box<3,float> box1({0.0,0.0,0.0},{0.5,0.5,0.5});
21 Box<3,float> box2({0.5,0.25,0.25},{0.75,0.5,0.5});
22
23 domain_proc.add(box1);
24 domain_proc.add(box2);
25
27
28 // first sub ghost area
29
30 Box<3,float> g1({0.0,0.0,0.0},{0.1,0.5,0.5});
31 Box<3,float> g2({0.0,0.0,0.4},{0.5,0.5,0.5});
32 Box<3,float> g3({0.0,0.0,0.0},{0.5,0.1,0.5});
33 Box<3,float> g4({0.0,0.4,0.0},{0.5,0.5,0.5});
34 Box<3,float> g5({0.0,0.0,0.0},{0.5,0.5,0.1});
35 Box<3,float> g6_1({0.4,0.0,0.0},{0.5,0.25,0.5});
36 Box<3,float> g6_2({0.4,0.0,0.0},{0.5,0.5,0.25});
37
38 // Second sub ghost area
39
40 Box<3,float> g7({0.5,0.25,0.25},{0.6,0.5,0.5});
41 Box<3,float> g8({0.65,0.25,0.25},{0.75,0.5,0.5});
42 Box<3,float> g9({0.5,0.25,0.25},{0.75,0.35,0.25});
43 Box<3,float> g10({0.5,0.4,0.25},{0.75,0.5,0.5});
44 Box<3,float> g11({0.5,0.25,0.25},{0.75,0.5,0.35});
45 Box<3,float> g12({0.5,0.25,0.4},{0.75,0.5,0.5});
46
47 ie_ghost.add(g1);
48 ie_ghost.add(g2);
49 ie_ghost.add(g3);
50 ie_ghost.add(g4);
51 ie_ghost.add(g5);
52 ie_ghost.add(g6_1);
53 ie_ghost.add(g6_2);
54
55 ie_ghost.add(g7);
56 ie_ghost.add(g8);
57 ie_ghost.add(g9);
58 ie_ghost.add(g10);
59 ie_ghost.add(g11);
60 ie_ghost.add(g12);
61
62 Box<3,float> pbox({0.0,0.0,0.0},{0.75,0.5,0.5});
63
64 Ghost<3,float> g(0.1);
65
66 auto & v_cl = create_vcluster<CudaMemory>();
67
68 dcc.CalculateInternalCells(v_cl,ie_ghost,domain_proc,pbox,0.1,g);
69
70 // Check
71
72 auto & ic = dcc.getIcells();
73 auto & dc = dcc.getDcells();
74
75 ic.template deviceToHost<0>();
76 dc.template deviceToHost<0>();
77
80
81 grid_sm<3,void> gr = dcc.getGrid();
82
83 Box<3,size_t> b1({2,2,2},{6,6,6});
84
85 size_t bc[3] = {NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
86
87 grid_skin_iterator_bc<3> it_skin(gr,b1,b1,bc);
88
89 while (it_skin.isNext())
90 {
91 auto p = it_skin.get();
92
93 if (p.get(0) == 6 && p.get(1) == 5 && p.get(2) == 5)
94 {}
95 else
96 {icheck.add(gr.LinId(p));}
97
98 ++it_skin;
99 }
100
101 Box<3,size_t> b3({7,4,4},{9,6,6});
102 grid_key_dx_iterator_sub<3> it_sub(gr,b3.getKP1(),b3.getKP2());
103
104 while (it_sub.isNext())
105 {
106 auto p = it_sub.get();
107
108 icheck.add(gr.LinId(p));
109
110 ++it_sub;
111 }
112
113 // dcheck has only the internal part of the first domain + 6,5,5
114
115 Box<3,size_t> b1i({3,3,3},{5,5,5});
116 grid_key_dx_iterator_sub<3> it_sub2(gr,b1i.getKP1(),b1i.getKP2());
117
118 while (it_sub2.isNext())
119 {
120 auto p = it_sub2.get();
121
122 dcheck.add(gr.LinId(p));
123
124 ++it_sub2;
125 }
126
127 grid_key_dx<3> kk({6,5,5});
128 dcheck.add(gr.LinId(kk));
129
130 icheck.sort();
131 dcheck.sort();
132
133 for (size_t i = 0 ; i < icheck.size() ; i++)
134 {BOOST_REQUIRE_EQUAL(icheck.template get<0>(i),ic.template get<0>(i));}
135
136 for (size_t i = 0 ; i < dcheck.size() ; i++)
137 {BOOST_REQUIRE_EQUAL(dcheck.template get<0>(i),dc.template get<0>(i));}
138
139 #endif
140}
141
142
143BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
Definition Box.hpp:61
openfpm::vector< aggregate< ids_type >, Memory, layout_base > & getIcells()
Return the list of the internal cells.
void CalculateInternalCells(VCluster_type &v_cl, openfpm::vector< Box< dim, T >, Memory, layout_base > &ig_box, openfpm::vector< SpaceBox< dim, T >, Memory, layout_base > &domain, Box< dim, T > &pbox, T r_cut, const Ghost< dim, T > &enlarge)
Calculate the subdomain that are in the skin part of the domain.
openfpm::vector< aggregate< ids_type >, Memory, layout_base > & getDcells()
Return the list of the internal cells.
const grid_sm< dim, void > & getGrid()
Get the grid base information about this cell decomposition.
Declaration grid_key_dx_iterator_sub.
grid_key_dx is the key to access any element in the grid
Definition grid_key.hpp:19
Declaration grid_sm.
Definition grid_sm.hpp:167
mem_id LinId(const grid_key_dx< N, ids_type > &gk, const signed char sum_id[N]) const
Linearization of the grid_key_dx with a specified shift.
Definition grid_sm.hpp:454
structure that store and compute the internal and external local ghost box
Definition ie_ghost.hpp:48
Implementation of 1-D std::vector like structure.
size_t size()
Stub size.