7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for ConnectivityData"
10 #include <boost/assign/list_of.hpp>
11 #include <boost/test/unit_test.hpp>
52 boost::shared_ptr< MeshReader > meshreader = build_component_abstract_type<MeshReader>(
"cf3.mesh.neu.Reader",
"meshreader");
55 meshreader->read_mesh_into(
"../../resources/quadtriag.neu",*
mesh2d);
56 meshreader->read_mesh_into(
"../../resources/hextet.neu",*mesh3d);
76 BOOST_FOREACH(
const FaceConnectivity& face_connectivity, find_components_recursively<FaceConnectivity>(root))
78 CFinfo <<
"------------------------- Connectivity for " << face_connectivity.
parent()->uri().base_path().string() <<
"/" << face_connectivity.
parent()->name() <<
" -------------------------" <<
CFendl;
80 const Uint nb_elements = celements->geometry_space().connectivity().array().size();
81 const Uint nb_faces = celements->element_type().nb_faces();
84 for(
Uint face = 0; face != nb_faces; ++face)
90 CFinfo <<
"Face " << face <<
" of element " <<
elem <<
" is connected to face " << face_connectivity.
adjacent_face(
elem, face) <<
" of element " << connected.second <<
" of Elements " << connected_entities.
uri().
string() <<
CFendl;
94 CFinfo <<
"Face " << face <<
" of element " <<
elem <<
" has no neighbour" <<
CFendl;
107 BOOST_AUTO_TEST_SUITE( ConnectivityDataSuite )
113 boost::shared_ptr<NodeConnectivity> node_conn = common::allocate_component<NodeConnectivity>(
"node_conn");
114 node_conn->initialize(find_components_recursively<Elements>(*
mesh2d));
116 for(
Uint i = 0; i != node_conn->entities().size(); ++i)
120 BOOST_CHECK_EQUAL(node_conn->entities().size(),
static_cast<Uint>(6));
137 for(
Uint i = 0; i != node_first_elements.size(); ++i)
139 CFinfo <<
"Node " << i <<
" is used by elements";
140 const Uint elements_begin = node_first_elements[i];
141 const Uint elements_end = elements_begin + node_element_counts[i];
142 for(
Uint j = elements_begin; j != elements_end; ++j)
144 CFinfo <<
" " << node_elements[j].first <<
", " << node_elements[j].second;
148 CFinfo <<
"node_elements = ";
149 for(
Uint i = 0; i != node_elements.size(); ++i)
150 CFinfo <<
"(std::make_pair(" << node_elements[i].first <<
", " << node_elements[i].second <<
"))";
153 NodeConnectivity::NodeElementsT reference = boost::assign::list_of(std::make_pair(1, 0))(std::make_pair(1, 1))(std::make_pair(1, 0))(std::make_pair(1, 1))(std::make_pair(1, 1))(std::make_pair(2, 2))(std::make_pair(2, 3))(std::make_pair(1, 0))(std::make_pair(2, 1))(std::make_pair(1, 0))(std::make_pair(1, 1))(std::make_pair(2, 0))(std::make_pair(2, 1))(std::make_pair(2, 3))(std::make_pair(0, 4))(std::make_pair(0, 5))(std::make_pair(2, 0))(std::make_pair(2, 1))(std::make_pair(0, 0))(std::make_pair(0, 1))(std::make_pair(2, 2))(std::make_pair(0, 0))(std::make_pair(0, 4))(std::make_pair(0, 9))(std::make_pair(2, 0))(std::make_pair(2, 2))(std::make_pair(2, 3))(std::make_pair(0, 5))(std::make_pair(0, 6))(std::make_pair(0, 1))(std::make_pair(0, 2))(std::make_pair(0, 6))(std::make_pair(0, 7))(std::make_pair(0, 3))(std::make_pair(0, 7))(std::make_pair(0, 8))(std::make_pair(0, 2))(std::make_pair(0, 3))(std::make_pair(0, 0))(std::make_pair(0, 1))(std::make_pair(0, 2))(std::make_pair(0, 3))(std::make_pair(0, 8))(std::make_pair(0, 9))(std::make_pair(0, 4))(std::make_pair(0, 5))(std::make_pair(0, 6))(std::make_pair(0, 7))(std::make_pair(0, 8))(std::make_pair(0, 9));
155 vector_test(node_elements, reference, accumulator);
181 create_face_element_connectivity(*entities.back(), entities, node_first_elements, node_element_counts, node_elements, face_has_neighbour, face_element_connectivity, face_face_connectivity);
184 const Entities& elements = *entities.back();
185 for(
Uint element_idx = 0; element_idx != elements.geometry_space().connectivity().array().size(); ++element_idx)
188 for(
Uint face_idx = 0; face_idx != nb_faces; ++face_idx)
190 const Uint global_face_idx = element_idx*nb_faces + face_idx;
191 if(face_has_neighbour[global_face_idx])
194 const Uint neighbour_entities_idx = neighbour_elem_ref.first;
195 const Uint neighbour_local_idx = neighbour_elem_ref.second;
196 CFinfo <<
"Face " << face_idx <<
" of element " << element_idx <<
" is connected to face " << face_face_connectivity[global_face_idx] <<
" of element (" << neighbour_entities_idx <<
", " << neighbour_local_idx <<
")" <<
CFendl;
200 CFinfo <<
"Face " << face_idx <<
" of element " << element_idx <<
" has no neighbour" <<
CFendl;
204 CFinfo <<
"face_element_connectivity = ";
205 for(
Uint i = 0; i != face_element_connectivity.size(); ++i)
206 CFinfo <<
"(std::make_pair(" << face_element_connectivity[i].first <<
", " << face_element_connectivity[i].second <<
"))";
210 NodeConnectivity::NodeElementsT reference = boost::assign::list_of(std::make_pair(2, 3))(std::make_pair(0, 4))(std::make_pair(2, 1))(std::make_pair(2, 0))(std::make_pair(0, 0))(std::make_pair(1, 0))(std::make_pair(0, 0))(std::make_pair(0, 0))(std::make_pair(2, 3))(std::make_pair(2, 2))(std::make_pair(2, 0))(std::make_pair(1, 1));
212 vector_test(face_element_connectivity, reference, accumulator);
310 CFinfo <<
"Node " << i <<
" is used by elements";
313 for(
Uint j = elements_begin; j != elements_end; ++j)
338 BOOST_AUTO_TEST_SUITE_END()
std::vector< ElementReferenceT > NodeElementsT
Type of the container used to store the actual connectivity.
#define CFinfo
these are always defined
void initialize(const EntitiesT &entities)
const EntitiesT & entities() const
Access to the raw data.
Fixture providing a simple mesh read from a .neu file. Unprofiled.
ElementType & element_type() const
return the elementType
URI uri() const
Construct the full path.
std::vector< bool > BoolsT
Storage for a list of boolean values.
std::vector< Uint > CountsT
Storage for counted numbers.
std::vector< Handle< Entities const > > EntitiesT
Storage for a list of Entities components.
Profile and time tests using this fixture.
void create_face_element_connectivity(const Entities &own_celements, const NodeConnectivity::EntitiesT &entities, const NodeConnectivity::IndicesT &node_first_elements, const NodeConnectivity::CountsT &node_element_counts, const NodeConnectivity::NodeElementsT &node_elements, FaceConnectivity::BoolsT &face_has_neighbour, NodeConnectivity::NodeElementsT &face_element_connectivity, NodeConnectivity::IndicesT &face_face_connectivity)
std::vector< Uint > IndicesT
Storage for indices into other arrays.
Real min(const Real a, const Real b)
Minimum between two scalars.
ConnectivityFixture()
common setup for each test case
Handle< Component > parent() const
Basic Classes for Mesh applications used by COOLFluiD.
ElementReferenceT adjacent_element(const Uint element, const Uint face) const
Get the element that is adjacent to the given face of the given element.
MeshSourceGlobalFixture< 1000 > MeshSource
Define the global fixture type.
std::pair< Uint, Uint > ElementReferenceT
Uniquely refer an element by its index into the list of entities and it's local element index...
Top-level namespace for coolfluid.
BOOST_FIXTURE_TEST_CASE(CreateElementVector, ConnectivityFixture)
const NodeConnectivity & node_connectivity() const
boost::proto::terminal< SFOp< CoordinatesOp > >::type const coordinates
common::Component & root() const
Gives the default root component.
const CountsT & node_element_counts() const
unsigned int Uint
typedef for unsigned int
BOOST_GLOBAL_FIXTURE(GlobalFixture) BOOST_AUTO_TEST_CASE(MeshStats)
Accumulate some statistics about the cell volumes.
const NodeElementsT & node_elements() const
const IndicesT & node_first_elements() const
Handle< Component > handle()
Get a handle to the component.
Uint adjacent_face(const Uint element, const Uint face) const
Get the face that is adjacent to the given face of the given element.
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.
void create_node_element_connectivity(const Uint nb_nodes, const NodeConnectivity::EntitiesT &entities, NodeConnectivity::IndicesT &node_first_elements, NodeConnectivity::CountsT &node_element_counts, NodeConnectivity::NodeElementsT &node_elements)
Most basic kernel library.
std::string string() const
bool has_adjacent_element(const Uint element, const Uint face) const
True if the given face of the given element has an adjacent element.
void print_connectivity(const Component &root, const bool print_empty=true)
Print out the connectivity information.