7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for cf3::mesh::ptscotch"
10 #include <boost/test/unit_test.hpp>
11 #include <boost/assign/list_of.hpp>
37 using namespace boost;
51 m_argc = boost::unit_test::framework::master_test_suite().argc;
52 m_argv = boost::unit_test::framework::master_test_suite().argv;
67 SCOTCH_Num*
to_ptr(std::vector<SCOTCH_Num>& vec)
100 SCOTCH_dgraphSize(&graph,
106 proccnttab.resize(common::PE::Comm::instance().size());
107 procvrttab.resize(common::PE::Comm::instance().size()+1);
111 PE::Comm::instance().all_gather(vertlocnbr, proccnttab);
113 for (
Uint p=0;
p<proccnttab.size(); ++
p)
116 cnt += proccnttab[
p];
118 procvrttab[common::PE::Comm::instance().size()] = cnt;
121 if (SCOTCH_dgraphGhst(&graph))
125 SCOTCH_dgraphData(&graph,
148 if (SCOTCH_dgraphInit(&graph, common::PE::Comm::instance().communicator()))
151 if (SCOTCH_dgraphBuild(&graph,
156 to_ptr(vertloctab)+1,
166 gather_global_data();
173 if (common::PE::Comm::instance().rank() == 0)
180 CFinfo <<
"proccnttab = [ ";
181 for (
Uint i=0; i<common::PE::Comm::instance().size(); ++i)
182 CFinfo << proccnttab[i] <<
" ";
184 CFinfo <<
"procvrttab = [ ";
185 for (
Uint i=0; i<common::PE::Comm::instance().size()+1; ++i)
186 CFinfo << procvrttab[i] <<
" ";
192 bool original_filter =
CFinfo.getFilterRankZero(LogStream::SCREEN);
193 CFinfo.setFilterRankZero(LogStream::SCREEN,
false);
194 for (
Uint proc=0; proc<common::PE::Comm::instance().size(); ++proc)
196 if (common::PE::Comm::instance().rank() == proc)
204 CFinfo <<
"vertloctab = [ ";
205 for (
int i=0; i<vertlocnbr; ++i)
206 CFinfo << vertloctab[i] <<
" ";
210 CFinfo <<
"edgeloctab = [ ";
211 for (
int i=0; i<edgelocnbr; ++i)
212 CFinfo << edgeloctab[i] <<
" ";
215 CFinfo <<
"edgegsttab = [ ";
216 for (
int i=0; i<edgelocnbr; ++i)
217 CFinfo << edgegsttab[i] <<
" ";
223 common::PE::Comm::instance().barrier();
225 common::PE::Comm::instance().barrier();
226 CFinfo.setFilterRankZero(LogStream::SCREEN,original_filter);
231 SCOTCH_Strat stradat;
232 if(SCOTCH_stratInit(&stradat))
235 partloctab.resize(vertlocmax);
237 if (SCOTCH_dgraphPart(&graph,
243 SCOTCH_stratExit(&stradat);
248 bool original_filter =
CFinfo.getFilterRankZero(LogStream::SCREEN);
249 CFinfo.setFilterRankZero(LogStream::SCREEN,
false);
250 for (
Uint proc=0; proc<common::PE::Comm::instance().size(); ++proc)
252 if (common::PE::Comm::instance().rank() == proc)
260 for (
int i=0; i<vertlocnbr; ++i)
261 CFinfo << procvrttab[proc]+i <<
" goes to part " << partloctab[i] << CFendl;
265 common::PE::Comm::instance().barrier();
267 common::PE::Comm::instance().barrier();
268 CFinfo.setFilterRankZero(LogStream::SCREEN,original_filter);
284 common::PE::Comm::instance().init(m_argc,m_argv);
292 if (common::PE::Comm::instance().size() == 3)
295 CFinfo <<
"+++++++++++++++++++ building graph ++++++++++++++++++++ \n" <<
CFendl;
297 switch (common::PE::Comm::instance().rank())
301 vertloctab = list_of(0)(2)(6)(9) (0);
302 vertlocnbr=vertloctab.size()-2;
303 vertlocmax=vertlocnbr;
305 edgeloctab = list_of(2)(1)(2)(4)(3)(0)(3)(1)(0) (0)(0);
306 edgelocnbr = edgeloctab.size()-2;
307 edgelocsiz = edgeloctab.size();
308 edgegsttab.resize(edgeloctab.size());
313 vertloctab = list_of(0)(5)(8) (0);
314 vertlocnbr=vertloctab.size()-2;
315 vertlocmax=vertlocnbr;
317 edgeloctab = list_of(2)(5)(1)(7)(4)(7)(1)(3) (0)(0);
318 edgelocnbr = edgeloctab.size()-2;
319 edgelocsiz = edgeloctab.size();
320 edgegsttab.resize(edgeloctab.size());
325 vertloctab = list_of(0)(3)(5)(9) (0);
326 vertlocnbr=vertloctab.size()-2;
327 vertlocmax=vertlocnbr;
329 edgeloctab = list_of(3)(6)(7)(5)(7)(3)(5)(6)(4) (0)(0);
330 edgelocnbr = edgeloctab.size()-2;
331 edgelocsiz = edgeloctab.size();
332 edgegsttab.resize(edgeloctab.size());
339 BOOST_CHECK_EQUAL(SCOTCH_dgraphCheck(&graph),0);
341 CFinfo <<
"\n\n+++++++++++++++++++ graph info ++++++++++++++++++++ " <<
CFendl;
348 CFinfo <<
"\n\n+++++++++++++++++++ partitioning ++++++++++++++++++++ \n" <<
CFendl;
352 output_graph_partitions();
356 CFinfo <<
"must run this testcase with 3 processors" <<
CFendl;
364 boost::shared_ptr< MeshReader > meshreader = build_component_abstract_type<MeshReader>(
"cf3.mesh.neu.Reader",
"meshreader");
365 meshreader->options().set(
"read_boundaries",
false);
368 URI fp_in (
"file:../../resources/quadtriag.neu");
371 Mesh&
mesh = *Core::instance().root().create_component<
Mesh>(
"mesh");
372 meshreader->read_mesh_into(fp_in,mesh);
375 boost::shared_ptr< MeshTransformer > glb_numbering = build_component_abstract_type<MeshTransformer>(
"cf3.mesh.actions.GlobalNumbering",
"glb_numbering");
376 glb_numbering->transform(mesh);
379 boost::shared_ptr< MeshTransformer > glb_connectivity = build_component_abstract_type<MeshTransformer>(
"cf3.mesh.actions.GlobalConnectivity",
"glb_connectivity");
380 glb_connectivity->transform(mesh);
383 boost::shared_ptr< MeshWriter > meshwriter = build_component_abstract_type<MeshWriter>(
"cf3.mesh.gmsh.Writer",
"meshwriter");
384 URI fp_out_1 (
"file:quadtriag.msh");
385 meshwriter->write_from_to(mesh,fp_out_1);
388 boost::shared_ptr< MeshTransformer > partitioner_ptr = build_component_abstract_type<MeshTransformer>(
"cf3.mesh.ptscotch.Partitioner",
"partitioner");
391 BOOST_CHECK_EQUAL(p.name(),
"partitioner");
408 URI fp_out_2 (
"file:quadtriag_repartitioned.msh");
417 common::PE::Comm::instance().finalize();
422 BOOST_AUTO_TEST_SUITE_END()
#define CFinfo
these are always defined
external boost library namespace
std::vector< SCOTCH_Num > procvrttab
PTScotchTests_Fixture()
common setup for each test case
#define CF3_DEBUG_POINT
Definition of a macro for placing a debug point in the code.
std::vector< SCOTCH_Num > partloctab
BOOST_AUTO_TEST_CASE(init_mpi)
void gather_global_data()
Basic Classes for Mesh applications used by COOLFluiD.
void output_graph_partitions()
Top-level namespace for coolfluid.
std::vector< SCOTCH_Num > proccnttab
std::vector< SCOTCH_Num > edgeloctab
#define CFLogVar(x)
log the value of a variable
void partition_graph(const Uint nb_parts)
unsigned int Uint
typedef for unsigned int
std::vector< SCOTCH_Num > edgegsttab
std::vector< SCOTCH_Num > vertloctab
SCOTCH_Num * to_ptr(std::vector< SCOTCH_Num > &vec)
possibly common functions used on the tests below
~PTScotchTests_Fixture()
common tear-down for each test case
SCOTCH_Dgraph graph
common values accessed by all tests goes here
Most basic kernel library.