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;
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;
66 for(
Uint i = 0; i != nb_rows; ++i)
74 boost::random::mt19937
gen;
77 static const Uint int_table_cols = 3;
79 static const Uint real_table_cols = 8;
102 int_table.
resize(int_table_size);
103 fill_table(int_table);
107 real_table.
resize(real_table_size);
108 fill_table(real_table);
111 int_list.
resize(int_list_size);
115 real_list.
resize(real_list_size);
116 fill_list(real_list);
128 empty_real_table.set_row_size(real_table_cols);
158 BOOST_CHECK_EQUAL(read_int_table.
row_size(), write_int_table->row_size());
159 BOOST_CHECK_EQUAL(read_int_table.
size(), write_int_table->size());
160 BOOST_CHECK(read_int_table.
array() == write_int_table->array());
161 BOOST_CHECK(read_real_table.
array() == write_real_table->array());
162 BOOST_CHECK(read_real_list.
array() == write_real_list->array());
163 BOOST_CHECK(read_int_list.
array() == write_int_list->array());
171 BOOST_CHECK_EQUAL(empty_real_list.size(), 0);
172 BOOST_CHECK_EQUAL(empty_real_table.
size(), 0);
173 BOOST_CHECK_EQUAL(empty_real_table.row_size(), 8);
178 BOOST_AUTO_TEST_SUITE_END()
180
void resize(const Uint new_size)
void close()
Close the current file.
boost::random::mt19937 gen
Uint append_data(const Table< T > &table)
Append a new data block containing data from the supplied table. An index into the current file is re...
Real max(const Real a, const Real b)
Maximum between two scalars.
void read_list(List< T > &list, const Uint block_idx)
Read the given block into the supplied list. The list is resized as needed.
const Uint real_list_size
void fill_table(common::Table< T > &table)
Real min(const Real a, const Real b)
Minimum between two scalars.
const Uint int_table_size
void fill_list(common::List< T > &list)
Handle< Component > get_child(const std::string &name)
void init(int argc=0, char **args=0)
void read_table(Table< T > &table, const Uint block_idx)
Read the given block into the supplied table. The table is resized as needed.
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
const Uint real_table_size
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
BOOST_AUTO_TEST_CASE(InitMPI)
static Comm & instance()
Return a reference to the current PE.
Base class for defining CF components.
Component for writing binary data collected into a single file.
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)
Component for writing binary data collected into a single file.