From: abn Date: Wed, 4 May 2016 14:08:42 +0000 (+0200) Subject: ParaMEDMEM: Copy operator fix on DisjointDEC. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=067f476c967577f5a9875db9a78c80aa7fa0ab4f;p=tools%2Fmedcoupling.git ParaMEDMEM: Copy operator fix on DisjointDEC. --- diff --git a/src/ParaMEDMEM/DisjointDEC.cxx b/src/ParaMEDMEM/DisjointDEC.cxx index 022d6f550..0ed91beae 100644 --- a/src/ParaMEDMEM/DisjointDEC.cxx +++ b/src/ParaMEDMEM/DisjointDEC.cxx @@ -101,16 +101,29 @@ namespace ParaMEDMEM void DisjointDEC::copyInstance(const DisjointDEC& other) { DEC::copyFrom(other); - if(other._target_group) + if (other._union_comm != MPI_COMM_NULL) { - _target_group=other._target_group->deepCpy(); - _owns_groups=true; - } - if(other._source_group) - { - _source_group=other._source_group->deepCpy(); - _owns_groups=true; + // Tricky: the DEC is responsible for the management of _union_comm. And this comm is referenced by + // the MPIProcGroups (source/targets). In the case where _union_comm is not NULL we must take care of rebuilding the + // MPIProcGroups with a communicator that will survive the destruction of 'other'. + _owns_groups = true; + MPI_Comm_dup(other._union_comm, &_union_comm); +// std::cout << "DUP union comm - new is "<< _union_comm << "\n"; + _target_group = new MPIProcessorGroup(*_comm_interface, other._target_group->getProcIDs(), _union_comm); + _source_group = new MPIProcessorGroup(*_comm_interface, other._source_group->getProcIDs(), _union_comm); } + else{ + if(other._target_group) + { + _target_group=other._target_group->deepCpy(); + _owns_groups=true; + } + if(other._source_group) + { + _source_group=other._source_group->deepCpy(); + _owns_groups=true; + } + } if (_source_group && _target_group) _union_group = _source_group->fuse(*_target_group); } diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest.hxx b/src/ParaMEDMEMTest/ParaMEDMEMTest.hxx index baf4dfe78..98454b701 100644 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest.hxx +++ b/src/ParaMEDMEMTest/ParaMEDMEMTest.hxx @@ -78,6 +78,7 @@ class ParaMEDMEMTest : public CppUnit::TestFixture CPPUNIT_TEST(testGauthier1); // 4 procs CPPUNIT_TEST(testGauthier2); // >= 2 procs CPPUNIT_TEST(testGauthier3); // 4 procs + CPPUNIT_TEST(testGauthier3_bis); // 4 procs CPPUNIT_TEST(testGauthier4); // 3 procs CPPUNIT_TEST(testFabienAPI1); // 3 procs CPPUNIT_TEST(testFabienAPI2); // 3 procs @@ -138,6 +139,7 @@ public: void testGauthier1(); void testGauthier2(); void testGauthier3(); + void testGauthier3_bis(); void testGauthier4(); void testFabienAPI1(); void testFabienAPI2(); @@ -159,7 +161,7 @@ private: void testInterpKernelDEC_2D_(const char *srcMeth, const char *targetMeth); void testInterpKernelDEC2_2D_(const char *srcMeth, const char *targetMeth); void testInterpKernelDEC_3D_(const char *srcMeth, const char *targetMeth); - + void testGauthier3_GEN(bool); }; // to automatically remove temporary files from disk diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest_Gauthier1.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTest_Gauthier1.cxx index 33fa177c1..a0174a91a 100644 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_Gauthier1.cxx +++ b/src/ParaMEDMEMTest/ParaMEDMEMTest_Gauthier1.cxx @@ -356,10 +356,20 @@ void ParaMEDMEMTest::testGauthier2() } } +void ParaMEDMEMTest::testGauthier3() +{ + testGauthier3_GEN(true); +} + +void ParaMEDMEMTest::testGauthier3_bis() +{ + testGauthier3_GEN(false); +} + /*! * Non regression test testing copy constructor of InterpKernelDEC. */ -void ParaMEDMEMTest::testGauthier3() +void ParaMEDMEMTest::testGauthier3_GEN(bool withIDs) { int num_cas=0; int rank, size; @@ -414,7 +424,8 @@ void ParaMEDMEMTest::testGauthier3() for (int rec=0;rec<2;rec++) { std::vector decu(1); - decu[0]=InterpKernelDEC(emetteur_group,recepteur_group); +// decu[0]=InterpKernelDEC(emetteur_group,recepteur_group); + decu[0]=InterpKernelDEC(emetteur_ids,recepteur_ids); InterpKernelDEC& dec_emetteur=decu[0]; ParaMEDMEM::ParaFIELD *champ_emetteur(0),*champ_recepteur(0); ParaMEDMEM::ParaMESH *paramesh(0);