OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
help_functions_unit_test.cpp
1//
2// Created by jstark on 03.01.22.
3//
4#define BOOST_TEST_DYN_LINK
5#include <boost/test/unit_test.hpp>
6
7// Include header files for testing
10
11BOOST_AUTO_TEST_SUITE(HelpFunctionsTestSuite)
12 const size_t Field = 0;
13
14 BOOST_AUTO_TEST_CASE(get_min_val_test)
15 {
16 const size_t grid_dim = 1;
17 const double box_lower = -1.0;
18 const double box_upper = 1.0;
19 Box<grid_dim, double> box({box_lower}, {box_upper});
21 typedef aggregate<double> props;
23 const size_t sz[grid_dim] = {32};
24 grid_type g_dist(sz, box, ghost);
25
26 // Each processor assigns smaller_value to the first grid node in its domain
27 double smaller_value = 0.1;
28 auto dom = g_dist.getDomainIterator();
29 auto key_0 = dom.get();
30 g_dist.template get<Field>(key_0) = smaller_value;
31 ++dom;
32
33 // Afterwards we loop over the other grid nodes and assign them another bigger number
34 double bigger_value = 0.5;
35 while(dom.isNext())
36 {
37 auto key = dom.get();
38 g_dist.template get<Field>(key) = bigger_value;
39 ++dom;
40 }
41
42 // Now we check if get_min_value returns smaller_value
43 auto min_value = get_min_val<Field>(g_dist);
44 double tolerance = 1e-12;
45//BOOST_CHECK_MESSAGE(isApproxEqual(min_value, smaller_value, tolerance), "Checking if smallest value stored "
46// "in grid "
47// "is returned.");
48 }
49
50 BOOST_AUTO_TEST_CASE(get_max_val_test)
51 {
52 const size_t grid_dim = 1;
53 const double box_lower = -1.0;
54 const double box_upper = 1.0;
55 Box<grid_dim, double> box({box_lower}, {box_upper});
57 typedef aggregate<double> props;
59 const size_t sz[grid_dim] = {32};
60 grid_type g_dist(sz, box, ghost);
61
62 // Each processor assigns smaller_value to the first grid node in its domain
63 double smaller_value = 0.1;
64 auto dom = g_dist.getDomainIterator();
65 auto key_0 = dom.get();
66 g_dist.template get<Field>(key_0) = smaller_value;
67 ++dom;
68
69 // Afterwards we loop over the other grid nodes and assign them another bigger number
70 double bigger_value = 0.5;
71 while(dom.isNext())
72 {
73 auto key = dom.get();
74 g_dist.template get<Field>(key) = bigger_value;
75 ++dom;
76 }
77
78 // Now we check if get_max_value returns bigger_value
79 auto max_value = get_max_val<Field>(g_dist);
80 double tolerance = 1e-12;
81// BOOST_CHECK_MESSAGE(isApproxEqual(max_value, bigger_value, tolerance), "Checking if smallest value stored in "
82// "grid "
83// "is returned.");
84 }
85BOOST_AUTO_TEST_SUITE_END()
Header file containing help-functions that perform on OpenFPM-grids.
Header file containing small mathematical help-functions that are needed e.g. for the Sussman redista...
This class represent an N-dimensional box.
Definition Box.hpp:61
Definition eq.hpp:83
This is a distributed grid.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...