7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Tests mesh component classes"
10 #include <boost/test/unit_test.hpp>
11 #include <boost/foreach.hpp>
12 #include <boost/assign/list_of.hpp>
30 using namespace boost;
58 std::vector<Real> coordVec;
59 coordVec.assign(coord,coord+2);
77 boost::shared_ptr<Component>
root = boost::static_pointer_cast<
Component>(allocate_component<Group>(
"root"));
81 BOOST_CHECK_EQUAL ( mesh.
name() ,
"mesh" );
83 BOOST_CHECK_EQUAL ( mesh.
uri().
string() ,
"cpath:/mesh" );
87 BOOST_CHECK_EQUAL ( region1.uri().string() ,
"cpath:/mesh/topology/region1" );
93 region2.create_region(
"subregion1");
95 BOOST_CHECK_EQUAL ( subregion.
uri().
string() ,
"cpath:/mesh/topology/region2/subregion2" );
99 BOOST_CHECK_EQUAL (
find_component_with_name(subregion,
"connTable").
uri().
string() ,
"cpath:/mesh/topology/region2/subregion2/connTable" );
103 BOOST_CHECK_EQUAL (
find_component_with_name(subregion,
"elementType").
uri().
string() ,
"cpath:/mesh/topology/region2/subregion2/elementType" );
109 find_component_with_name<Region>(region2,
"subregion1").create_region(
"subsubregion1");
110 find_component_with_name<Region>(region2,
"subregion1").create_region(
"subsubregion2");
121 table->set_row_size(nbCols);
126 std::vector<Uint> row(nbCols);
129 for(
Uint i=0; i<nbCols; i++) row[i] = 0;
131 for(
Uint i=0; i<nbCols; i++) row[i] = 1;
133 for(
Uint i=0; i<nbCols; i++) row[i] = 2;
135 for(
Uint i=0; i<nbCols; i++) row[i] = 3;
143 BOOST_CHECK_EQUAL(table->array().size(),(
Uint) 0);
149 BOOST_CHECK_EQUAL(table->array().size(),(
Uint) 2);
150 BOOST_CHECK_EQUAL(table->array()[0][0], (
Uint) 1);
151 BOOST_CHECK_EQUAL(table->array()[1][0], (
Uint) 3);
156 for(
Uint i=0; i<nbCols; i++) row[i] = 4;
160 BOOST_CHECK_EQUAL(table->array().size(),(
Uint) 2);
164 BOOST_CHECK_EQUAL(table->array().size(),(
Uint) 1);
165 BOOST_CHECK_EQUAL(table->array()[0][0], (
Uint) 4);
177 table->set_row_size(nbCols);
190 table->set_row_size(nbCols);
195 std::vector<Uint> row(nbCols);
198 for(
Uint i=0; i<nbCols; i++) row[i] = 0;
200 for(
Uint i=0; i<nbCols; i++) row[i] = 1;
202 for(
Uint i=0; i<nbCols; i++) row[i] = 2;
204 BOOST_CHECK_EQUAL(buffer.total_allocated(), (
Uint) 3);
205 for(
Uint i=0; i<nbCols; i++) row[i] = 3;
208 BOOST_CHECK_EQUAL(buffer.total_allocated(), (
Uint) 6);
211 BOOST_CHECK_EQUAL(buffer.total_allocated(), (
Uint) 4);
212 BOOST_CHECK_EQUAL(table->array().size(),(
Uint) 4);
216 for(
Uint i=0; i<nbCols; i++) row[i] = 4;
219 for(
Uint i=0; i<nbCols; i++) row[i] = 5;
221 BOOST_CHECK_EQUAL(buffer.total_allocated(), (
Uint) 7);
225 BOOST_CHECK_EQUAL(buffer.total_allocated(), (
Uint) 5);
226 BOOST_CHECK_EQUAL(table->array().size(),(
Uint) 5);
227 BOOST_CHECK_EQUAL(table->array()[4][0],(
Uint) 5);
235 BOOST_CHECK_EQUAL(table->array().size(),(
Uint) 5);
240 BOOST_CHECK_EQUAL(table->array().size(),(
Uint) 2);
241 BOOST_CHECK_EQUAL(table->array()[0][0],(
Uint) 3);
242 BOOST_CHECK_EQUAL(table->array()[1][0],(
Uint) 5);
253 Logger::instance().getStream(
DEBUG).set_log_level(
SILENT);
255 boost::shared_ptr<Component>
root = boost::static_pointer_cast<
Component>(allocate_component<Group>(
"root"));
266 BOOST_CHECK_EQUAL(connTable.
size(),(
Uint) 0);
268 BOOST_CHECK_EQUAL(connTable.
array().num_elements(),(
Uint) 0);
275 BOOST_CHECK_EQUAL(connTable.
size(),(
Uint) 0);
277 BOOST_CHECK_EQUAL(connTable.
array().num_elements(),(
Uint) 0);
280 std::vector<Uint> row(nbCols);
281 for (
Uint i=0; i<nbCols; ++i)
284 tableBuffer.add_row(row);
286 BOOST_CHECK_EQUAL(connTable.
size(),(
Uint) 1);
288 BOOST_CHECK_EQUAL(connTable.
array().num_elements(),(
Uint) 5);
292 for (
Uint i=0; i<1023; ++i)
293 tableBuffer.add_row(row);
294 BOOST_CHECK_EQUAL(connTable.
size(),(
Uint) 1);
296 BOOST_CHECK_EQUAL(connTable.
array().num_elements(),(
Uint) 5);
298 tableBuffer.add_row(row);
300 BOOST_CHECK_EQUAL(connTable.
size(),(
Uint) 1025);
302 BOOST_CHECK_EQUAL(connTable.
array().num_elements(),(
Uint) 5*1025);
305 BOOST_CHECK_EQUAL(connTable[0][0], (
Uint) 0);
306 BOOST_CHECK_EQUAL(connTable[1][1], (
Uint) 1);
307 BOOST_CHECK_EQUAL(connTable[2][2], (
Uint) 2);
311 for (
Uint i=0; i<nbCols; ++i)
312 BOOST_CHECK_EQUAL(rowRef[i], i);
325 coordinates->set_row_size(dim);
326 BOOST_CHECK_EQUAL(coordinates->row_size(),dim);
330 coordinatesBuffer.
add_row(create_coord( 0.0 , 0.0 ));
331 coordinatesBuffer.add_row(create_coord( 1.0 , 0.0 ));
332 coordinatesBuffer.add_row(create_coord( 1.0 , 1.0 ));
333 coordinatesBuffer.add_row(create_coord( 0.0 , 1.0 ));
334 coordinatesBuffer.flush();
336 BOOST_CHECK_EQUAL(coordinates->array()[2][1], 1.0);
356 boost::shared_ptr<Component>
root = boost::static_pointer_cast<
Component>(allocate_component<Group>(
"root"));
361 BOOST_CHECK_EQUAL(find_components<Region>(subregion1).empty(),
true);
364 BOOST_CHECK_EQUAL(find_components<Region>(subregion1).empty(),
true);
368 BOOST_CHECK_EQUAL(find_components<Region>(subregion1).empty(),
false);
369 BOOST_CHECK_EQUAL(
count(find_components<Region>(regions)), (
Uint) 1);
374 regions.add_component(subregion2_ptr);
375 BOOST_CHECK_EQUAL(find_components<Region>(subregion1).empty(),
true);
376 BOOST_CHECK_EQUAL(
count(find_components<Region>(regions)), (
Uint) 2);
384 BOOST_CHECK_EQUAL(bool_list.
type_name(),
"List<bool>");
387 BOOST_CHECK_EQUAL(integer_list->
type_name(),
"List<integer>");
390 BOOST_CHECK_EQUAL(unsigned_list->type_name(),
"List<unsigned>");
393 BOOST_CHECK_EQUAL(real_list->type_name(),
"List<real>");
396 BOOST_CHECK_EQUAL(string_list->type_name(),
"List<string>");
399 BOOST_CHECK_EQUAL(bool_list.
size(),(
Uint) 10);
403 for (
Uint i=0; i<10; ++i)
409 BOOST_CHECK_EQUAL(bool_list[i],
true);
412 BOOST_CHECK_EQUAL(bool_list[i],
false);
418 BOOST_CHECK_EQUAL(bool_list.
size(),(
Uint) 20);
420 for (
Uint i=0; i<20; ++i)
426 BOOST_CHECK_EQUAL(bool_list[i],
true);
429 BOOST_CHECK_EQUAL(bool_list[i],
false);
441 table->set_row_size(nbCols);
446 std::vector<Uint> row(nbCols);
449 for(
Uint i=0; i<nbCols; i++) row[i] = 0;
451 for(
Uint i=0; i<nbCols; i++) row[i] = 1;
453 for(
Uint i=0; i<nbCols; i++) row[i] = 2;
455 for(
Uint i=0; i<nbCols; i++) row[i] = 3;
463 BOOST_CHECK_EQUAL(table->array().size(),(
Uint) 0);
469 BOOST_CHECK_EQUAL(table->array().size(),(
Uint) 2);
470 BOOST_CHECK_EQUAL(table->array()[0][0], (
Uint) 1);
471 BOOST_CHECK_EQUAL(table->array()[1][0], (
Uint) 3);
476 for(
Uint i=0; i<nbCols; i++) row[i] = 4;
480 BOOST_CHECK_EQUAL(table->array().size(),(
Uint) 2);
484 BOOST_CHECK_EQUAL(table->array().size(),(
Uint) 1);
485 BOOST_CHECK_EQUAL(table->array()[0][0], (
Uint) 4);
508 BOOST_CHECK_EQUAL(buffer.total_allocated(), (
Uint) 3);
513 BOOST_CHECK_EQUAL(buffer.total_allocated(), (
Uint) 6);
516 BOOST_CHECK_EQUAL(buffer.total_allocated(), (
Uint) 4);
517 BOOST_CHECK_EQUAL(list.
size(),(
Uint) 4);
527 BOOST_CHECK_EQUAL(buffer.total_allocated(), (
Uint) 7);
531 BOOST_CHECK_EQUAL(buffer.total_allocated(), (
Uint) 5);
532 BOOST_CHECK_EQUAL(list.
size(),(
Uint) 5);
533 BOOST_CHECK_EQUAL(list[4],(
Uint) 5);
541 BOOST_CHECK_EQUAL(list.
size(),(
Uint) 5);
546 BOOST_CHECK_EQUAL(list.
size(),(
Uint) 2);
547 BOOST_CHECK_EQUAL(list[0],(
Uint) 3);
548 BOOST_CHECK_EQUAL(list[1],(
Uint) 5);
560 std::vector<Uint> row;
563 for(
Uint i=0; i<row.size(); i++) row[i] = 0;
567 for(
Uint i=0; i<row.size(); i++) row[i] = 1;
571 for(
Uint i=0; i<row.size(); i++) row[i] = 2;
575 for(
Uint i=0; i<row.size(); i++) row[i] = 3;
578 BOOST_CHECK_EQUAL(table.
size(), (
Uint) 0);
582 BOOST_CHECK_EQUAL(table.
size(), (
Uint) 4);
584 BOOST_CHECK_EQUAL(table[0][0], (
Uint) 0);
585 BOOST_CHECK_EQUAL(table[0].size(), (
Uint) 3);
588 BOOST_CHECK_EQUAL(table[1][0], (
Uint) 1);
589 BOOST_CHECK_EQUAL(table[1].size(), (
Uint) 4);
593 BOOST_CHECK_EQUAL(table[2][0], (
Uint) 2);
594 BOOST_CHECK_EQUAL(table[2].size(), (
Uint) 6);
598 BOOST_CHECK_EQUAL(table[3][0], (
Uint) 3);
599 BOOST_CHECK_EQUAL(table[3].size(), (
Uint) 2);
606 for(
Uint i=0; i<row.size(); i++) row[i] = 4;
611 for(
Uint i=0; i<row.size(); i++) row[i] = 5;
618 BOOST_CHECK_EQUAL(table.
size(),(
Uint) 5);
619 BOOST_CHECK_EQUAL(table[4][0],(
Uint) 5);
630 BOOST_CHECK_EQUAL(table.
size(),(
Uint) 5);
637 BOOST_CHECK_EQUAL(table.
size(),(
Uint) 2);
639 BOOST_CHECK_EQUAL(table[0][0],(
Uint) 3);
642 BOOST_CHECK_EQUAL(table[1][0],(
Uint) 5);
663 std::vector<Uint> row;
674 row = list_of(1)(4)(5);
706 boost::shared_ptr<Component>
root = boost::static_pointer_cast<
Component>(allocate_component<Group>(
"root"));
717 Logger::instance().getStream(
DEBUG).set_log_level(
SILENT);
719 boost::shared_ptr<Component>
root = boost::static_pointer_cast<
Component>(allocate_component<Group>(
"root"));
721 boost::shared_ptr<Mesh>
mesh = allocate_component<Mesh> (
"mesh" ) ;
723 root->add_component( mesh );
732 BOOST_CHECK_EQUAL(connTable.
size(),(
Uint) 0);
733 BOOST_CHECK_EQUAL(connTable.
array().num_elements(),(
Uint) 0);
738 BOOST_CHECK_EQUAL(connTable.
size(),(
Uint) 0);
739 BOOST_CHECK_EQUAL(connTable.
array().num_elements(),(
Uint) 0);
743 tableBuffer.add_row(0);
745 BOOST_CHECK_EQUAL(connTable.
size(),(
Uint) 1);
746 BOOST_CHECK_EQUAL(connTable.
array().num_elements(),(
Uint) 1);
749 for (
Uint i=0; i<10; ++i)
750 tableBuffer.add_row(1);
751 BOOST_CHECK_EQUAL(connTable.
size(),(
Uint) 1);
752 BOOST_CHECK_EQUAL(connTable.
array().num_elements(),(
Uint) 1);
754 tableBuffer.add_row(1);
756 BOOST_CHECK_EQUAL(connTable.
size(),(
Uint) 12);
757 BOOST_CHECK_EQUAL(connTable.
array().num_elements(),(
Uint) 12);
760 BOOST_CHECK_EQUAL(connTable[0], (
Uint) 0);
761 BOOST_CHECK_EQUAL(connTable[1], (
Uint) 1);
762 BOOST_CHECK_EQUAL(connTable[2], (
Uint) 1);
767 tableBuffer.rm_row(0);
768 tableBuffer.add_row(2);
769 tableBuffer.add_row(3);
770 tableBuffer.add_row(4);
771 tableBuffer.add_row(5);
772 tableBuffer.add_row(6);
773 tableBuffer.rm_row(2);
774 tableBuffer.rm_row(13);
779 tableBuffer.rm_row(2);
780 tableBuffer.rm_row(5);
781 tableBuffer.rm_row(7);
782 tableBuffer.rm_row(3);
783 tableBuffer.add_row(10);
784 tableBuffer.add_row(10);
794 Logger::instance().getStream(
DEBUG).set_log_level(
SILENT);
796 boost::shared_ptr<Component>
root = boost::static_pointer_cast<
Component>(allocate_component<Group>(
"root"));
798 boost::shared_ptr<Mesh>
mesh = allocate_component<Mesh> (
"mesh" ) ;
800 root->add_component( mesh );
823 BOOST_CHECK_EQUAL( list[0] , 0u);
824 BOOST_CHECK_EQUAL( list[1] , 1u);
825 BOOST_CHECK_EQUAL( list[2] , 2u);
826 BOOST_CHECK_EQUAL( list[3] , 3u);
827 BOOST_CHECK_EQUAL( list[4] , 6u);
828 BOOST_CHECK_EQUAL( list[5] , 7u);
829 BOOST_CHECK_EQUAL( list[6] , 8u);
836 BOOST_CHECK_EQUAL( list[0] , 7u);
837 BOOST_CHECK_EQUAL( list[1] , 1u);
838 BOOST_CHECK_EQUAL( list[2] , 2u);
839 BOOST_CHECK_EQUAL( list[3] , 8u);
845 Logger::instance().getStream(
DEBUG).set_log_level(
SILENT);
847 boost::shared_ptr<Component>
root = boost::static_pointer_cast<
Component>(allocate_component<Group>(
"root"));
849 boost::shared_ptr<Mesh>
mesh = allocate_component<Mesh> (
"mesh" ) ;
851 root->add_component( mesh );
860 BOOST_CHECK_EQUAL(connTable.
size(),(
Uint) 0);
861 BOOST_CHECK_EQUAL(connTable.
array().num_elements(),(
Uint) 0);
866 BOOST_CHECK_EQUAL(connTable.
size(),(
Uint) 0);
867 BOOST_CHECK_EQUAL(connTable.
array().num_elements(),(
Uint) 0);
871 tableBuffer.add_row(
false);
873 BOOST_CHECK_EQUAL(connTable.
size(),(
Uint) 1);
874 BOOST_CHECK_EQUAL(connTable.
array().num_elements(),(
Uint) 1);
876 for (
Uint i=0; i<10; ++i)
877 tableBuffer.add_row(
true);
878 BOOST_CHECK_EQUAL(connTable.
size(),(
Uint) 1);
879 BOOST_CHECK_EQUAL(connTable.
array().num_elements(),(
Uint) 1);
880 BOOST_CHECK_EQUAL(tableBuffer.get_row(10),
true);
882 tableBuffer.add_row(
true);
884 BOOST_CHECK_EQUAL(connTable.
size(),(
Uint) 12);
885 BOOST_CHECK_EQUAL(connTable.
array().num_elements(),(
Uint) 12);
888 BOOST_CHECK_EQUAL(connTable[0],
false);
889 BOOST_CHECK_EQUAL(connTable[1],
true);
890 BOOST_CHECK_EQUAL(connTable[2],
true);
895 tableBuffer.rm_row(0);
897 BOOST_CHECK_EQUAL(connTable[0],
true);
906 BOOST_AUTO_TEST_SUITE_END()
#define CFinfo
these are always defined
external boost library namespace
void resize(const Uint new_size)
void initialize_nodes(const Uint nb_nodes, const Uint dimension)
will among others set the coordinate dimension for the nodes
BOOST_AUTO_TEST_CASE(MeshComponentTest)
Uint add_row(const vectorType &row)
static std::string type_name()
URI uri() const
Construct the full path.
Region & create_region(const std::string &name)
Buffer create_buffer(const size_t buffersize=16384)
common::URI uri(ComponentWrapper &self)
MeshComponent_Fixture()
common setup for each test case
const std::string & name() const
Access the name of the component.
const Field & coordinates() const
boost::proto::terminal< SFOp< NodesOp > >::type const nodes
Component & root
common values accessed by all tests goes here
Uint row_size(const Uint i) const
ComponentReference< Component >::type find_component_with_name(Component &parent, StringConverter name)
Basic Classes for Mesh applications used by COOLFluiD.
Top-level namespace for coolfluid.
std::string tree(bool basic_mode=false, Uint depth=0, Uint recursion_level=0) const
~MeshComponent_Fixture()
common tear-down for each test case
Uint row_size(Uint i=0) const
boost::proto::terminal< SFOp< CoordinatesOp > >::type const coordinates
void set_row_size(const Uint nb_cols)
boost::shared_ptr< Component > remove_component(const std::string &name)
Remove a (sub)component of this component.
unsigned int Uint
typedef for unsigned int
Buffer create_buffer(const size_t buffersize=16384)
Buffer create_buffer(const size_t buffersize=16384)
Region & topology() const
std::vector< Real > create_coord(const Real &x, const Real &y)
possibly common functions used on the tests below
Dictionary & geometry_fields() const
Base class for defining CF components.
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.
Most basic kernel library.
std::string string() const
Uint count(const RangeT &range)
Count the elements in a range.
boost::shared_ptr< T > allocate_component(const std::string &name)
Stand-alone function to allocate components of a given type.