Back to index

salome-med  6.5.0
ParaMEDSPLITTERTest_ParaDomainSelector.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 // File      : ParaMEDSPLITTERTest_ParaDomainSelector.cxx
00020 // Created   : Tue Jul 21 16:25:50 2009
00021 // Author    : Edward AGAPOV (eap)
00022 
00023 #include "ParaMEDSPLITTERTest.hxx"
00024 #include "MEDSPLITTERTest_Utils.hxx"
00025 
00026 #include "MEDSPLITTER_ParaDomainSelector.hxx"
00027 #include "MEDSPLITTER_UserGraph.hxx"
00028 #include "MEDSPLITTER_JointExchangeData.hxx"
00029 #include "MEDSPLITTER_FaceModel.hxx"
00030 
00031 #include <MEDMEM_Meshing.hxx>
00032 #include <MEDMEM_Grid.hxx>
00033 #include <MEDMEM_ConnectZone.hxx>
00034 
00035 #include <cppunit/TestAssert.h>
00036 #include <set>
00037 
00038 using namespace std;
00039 using namespace MEDSPLITTER;
00040 using namespace MED_EN;
00041 
00042 //================================================================================
00046 //================================================================================
00047 
00048 void ParaMEDSPLITTERTest::testParaDomainSelector_gatherGraph()
00049 {
00050   int world_size;
00051   MPI_Comm_size(MPI_COMM_WORLD,&world_size);
00052 
00053   if ( world_size != 2 )
00054     return;
00055 
00056   // Combine two equal graphs:
00057   // index: [ 1, 3, 6 ]
00058   // value: [ 1, 2, 1, 2, 3]
00059   // partition: [ 0, 1 ]
00060   //
00061   // Expect to get:
00062   // index: [ 1, 3, 6, 8, 11 ]
00063   // value: [ 1, 2, 1, 2, 3, 1, 2, 1, 2, 3]
00064   // partition: [ 0, 1, 0, 1 ]
00065 
00066   ParaDomainSelector dom_sel;
00067   CPPUNIT_ASSERT_NO_THROW( dom_sel.isOnDifferentHosts() );
00068 #ifdef _DEBUG_
00069   cout << "On different hosts = " << dom_sel.isOnDifferentHosts() << endl;
00070 #endif
00071 
00072   // Let ParaDomainSelector know domain sizes
00073 
00074   MEDMEM::MESHING meshing;
00075   int nb_elems[] = { 2 }; medGeometryElement type = MED_POINT1;
00076   meshing.setNumberOfTypes   ( 1, MED_CELL );
00077   meshing.setTypes           ( &type, MED_CELL );
00078   meshing.setNumberOfElements( nb_elems, MED_CELL );
00079 
00080   vector<MEDMEM::MESH*> domain_meshes(2, (MEDMEM::MESH*)0);
00081   domain_meshes[ dom_sel.rank() ] = &meshing;
00082   dom_sel.gatherNbOf( MED_CELL, domain_meshes );
00083 
00084   // Make the graph
00085 
00086   int index[] = { 1, 3, 6 };
00087   int value[] = { 1, 2, 1, 2, 3 };
00088   int* partition = new int[2];
00089   partition[0]=0; partition[1] = 1;
00090   MEDMEM::MEDSKYLINEARRAY* array = new MEDMEM::MEDSKYLINEARRAY( 2, 5, index, value);
00091   auto_ptr<Graph> graph( new UserGraph( array, partition, 2 ));
00092 
00093   // Gather graphs
00094 
00095   auto_ptr<Graph> glob_graph( dom_sel.gatherGraph( graph.get() ));
00096 
00097   const int* ind = glob_graph->getGraph()->getIndex();
00098   const int* val = glob_graph->getGraph()->getValue();
00099   const int* part= glob_graph->getPart();
00100 
00101   CPPUNIT_ASSERT_EQUAL( 4, glob_graph->getGraph()->getNumberOf() );
00102   CPPUNIT_ASSERT_EQUAL( index[0], ind[0] );
00103   CPPUNIT_ASSERT_EQUAL( index[1], ind[1] );
00104   CPPUNIT_ASSERT_EQUAL( index[2], ind[2] );
00105   CPPUNIT_ASSERT_EQUAL( index[2]+ind[1]-ind[0], ind[3] );
00106   CPPUNIT_ASSERT_EQUAL( index[2]+ind[2]-ind[0], ind[4] );
00107 
00108   CPPUNIT_ASSERT_EQUAL( 10, glob_graph->getGraph()->getLength() );
00109   CPPUNIT_ASSERT_EQUAL( value[0], val[0] );
00110   CPPUNIT_ASSERT_EQUAL( value[1], val[1] );
00111   CPPUNIT_ASSERT_EQUAL( value[2], val[2] );
00112   CPPUNIT_ASSERT_EQUAL( value[3], val[3] );
00113   CPPUNIT_ASSERT_EQUAL( value[4], val[4] );
00114   CPPUNIT_ASSERT_EQUAL( value[0], val[5] );
00115   CPPUNIT_ASSERT_EQUAL( value[1], val[6] );
00116   CPPUNIT_ASSERT_EQUAL( value[2], val[7] );
00117   CPPUNIT_ASSERT_EQUAL( value[3], val[8] );
00118   CPPUNIT_ASSERT_EQUAL( value[4], val[9] );
00119 
00120   CPPUNIT_ASSERT_EQUAL( partition[0], part[0] );
00121   CPPUNIT_ASSERT_EQUAL( partition[1], part[1] );
00122   CPPUNIT_ASSERT_EQUAL( partition[0], part[2] );
00123   CPPUNIT_ASSERT_EQUAL( partition[1], part[3] );
00124 }
00125 
00126 //================================================================================
00130 //================================================================================
00131 
00132 void ParaMEDSPLITTERTest::testParaDomainSelector_gatherNbOf ()
00133 {
00134   int world_size;
00135   MPI_Comm_size(MPI_COMM_WORLD,&world_size);
00136 
00137   if ( world_size != 2 )
00138     return;
00139 
00140   string filename = MEDSPLITTERTest_Utils::getResourceFile("square1_split1.med");
00141   string meshname  = "Mesh_2_1";
00142 
00143   ParaDomainSelector dom_sel;
00144 
00145   MEDMEM::MESH mesh_full( MEDMEM::MED_DRIVER, filename, meshname);
00146   MEDMEM::MESH mesh_empty;
00147 
00148   vector<MEDMEM::MESH*> meshes(2);
00149   meshes[0] = & mesh_full;
00150   meshes[1] = & mesh_empty;
00151   if ( dom_sel.rank() > 0 )
00152     swap( meshes[0], meshes[1] );
00153 
00154   // test gatherNbOf( MED_CELL )
00155   int nb_cells, init_nb_cells = mesh_full.getNumberOfElements( MED_CELL, MED_ALL_ELEMENTS );
00156   CPPUNIT_ASSERT_NO_THROW( nb_cells = dom_sel.gatherNbOf( MED_CELL, meshes ));
00157   CPPUNIT_ASSERT_EQUAL( 2 * init_nb_cells, nb_cells );
00158 
00159   // test gatherNbOf( MED_EDGE )
00160   int nb_edges, init_nb_edges = mesh_full.getNumberOfElements( MED_EDGE, MED_ALL_ELEMENTS );
00161   CPPUNIT_ASSERT_NO_THROW( nb_edges = dom_sel.gatherNbOf( MED_EDGE, meshes ));
00162   CPPUNIT_ASSERT_EQUAL( 2 * init_nb_edges, nb_edges );
00163 
00164   // test getNbVertOfProcs()
00165   int* nb_cell_by_proc;
00166   CPPUNIT_ASSERT_NO_THROW( nb_cell_by_proc = dom_sel.getNbVertOfProcs() );
00167   CPPUNIT_ASSERT_EQUAL( init_nb_cells, nb_cell_by_proc[1]-nb_cell_by_proc[0] );
00168   CPPUNIT_ASSERT_EQUAL( init_nb_cells, nb_cell_by_proc[2]-nb_cell_by_proc[1] );
00169 
00170   // test getProcShift()
00171   if ( dom_sel.rank() == 0 )
00172     CPPUNIT_ASSERT_EQUAL( 0, dom_sel.getProcShift() );
00173   else
00174     CPPUNIT_ASSERT_EQUAL( init_nb_cells, dom_sel.getProcShift() );
00175 
00176   CPPUNIT_ASSERT_EQUAL( 0, dom_sel.getDomainShift(0) );
00177   CPPUNIT_ASSERT_EQUAL( init_nb_cells, dom_sel.getDomainShift(1) );
00178 }
00179 
00180 //================================================================================
00184 //================================================================================
00185 
00186 void ParaMEDSPLITTERTest::testParaDomainSelector_gatherEntityTypesInfo ()
00187 {
00188   int world_size;
00189   MPI_Comm_size(MPI_COMM_WORLD,&world_size);
00190 
00191   if ( world_size != 2 )
00192     return;
00193 
00194   string filename = MEDSPLITTERTest_Utils::getResourceFile("square1_split1.med");
00195   string meshname  = "Mesh_2_1";
00196 
00197   ParaDomainSelector dom_sel;
00198 
00199   MEDMEM::MESH mesh_full( MEDMEM::MED_DRIVER, filename, meshname);
00200   MEDMEM::MESH mesh_empty;
00201 
00202   vector<MEDMEM::MESH*> meshes(2);
00203   meshes[0] = & mesh_full;
00204   meshes[1] = & mesh_empty;
00205   if ( dom_sel.rank() > 0 )
00206     swap( meshes[0], meshes[1] );
00207 
00208   // ---------------
00209   // test for cells
00210   // ---------------
00211 
00212   const medGeometryElement * init_cell_types = mesh_full.getTypes               (MED_CELL);
00213   const int * init_cell_nb_index             = mesh_full.getGlobalNumberingIndex(MED_CELL);
00214   int nb_init_cell_types                     = mesh_full.getNumberOfTypes       (MED_CELL);
00215 
00216   // pass info on cell types from mesh_full on other proc to mesh_empty on this proc
00217   CPPUNIT_ASSERT_NO_THROW( dom_sel.gatherEntityTypesInfo( meshes, MED_CELL ));
00218 
00219   const medGeometryElement * got_cell_types = mesh_empty.getTypes               (MED_CELL);
00220   const int * got_cell_nb_index             = mesh_empty.getGlobalNumberingIndex(MED_CELL);
00221   int nb_got_cell_types                     = mesh_empty.getNumberOfTypes       (MED_CELL);
00222 
00223   // check that we got the same info
00224   CPPUNIT_ASSERT_EQUAL( nb_init_cell_types, nb_got_cell_types);
00225   CPPUNIT_ASSERT_EQUAL( nb_init_cell_types, mesh_full.getNumberOfTypes(MED_CELL));
00226   CPPUNIT_ASSERT_EQUAL( init_cell_types,    mesh_full.getTypes (MED_CELL));
00227   for ( int i = 0; i < nb_got_cell_types; ++i )
00228   {
00229     CPPUNIT_ASSERT_EQUAL( init_cell_types[i], got_cell_types[i] );
00230     CPPUNIT_ASSERT_EQUAL( mesh_full.getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS ),
00231                           mesh_empty.getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS ));
00232     CPPUNIT_ASSERT_EQUAL( init_cell_nb_index[ i+1 ], got_cell_nb_index[ i+1 ]);
00233   }
00234 
00235   // test for faces - there are no faces
00236   CPPUNIT_ASSERT_THROW( dom_sel.gatherEntityTypesInfo( meshes, MED_FACE ), MED_EXCEPTION);
00237 
00238   // ---------------
00239   // test for edges
00240   // ---------------
00241 
00242   const medGeometryElement * init_edge_types = mesh_full.getTypes               (MED_EDGE);
00243   const int * init_edge_nb_index             = mesh_full.getGlobalNumberingIndex(MED_EDGE);
00244   int nb_init_edge_types                     = mesh_full.getNumberOfTypes       (MED_EDGE);
00245 
00246   // pass info on edge types from mesh_full on other proc to mesh_empty on this proc
00247   CPPUNIT_ASSERT_NO_THROW( dom_sel.gatherEntityTypesInfo( meshes, MED_EDGE ));
00248 
00249   const medGeometryElement * got_edge_types = mesh_empty.getTypes               (MED_EDGE);
00250   const int * got_edge_nb_index             = mesh_empty.getGlobalNumberingIndex(MED_EDGE);
00251   int nb_got_edge_types                     = mesh_empty.getNumberOfTypes       (MED_EDGE);
00252 
00253   // check that we got the same info
00254   CPPUNIT_ASSERT_EQUAL( nb_init_edge_types, nb_got_edge_types);
00255   CPPUNIT_ASSERT_EQUAL( nb_init_edge_types, mesh_full.getNumberOfTypes(MED_EDGE));
00256   CPPUNIT_ASSERT_EQUAL( init_edge_types,    mesh_full.getTypes (MED_EDGE));
00257   for ( int i = 0; i < nb_got_edge_types; ++i )
00258   {
00259     CPPUNIT_ASSERT_EQUAL( init_edge_types[i], got_edge_types[i] );
00260     CPPUNIT_ASSERT_EQUAL( mesh_full.getNumberOfElements(MED_EDGE, MED_ALL_ELEMENTS ),
00261                           mesh_empty.getNumberOfElements(MED_EDGE, MED_ALL_ELEMENTS ));
00262     CPPUNIT_ASSERT_EQUAL( init_edge_nb_index[ i+1 ], got_edge_nb_index[ i+1 ]);
00263   }
00264 }
00265 
00266 void ParaMEDSPLITTERTest::testParaDomainSelector_gatherNbCellPairs ()
00267 {
00268   int world_size;
00269   MPI_Comm_size(MPI_COMM_WORLD,&world_size);
00270 
00271   if ( world_size != 2 )
00272     return;
00273 
00274   ParaDomainSelector dom_sel;
00275   CPPUNIT_ASSERT_EQUAL( 2, dom_sel.nbProcs() );
00276 
00277   // imagine we have 5 domains
00278   const int nb_domains = 5;
00279   dom_sel.setNbDomains(nb_domains);
00280 
00281   // ----------------------------------------
00282   // test isMyDomain() and getProccessorID()
00283   // ----------------------------------------
00284   set<int> doms_here;
00285   for ( int idomain = 0; idomain < nb_domains; ++idomain )
00286     if ( dom_sel.isMyDomain( idomain ))
00287     {
00288       doms_here.insert( idomain );
00289       CPPUNIT_ASSERT_EQUAL( dom_sel.getProccessorID( idomain ), dom_sel.rank() );
00290     }
00291   CPPUNIT_ASSERT( doms_here.size() == 2 || doms_here.size() == 3 );
00292 
00293   // ---------------
00294   // test jointId()
00295   // ---------------
00296   set<int> joint_ids;
00297   set< pair< int, int> > dom_pairs;
00298   for ( int idom1 = 0; idom1 < nb_domains; ++idom1 )
00299     for ( int idom2 = 0; idom2 < nb_domains; ++idom2 )
00300       if ( idom1 != idom2 )
00301       {
00302         joint_ids.insert( dom_sel.jointId( idom1, idom2 ));
00303         dom_pairs.insert( idom1 < idom2 ? make_pair( idom1, idom2 ) : make_pair( idom2, idom1 ));
00304       }
00305   CPPUNIT_ASSERT_EQUAL( dom_pairs.size(), joint_ids.size() );
00306 
00307   // -------------------------
00308   // test gatherNbCellPairs()
00309   // -------------------------
00310   joint_ids.clear();
00311   int nb_interproc_pairs = 0, nb_local_pairs = 0, total_joint_size = 0;
00312   for ( int idom1 = 0; idom1 < nb_domains; ++idom1 )
00313     for ( int idom2 = idom1+1; idom2 < nb_domains; ++idom2 )
00314     {
00315       // gather data for further checks
00316       int nb_doms_here   = doms_here.count( idom1 ) + doms_here.count( idom2 );
00317       bool is_inter_proc = ( nb_doms_here == 1 );
00318       bool is_local      = ( nb_doms_here%2 == 0 );
00319       int nb_pairs       = dom_sel.jointId( idom1, idom2 );
00320       total_joint_size += nb_pairs;
00321       if ( is_inter_proc ) nb_interproc_pairs += nb_pairs;
00322       if ( is_local      ) nb_local_pairs     += nb_pairs;
00323       if ( nb_doms_here == 0 || idom1 == idom2 ) continue;
00324       // set data to ParaDomainSelector
00325       if ( is_inter_proc && doms_here.count( idom1 ) ||
00326            is_local      && nb_doms_here == 2 )
00327       {
00328         dom_sel.setNbCellPairs( nb_pairs, idom1, idom2 );
00329       }
00330     }
00331   dom_sel.gatherNbCellPairs();
00332   //CPPUNIT_ASSERT_EQUAL( nb_local_pairs, dom_sel.getNbSubentitiesWithoutProcJoints() );
00333 
00334   for ( int idom1 = 0; idom1 < nb_domains; ++idom1 )
00335     for ( int idom2 = 0; idom2 < nb_domains; ++idom2 )
00336     {
00337       //int nb_doms_here = doms_here.count( idom1 ) + doms_here.count( idom2 );
00338       int nb_pairs_expect = dom_sel.jointId( idom1, idom2 );
00339       if ( int nb_pairs = dom_sel.getNbCellPairs( idom1, idom2 ))
00340       {
00341         CPPUNIT_ASSERT_EQUAL( nb_pairs_expect, nb_pairs );
00342         int fisrt_id = dom_sel.getFisrtGlobalIdOfSubentity( idom1, idom2 );
00343         CPPUNIT_ASSERT(0 < fisrt_id && fisrt_id <= total_joint_size);
00344       }
00345     }
00346 }
00347 
00348 //================================================================================
00352 //================================================================================
00353 
00354 void ParaMEDSPLITTERTest::testParaDomainSelector_exchangeJoint ()
00355 {
00356   int world_size;
00357   MPI_Comm_size(MPI_COMM_WORLD,&world_size);
00358 
00359   if ( world_size != 2 )
00360     return;
00361 
00362   ParaDomainSelector dom_sel;
00363 
00364   // Exchange a joint between two grids with following global ids
00365   //    5     6      6     9
00366   //   *-----*      *-----*
00367   //   |     |      |     |
00368   //   |  2  |      |  4  |
00369   //   |3    |4     |4    |8
00370   //   *-----*      *-----*
00371   //   |     |      |     |
00372   //   |  1  |      |  3  |
00373   //   |1    |2     |2    |7
00374   //   *-----*      *-----*
00375   
00376   // make grids; actually we make one grid as their connectivities are same and
00377   // coordinates doesn't matter here
00378   const MEDMEM::MESH* grid = 0;
00379   {
00380     const int dim = 2;
00381     vector<vector<double> > xyz_array(dim);
00382     vector<string>          coord_name(dim,"coo");
00383     vector<string>          unit(dim,"m");
00384 
00385     xyz_array[0].resize(2, 0.);
00386     xyz_array[1].resize(3, 0.);
00387     MEDMEM::GRID tmpGrid( xyz_array, coord_name, unit );
00388     grid = tmpGrid.convertInMESH();
00389   }
00390 
00391   // global ids
00392   int cells1[] = { 1, 2 };
00393   int cells2[] = { 3, 4 };
00394   int nodes1[] = { 1, 2, 3, 4, 5, 6 };
00395   int nodes2[] = { 2, 7, 4, 8, 6, 9 };
00396   int* cells_here = dom_sel.rank() ? cells2 : cells1;
00397   int* cells_dist = dom_sel.rank() ? cells2 : cells1;
00398   int* nodes_here = dom_sel.rank() ? nodes2 : nodes1;
00399   //int* nodes_dist = dom_sel.rank() ? nodes2 : nodes1;
00400 
00401   int dom_here = dom_sel.isMyDomain( 0 ) ? 0 : 1;
00402   int dom_dist = 1 - dom_here;
00403 
00404   // store cell/cell correspondencies
00405   JointExchangeData joint;
00406   joint.addCellCorrespondence( grid, dom_dist, dom_here, cells_dist[0], cells_here[0], 1 );
00407   joint.addCellCorrespondence( grid, dom_dist, dom_here, cells_dist[1], cells_here[1], 2 );
00408   CPPUNIT_ASSERT_EQUAL( 2, joint.nbCellPairs());
00409 
00410   // prepare to exchangeJoint()
00411   joint.setMeshes( dom_dist, grid, dom_here, grid );
00412   CPPUNIT_ASSERT_EQUAL( dom_dist, joint.distantDomain() );
00413   CPPUNIT_ASSERT_EQUAL( dom_here, joint.localDomain() );
00414 
00415   joint.setConnectivity( nodes_here );
00416   // in general case we woul need to call dom_sel.gatherEntityTypesInfo() but grid
00417   // knows nb of elements without connectivity initialization
00418   CPPUNIT_ASSERT_THROW( dom_sel.exchangeJoint( & joint ), MED_EXCEPTION);
00419   dom_sel.setNbDomains( 2 );
00420   dom_sel.setNbCellPairs( 2, dom_dist, dom_here );
00421   dom_sel.gatherNbCellPairs();
00422   CPPUNIT_ASSERT_NO_THROW( dom_sel.exchangeJoint( & joint ));
00423 
00424   // get CONNECTZONE
00425   const int joint_edge_glob_id = 100;
00426   joint.setFisrtGlobalIdOfSubentity( joint_edge_glob_id );
00427   TGeom2FacesByDomian face_map(2);
00428   auto_ptr<MEDMEM::CONNECTZONE> cz( joint.makeConnectZone(face_map));
00429   CPPUNIT_ASSERT( cz.get() );
00430 
00431   // ---------
00432   // check cz
00433   // ---------
00434 
00435   CPPUNIT_ASSERT_EQUAL( dom_dist, cz->getDistantDomainNumber() );
00436   CPPUNIT_ASSERT_EQUAL( dom_here, cz->getLocalDomainNumber() );
00437 
00438   CPPUNIT_ASSERT_EQUAL( long(grid), long(cz->getLocalMesh()) );
00439   CPPUNIT_ASSERT_EQUAL( long(grid), long(cz->getDistantMesh()) );
00440 
00441   CPPUNIT_ASSERT( cz->isEntityCorrespPresent(MED_CELL, MED_CELL) );
00442   CPPUNIT_ASSERT( !cz->isEntityCorrespPresent(MED_NODE, MED_NODE) );
00443   CPPUNIT_ASSERT( !cz->isEntityCorrespPresent(MED_EDGE, MED_EDGE) );
00444   CPPUNIT_ASSERT( !cz->isEntityCorrespPresent(MED_FACE, MED_FACE) );
00445 
00446   CPPUNIT_ASSERT_EQUAL( 3, cz->getNodeNumber() );
00447   CPPUNIT_ASSERT_EQUAL( 2, cz->getEntityCorrespNumber(MED_CELL,MED_CELL));
00448 
00449   const int * node_index = cz->getNodeCorrespIndex();
00450   CPPUNIT_ASSERT(node_index);
00451   for ( int i = 0; i < 4; ++i )
00452     CPPUNIT_ASSERT_EQUAL( i + 1, node_index[ i ]);
00453 
00454   const int * node_value = cz->getNodeCorrespValue();
00455   CPPUNIT_ASSERT(node_value);
00456   int val[2][6] = {{ 2, 1, 4, 3, 6, 5 },
00457                    { 1, 2, 3, 4, 5, 6 }}; // local ids of neighbouring domain
00458   for ( int i = 0; i < 6; ++i )
00459     CPPUNIT_ASSERT_EQUAL( val[ dom_sel.rank()][ i ], node_value[ i ]);
00460 
00461   const int * cell_index = cz->getEntityCorrespIndex(MED_CELL, MED_CELL);
00462   CPPUNIT_ASSERT(cell_index);
00463   for ( int i = 0; i < 3; ++i )
00464     CPPUNIT_ASSERT_EQUAL( i + 1, cell_index[ i ]);
00465 
00466   const int * cell_value = cz->getEntityCorrespValue(MED_CELL, MED_CELL);
00467   CPPUNIT_ASSERT(cell_value);
00468   CPPUNIT_ASSERT_EQUAL( 1, cell_value[ 0 ]);
00469   CPPUNIT_ASSERT_EQUAL( 2, cell_value[ 1 ]);
00470 
00471   CPPUNIT_ASSERT_EQUAL( 1, int( face_map[ dom_sel.rank() ].size() ));
00472   CPPUNIT_ASSERT_EQUAL( 0, int( face_map[ 1 - dom_sel.rank() ].size() ));
00473   CPPUNIT_ASSERT_EQUAL( MED_SEG2, face_map[ dom_sel.rank() ].begin()->first );
00474 
00475   vector< MEDSPLITTER_FaceModel* >& faces = face_map[ dom_sel.rank() ][ MED_SEG2 ];
00476   CPPUNIT_ASSERT_EQUAL( 2, int( faces.size() ));
00477   CPPUNIT_ASSERT_EQUAL( MED_SEG2, faces[0]->getType());
00478   CPPUNIT_ASSERT_EQUAL( joint_edge_glob_id+0, faces[0]->getGlobal());
00479   CPPUNIT_ASSERT_EQUAL( joint_edge_glob_id+1, faces[1]->getGlobal());
00480   // edge connectivity
00481   CPPUNIT_ASSERT_EQUAL( dom_sel.rank() ? 1 : 4, (*faces[0])[0]);
00482   CPPUNIT_ASSERT_EQUAL( dom_sel.rank() ? 3 : 2, (*faces[0])[1]);
00483   CPPUNIT_ASSERT_EQUAL( dom_sel.rank() ? 3 : 6, (*faces[1])[0]);
00484   CPPUNIT_ASSERT_EQUAL( dom_sel.rank() ? 5 : 4, (*faces[1])[1]);
00485 
00486   grid->removeReference();
00487 }
00488 
00489 //================================================================================
00493 //================================================================================
00494 
00495 void ParaMEDSPLITTERTest::testParaDomainSelector_exchangeSubentityIds ()
00496 {
00497   int world_size;
00498   MPI_Comm_size(MPI_COMM_WORLD,&world_size);
00499 
00500   if ( world_size != 2 )
00501     return;
00502 
00503   ParaDomainSelector dom_sel;
00504   vector<int> loc_ids_here(3, -373);
00505   int* got_ids;
00506   CPPUNIT_ASSERT_THROW
00507     ( dom_sel.exchangeSubentityIds( dom_sel.rank(), 1-dom_sel.rank(), loc_ids_here),MED_EXCEPTION);
00508   dom_sel.setNbDomains( 2 );
00509   CPPUNIT_ASSERT_NO_THROW
00510     ( got_ids = dom_sel.exchangeSubentityIds( dom_sel.rank(), 1-dom_sel.rank(), loc_ids_here));
00511   CPPUNIT_ASSERT_EQUAL( loc_ids_here[0], got_ids[0] );
00512   CPPUNIT_ASSERT_EQUAL( loc_ids_here[1], got_ids[1] );
00513   CPPUNIT_ASSERT_EQUAL( loc_ids_here[2], got_ids[2] );
00514   delete [] got_ids;
00515 }
00516