Salome HOME
Correction of bug concerning UNIV info status.
[tools/medcoupling.git] / src / ParaMEDMEM / DisjointDEC.cxx
index e601cb4814aa46723b33dafe41a4351fcbb072c7..f3f9bf666ee75f34963bd4132f52f28b3a6eb2ed 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2015  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -26,7 +26,6 @@
 #include "ParaMESH.hxx"
 #include "ICoCoField.hxx"
 #include "ICoCoMEDField.hxx"
-#include "ICoCoTrioField.hxx"
 #include "MPIProcessorGroup.hxx"
 
 #include <cmath>
@@ -43,8 +42,7 @@
  * On top of attaching a \c ParaMEDMEM::FIELD, it is possible to
  * attach a ICoCo::Field. This class is an abstract class that enables 
  * coupling of codes that respect the ICoCo interface \ref icoco. It has two implementations:
- * one for codes that express their fields as \ref medoupling fields (ICoCo::MEDField) and one
- * for codes that express their fields as Trio/U fields.
+ * one for codes that express their fields as \ref medoupling fields (ICoCo::MEDField).
  * 
  * \section dec_options DEC Options
  * Options supported by \c DEC objects are
@@ -80,13 +78,12 @@ namespace ParaMEDMEM
                                                                                        _source_group(&source_group),
                                                                                        _target_group(&target_group),
                                                                                        _owns_field(false),
-                                                                                       _owns_groups(false),
-                                                                                       _icoco_field(0)
+                                                                                       _owns_groups(false)
   {
     _union_group = source_group.fuse(target_group);  
   }
   
-  DisjointDEC::DisjointDEC(const DisjointDEC& s):DEC(s),_local_field(0),_union_group(0),_source_group(0),_target_group(0),_owns_field(false),_owns_groups(false),_icoco_field(0)
+  DisjointDEC::DisjointDEC(const DisjointDEC& s):DEC(s),_local_field(0),_union_group(0),_source_group(0),_target_group(0),_owns_field(false),_owns_groups(false)
   {
     copyInstance(s);
   }
@@ -118,8 +115,7 @@ namespace ParaMEDMEM
 
   DisjointDEC::DisjointDEC(const std::set<int>& source_ids, const std::set<int>& target_ids, const MPI_Comm& world_comm):_local_field(0), 
                                                                                                                          _owns_field(false),
-                                                                                                                         _owns_groups(true),
-                                                                                                                         _icoco_field(0)
+                                                                                                                         _owns_groups(true)
   {
     ParaMEDMEM::CommInterface comm;
     // Create the list of procs including source and target
@@ -195,8 +191,6 @@ namespace ParaMEDMEM
     _owns_groups=false;
     _source_group=0;
     _target_group=0;
-    delete _icoco_field;
-    _icoco_field=0;
     delete _union_group;
     _union_group=0;
   }
@@ -212,7 +206,7 @@ namespace ParaMEDMEM
     will be updated by a recvData() call.
     Reversely, if the processor is on the sending end, the field will be read, possibly transformed, and sent appropriately to the other side.
   */
-  void DisjointDEC::attachLocalField(const ParaFIELD* field, bool ownPt) 
+  void DisjointDEC::attachLocalField(const ParaFIELD *field, bool ownPt)
   {
     if(!isInUnion())
       return ;
@@ -234,7 +228,7 @@ namespace ParaMEDMEM
     and sent appropriately to the other side.
   */
 
-  void DisjointDEC::attachLocalField(MEDCouplingFieldDouble* field) 
+  void DisjointDEC::attachLocalField(MEDCouplingFieldDouble *field)
   {
     if(!isInUnion())
       return ;
@@ -245,7 +239,7 @@ namespace ParaMEDMEM
       local_group=_target_group;
     else
       throw INTERP_KERNEL::Exception("Invalid procgroup for field attachment to DEC");
-    ParaMESH *paramesh=new ParaMESH((MEDCouplingPointSet *)field->getMesh(),*local_group,field->getMesh()->getName());
+    ParaMESH *paramesh=new ParaMESH(static_cast<MEDCouplingPointSet *>(const_cast<MEDCouplingMesh *>(field->getMesh())),*local_group,field->getMesh()->getName());
     ParaFIELD *tmp=new ParaFIELD(field, paramesh, *local_group);
     tmp->setOwnSupport(true);
     attachLocalField(tmp,true);
@@ -259,34 +253,15 @@ namespace ParaMEDMEM
     Reversely, if the processor is on the sending end, the field will be read, possibly transformed, and sent appropriately to the other side.
     The field type is a generic ICoCo Field, so that the DEC can couple a number of different fields :
     - a ICoCo::MEDField, that is created from a MEDCoupling structure
-    - a ICOCo::TrioField, that is created from tables extracted from a TRIO-U structure.
     
   */
-  void DisjointDEC::attachLocalField(const ICoCo::Field* field)
+  void DisjointDEC::attachLocalField(const ICoCo::MEDField *field)
   {
     if(!isInUnion())
       return ;
-    const ICoCo::MEDField* medfield=dynamic_cast<const ICoCo::MEDField*> (field);
-    if(medfield !=0)
-      {
-        attachLocalField(medfield->getField());
-        return;
-      }
-    const ICoCo::TrioField* triofield=dynamic_cast<const ICoCo::TrioField*> (field);
-    if (triofield !=0)
-      {
-        ProcessorGroup* localgroup;
-        if (_source_group->containsMyRank())
-          localgroup=_source_group;
-        else
-          localgroup=_target_group;
-        delete _icoco_field;
-        
-        _icoco_field=new ICoCo::MEDField(*const_cast<ICoCo::TrioField* >(triofield));
-        attachLocalField(_icoco_field);
-        return;
-      }
-    throw INTERP_KERNEL::Exception("incompatible field type");
+    if(!field)
+      throw INTERP_KERNEL::Exception("DisjointDEC::attachLocalField : ICoCo::MEDField pointer is NULL !");
+    attachLocalField(field->getField());
   }
   
   /*!