COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-mesh-unified-data.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 cf3::mesh::UnifiedData<T>"
9 
10 #include <boost/test/unit_test.hpp>
11 
12 #include "common/Log.hpp"
13 #include "common/Core.hpp"
15 
16 #include "mesh/Mesh.hpp"
17 #include "mesh/Elements.hpp"
18 #include "mesh/Dictionary.hpp"
19 #include "mesh/MeshReader.hpp"
20 #include "mesh/UnifiedData.hpp"
22 
23 using namespace boost;
24 using namespace cf3;
25 using namespace cf3::mesh;
26 using namespace cf3::common;
27 
29 
31 {
34  {
35  // uncomment if you want to use arguments to the test executable
36  //int* argc = &boost::unit_test::framework::master_test_suite().argc;
37  //char*** argv = &boost::unit_test::framework::master_test_suite().argv;
38  }
39 
42  {
43  }
44 
46 
47 
49 
50 };
51 
53 
54 BOOST_FIXTURE_TEST_SUITE( UnifiedData_TestSuite, UnifiedData_Fixture )
55 
56 
58 BOOST_AUTO_TEST_CASE( Constructors)
59 {
60  boost::shared_ptr<UnifiedData> unified_elems = allocate_component<UnifiedData>("unified_elems");
61  BOOST_CHECK_EQUAL(unified_elems->name(),"unified_elems");
62  BOOST_CHECK_EQUAL(UnifiedData::type_name(), "UnifiedData");
63 }
64 
66 
67 BOOST_AUTO_TEST_CASE( data_location )
68 {
69  // create meshreader
70  boost::shared_ptr< MeshReader > meshreader = build_component_abstract_type<MeshReader>("cf3.mesh.neu.Reader","meshreader");
71 
72  BOOST_CHECK( true );
73 
74  Mesh& mesh = *Core::instance().root().create_component<Mesh>("mesh");
75  meshreader->read_mesh_into("../../resources/quadtriag.neu",mesh);
76 
77  BOOST_CHECK( true );
78 
79  boost::shared_ptr<UnifiedData> unified_elems = allocate_component<UnifiedData>("unified_elems");
80 
81 
82  boost_foreach(Elements& elements, find_components_recursively<Elements>(mesh))
83  unified_elems->add(elements);
84 
85 
86 
87 
88 
89  Handle< Component > elements;
90  Uint elem_idx;
91 
92  BOOST_CHECK_EQUAL( unified_elems->size() , 28u );
93  tie(elements,elem_idx) = unified_elems->location(25);
94 
95  for (Uint i=0; i<unified_elems->size(); ++i)
96  {
97  tie(elements,elem_idx) = unified_elems->location(i);
98  CFinfo << i << ": " << elements->uri().path() << " ["<<elem_idx<<"]" << CFendl;
99  }
100 
101  boost::shared_ptr<UnifiedData> unified_nodes = allocate_component<UnifiedData>("unified_nodes");
102  boost_foreach(Dictionary& nodes, find_components_recursively<Dictionary>(mesh))
103  unified_nodes->add(nodes);
104 
106  Uint node_idx;
107 
108  BOOST_CHECK_EQUAL( unified_nodes->size() , 16u );
109 
110  CFinfo << CFendl;
111  for (Uint i=0; i<unified_nodes->size(); ++i)
112  {
113  tie(nodes,node_idx) = unified_nodes->location(i);
114  CFinfo << i << ": " << nodes->uri().path() << " ["<<node_idx<<"]" << CFendl;
115  }
116 
117 }
118 
120 
121 BOOST_AUTO_TEST_SUITE_END()
122 
123 
#define CFinfo
these are always defined
Definition: Log.hpp:104
Safe pointer to an object. This is the supported method for referring to components.
Definition: Handle.hpp:39
external boost library namespace
std::string path() const
Definition: URI.cpp:253
URI uri() const
Construct the full path.
Definition: Component.cpp:248
std::string type_name(const boost::python::api::object &python_object)
Definition: PythonAny.cpp:283
#define boost_foreach
lowercase version of BOOST_FOREACH
Definition: Foreach.hpp:16
#define CFendl
Definition: Log.hpp:109
boost::proto::terminal< SFOp< NodesOp > >::type const nodes
UnifiedData_Fixture()
common setup for each test case
Basic Classes for Mesh applications used by COOLFluiD.
Top-level namespace for coolfluid.
Definition: Action.cpp:18
~UnifiedData_Fixture()
common tear-down for each test case
unsigned int Uint
typedef for unsigned int
Definition: CF.hpp:90
BOOST_AUTO_TEST_CASE(Constructors)
Most basic kernel library.
Definition: Action.cpp:19
Send comments to:
COOLFluiD Web Admin