Salome HOME
refactor!: remove adm_local/ directory
[tools/medcoupling.git] / src / ParaMEDMEM / OverlapDEC.cxx
index ae6a4f0cca29a12cedaa8599fd9299e633b92c55..2bb5cc152c3d55afc78c37d2abbbecdad06a347d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2020  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2024  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -25,7 +25,7 @@
 #include "MPIProcessorGroup.hxx"
 #include "OverlapElementLocator.hxx"
 #include "OverlapInterpolationMatrix.hxx"
-#include "ICoCoMEDField.hxx"
+#include "ICoCoMEDDoubleField.hxx"
 
 namespace MEDCoupling
 {
@@ -59,20 +59,40 @@ namespace MEDCoupling
   }
 
   OverlapDEC::~OverlapDEC()
+  {
+    release();
+  }
+
+  /** Destructor involves MPI operations: make sure this is accessible from a proper
+   * method for Python wrapping.
+   */
+  void OverlapDEC::release()
   {
     if(_own_group)
-      delete _group;
+      {
+        delete _group;
+        _group = nullptr;
+      }
     if(_own_source_field)
-      delete _source_field;
+      {
+        delete _source_field;
+        _source_field = nullptr;
+      }
     if(_own_target_field)
-      delete _target_field;
+      {
+        delete _target_field;
+        _target_field = nullptr;
+      }
     delete _interpolation_matrix;
+    _interpolation_matrix = nullptr;
     delete _locator;
+    _locator = nullptr;
     if (_comm != MPI_COMM_NULL)
       {
         MEDCoupling::CommInterface comm;
         comm.commFree(&_comm);
       }
+    _comm = MPI_COMM_NULL;
   }
 
   void OverlapDEC::sendRecvData(bool way)
@@ -169,14 +189,14 @@ namespace MEDCoupling
     attachTargetLocalField(tmpField,true);
   }
 
-  void OverlapDEC::attachSourceLocalField(ICoCo::MEDField *field)
+  void OverlapDEC::attachSourceLocalField(ICoCo::MEDDoubleField *field)
   {
-    attachSourceLocalField(field->getField());
+    attachSourceLocalField(field->getMCField());
   }
 
-  void OverlapDEC::attachTargetLocalField(ICoCo::MEDField *field)
+  void OverlapDEC::attachTargetLocalField(ICoCo::MEDDoubleField *field)
   {
-    attachTargetLocalField(field->getField());
+    attachTargetLocalField(field->getMCField());
   }
 
   bool OverlapDEC::isInGroup() const