From: Anthony Geay Date: Thu, 17 Aug 2023 15:30:11 +0000 (+0200) Subject: [EDF26706] : Preparation to implementation X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0883264b9369a9d46677da4b3367f73e0f9dddb2;p=tools%2Fmedcoupling.git [EDF26706] : Preparation to implementation --- diff --git a/src/ParaMEDMEM/InterpKernelDEC.cxx b/src/ParaMEDMEM/InterpKernelDEC.cxx index 18cf01e7c..d786641ee 100644 --- a/src/ParaMEDMEM/InterpKernelDEC.cxx +++ b/src/ParaMEDMEM/InterpKernelDEC.cxx @@ -26,15 +26,12 @@ #include "MPIProcessorGroup.hxx" #include "ParaMESH.hxx" #include "DEC.hxx" -#include "InterpolationMatrix.hxx" #include "InterpKernelDEC.hxx" #include "ElementLocator.hxx" namespace MEDCoupling { - InterpKernelDEC::InterpKernelDEC(): - DisjointDEC(), - _interpolation_matrix(0) + InterpKernelDEC::InterpKernelDEC():_interpolation_matrix(nullptr) { } @@ -50,8 +47,7 @@ namespace MEDCoupling */ InterpKernelDEC::InterpKernelDEC(ProcessorGroup& source_group, ProcessorGroup& target_group): - DisjointDEC(source_group, target_group), - _interpolation_matrix(0) + DisjointDEC(source_group, target_group) { } @@ -64,8 +60,7 @@ namespace MEDCoupling */ InterpKernelDEC::InterpKernelDEC(const std::set& src_ids, const std::set& trg_ids, const MPI_Comm& world_comm): - DisjointDEC(src_ids,trg_ids,world_comm), - _interpolation_matrix(0) + DisjointDEC(src_ids,trg_ids,world_comm) { } @@ -76,9 +71,7 @@ namespace MEDCoupling void InterpKernelDEC::release() { - if (_interpolation_matrix != nullptr) - delete _interpolation_matrix; - _interpolation_matrix = nullptr; + _interpolation_matrix.reset(nullptr); DisjointDEC::cleanInstance(); } @@ -100,8 +93,7 @@ namespace MEDCoupling { if(!isInUnion()) return ; - delete _interpolation_matrix; - _interpolation_matrix = new InterpolationMatrix (_local_field, *_source_group,*_target_group,*this,*this); + _interpolation_matrix.reset( new InterpolationMatrix (_local_field, *_source_group,*_target_group,*this,*this) ); //setting up the communication DEC on both sides if (_source_group->containsMyRank()) diff --git a/src/ParaMEDMEM/InterpKernelDEC.hxx b/src/ParaMEDMEM/InterpKernelDEC.hxx index eaa87526e..e18169f6b 100644 --- a/src/ParaMEDMEM/InterpKernelDEC.hxx +++ b/src/ParaMEDMEM/InterpKernelDEC.hxx @@ -23,11 +23,12 @@ #include "DisjointDEC.hxx" #include "MxN_Mapping.hxx" #include "InterpolationOptions.hxx" +#include "InterpolationMatrix.hxx" + +#include namespace MEDCoupling { - class InterpolationMatrix; - /*! \anchor InterpKernelDEC-det \class InterpKernelDEC @@ -131,6 +132,8 @@ namespace MEDCoupling InterpKernelDEC(); InterpKernelDEC(ProcessorGroup& source_group, ProcessorGroup& target_group); InterpKernelDEC(const std::set& src_ids, const std::set& trg_ids, const MPI_Comm& world_comm=MPI_COMM_WORLD); + InterpKernelDEC(InterpKernelDEC&& other) = default; + InterpKernelDEC& operator=(InterpKernelDEC&& other) = default; virtual ~InterpKernelDEC(); void release(); @@ -147,7 +150,7 @@ namespace MEDCoupling MCAuto retrieveNonFetchedIdsSource() const; MCAuto retrieveNonFetchedIdsTarget() const; private: - InterpolationMatrix* _interpolation_matrix; + std::unique_ptr _interpolation_matrix; }; } diff --git a/src/ParaMEDMEM/InterpolationMatrix.hxx b/src/ParaMEDMEM/InterpolationMatrix.hxx index a25cbe7c9..c631727a8 100644 --- a/src/ParaMEDMEM/InterpolationMatrix.hxx +++ b/src/ParaMEDMEM/InterpolationMatrix.hxx @@ -28,6 +28,7 @@ namespace MEDCoupling { class ElementLocator; + class MEDCouplingPointSet; /*! Internal class, not part of the public API. diff --git a/src/ParaMEDMEM/MPIProcessorGroup.cxx b/src/ParaMEDMEM/MPIProcessorGroup.cxx index 70d14565b..4c33fb097 100644 --- a/src/ParaMEDMEM/MPIProcessorGroup.cxx +++ b/src/ParaMEDMEM/MPIProcessorGroup.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include "mpi.h" using namespace std; @@ -73,7 +74,6 @@ namespace MEDCoupling _comm_interface.commSize(_world_comm,&size); for (int i=0; i ranks( new int[_proc_ids.size()] ); // copying proc_ids in ranks - copy::const_iterator,int*> (_proc_ids.begin(), _proc_ids.end(), ranks); + copy::const_iterator,int*> (_proc_ids.begin(), _proc_ids.end(), ranks.get()); for (int i=0; i< (int)_proc_ids.size();i++) if (ranks[i]>size_world-1) { - delete[] ranks; _comm_interface.groupFree(&group_world); // MPI_Group is a C structure and won't get de-allocated automatically? throw INTERP_KERNEL::Exception("invalid rank in set argument of MPIProcessorGroup constructor"); } - _comm_interface.groupIncl(group_world, (int)_proc_ids.size(), ranks, &_group); + _comm_interface.groupIncl(group_world, (int)_proc_ids.size(), ranks.get(), &_group); _comm_interface.commCreate(_world_comm, _group, &_comm); // clean-up - delete[] ranks; _comm_interface.groupFree(&group_world); // MPI_Group is a C structure and won't get de-allocated automatically? }