]> SALOME platform Git repositories - tools/medcoupling.git/blobdiff - src/ParaMEDMEM/ParaFIELD.cxx
Salome HOME
refactor!: remove adm_local/ directory
[tools/medcoupling.git] / src / ParaMEDMEM / ParaFIELD.cxx
index 1cdcfd821129b5d90fce96e175e59b67131cbdfa..f90fe3444577233fecdd1e59f3ef540a301b46b8 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  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
@@ -112,7 +112,7 @@ namespace MEDCoupling
   */
   ParaFIELD::ParaFIELD(MEDCouplingFieldDouble* subdomain_field, ParaMESH *sup, const ProcessorGroup& proc_group):
     _field(subdomain_field),
-    _component_topology(ComponentTopology(_field->getNumberOfComponents())),_topology(0),_own_support(false),
+    _component_topology(ComponentTopology((int)_field->getNumberOfComponents())),_topology(0),_own_support(false),
     _support(sup)
   {
     if(_field)
@@ -122,12 +122,28 @@ namespace MEDCoupling
   }
 
   ParaFIELD::~ParaFIELD()
+  {
+    release();
+  }
+
+  /** Destructor involves MPI operations: make sure this is accessible from a proper
+   * method for Python wrapping.
+   */
+  void ParaFIELD::release()
   {
     if(_field)
-      _field->decrRef();
+      {
+        _field->decrRef();
+        _field = nullptr;
+      }
+
     if(_own_support)
-      delete _support;
+      {
+        delete _support;
+        _support = nullptr;
+      }
     delete _topology;
+    _topology = nullptr;
   }
 
   void ParaFIELD::synchronizeTarget(ParaFIELD* source_field)
@@ -174,7 +190,7 @@ namespace MEDCoupling
    * For example if _field is a nodal field : returned array will be the nodal global numbers.
    * The content of this method is used to inform Working side to accumulate data received by lazy side.
    */
-  DataArrayInt* ParaFIELD::returnCumulativeGlobalNumbering() const
+  DataArrayIdType* ParaFIELD::returnCumulativeGlobalNumbering() const
   {
     if(!_field)
       return 0;
@@ -190,7 +206,7 @@ namespace MEDCoupling
       }
   }
 
-  DataArrayInt* ParaFIELD::returnGlobalNumbering() const
+  DataArrayIdType* ParaFIELD::returnGlobalNumbering() const
   {
     if(!_field)
       return 0;