COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-mesh-hash.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2013 von Karman Institute for Fluid Dynamics, Belgium
2 //
3 // This software is distributed under the terms of the
4 // GNU Lesser General Public License version 3 (LGPLv3).
5 // See doc/lgpl.txt and doc/gpl.txt for the license text.
6 
7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Tests mesh interpolation"
9 
10 #include <boost/test/unit_test.hpp>
11 #include "common/Log.hpp"
12 #include "common/OptionList.hpp"
13 
14 
17 
18 using namespace cf3;
19 using namespace cf3::common;
20 using namespace cf3::mesh;
21 
23 
25 {
28  {
29  // uncomment if you want to use arguments to the test executable
30  //int* argc = &boost::unit_test::framework::master_test_suite().argc;
31  //char*** argv = &boost::unit_test::framework::master_test_suite().argv;
32  }
33 
36  {
37  }
38 
40 
41 
43 
44 };
45 
47 
48 BOOST_FIXTURE_TEST_SUITE( TestParallelDistribution_TestSuite, TestParallelDistribution_Fixture )
49 
50 
52 BOOST_AUTO_TEST_CASE( Constructors)
53 {
54  boost::shared_ptr<ParallelDistribution> hash = allocate_component<ParallelDistribution>("hash");
55  BOOST_CHECK_EQUAL(hash->name(),"hash");
56 }
57 
59 
60 BOOST_AUTO_TEST_CASE( SingleHash )
61 {
62  boost::shared_ptr<ParallelDistribution> hash = allocate_component<ParallelDistribution>("hash");
63  hash->options().set("nb_obj", (Uint) 11);
64  hash->options().set("nb_parts", (Uint) 3);
65 
66  BOOST_CHECK(true);
67 
68  BOOST_CHECK_EQUAL(hash->part_of_obj(0), (Uint) 0);
69  BOOST_CHECK_EQUAL(hash->part_of_obj(2), (Uint) 0);
70  BOOST_CHECK_EQUAL(hash->part_of_obj(3), (Uint) 1);
71  BOOST_CHECK_EQUAL(hash->part_of_obj(5), (Uint) 1);
72  BOOST_CHECK_EQUAL(hash->part_of_obj(6), (Uint) 2);
73  BOOST_CHECK_EQUAL(hash->part_of_obj(10), (Uint) 2);
74 
75  BOOST_CHECK_EQUAL(hash->start_idx_in_part(0), (Uint) 0);
76  BOOST_CHECK_EQUAL(hash->start_idx_in_part(1), (Uint) 3);
77  BOOST_CHECK_EQUAL(hash->start_idx_in_part(2), (Uint) 6);
78 
79  BOOST_CHECK_EQUAL(hash->end_idx_in_part(0), (Uint) 3);
80  BOOST_CHECK_EQUAL(hash->end_idx_in_part(1), (Uint) 6);
81  BOOST_CHECK_EQUAL(hash->end_idx_in_part(2), (Uint) 11);
82 
83  BOOST_CHECK_EQUAL(hash->nb_objects_in_part(0), (Uint) 3);
84  BOOST_CHECK_EQUAL(hash->nb_objects_in_part(1), (Uint) 3);
85  BOOST_CHECK_EQUAL(hash->nb_objects_in_part(2), (Uint) 5);
86 }
87 
89 
91 {
92  boost::shared_ptr<MergedParallelDistribution> hash = allocate_component<MergedParallelDistribution>("hash");
93  std::vector<Uint> num_obj(2);
94  num_obj[0] = 10;
95  num_obj[1] = 8;
96  hash->options().set("nb_parts", (Uint) 3);
97  hash->options().set("nb_obj", num_obj);
98 
99  BOOST_CHECK(true);
100 
101  BOOST_CHECK_EQUAL(hash->subhash(0).part_of_obj(0), (Uint) 0);
102  BOOST_CHECK_EQUAL(hash->subhash(0).part_of_obj(3), (Uint) 1);
103  BOOST_CHECK_EQUAL(hash->subhash(0).part_of_obj(6), (Uint) 2);
104  BOOST_CHECK_EQUAL(hash->subhash(1).part_of_obj(0), (Uint) 0);
105  BOOST_CHECK_EQUAL(hash->subhash(1).part_of_obj(2), (Uint) 1);
106  BOOST_CHECK_EQUAL(hash->subhash(1).part_of_obj(4), (Uint) 2);
107 
108  BOOST_CHECK_EQUAL(hash->subhash(0).part_size(), (Uint) 3);
109  BOOST_CHECK_EQUAL(hash->subhash(1).part_size(), (Uint) 2);
110  BOOST_CHECK_EQUAL(hash->part_size(), (Uint) 5);
111 
112  BOOST_CHECK_EQUAL(hash->part_of_obj(0), (Uint) 0);
113  BOOST_CHECK_EQUAL(hash->part_of_obj(2), (Uint) 0);
114  BOOST_CHECK_EQUAL(hash->part_of_obj(3), (Uint) 0);
115  BOOST_CHECK_EQUAL(hash->part_of_obj(4), (Uint) 0);
116  BOOST_CHECK_EQUAL(hash->part_of_obj(5), (Uint) 1);
117  BOOST_CHECK_EQUAL(hash->part_of_obj(7), (Uint) 1);
118  BOOST_CHECK_EQUAL(hash->part_of_obj(8), (Uint) 1);
119  BOOST_CHECK_EQUAL(hash->part_of_obj(9), (Uint) 1);
120  BOOST_CHECK_EQUAL(hash->part_of_obj(10), (Uint) 2);
121  BOOST_CHECK_EQUAL(hash->part_of_obj(13), (Uint) 2);
122  BOOST_CHECK_EQUAL(hash->part_of_obj(14), (Uint) 2);
123  BOOST_CHECK_EQUAL(hash->part_of_obj(16), (Uint) 2);
124 
125  BOOST_CHECK_EQUAL(hash->start_idx_in_part(0), (Uint) 0);
126  BOOST_CHECK_EQUAL(hash->start_idx_in_part(1), (Uint) 5);
127  BOOST_CHECK_EQUAL(hash->start_idx_in_part(2), (Uint) 10);
128 
129  BOOST_CHECK_EQUAL(hash->end_idx_in_part(0), (Uint) 5);
130  BOOST_CHECK_EQUAL(hash->end_idx_in_part(1), (Uint) 10);
131  BOOST_CHECK_EQUAL(hash->end_idx_in_part(2), (Uint) 18);
132 
133  BOOST_CHECK_EQUAL(hash->nb_objects_in_part(0), (Uint) 5);
134  BOOST_CHECK_EQUAL(hash->nb_objects_in_part(1), (Uint) 5);
135  BOOST_CHECK_EQUAL(hash->nb_objects_in_part(2), (Uint) 8);
136 
137 
138  BOOST_CHECK_EQUAL(hash->subhash_of_obj(0), (Uint) 0);
139  BOOST_CHECK_EQUAL(hash->subhash_of_obj(2), (Uint) 0);
140  BOOST_CHECK_EQUAL(hash->subhash_of_obj(3), (Uint) 1);
141  BOOST_CHECK_EQUAL(hash->subhash_of_obj(4), (Uint) 1);
142  BOOST_CHECK_EQUAL(hash->subhash_of_obj(5), (Uint) 0);
143  BOOST_CHECK_EQUAL(hash->subhash_of_obj(7), (Uint) 0);
144  BOOST_CHECK_EQUAL(hash->subhash_of_obj(8), (Uint) 1);
145  BOOST_CHECK_EQUAL(hash->subhash_of_obj(9), (Uint) 1);
146  BOOST_CHECK_EQUAL(hash->subhash_of_obj(10), (Uint) 0);
147  BOOST_CHECK_EQUAL(hash->subhash_of_obj(13), (Uint) 0);
148  BOOST_CHECK_EQUAL(hash->subhash_of_obj(14), (Uint) 1);
149  BOOST_CHECK_EQUAL(hash->subhash_of_obj(16), (Uint) 1);
150 
151 
152 }
153 
155 
156 BOOST_AUTO_TEST_SUITE_END()
157 
158 
~TestParallelDistribution_Fixture()
common tear-down for each test case
BOOST_AUTO_TEST_CASE(Constructors)
Basic Classes for Mesh applications used by COOLFluiD.
Top-level namespace for coolfluid.
Definition: Action.cpp:18
TestParallelDistribution_Fixture()
common setup for each test case
unsigned int Uint
typedef for unsigned int
Definition: CF.hpp:90
Most basic kernel library.
Definition: Action.cpp:19
Send comments to:
COOLFluiD Web Admin