7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for cf3::Component"
12 #include <boost/mpl/if.hpp>
13 #include <boost/test/unit_test.hpp>
14 #include <boost/random/mersenne_twister.hpp>
15 #include <boost/random/uniform_int_distribution.hpp>
16 #include <boost/random/uniform_real_distribution.hpp>
35 rank(common::PE::Comm::instance().rank()),
37 int_table_size(10000+1000*rank),
38 real_table_size(20000+2000*rank),
39 int_list_size(30000-3000*rank),
40 real_list_size(40000+4000*rank)
47 typedef typename boost::mpl::if_< typename boost::is_integral<T>::type, boost::random::uniform_int_distribution<T>, boost::random::uniform_real_distribution<T> >::type distribution_type;
48 distribution_type dist(0, 1);
51 for(
Uint i = 0; i != nb_rows; ++i)
53 for(
Uint j = 0; j != nb_cols; ++j)
55 table[i][j] = dist(gen);
63 typedef typename boost::mpl::if_< typename boost::is_integral<T>::type, boost::random::uniform_int_distribution<T>, boost::random::uniform_real_distribution<T> >::type distribution_type;
64 distribution_type dist(0, 1);
66 for(
Uint i = 0; i != nb_rows; ++i)
75 for(
Uint i = 0; i != nb_rows; ++i)
77 list[i] = (i % 2 == 0);
83 boost::random::mt19937 gen;
85 const Uint int_table_size;
86 static const Uint int_table_cols = 3;
87 const Uint real_table_size;
88 static const Uint real_table_cols = 8;
90 const Uint int_list_size;
91 const Uint real_list_size;
113 int_table1.set_row_size(int_table_cols);
114 int_table1.resize(int_table_size);
115 fill_table(int_table1);
117 int_table2.
resize(int_table_size);
118 int_table2.
array() = int_table1.array();
119 array_differ->
options().
set(
"left", int_table1.handle());
120 array_differ->options().set(
"right", int_table2.
handle());
121 array_differ->execute();
122 BOOST_CHECK(array_differ->properties().value<
bool>(
"arrays_equal"));
123 int_table2[rank][rank] += rank+1;
124 array_differ->execute();
125 BOOST_CHECK(!array_differ->properties().value<
bool>(
"arrays_equal"));
130 real_table1.
resize(real_table_size);
132 real_table2.
resize(real_table_size);
133 fill_table(real_table1);
135 array_differ->options().set(
"left", real_table1.
handle());
136 array_differ->options().set(
"right", real_table2.
handle());
137 array_differ->execute();
138 BOOST_CHECK(array_differ->properties().value<
bool>(
"arrays_equal"));
139 real_table2[rank][rank] +=
static_cast<Real
>(rank+1)*1
e-18;
140 array_differ->execute();
141 BOOST_CHECK(array_differ->properties().value<
bool>(
"arrays_equal"));
142 real_table2[rank][rank] +=
static_cast<Real
>(rank+1)*1
e-15;
143 array_differ->execute();
144 BOOST_CHECK(!array_differ->properties().value<
bool>(
"arrays_equal"));
148 int_list1.
resize(int_list_size);
149 int_list2.
resize(int_list_size);
150 fill_list( int_list1 );
152 array_differ->options().set(
"left", int_list1.
handle());
153 array_differ->options().set(
"right", int_list2.
handle());
154 array_differ->execute();
155 BOOST_CHECK(array_differ->properties().value<
bool>(
"arrays_equal"));
156 int_list1[rank] += rank+1;
157 array_differ->execute();
158 BOOST_CHECK(!array_differ->properties().value<
bool>(
"arrays_equal"));
162 real_list1.
resize(real_list_size);
163 real_list2.
resize(real_list_size);
164 fill_list( real_list1 );
166 array_differ->options().set(
"left", real_list1.
handle());
167 array_differ->options().set(
"right", real_list2.
handle());
168 array_differ->execute();
169 BOOST_CHECK(array_differ->properties().value<
bool>(
"arrays_equal"));
170 real_list2[rank] +=
static_cast<Real
>(rank+1)*1
e-18;
171 array_differ->execute();
172 BOOST_CHECK(array_differ->properties().value<
bool>(
"arrays_equal"));
173 real_list2[rank] +=
static_cast<Real
>(rank+1)*1
e-14;
174 array_differ->execute();
175 BOOST_CHECK(!array_differ->properties().value<
bool>(
"arrays_equal"));
179 bool_list1.
resize(int_list_size);
180 bool_list2.
resize(int_list_size);
181 fill_list( bool_list1 );
183 array_differ->options().set(
"left", bool_list1.
handle());
184 array_differ->options().set(
"right", bool_list2.
handle());
185 array_differ->execute();
186 BOOST_CHECK(array_differ->properties().value<
bool>(
"arrays_equal"));
187 bool_list1[rank] = !bool_list2[rank];
188 array_differ->execute();
189 BOOST_CHECK(!array_differ->properties().value<
bool>(
"arrays_equal"));
194 BOOST_AUTO_TEST_SUITE_END()
196
Safe pointer to an object. This is the supported method for referring to components.
void resize(const Uint new_size)
void fill_list(common::List< bool > &list)
BOOST_AUTO_TEST_CASE(InitMPI)
Real e()
Definition of the Unit charge [C].
void fill_table(common::Table< T > &table)
void fill_list(common::List< T > &list)
void init(int argc=0, char **args=0)
Top-level namespace for coolfluid.
Component holding a 1 dimensional array of a templated type.
Component holding a 2 dimensional array of a templated type.
Uint row_size(Uint i=0) const
void set_row_size(const Uint nb_cols)
common::Component & root() const
Gives the default root component.
static boost::proto::terminal< ExpressionGroupTag >::type group
Use group(expr1, expr2, ..., exprN) to evaluate a group of expressions.
common::Environment & environment() const
unsigned int Uint
typedef for unsigned int
Handle< Component > handle()
Get a handle to the component.
static Comm & instance()
Return a reference to the current PE.
Base class for defining CF components.
void set(const std::string &pname, const boost::any &val)
Handle< Component > create_component(const std::string &name, const std::string &builder)
Build a (sub)component of this component using the extended type_name of the component.
virtual void resize(const Uint nb_rows)