OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
main.cpp
1 /*
2  * ### WIKI 1 ###
3  *
4  * ## Security enhancement example
5  *
6  * This example show how to see where an allocation or corruption happen offline and online.
7  * Every time an error occur, the library output where the detection happen filename and line,
8  * in order to debug, there is an online option and an offline option
9  *
10  * * online: put a breakpoint on the indicated line with your preferred debugger
11  * * offline: set ulimit -c unlimited to activate the core dump file and open the core dump with your debugger
12  *
13  */
14 
15 #define SE_CLASS1
16 #define SE_CLASS2
17 #define SE_CLASS3
18 #define THROW_ON_ERROR
19 #include "Memleak_check.hpp"
20 #include "Grid/grid_dist_id.hpp"
21 #include "Decomposition/CartDecomposition.hpp"
22 #include "Point_test.hpp"
23 
24 /*
25  * ### WIKI END ###
26  */
27 
28 
29 int main(int argc, char* argv[])
30 {
31  //
32  // ### WIKI 2 ###
33  //
34  // Here we Initialize the library,
35  // * message_on_allocation set a message to print when one allocation is reached, the filename and line number can be used to set a breakpoint and analyze the stacktrace.
36  // * throw_on_allocation throw when one allocation is reached, producing the termination of the program and a core dump (if no try catch is set-up)
37  //
38  openfpm_init(&argc,&argv);
39  Vcluster & v_cl = create_vcluster();
40 
41  throw_on_alloc(10);
42  // message_on_alloc(10);
43 
44  //
45  // ### WIKI 3 ###
46  //
47  // Create several object needed later, in particular
48  // * A 3D box that define the domain
49  // * an array of 3 unsigned integer that define the size of the grid on each dimension
50  // * A Ghost object that will define the extension of the ghost part for each sub-domain in physical units
51  Box<3,float> domain({0.0,0.0,0.0},{1.0,1.0,1.0});
52  size_t sz[3];
53  sz[0] = 100;
54  sz[1] = 100;
55  sz[2] = 100;
56 
57  // Ghost
58  Ghost<3,float> g(0.01);
59 
60  //
61  // ### WIKI 4 ###
62  //
63  // Create a distributed grid in 3D (1° template parameter) defined in R^3 with float precision (2° template parameter)
64  // using a CartesianDecomposition strategy (3° parameter) (the parameter 1° and 2° inside CartDecomposition must match 1° and 2°
65  // of grid_dist_id)
66  //
67  // Constructor parameters:
68  //
69  // * sz: size of the grid on each dimension
70  // * domain: where the grid is defined
71  // * g: ghost extension
72  //
73  //
75 
76  //
77  // ### WIKI 6 ###
78  //
79  // print allocated structures
80  //
81 
82  if (v_cl.getProcessUnitID() == 0)
83  print_alloc();
84 
85  //
86  // ### WIKI 5 ###
87  //
88  // delete g_dist
89  //
90 
91  delete g_dist;
92 
93  //
94  // ### WIKI 6 ###
95  //
96  // On purpose we try to access a deleted object
97  //
98 
99  g_dist->getGridInfo();
100 
101  //
102  // ### WIKI 13 ###
103  //
104  // Deinitialize the library
105  //
106  openfpm_finalize();
107 }
108 
size_t getProcessUnitID()
Get the process unit id.
const grid_sm< dim, T > & getGridInfo() const
Get an object containing the grid informations.
Definition: Ghost.hpp:39
Implementation of VCluster class.
Definition: VCluster.hpp:36
This class decompose a space into sub-sub-domains and distribute them across processors.
This is a distributed grid.