7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for Mesh Manipulations"
10 #include <boost/test/unit_test.hpp>
35 using namespace boost;
47 m_argc = boost::unit_test::framework::master_test_suite().argc;
48 m_argv = boost::unit_test::framework::master_test_suite().argv;
72 PE::Comm::instance().init(m_argc,m_argv);
80 boost::shared_ptr< MeshGenerator > meshgenerator = build_component_abstract_type<MeshGenerator>(
"cf3.mesh.SimpleMeshGenerator",
"1Dgenerator");
81 meshgenerator->options().set(
"mesh",
URI(
"//line2"));
82 meshgenerator->options().set(
"nb_cells",std::vector<Uint>(1,10));
83 meshgenerator->options().set(
"lengths",std::vector<Real>(1,10.));
84 Mesh&
mesh = meshgenerator->generate();
95 BOOST_CHECK_NO_THROW( mesh_adaptor.
prepare() );
106 BOOST_CHECK_NO_THROW( mesh_adaptor.
remove_node(node) );
109 buf >> unpacked_elem >> unpacked_node;
112 BOOST_CHECK_NO_THROW( mesh_adaptor.
add_element(unpacked_elem) );
113 BOOST_CHECK_NO_THROW( mesh_adaptor.
add_node(unpacked_node) );
117 BOOST_CHECK_NO_THROW( mesh_adaptor.
finish() );
125 boost::shared_ptr< MeshGenerator > meshgenerator = build_component_abstract_type<MeshGenerator>(
"cf3.mesh.SimpleMeshGenerator",
"1Dgenerator");
126 meshgenerator->options().set(
"mesh",
URI(
"//line3"));
127 meshgenerator->options().set(
"nb_cells",std::vector<Uint>(1,10));
128 meshgenerator->options().set(
"lengths",std::vector<Real>(1,10.));
129 Mesh&
mesh = meshgenerator->generate();
142 BOOST_CHECK_EQUAL(mesh.
elements().size(), 3u);
144 std::vector< std::vector<std::vector<Uint> > > change_set(PE::Comm::instance().size(),
145 std::vector<std::vector<Uint> >(mesh.
elements().size()));
147 if (PE::Comm::instance().size() >= 2)
150 switch (PE::Comm::instance().rank())
154 change_set[1][0].push_back(4);
157 change_set[0][0].push_back(4);
163 BOOST_CHECK_NO_THROW( mesh_adaptor.
prepare() );
165 BOOST_CHECK_NO_THROW(mesh_adaptor.
move_elements(change_set));
169 BOOST_CHECK_NO_THROW( mesh_adaptor.
finish() );
179 boost::shared_ptr< MeshGenerator > meshgenerator = build_component_abstract_type<MeshGenerator>(
"cf3.mesh.SimpleMeshGenerator",
"1Dgenerator");
180 meshgenerator->options().set(
"mesh",
URI(
"//line"));
181 meshgenerator->options().set(
"nb_cells",std::vector<Uint>(1,10));
182 meshgenerator->options().set(
"lengths",std::vector<Real>(1,10.));
183 Mesh&
mesh = meshgenerator->generate();
194 if (PE::Comm::instance().size() == 2)
196 BOOST_CHECK_EQUAL(mesh.
elements()[0]->size(),4u);
197 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[0][0], 0u);
198 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[0][1], 1u);
199 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[1][0], 4u);
200 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[1][1], 5u);
201 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[2][0], 2u);
202 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[2][1], 3u);
208 if (PE::Comm::instance().size() == 2)
210 switch (PE::Comm::instance().rank())
213 BOOST_CHECK_EQUAL(mesh.
elements()[0]->size(),4u);
214 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[0][0], 0u);
215 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[0][1], 1u);
216 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[1][0], 4u);
217 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[1][1], 5u);
218 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[2][0], 2u);
219 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[2][1], 3u);
222 BOOST_CHECK_EQUAL(mesh.
elements()[0]->size(),4u);
223 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[0][0], 5u);
224 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[0][1], 6u);
225 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[1][0], 9u);
226 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[1][1], 10u);
227 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[2][0], 7u);
228 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[2][1], 8u);
238 BOOST_CHECK_EQUAL(entities_idx , 0u);
240 const Uint elem_idx = 1u;
248 const Uint dict_idx = 0u;
249 const Uint node_idx = 2u;
250 PackedNode packed_node(mesh,dict_idx,node_idx);
263 buf >> unpacked_elem;
264 buf >> unpacked_node;
268 BOOST_CHECK_EQUAL(unpacked_node.loc_idx(), packed_node.loc_idx());
269 BOOST_CHECK_EQUAL(unpacked_node.glb_idx(), packed_node.glb_idx());
270 BOOST_CHECK_EQUAL(unpacked_node.rank(), packed_node.rank());
271 BOOST_CHECK(unpacked_node.field_values() == packed_node.field_values());
276 if (PE::Comm::instance().size() == 2)
278 BOOST_CHECK_EQUAL(mesh.
elements()[0]->size(),4u);
279 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[0][0], 0u);
280 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[0][1], 1u);
281 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[1][0], 4u);
282 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[1][1], 5u);
283 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[2][0], 2u);
284 BOOST_CHECK_EQUAL(mesh.
elements()[0]->geometry_space().connectivity()[2][1], 3u);
293 PE::Comm::instance().finalize();
298 BOOST_AUTO_TEST_SUITE_END()
~MeshManipulationsTests_Fixture()
common tear-down for each test case
const std::vector< Handle< Entities > > & elements() const
external boost library namespace
void move_elements(const std::vector< std::vector< std::vector< Uint > > > &exported_elements_loc_id)
Move elements and attached nodes between processors, according to an elements_changeset.
void add_element(const PackedElement &packed_element)
Add element to the mesh.
int m_argc
possibly common functions used on the tests below
void remove_element(const PackedElement &packed_element)
Remove element from the mesh.
Class that contains all stand-alone global information of an element.
MeshManipulationsTests_Fixture()
common setup for each test case
void make_element_node_connectivity_global()
Element-node connectivity is replaced with global indices.
void flush_elements()
Apply all changes to elements.
void remove_node(const PackedNode &packed_node)
Remove node from the mesh.
void restore_element_node_connectivity()
Element-node connectivity is restored with local indices.
Class that contains all stand-alone global information of point in a dictionary.
Buffer that can hold multiple data types, useful for MPI communication.
Basic Classes for Mesh applications used by COOLFluiD.
Top-level namespace for coolfluid.
void rebuild_map_glb_to_loc()
void finish()
Apply the changes the mesh adaptor for changes and fix inconsistent state.
BOOST_AUTO_TEST_CASE(init_mpi)
void create_element_buffers()
Creates buffers for element changes.
unsigned int Uint
typedef for unsigned int
void prepare()
Prepare the mesh adaptor for changes.
void add_node(const PackedNode &packed_node)
Add node from the mesh.
Dictionary & geometry_fields() const
Most basic kernel library.
Handle< Component > access_component_checked(const URI &path)