COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-mesh-node-element-connectivity.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::NodeElementConnectivity"
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/Region.hpp"
20 #include "mesh/MeshReader.hpp"
22 #include "mesh/Connectivity.hpp"
23 
24 using namespace boost;
25 using namespace cf3;
26 using namespace cf3::mesh;
27 using namespace cf3::common;
28 
30 
32 {
35  {
36  // uncomment if you want to use arguments to the test executable
37  //int* argc = &boost::unit_test::framework::master_test_suite().argc;
38  //char*** argv = &boost::unit_test::framework::master_test_suite().argv;
39  }
40 
43  {
44  }
45 
47 
48 
50 
51 };
52 
54 
55 BOOST_FIXTURE_TEST_SUITE( NodeElementConnectivity_TestSuite, NodeElementConnectivity_Fixture )
56 
57 
59 BOOST_AUTO_TEST_CASE( Constructors)
60 {
61  boost::shared_ptr<NodeElementConnectivity> c = allocate_component<NodeElementConnectivity>("nodes_to_elements");
62  BOOST_CHECK_EQUAL(c->name(),"nodes_to_elements");
63  BOOST_CHECK_EQUAL(NodeElementConnectivity::type_name(), "NodeElementConnectivity");
64 }
65 
67 
68 BOOST_AUTO_TEST_CASE( node_elem_connectivity )
69 {
70  // create meshreader
71  boost::shared_ptr< MeshReader > meshreader = build_component_abstract_type<MeshReader>("cf3.mesh.neu.Reader","meshreader");
72 
73  Mesh& mesh = *Core::instance().root().create_component<Mesh>("quadtriag");
74  meshreader->read_mesh_into("../../resources/quadtriag.neu",mesh);
75 
76  BOOST_CHECK( true );
77 
78  // create and setup node to elements connectivity
79  Handle<NodeElementConnectivity> c = mesh.create_component<NodeElementConnectivity>("node_elem_connectivity");
80  c->setup( find_component<Region>(mesh) );
81 
82  BOOST_CHECK( true );
83 
84  // Output whole node to elements connectivity
85  CFinfo << c->connectivity() << CFendl;
86 
87  // Output connectivity of node 10
88  DynTable<Uint>::ConstRow elements = c->connectivity()[10];
89  CFinfo << CFendl << "node 10 is connected to elements: \n";
90  boost_foreach(const Uint elem, elements)
91  {
92  Handle< Component > connected_comp;
93  Uint connected_idx;
94  tie(connected_comp,connected_idx) = c->elements().location(elem);
95  CFinfo << " " << connected_comp->uri().path() << " [" <<connected_idx << "] " << CFendl;
96  }
97  CFinfo << CFendl;
98 }
99 
101 
102 BOOST_AUTO_TEST_SUITE_END()
103 
104 
#define CFinfo
these are always defined
Definition: Log.hpp:104
common::DynTable< Uint > & connectivity()
const access to the node to element connectivity table in unified indices
~NodeElementConnectivity_Fixture()
common tear-down for each test case
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
NodeElementConnectivity_Fixture()
common setup for each test case
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_AUTO_TEST_CASE(Constructors)
Basic Classes for Mesh applications used by COOLFluiD.
Top-level namespace for coolfluid.
Definition: Action.cpp:18
boost::tuple< Handle< common::Component >, Uint > location(const Uint data_glb_idx)
Definition: UnifiedData.cpp:78
unsigned int Uint
typedef for unsigned int
Definition: CF.hpp:90
Most basic kernel library.
Definition: Action.cpp:19
const std::vector< T > & ConstRow
Definition: DynTable.hpp:38
Send comments to:
COOLFluiD Web Admin