]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
*** empty log message ***
authorageay <ageay>
Fri, 17 Apr 2009 08:27:39 +0000 (08:27 +0000)
committerageay <ageay>
Fri, 17 Apr 2009 08:27:39 +0000 (08:27 +0000)
46 files changed:
src/MEDCoupling/MEDCouplingCMesh.cxx [new file with mode: 0644]
src/MEDCoupling/MEDCouplingCMesh.hxx [new file with mode: 0644]
src/MEDCoupling/MEDCouplingField.cxx
src/MEDCoupling/MEDCouplingField.hxx
src/MEDCoupling/MEDCouplingFieldDiscretization.cxx
src/MEDCoupling/MEDCouplingFieldDiscretization.hxx
src/MEDCoupling/MEDCouplingFieldDouble.cxx
src/MEDCoupling/MEDCouplingFieldDouble.hxx
src/MEDCoupling/MEDCouplingMemArray.cxx [new file with mode: 0644]
src/MEDCoupling/MEDCouplingMemArray.hxx [new file with mode: 0644]
src/MEDCoupling/MEDCouplingMemArray.txx [new file with mode: 0644]
src/MEDCoupling/MEDCouplingMesh.hxx
src/MEDCoupling/MEDCouplingNatureOfField.hxx [new file with mode: 0644]
src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx
src/MEDCoupling/MEDCouplingPointSet.cxx
src/MEDCoupling/MEDCouplingPointSet.hxx
src/MEDCoupling/MEDCouplingRMesh.cxx [deleted file]
src/MEDCoupling/MEDCouplingRMesh.hxx [deleted file]
src/MEDCoupling/MEDCouplingRefCountObject.cxx [new file with mode: 0644]
src/MEDCoupling/MEDCouplingRefCountObject.hxx [new file with mode: 0644]
src/MEDCoupling/MEDCouplingTimeDiscretization.cxx
src/MEDCoupling/MEDCouplingTimeDiscretization.hxx
src/MEDCoupling/MEDCouplingTimeLabel.cxx [new file with mode: 0644]
src/MEDCoupling/MEDCouplingTimeLabel.hxx [new file with mode: 0644]
src/MEDCoupling/MEDCouplingUMesh.cxx
src/MEDCoupling/MEDCouplingUMesh.hxx
src/MEDCoupling/MEDCouplingUMeshDesc.cxx
src/MEDCoupling/MEDCouplingUMeshDesc.hxx
src/MEDCoupling/Makefile.am
src/MEDCoupling/MemArray.cxx [deleted file]
src/MEDCoupling/MemArray.hxx [deleted file]
src/MEDCoupling/MemArray.txx [deleted file]
src/MEDCoupling/RefCountObject.hxx [deleted file]
src/MEDCoupling/Test/MEDCouplingBasicsTest.cxx
src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx
src/MEDCoupling/TimeLabel.cxx [deleted file]
src/MEDCoupling/TimeLabel.hxx [deleted file]
src/ParaMEDMEM/BlockTopology.cxx
src/ParaMEDMEM/BlockTopology.hxx
src/ParaMEDMEM/ElementLocator.cxx
src/ParaMEDMEM/ParaFIELD.hxx
src/ParaMEDMEM/ParaGRID.cxx
src/ParaMEDMEM/ParaGRID.hxx
src/ParaMEDMEM/ParaMESH.cxx
src/ParaMEDMEM/ParaMESH.hxx
src/ParaMEDMEM/Test/ParaMEDMEMTest_MEDLoader.cxx

diff --git a/src/MEDCoupling/MEDCouplingCMesh.cxx b/src/MEDCoupling/MEDCouplingCMesh.cxx
new file mode 100644 (file)
index 0000000..33f7214
--- /dev/null
@@ -0,0 +1,182 @@
+//  Copyright (C) 2007-2008  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.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include "MEDCouplingCMesh.hxx"
+#include "MEDCouplingMemArray.hxx"
+
+using namespace ParaMEDMEM;
+
+MEDCouplingCMesh::MEDCouplingCMesh():_x_array(0),_y_array(0),_z_array(0)
+{
+}
+
+MEDCouplingCMesh::~MEDCouplingCMesh()
+{
+  if(_x_array)
+    _x_array->decrRef();
+  if(_y_array)
+    _y_array->decrRef();
+  if(_z_array)
+    _z_array->decrRef();
+}
+
+MEDCouplingCMesh *MEDCouplingCMesh::New()
+{
+  return new MEDCouplingCMesh;
+}
+
+void MEDCouplingCMesh::updateTime()
+{
+  if(_x_array)
+    updateTimeWith(*_x_array);
+  if(_y_array)
+    updateTimeWith(*_y_array);
+  if(_z_array)
+    updateTimeWith(*_z_array);
+}
+
+bool MEDCouplingCMesh::isEqual(const MEDCouplingMesh *other, double prec) const
+{
+  const MEDCouplingCMesh *otherC=dynamic_cast<const MEDCouplingCMesh *>(other);
+  if(!otherC)
+    return false;
+  return true;
+}
+
+void MEDCouplingCMesh::checkCoherency() const throw(INTERP_KERNEL::Exception)
+{
+  const char msg0[]="Invalid ";
+  const char msg1[]=" array ! Must contain more than 1 element.";
+  if(_x_array)
+    if(_x_array->getNbOfElems()<2)
+      {
+        std::ostringstream os; os << msg0 << 'X' << msg1;
+        throw INTERP_KERNEL::Exception(os.str().c_str());
+      }
+  if(_y_array)
+    if(_y_array->getNbOfElems()<2)
+      {
+        std::ostringstream os; os << msg0 << 'Y' << msg1;
+        throw INTERP_KERNEL::Exception(os.str().c_str());
+      }
+  if(_z_array)
+    if(_z_array->getNbOfElems()<2)
+      {
+        std::ostringstream os; os << msg0 << 'Z' << msg1;
+        throw INTERP_KERNEL::Exception(os.str().c_str());
+      }
+}
+
+bool MEDCouplingCMesh::isStructured() const
+{
+  return true;
+}
+
+int MEDCouplingCMesh::getNumberOfCells() const
+{
+  int ret=1;
+  if(_x_array)
+    ret*=_x_array->getNbOfElems()-1;
+  if(_y_array)
+    ret*=_y_array->getNbOfElems()-1;
+  if(_z_array)
+    ret*=_z_array->getNbOfElems()-1;
+  return ret;
+}
+
+int MEDCouplingCMesh::getNumberOfNodes() const
+{
+  int ret=1;
+  if(_x_array)
+    ret*=_x_array->getNbOfElems();
+  if(_y_array)
+    ret*=_y_array->getNbOfElems();
+  if(_z_array)
+    ret*=_z_array->getNbOfElems();
+  return ret;
+}
+
+int MEDCouplingCMesh::getSpaceDimension() const
+{
+  int ret=0;
+  if(_x_array)
+    ret++;
+  if(_y_array)
+    ret++;
+  if(_z_array)
+    ret++;
+  return ret;
+}
+
+int MEDCouplingCMesh::getMeshDimension() const
+{
+  int ret=0;
+  if(_x_array)
+    ret++;
+  if(_y_array)
+    ret++;
+  if(_z_array)
+    ret++;
+  return ret;
+}
+
+DataArrayDouble *MEDCouplingCMesh::getCoordsAt(int i) const throw(INTERP_KERNEL::Exception)
+{
+  switch(i)
+    {
+    case 0:
+      return _x_array;
+    case 1:
+      return _y_array;
+    case 2:
+      return _z_array;
+    default:
+      throw INTERP_KERNEL::Exception("Invalid rank specified must be 0 or 1 or 2.");
+    }
+}
+
+void MEDCouplingCMesh::setCoords(DataArrayDouble *coordsX, DataArrayDouble *coordsY, DataArrayDouble *coordsZ)
+{
+  if(_x_array)
+    _x_array->decrRef();
+  _x_array=coordsX;
+  if(_x_array)
+    _x_array->incrRef();
+  if(_y_array)
+    _y_array->decrRef();
+  _y_array=coordsY;
+  if(_y_array)
+    _y_array->incrRef();
+  if(_z_array)
+    _z_array->decrRef();
+  _z_array=coordsZ;
+  if(_z_array)
+    _z_array->incrRef();
+  declareAsNew();
+}
+
+void MEDCouplingCMesh::getBoundingBox(double *bbox) const
+{
+  //not implemented yet !
+}
+
+MEDCouplingFieldDouble *MEDCouplingCMesh::getMeasureField() const
+{
+  //not implemented yet !
+  return 0;
+}
diff --git a/src/MEDCoupling/MEDCouplingCMesh.hxx b/src/MEDCoupling/MEDCouplingCMesh.hxx
new file mode 100644 (file)
index 0000000..212535c
--- /dev/null
@@ -0,0 +1,59 @@
+//  Copyright (C) 2007-2008  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.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef __PARAMEDMEM_MEDCOUPLINGCMESH_HXX__
+#define __PARAMEDMEM_MEDCOUPLINGCMESH_HXX__
+
+#include "MEDCoupling.hxx"
+#include "MEDCouplingMesh.hxx"
+
+namespace ParaMEDMEM
+{
+  class DataArrayDouble;
+
+  class MEDCouplingCMesh : public MEDCouplingMesh
+  {
+  public:
+    static MEDCouplingCMesh *New();
+    void updateTime();
+    MEDCouplingMeshType getType() const { return CARTESIAN; }
+    bool isEqual(const MEDCouplingMesh *other, double prec) const;
+    void checkCoherency() const throw(INTERP_KERNEL::Exception);
+    bool isStructured() const;
+    int getNumberOfCells() const;
+    int getNumberOfNodes() const;
+    int getSpaceDimension() const;
+    int getMeshDimension() const;
+    DataArrayDouble *getCoordsAt(int i) const throw(INTERP_KERNEL::Exception);
+    void setCoords(DataArrayDouble *coordsX,
+                   DataArrayDouble *coordsY=0,
+                   DataArrayDouble *coordsZ=0);
+    // tools
+    void getBoundingBox(double *bbox) const;
+    MEDCouplingFieldDouble *getMeasureField() const;
+  private:
+    MEDCouplingCMesh();
+    ~MEDCouplingCMesh();
+  private:
+    DataArrayDouble *_x_array;
+    DataArrayDouble *_y_array;
+    DataArrayDouble *_z_array;
+  };
+}
+
+#endif
index 1a65f4722f9bb8136197ba92eda1e138fae548e0..c5b53a5f820d4474c9bcc5ddc469f25933ba1c94 100644 (file)
 
 using namespace ParaMEDMEM;
 
+bool MEDCouplingField::isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const
+{
+  if(_name!=other->_name)
+    return false;
+  if(_desc!=other->_desc)
+    return false;
+  if(!_type->isEqual(other->_type))
+    return false;
+  if(_mesh==0 && other->_mesh==0)
+    return true;
+  if(_mesh==0 || other->_mesh==0)
+    return false;
+  if(_mesh==other->_mesh)
+    return true;
+  return _mesh->isEqual(other->_mesh,meshPrec);
+}
+
 void MEDCouplingField::updateTime()
 {
   if(_mesh)
@@ -33,12 +50,12 @@ TypeOfField MEDCouplingField::getEntity() const
   return _type->getEnum();
 }
 
-void MEDCouplingField::setMesh(MEDCouplingMesh *mesh)
+void MEDCouplingField::setMesh(const MEDCouplingMesh *mesh)
 {
   if(mesh!=_mesh)
     {
       if(_mesh)
-        _mesh->decrRef();
+        ((MEDCouplingMesh *)_mesh)->decrRef();
       _mesh=mesh;
       if(_mesh)
         {
@@ -51,7 +68,7 @@ void MEDCouplingField::setMesh(MEDCouplingMesh *mesh)
 MEDCouplingField::~MEDCouplingField()
 {
   if(_mesh)
-    _mesh->decrRef();
+    ((MEDCouplingMesh *)_mesh)->decrRef();
   delete _type;
 }
 
index 55c32688fd94cf2859804ae01f295711c8637f4d..5f59bccfe07555be9f078197d8d0e689eefcf4c7 100644 (file)
@@ -20,7 +20,8 @@
 #define __PARAMEDMEM_MEDCOUPLINGFIELD_HXX__
 
 #include "MEDCoupling.hxx"
-#include "RefCountObject.hxx"
+#include "MEDCouplingTimeLabel.hxx"
+#include "MEDCouplingRefCountObject.hxx"
 #include "InterpKernelException.hxx"
 
 #include <string>
@@ -30,13 +31,15 @@ namespace ParaMEDMEM
   class MEDCouplingMesh;
   class MEDCouplingFieldDiscretization;
 
-  class MEDCOUPLING_EXPORT MEDCouplingField : public RefCountObject
+  class MEDCOUPLING_EXPORT MEDCouplingField : public RefCountObject, public TimeLabel
   {
   public:
     virtual void checkCoherency() const throw(INTERP_KERNEL::Exception) = 0;
-    void setMesh(ParaMEDMEM::MEDCouplingMesh *mesh);
-    ParaMEDMEM::MEDCouplingMesh *getMesh() const { return _mesh; }
+    virtual bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
+    void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh);
+    const ParaMEDMEM::MEDCouplingMesh *getMesh() const { return _mesh; }
     void setName(const char *name) { _name=name; }
+    const char *getDescription() const { return _desc.c_str(); }
     void setDescription(const char *desc) { _desc=desc; }
     const char *getName() const { return _name.c_str(); }
     TypeOfField getEntity() const;
@@ -49,7 +52,7 @@ namespace ParaMEDMEM
   protected:
     std::string _name;
     std::string _desc;
-    MEDCouplingMesh *_mesh;
+    const MEDCouplingMesh *_mesh;
     MEDCouplingFieldDiscretization *_type;
   };
 }
index 2b45ef279be29c6ebd8c3b99b909ed0bb475317f..844f67eee486e78f5161dba251c73051ff86f5a5 100644 (file)
@@ -58,11 +58,21 @@ const char *MEDCouplingFieldDiscretizationP0::getStringRepr() const
   return REPR;
 }
 
+bool MEDCouplingFieldDiscretizationP0::isEqual(const MEDCouplingFieldDiscretization *other) const
+{
+  const MEDCouplingFieldDiscretizationP0 *otherC=dynamic_cast<const MEDCouplingFieldDiscretizationP0 *>(other);
+  return otherC!=0;
+}
+
 int MEDCouplingFieldDiscretizationP0::getNumberOfTuples(const MEDCouplingMesh *mesh) const
 {
   return mesh->getNumberOfCells();
 }
 
+void MEDCouplingFieldDiscretizationP0::checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception)
+{
+}
+
 void MEDCouplingFieldDiscretizationP0::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception)
 {
   if(mesh->getNumberOfCells()!=da->getNumberOfTuples())
@@ -94,11 +104,23 @@ const char *MEDCouplingFieldDiscretizationP1::getStringRepr() const
   return REPR;
 }
 
+bool MEDCouplingFieldDiscretizationP1::isEqual(const MEDCouplingFieldDiscretization *other) const
+{
+  const MEDCouplingFieldDiscretizationP1 *otherC=dynamic_cast<const MEDCouplingFieldDiscretizationP1 *>(other);
+  return otherC!=0;
+}
+
 int MEDCouplingFieldDiscretizationP1::getNumberOfTuples(const MEDCouplingMesh *mesh) const
 {
   return mesh->getNumberOfNodes();
 }
 
+void MEDCouplingFieldDiscretizationP1::checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception)
+{
+  if(nat!=ConservativeVolumic)
+    throw INTERP_KERNEL::Exception("Invalid nature for P1 field !");
+}
+
 void MEDCouplingFieldDiscretizationP1::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception)
 {
   if(mesh->getNumberOfNodes()!=da->getNumberOfTuples())
index 3c0c54332be54955c5bd2858aae25db21708dd7b..35b83f809832843f2d0b054925bb66a74c7262f4 100644 (file)
@@ -20,8 +20,9 @@
 #define __MEDCOUPLINGFIELDDISCRETIZATION_HXX__
 
 #include "MEDCoupling.hxx"
-#include "RefCountObject.hxx"
+#include "MEDCouplingRefCountObject.hxx"
 #include "InterpKernelException.hxx"
+#include "MEDCouplingNatureOfField.hxx"
 
 namespace ParaMEDMEM
 {
@@ -34,9 +35,11 @@ namespace ParaMEDMEM
   public:
     static MEDCouplingFieldDiscretization *New(TypeOfField type);
     virtual TypeOfField getEnum() const = 0;
+    virtual bool isEqual(const MEDCouplingFieldDiscretization *other) const = 0;
     virtual MEDCouplingFieldDiscretization *clone() const = 0;
     virtual const char *getStringRepr() const = 0;
     virtual int getNumberOfTuples(const MEDCouplingMesh *mesh) const = 0;
+    virtual void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception) = 0;
     virtual void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception) = 0;
     virtual MEDCouplingFieldDouble *getWeightingField(const MEDCouplingMesh *mesh) const = 0;
   };
@@ -47,7 +50,9 @@ namespace ParaMEDMEM
     TypeOfField getEnum() const;
     MEDCouplingFieldDiscretization *clone() const;
     const char *getStringRepr() const;
+    bool isEqual(const MEDCouplingFieldDiscretization *other) const;
     int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
+    void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
     void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldDouble *getWeightingField(const MEDCouplingMesh *mesh) const;
   public:
@@ -61,7 +66,9 @@ namespace ParaMEDMEM
     TypeOfField getEnum() const;
     MEDCouplingFieldDiscretization *clone() const;
     const char *getStringRepr() const;
+    bool isEqual(const MEDCouplingFieldDiscretization *other) const;
     int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
+    void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
     void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldDouble *getWeightingField(const MEDCouplingMesh *mesh) const;
   public:
index 40cc5724758edccbf456663820a89e23cb4e9546..6b1fa4e64e3dbf46034620806600d74bd3b388f8 100644 (file)
@@ -35,12 +35,31 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::clone(bool recDeepCpy) const
   return new MEDCouplingFieldDouble(*this,recDeepCpy);
 }
 
-MEDCouplingFieldDouble::MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingField(type),
+bool MEDCouplingFieldDouble::isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const
+{
+  const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
+  if(!otherC)
+    return false;
+  if(_nature!=otherC->_nature)
+    return false;
+  if(!MEDCouplingField::isEqual(other,meshPrec,valsPrec))
+    return false;
+  if(!_time_discr->isEqual(otherC->_time_discr,valsPrec))
+    return false;
+  return true;
+}
+
+TypeOfTimeDiscretization MEDCouplingFieldDouble::getTimeDiscretization() const
+{
+  return _time_discr->getEnum();
+}
+
+MEDCouplingFieldDouble::MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingField(type),_nature(NoNature),
                                                                                               _time_discr(MEDCouplingTimeDiscretization::New(td))
 {
 }
 
-MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCpy):MEDCouplingField(other),
+MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCpy):MEDCouplingField(other),_nature(other._nature),
                                                                                                   _time_discr(other._time_discr->performCpy(deepCpy))
 {
 }
@@ -123,7 +142,76 @@ void MEDCouplingFieldDouble::updateTime()
     updateTimeWith(*getArray());
 }
 
+void MEDCouplingFieldDouble::setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception)
+{
+  _type->checkCompatibilityWithNature(nat);
+  _nature=nat;
+}
+
 void MEDCouplingFieldDouble::setArray(DataArrayDouble *array)
 {
   _time_discr->setArray(array,this);
 }
+
+void MEDCouplingFieldDouble::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
+{
+  tinyInfo.clear();
+  _time_discr->getTinySerializationStrInformation(tinyInfo);
+  tinyInfo.push_back(_name);
+  tinyInfo.push_back(_desc);
+}
+
+/*!
+ * This method retrieves some critical values to resize and prepare remote instance.
+ * The first two elements returned in tinyInfo correspond to the parameters to give in constructor.
+ * @param tinyInfo out parameter resized correctly after the call. The length of this vector is tiny.
+ */
+void MEDCouplingFieldDouble::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
+{
+  tinyInfo.clear();
+  tinyInfo.push_back((int)_type->getEnum());
+  tinyInfo.push_back((int)_time_discr->getEnum());
+  tinyInfo.push_back((int)_nature);
+  _time_discr->getTinySerializationIntInformation(tinyInfo);
+}
+
+/*!
+ * This method retrieves some critical values to resize and prepare remote instance.
+ * @param tinyInfo out parameter resized correctly after the call. The length of this vector is tiny.
+ */
+void MEDCouplingFieldDouble::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
+{
+  tinyInfo.clear();
+  _time_discr->getTinySerializationDbleInformation(tinyInfo);
+}
+
+/*!
+ * This method has to be called to the new instance filled by CORBA, MPI, File...
+ * @param tinyInfoI is the value retrieves from distant result of getTinySerializationIntInformation on source instance to be copied.
+ * @param arrays out parameter is a vector resized to the right size. The pointers in the vector is already owned by 'this' after the call of this method.
+ *               No decrRef must be applied to every instances in returned vector.
+ */
+void MEDCouplingFieldDouble::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
+{
+  std::vector<int> tinyInfoI2(tinyInfoI.begin()+3,tinyInfoI.end());
+  _time_discr->resizeForUnserialization(tinyInfoI2,arrays);
+}
+
+void MEDCouplingFieldDouble::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
+{
+  std::vector<int> tinyInfoI2(tinyInfoI.begin()+3,tinyInfoI.end());
+  _time_discr->finishUnserialization(tinyInfoI2,tinyInfoD,tinyInfoS);
+  _nature=(NatureOfField)tinyInfoI[2];
+  int nbOfElemS=tinyInfoS.size();
+  _name=tinyInfoS[nbOfElemS-2];
+  _desc=tinyInfoS[nbOfElemS-1];
+}
+
+/*!
+ * Contrary to MEDCouplingPointSet class the returned arrays are \b not the responsabilities af the caller.
+ * The values returned must be consulted only in readonly mode.
+ */
+void MEDCouplingFieldDouble::serialize(std::vector<DataArrayDouble *>& arrays) const
+{
+  _time_discr->getArrays(arrays);
+}
index 8a7d32967b9ac121cb5957b1ab8142627279e646..a05035b0f3be75ca46456dfc8d96c98a264a9488 100644 (file)
@@ -22,7 +22,8 @@
 #include "MEDCoupling.hxx"
 #include "MEDCouplingField.hxx"
 #include "MEDCouplingTimeDiscretization.hxx"
-#include "MemArray.hxx"
+#include "MEDCouplingNatureOfField.hxx"
+#include "MEDCouplingMemArray.hxx"
 
 namespace ParaMEDMEM
 {
@@ -30,8 +31,12 @@ namespace ParaMEDMEM
   {
   public:
     static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=NO_TIME);
+    bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
     MEDCouplingFieldDouble *clone(bool recDeepCpy) const;
+    TypeOfTimeDiscretization getTimeDiscretization() const;
     void checkCoherency() const throw(INTERP_KERNEL::Exception);
+    NatureOfField getNature() const { return _nature; }
+    void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception);
     void setTime(double val, int dt, int it) { _time_discr->setTime(val,dt,it); }
     double getTime(int& dt, int& it) const { return _time_discr->getTime(dt,it); }
     double getIJ(int tupleId, int compoId) const { return getArray()->getIJ(tupleId,compoId); }
@@ -46,11 +51,19 @@ namespace ParaMEDMEM
     int getNumberOfComponents() const;
     int getNumberOfTuples() const throw(INTERP_KERNEL::Exception);
     void updateTime();
+    //
+    void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
+    void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
+    void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
+    void resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays);
+    void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
+    void serialize(std::vector<DataArrayDouble *>& arrays) const;
   private:
     MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td);
     MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCpy);
     ~MEDCouplingFieldDouble();
   private:
+    NatureOfField _nature;
     MEDCouplingTimeDiscretization *_time_discr;
   };
 }
diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx
new file mode 100644 (file)
index 0000000..b907df1
--- /dev/null
@@ -0,0 +1,161 @@
+//  Copyright (C) 2007-2008  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.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include "MEDCouplingMemArray.txx"
+
+using namespace ParaMEDMEM;
+
+void DataArray::setName(const char *name)
+{
+  _name=name;
+}
+
+bool DataArray::areInfoEquals(const DataArray& other) const
+{
+  if(_nb_of_tuples!=other._nb_of_tuples)
+    return false;
+  if(_name!=other._name)
+    return false;
+  return _info_on_compo==other._info_on_compo;
+}
+
+DataArrayDouble *DataArrayDouble::New()
+{
+  return new DataArrayDouble;
+}
+
+DataArrayDouble *DataArrayDouble::deepCopy() const
+{
+  return new DataArrayDouble(*this);
+}
+
+DataArrayDouble *DataArrayDouble::performCpy(bool deepCpy) const
+{
+  if(deepCpy)
+    return deepCopy();
+  else
+    {
+      incrRef();
+      return const_cast<DataArrayDouble *>(this);
+    }
+}
+
+void DataArrayDouble::alloc(int nbOfTuple, int nbOfCompo)
+{
+  _nb_of_tuples=nbOfTuple;
+  _info_on_compo.resize(nbOfCompo);
+  _mem.alloc(nbOfCompo*_nb_of_tuples);
+  declareAsNew();
+}
+
+bool DataArrayDouble::isEqual(const DataArrayDouble& other, double prec) const
+{
+  if(!areInfoEquals(other))
+    return false;
+  return _mem.isEqual(other._mem,prec);
+}
+
+void DataArrayDouble::reAlloc(int nbOfTuples)
+{
+  _mem.reAlloc(_info_on_compo.size()*nbOfTuples);
+  _nb_of_tuples=nbOfTuples;
+  declareAsNew();
+}
+
+void DataArrayDouble::setArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet)
+{
+  if(newArray!=arrayToSet)
+    {
+      if(arrayToSet)
+        arrayToSet->decrRef();
+      arrayToSet=newArray;
+      if(arrayToSet)
+        arrayToSet->incrRef();
+    }
+}
+
+void DataArrayDouble::useArray(const double *array, bool ownership,  DeallocType type, int nbOfTuple, int nbOfCompo)
+{
+  _nb_of_tuples=nbOfTuple;
+  _info_on_compo.resize(nbOfCompo);
+  _mem.useArray(array,ownership,type,nbOfTuple*nbOfCompo);
+  declareAsNew();
+}
+
+DataArrayInt *DataArrayInt::New()
+{
+  return new DataArrayInt;
+}
+
+DataArrayInt *DataArrayInt::deepCopy() const
+{
+  return new DataArrayInt(*this);
+}
+
+DataArrayInt *DataArrayInt::performCpy(bool deepCpy) const
+{
+  if(deepCpy)
+    return deepCopy();
+  else
+    {
+      incrRef();
+      return const_cast<DataArrayInt *>(this);
+    }
+}
+
+void DataArrayInt::alloc(int nbOfTuple, int nbOfCompo)
+{
+  _nb_of_tuples=nbOfTuple;
+  _info_on_compo.resize(nbOfCompo);
+  _mem.alloc(nbOfCompo*_nb_of_tuples);
+  declareAsNew();
+}
+
+bool DataArrayInt::isEqual(const DataArrayInt& other) const
+{
+  if(!areInfoEquals(other))
+    return false;
+  return _mem.isEqual(other._mem,0);
+}
+
+void DataArrayInt::useArray(const int *array, bool ownership,  DeallocType type, int nbOfTuple, int nbOfCompo)
+{
+  _nb_of_tuples=nbOfTuple;
+  _info_on_compo.resize(nbOfCompo);
+  _mem.useArray(array,ownership,type,nbOfTuple*nbOfCompo);
+  declareAsNew();
+}
+
+void DataArrayInt::reAlloc(int nbOfTuples)
+{
+  _mem.reAlloc(_info_on_compo.size()*nbOfTuples);
+  _nb_of_tuples=nbOfTuples;
+  declareAsNew();
+}
+
+void DataArrayInt::setArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet)
+{
+  if(newArray!=arrayToSet)
+    {
+      if(arrayToSet)
+        arrayToSet->decrRef();
+      arrayToSet=newArray;
+      if(arrayToSet)
+        arrayToSet->incrRef();
+    }
+}
diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx
new file mode 100644 (file)
index 0000000..1865161
--- /dev/null
@@ -0,0 +1,155 @@
+//  Copyright (C) 2007-2008  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.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef __PARAMEDMEM_MEDCOUPLINGMEMARRAY_HXX__
+#define __PARAMEDMEM_MEDCOUPLINGMEMARRAY_HXX__
+
+#include "MEDCoupling.hxx"
+#include "MEDCouplingTimeLabel.hxx"
+#include "MEDCouplingRefCountObject.hxx"
+#include "InterpKernelException.hxx"
+
+#include <string>
+#include <vector>
+
+namespace ParaMEDMEM
+{
+  template<class T>
+  class MEDCouplingPointer
+  {
+  public:
+    MEDCouplingPointer():_internal(0),_external(0) { }
+    void null() { _internal=0; _external=0; }
+    bool isNull() const { return _internal==0 && _external==0; }
+    void setInternal(T *pointer);
+    void setExternal(const T *pointer);
+    const T *getConstPointer() const { if(_internal) return _internal; else return _external; }
+    const T *getConstPointerLoc(int offset) const { if(_internal) return _internal+offset; else return _external+offset; }
+    T *getPointer() const { if(_internal) return _internal; if(_external) throw INTERP_KERNEL::Exception("Trying to write on an external pointer."); else return 0; }
+  private:
+    T *_internal;
+    const T *_external;
+  };
+
+  template<class T>
+  class MemArray
+  {
+  public:
+    MemArray():_nb_of_elem(-1),_ownership(false),_dealloc(CPP_DEALLOC) { }
+    MemArray(const MemArray<T>& other);
+    const T *getConstPointerLoc(int offset) const { return _pointer.getConstPointerLoc(offset); }
+    const T *getConstPointer() const { return _pointer.getConstPointer(); }
+    T *getPointer() const { return _pointer.getPointer(); }
+    MemArray<T> &operator=(const MemArray<T>& other);
+    T operator[](int id) const { return _pointer.getConstPointer()[id]; }
+    T& operator[](int id) { return _pointer.getPointer()[id]; }
+    bool isEqual(const MemArray<T>& other, T prec) const;
+    void alloc(int nbOfElements);
+    void reAlloc(int newNbOfElements);
+    void useArray(const T *array, bool ownership, DeallocType type, int nbOfElem);
+    void writeOnPlace(int id, T element0, const T *others, int sizeOfOthers);
+    ~MemArray() { destroy(); }
+  private:
+    void destroy();
+    static void destroyPointer(T *pt, DeallocType type);
+  private:
+    int _nb_of_elem;
+    bool _ownership;
+    MEDCouplingPointer<T> _pointer;
+    //T *_pointer;
+    DeallocType _dealloc;
+  };
+
+  class MEDCOUPLING_EXPORT DataArray : public RefCountObject, public TimeLabel
+  {
+  public:
+    void setName(const char *name);
+    bool areInfoEquals(const DataArray& other) const;
+    std::string getName() const { return _name; }
+    std::string getInfoOnComponent(int i) const { return _info_on_compo[i]; }
+    void setInfoOnComponent(int i, const char *info) { _info_on_compo[i]=info; }
+    int getNumberOfComponents() const { return _info_on_compo.size(); }
+    int getNumberOfTuples() const { return _nb_of_tuples; }
+    int getNbOfElems() const { return _info_on_compo.size()*_nb_of_tuples; }
+  protected:
+    DataArray():_nb_of_tuples(-1) { }
+  protected:
+    int _nb_of_tuples;
+    std::string _name;
+    std::vector<std::string> _info_on_compo;
+  };
+}
+
+#include "MEDCouplingMemArray.txx"
+
+namespace ParaMEDMEM
+{
+  class MEDCOUPLING_EXPORT DataArrayDouble : public DataArray
+  {
+  public:
+    static DataArrayDouble *New();
+    DataArrayDouble *deepCopy() const;
+    DataArrayDouble *performCpy(bool deepCpy) const;
+    void alloc(int nbOfTuple, int nbOfCompo);
+    bool isEqual(const DataArrayDouble& other, double prec) const;
+    //!alloc or useArray should have been called before.
+    void reAlloc(int nbOfTuples);
+    void getTuple(int tupleId, double *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
+    double getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
+    void setIJ(int tupleId, int compoId, double newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
+    double *getPointer() const { return _mem.getPointer(); }
+    static void setArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet);
+    const double *getConstPointer() const { return _mem.getConstPointer(); }
+    void useArray(const double *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
+    void writeOnPlace(int id, double element0, const double *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
+    //! nothing to do here because this class does not aggregate any TimeLabel instance.
+    void updateTime() { }
+  private:
+    DataArrayDouble() { }
+  private:
+    MemArray<double> _mem;
+  };
+
+  class MEDCOUPLING_EXPORT DataArrayInt : public DataArray
+  {
+  public:
+    static DataArrayInt *New();
+    DataArrayInt *deepCopy() const;
+    DataArrayInt *performCpy(bool deepCpy) const;
+    void alloc(int nbOfTuple, int nbOfCompo);
+    bool isEqual(const DataArrayInt& other) const;
+    //!alloc or useArray should have been called before.
+    void reAlloc(int nbOfTuples);
+    void getTuple(int tupleId, int *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
+    int getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
+    void setIJ(int tupleId, int compoId, int newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
+    int *getPointer() const { return _mem.getPointer(); }
+    static void setArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet);
+    const int *getConstPointer() const { return _mem.getConstPointer(); }
+    void useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
+    void writeOnPlace(int id, int element0, const int *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
+    //! nothing to do here because this class does not aggregate any TimeLabel instance.
+    void updateTime() { }
+  private:
+    DataArrayInt() { }
+  private:
+    MemArray<int> _mem;
+  };
+}
+
+#endif
diff --git a/src/MEDCoupling/MEDCouplingMemArray.txx b/src/MEDCoupling/MEDCouplingMemArray.txx
new file mode 100644 (file)
index 0000000..8d6a819
--- /dev/null
@@ -0,0 +1,159 @@
+//  Copyright (C) 2007-2008  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.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef __PARAMEDMEM_MEDCOUPLINGMEMARRAY_TXX__
+#define __PARAMEDMEM_MEDCOUPLINGMEMARRAY_TXX__
+
+#include "MEDCouplingMemArray.hxx"
+#include "NormalizedUnstructuredMesh.hxx"
+#include "InterpKernelException.hxx"
+
+#include <sstream>
+#include <algorithm>
+
+namespace ParaMEDMEM
+{
+  template<class T>
+  void MEDCouplingPointer<T>::setInternal(T *pointer)
+  {
+    _internal=pointer;
+    _external=0;
+  }
+
+  template<class T>
+  void MEDCouplingPointer<T>::setExternal(const T *pointer)
+  {
+    _external=pointer;
+    _internal=0;
+  }
+
+  template<class T>
+  MemArray<T>::MemArray(const MemArray<T>& other):_nb_of_elem(-1),_ownership(false),_dealloc(CPP_DEALLOC)
+  {
+    if(!other._pointer.isNull())
+      {
+        T *pointer=new T[other._nb_of_elem];
+        std::copy(other._pointer.getConstPointer(),other._pointer.getConstPointer()+other._nb_of_elem,pointer);
+        useArray(pointer,true,CPP_DEALLOC,other._nb_of_elem);
+      }
+  }
+
+  template<class T>
+  void MemArray<T>::useArray(const T *array, bool ownership, DeallocType type, int nbOfElem)
+  {
+    _nb_of_elem=nbOfElem;
+    destroy();
+    if(ownership)
+      _pointer.setInternal((T *)array);
+    else
+      _pointer.setExternal(array);
+    _ownership=ownership;
+    _dealloc=type;
+  }
+
+  template<class T>
+  void MemArray<T>::writeOnPlace(int id, T element0, const T *others, int sizeOfOthers)
+  {
+    if(id+sizeOfOthers>=_nb_of_elem)
+      reAlloc(2*_nb_of_elem+sizeOfOthers+1);
+    T *pointer=_pointer.getPointer();
+    pointer[id]=element0;
+    std::copy(others,others+sizeOfOthers,pointer+id+1);
+  }
+
+  template<class T>
+  bool MemArray<T>::isEqual(const MemArray<T>& other, T prec) const
+  {
+    if(_nb_of_elem!=other._nb_of_elem)
+      return false;
+    const T *pt1=_pointer.getConstPointer();
+    const T *pt2=other._pointer.getConstPointer();
+    if(pt1==0 && pt2==0)
+      return true;
+    if(pt1==0 || pt2==0)
+      return false;
+    for(int i=0;i<_nb_of_elem;i++)
+      if(pt1[i]-pt2[i]<-prec || (pt1[i]-pt2[i])>prec)
+        return false;
+    return true;
+  }
+
+  template<class T>
+  void MemArray<T>::alloc(int nbOfElements)
+  {
+    destroy();
+    _nb_of_elem=nbOfElements;
+    _pointer.setInternal(new T[_nb_of_elem]);
+    _ownership=true;
+    _dealloc=CPP_DEALLOC;
+  }
+  
+  template<class T>
+  void MemArray<T>::reAlloc(int newNbOfElements)
+  {
+    T *pointer=new T[newNbOfElements];
+    std::copy(_pointer.getConstPointer(),_pointer.getConstPointer()+std::min<int>(_nb_of_elem,newNbOfElements),pointer);
+    if(_ownership)
+      destroyPointer((T *)_pointer.getConstPointer(),_dealloc);
+    _pointer.setInternal(pointer);
+    _nb_of_elem=newNbOfElements;
+    _ownership=true;
+    _dealloc=CPP_DEALLOC;
+  }
+
+  template<class T>
+  void MemArray<T>::destroyPointer(T *pt, DeallocType type)
+  {
+    switch(type)
+      {
+      case CPP_DEALLOC:
+        {
+          delete [] pt;
+          return ;
+        }
+      case C_DEALLOC:
+        {
+          free(pt);
+          return ;
+        }
+      default:
+        std::stringstream stream;
+        stream << "Invalid deallocation requested for pointer " << pt;
+        throw INTERP_KERNEL::Exception(stream.str().c_str());
+      }
+  }
+
+  template<class T>
+  void MemArray<T>::destroy()
+  {
+    if(_ownership)
+      destroyPointer((T *)_pointer.getConstPointer(),_dealloc);
+    _pointer.null();
+    _ownership=false;
+  }
+  
+  template<class T>
+  MemArray<T> &MemArray<T>::operator=(const MemArray<T>& other)
+  {
+    alloc(other._nb_of_elem);
+    std::copy(other._pointer.getConstPointer(),other._pointer.getConstPointer()+_nb_of_elem,_pointer.getPointer());
+    return *this;
+  }
+}
+
+#endif
index 3b860a226159ca8bdd8191f0d7f6415e9348fbf5..61324c2f8b15c7d02b6ad9e89d8b7c3caa7b3952 100644 (file)
 #define __PARAMEDMEM_MEDCOUPLINGMESH_HXX__
 
 #include "MEDCoupling.hxx"
-#include "RefCountObject.hxx"
+#include "MEDCouplingTimeLabel.hxx"
+#include "MEDCouplingRefCountObject.hxx"
 #include "InterpKernelException.hxx"
 
 namespace ParaMEDMEM
 {
+  typedef enum
+    {
+      UNSTRUCTURED = 5,
+      UNSTRUCTURED_DESC = 6,
+      CARTESIAN = 7,
+    } MEDCouplingMeshType;
+
   class MEDCouplingFieldDouble;
 
-  class MEDCOUPLING_EXPORT MEDCouplingMesh : public RefCountObject
+  class MEDCOUPLING_EXPORT MEDCouplingMesh : public RefCountObject, public TimeLabel
   {
   public:
     void setName(const char *name) { _name=name; }
     const char *getName() const { return _name.c_str(); }
+    virtual MEDCouplingMeshType getType() const = 0;
     virtual bool isEqual(const MEDCouplingMesh *other, double prec) const { return _name==other->_name; }
     virtual void checkCoherency() const throw(INTERP_KERNEL::Exception) = 0;
     virtual bool isStructured() const = 0;
diff --git a/src/MEDCoupling/MEDCouplingNatureOfField.hxx b/src/MEDCoupling/MEDCouplingNatureOfField.hxx
new file mode 100644 (file)
index 0000000..baffb73
--- /dev/null
@@ -0,0 +1,33 @@
+//  Copyright (C) 2007-2008  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.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef __MEDCOUPLINGNATUREOFFIELD_HXX__
+#define __MEDCOUPLINGNATUREOFFIELD_HXX__
+
+namespace ParaMEDMEM
+{
+  typedef enum
+    {
+      NoNature               = 17,
+      ConservativeVolumic    = 26,
+      Integral               = 32,
+      IntegralGlobConstraint = 35
+    } NatureOfField;
+}
+
+#endif
index 65970cfe95371ad8f5b672261549eb16bf4c0ead..7b08b093acba172ab0a6ce7ec8f9b6fc8f3d6d78 100644 (file)
@@ -22,7 +22,7 @@
 #include "MEDCouplingNormalizedUnstructuredMesh.hxx"
 
 #include "MEDCouplingUMesh.hxx"
-#include "MemArray.hxx"
+#include "MEDCouplingMemArray.hxx"
 
 template<int SPACEDIM,int MESHDIM>
 MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::MEDCouplingNormalizedUnstructuredMesh(ParaMEDMEM::MEDCouplingUMesh *mesh):_mesh(mesh)
index 0f0cadec2699cbad7f704b95df624a4fd33f1776..abbc4cfd04b882831ea022452897f13629c630db 100644 (file)
@@ -17,7 +17,9 @@
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 #include "MEDCouplingPointSet.hxx"
-#include "MemArray.hxx"
+#include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingUMeshDesc.hxx"
+#include "MEDCouplingMemArray.hxx"
 
 using namespace ParaMEDMEM;
 
@@ -81,7 +83,13 @@ void MEDCouplingPointSet::setCoords(DataArrayDouble *coords)
 
 bool MEDCouplingPointSet::areCoordsEqual(const MEDCouplingPointSet& other, double prec) const
 {
-  return _coords->isEqual(other._coords,prec);
+  if(_coords==0 && other._coords==0)
+    return true;
+  if(_coords==0 || other._coords==0)
+    return false;
+  if(_coords==other._coords)
+    return true;
+  return _coords->isEqual(*other._coords,prec);
 }
 
 void MEDCouplingPointSet::getBoundingBox(double *bbox) const
@@ -110,6 +118,81 @@ void MEDCouplingPointSet::getBoundingBox(double *bbox) const
     }
 }
 
+MEDCouplingPointSet *MEDCouplingPointSet::buildInstanceFromMeshType(MEDCouplingMeshType type)
+{
+  switch(type)
+    {
+    case UNSTRUCTURED:
+      return MEDCouplingUMesh::New();
+    case UNSTRUCTURED_DESC:
+      return MEDCouplingUMeshDesc::New();
+    default:
+      throw INTERP_KERNEL::Exception("Invalid type of mesh specified");
+    }
+}
+
+void MEDCouplingPointSet::getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
+{
+  if(_coords)
+    {
+      int spaceDim=getSpaceDimension();
+      littleStrings.resize(spaceDim+1);
+      littleStrings[0]=getName();
+      for(int i=0;i<spaceDim;i++)
+        littleStrings[i+1]=getCoords()->getInfoOnComponent(i);
+      tinyInfo.clear();
+      tinyInfo.push_back(getType());
+      tinyInfo.push_back(spaceDim);
+      tinyInfo.push_back(getNumberOfNodes());
+    }
+  else
+    {
+      littleStrings.resize(1);
+      littleStrings[0]=getName();
+      tinyInfo.clear();
+      tinyInfo.push_back(getType());
+      tinyInfo.push_back(-1);
+      tinyInfo.push_back(-1);
+    }
+}
+
+void MEDCouplingPointSet::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const
+{
+  if(_coords)
+    {
+      a2=getCoords();
+      a2->incrRef();
+    }
+  else
+    a2=0;
+}
+
+void MEDCouplingPointSet::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings)
+{
+  if(tinyInfo[2]>=0 && tinyInfo[1]>=1)
+    {
+      a2->alloc(tinyInfo[2],tinyInfo[1]);
+      littleStrings.resize(tinyInfo[1]+1);
+    }
+  else
+    {
+      littleStrings.resize(1);
+    }
+}
+
+void MEDCouplingPointSet::unserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
+{
+  if(tinyInfo[2]>=0 && tinyInfo[1]>=1)
+    {
+      setCoords(a2);
+      setName(littleStrings[0].c_str());
+      for(int i=0;i<tinyInfo[1];i++)
+        getCoords()->setInfoOnComponent(i,littleStrings[i+1].c_str());
+    }
+  else
+    setName(littleStrings[0].c_str());
+}
+
 // =============================================
 // Intersect Bounding Box given 2 Bounding Boxes
 // =============================================
@@ -140,3 +223,4 @@ bool MEDCouplingPointSet::intersectsBoundingBox(const double* bb1, const double*
     }
   return true;
 }
+
index 9acf855902ee86782033e9867925242815bc11ac..26694f4131f5cdb251def551a017d9e9f8149782 100644 (file)
@@ -44,12 +44,14 @@ namespace ParaMEDMEM
     DataArrayDouble *getCoords() const { return _coords; }
     bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const;
     void getBoundingBox(double *bbox) const;
+    static MEDCouplingPointSet *buildInstanceFromMeshType(MEDCouplingMeshType type);
     virtual MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const = 0;
     //! size of returned tinyInfo must be always the same.
-    virtual void getTinySerializationInformation(std::vector<int>& tinyInfo) const = 0;
-    virtual void resizeForSerialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2) = 0;
-    virtual void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) = 0;
-    virtual MEDCouplingPointSet *buildObjectFromUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2) = 0;
+    virtual void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
+    virtual void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings);
+    virtual void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
+    virtual void unserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2,
+                                 const std::vector<std::string>& littleStrings);
     virtual void giveElemsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems) = 0;
   protected:
     static bool intersectsBoundingBox(const double* bb1, const double* bb2, int dim, double eps);
diff --git a/src/MEDCoupling/MEDCouplingRMesh.cxx b/src/MEDCoupling/MEDCouplingRMesh.cxx
deleted file mode 100644 (file)
index 70e2fc7..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-//  Copyright (C) 2007-2008  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.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "MEDCouplingRMesh.hxx"
-#include "MemArray.hxx"
-
-using namespace ParaMEDMEM;
-
-MEDCouplingRMesh::MEDCouplingRMesh():_x_array(0),_y_array(0),_z_array(0)
-{
-}
-
-MEDCouplingRMesh::~MEDCouplingRMesh()
-{
-  if(_x_array)
-    _x_array->decrRef();
-  if(_y_array)
-    _y_array->decrRef();
-  if(_z_array)
-    _z_array->decrRef();
-}
-
-MEDCouplingRMesh *MEDCouplingRMesh::New()
-{
-  return new MEDCouplingRMesh;
-}
-
-void MEDCouplingRMesh::updateTime()
-{
-  if(_x_array)
-    updateTimeWith(*_x_array);
-  if(_y_array)
-    updateTimeWith(*_y_array);
-  if(_z_array)
-    updateTimeWith(*_z_array);
-}
-
-bool MEDCouplingRMesh::isEqual(const MEDCouplingMesh *other, double prec) const
-{
-  const MEDCouplingRMesh *otherC=dynamic_cast<const MEDCouplingRMesh *>(other);
-  if(!otherC)
-    return false;
-  return true;
-}
-
-void MEDCouplingRMesh::checkCoherency() const throw(INTERP_KERNEL::Exception)
-{
-  const char msg0[]="Invalid ";
-  const char msg1[]=" array ! Must contain more than 1 element.";
-  if(_x_array)
-    if(_x_array->getNbOfElems()<2)
-      {
-        std::ostringstream os; os << msg0 << 'X' << msg1;
-        throw INTERP_KERNEL::Exception(os.str().c_str());
-      }
-  if(_y_array)
-    if(_y_array->getNbOfElems()<2)
-      {
-        std::ostringstream os; os << msg0 << 'Y' << msg1;
-        throw INTERP_KERNEL::Exception(os.str().c_str());
-      }
-  if(_z_array)
-    if(_z_array->getNbOfElems()<2)
-      {
-        std::ostringstream os; os << msg0 << 'Z' << msg1;
-        throw INTERP_KERNEL::Exception(os.str().c_str());
-      }
-}
-
-bool MEDCouplingRMesh::isStructured() const
-{
-  return true;
-}
-
-int MEDCouplingRMesh::getNumberOfCells() const
-{
-  int ret=1;
-  if(_x_array)
-    ret*=_x_array->getNbOfElems()-1;
-  if(_y_array)
-    ret*=_y_array->getNbOfElems()-1;
-  if(_z_array)
-    ret*=_z_array->getNbOfElems()-1;
-  return ret;
-}
-
-int MEDCouplingRMesh::getNumberOfNodes() const
-{
-  int ret=1;
-  if(_x_array)
-    ret*=_x_array->getNbOfElems();
-  if(_y_array)
-    ret*=_y_array->getNbOfElems();
-  if(_z_array)
-    ret*=_z_array->getNbOfElems();
-  return ret;
-}
-
-int MEDCouplingRMesh::getSpaceDimension() const
-{
-  int ret=0;
-  if(_x_array)
-    ret++;
-  if(_y_array)
-    ret++;
-  if(_z_array)
-    ret++;
-  return ret;
-}
-
-int MEDCouplingRMesh::getMeshDimension() const
-{
-  int ret=0;
-  if(_x_array)
-    ret++;
-  if(_y_array)
-    ret++;
-  if(_z_array)
-    ret++;
-  return ret;
-}
-
-DataArrayDouble *MEDCouplingRMesh::getCoordsAt(int i) const throw(INTERP_KERNEL::Exception)
-{
-  switch(i)
-    {
-    case 0:
-      return _x_array;
-    case 1:
-      return _y_array;
-    case 2:
-      return _z_array;
-    default:
-      throw INTERP_KERNEL::Exception("Invalid rank specified must be 0 or 1 or 2.");
-    }
-}
-
-void MEDCouplingRMesh::setCoords(DataArrayDouble *coordsX, DataArrayDouble *coordsY, DataArrayDouble *coordsZ)
-{
-  if(_x_array)
-    _x_array->decrRef();
-  _x_array=coordsX;
-  if(_x_array)
-    _x_array->incrRef();
-  if(_y_array)
-    _y_array->decrRef();
-  _y_array=coordsY;
-  if(_y_array)
-    _y_array->incrRef();
-  if(_z_array)
-    _z_array->decrRef();
-  _z_array=coordsZ;
-  if(_z_array)
-    _z_array->incrRef();
-  declareAsNew();
-}
-
-void MEDCouplingRMesh::getBoundingBox(double *bbox) const
-{
-  //not implemented yet !
-}
-
-MEDCouplingFieldDouble *MEDCouplingRMesh::getMeasureField() const
-{
-  //not implemented yet !
-}
diff --git a/src/MEDCoupling/MEDCouplingRMesh.hxx b/src/MEDCoupling/MEDCouplingRMesh.hxx
deleted file mode 100644 (file)
index e077459..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-//  Copyright (C) 2007-2008  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.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef __PARAMEDMEM_MEDCOUPLINGRMESH_HXX__
-#define __PARAMEDMEM_MEDCOUPLINGRMESH_HXX__
-
-#include "MEDCoupling.hxx"
-#include "MEDCouplingMesh.hxx"
-
-namespace ParaMEDMEM
-{
-  class DataArrayDouble;
-
-  class MEDCouplingRMesh : public MEDCouplingMesh
-  {
-  public:
-    static MEDCouplingRMesh *New();
-    void updateTime();
-    bool isEqual(const MEDCouplingMesh *other, double prec) const;
-    void checkCoherency() const throw(INTERP_KERNEL::Exception);
-    bool isStructured() const;
-    int getNumberOfCells() const;
-    int getNumberOfNodes() const;
-    int getSpaceDimension() const;
-    int getMeshDimension() const;
-    DataArrayDouble *getCoordsAt(int i) const throw(INTERP_KERNEL::Exception);
-    void setCoords(DataArrayDouble *coordsX,
-                   DataArrayDouble *coordsY=0,
-                   DataArrayDouble *coordsZ=0);
-    // tools
-    void getBoundingBox(double *bbox) const;
-    MEDCouplingFieldDouble *getMeasureField() const;
-  private:
-    MEDCouplingRMesh();
-    ~MEDCouplingRMesh();
-  private:
-    DataArrayDouble *_x_array;
-    DataArrayDouble *_y_array;
-    DataArrayDouble *_z_array;
-  };
-}
-
-#endif
diff --git a/src/MEDCoupling/MEDCouplingRefCountObject.cxx b/src/MEDCoupling/MEDCouplingRefCountObject.cxx
new file mode 100644 (file)
index 0000000..c9825ed
--- /dev/null
@@ -0,0 +1,46 @@
+//  Copyright (C) 2007-2008  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.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include "MEDCouplingRefCountObject.hxx"
+
+using namespace ParaMEDMEM;
+
+RefCountObject::RefCountObject():_cnt(1)
+{
+}
+
+RefCountObject::RefCountObject(const RefCountObject& other):_cnt(1)
+{
+}
+
+bool RefCountObject::decrRef()
+{
+  bool ret=((--_cnt)==0);
+  if(ret)
+    delete this;
+  return ret;
+}
+
+void RefCountObject::incrRef() const
+{
+  _cnt++;
+}
+
+RefCountObject::~RefCountObject()
+{
+}
diff --git a/src/MEDCoupling/MEDCouplingRefCountObject.hxx b/src/MEDCoupling/MEDCouplingRefCountObject.hxx
new file mode 100644 (file)
index 0000000..adeb8c7
--- /dev/null
@@ -0,0 +1,58 @@
+//  Copyright (C) 2007-2008  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.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef __PARAMEDMEM_MEDCOUPLINGREFCOUNTOBJECT_HXX__
+#define __PARAMEDMEM_MEDCOUPLINGREFCOUNTOBJECT_HXX__
+
+namespace ParaMEDMEM
+{
+  typedef enum
+    {
+      C_DEALLOC = 2,
+      CPP_DEALLOC = 3
+    } DeallocType;
+
+  typedef enum
+    {
+      ON_CELLS = 0,
+      ON_NODES = 1
+    } TypeOfField;
+
+  typedef enum
+    {
+      NO_TIME = 4,
+      ONE_TIME = 5,
+      LINEAR_TIME = 6
+    } TypeOfTimeDiscretization;
+
+  class RefCountObject
+  {
+  protected:
+    RefCountObject();
+    RefCountObject(const RefCountObject& other);
+  public:
+    bool decrRef();
+    void incrRef() const;
+  protected:
+    virtual ~RefCountObject();
+  private:
+    mutable int _cnt;
+  };
+}
+
+#endif
index 892a52caad398b78ffc854b44bae388a36399527..6c75e607cc0e99199d44160d95565e4720a8e660 100644 (file)
@@ -17,7 +17,7 @@
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 #include "MEDCouplingTimeDiscretization.hxx"
-#include "MemArray.hxx"
+#include "MEDCouplingMemArray.hxx"
 
 #include <cmath>
 
@@ -42,6 +42,68 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::New(TypeOfTimeDisc
     }
 }
 
+bool MEDCouplingTimeDiscretization::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
+{
+  if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
+    return false;
+  if(_array==0 && other->_array==0)
+    return true;
+  if(_array==0 || other->_array==0)
+    return false;
+  if(_array==other->_array)
+    return true;
+  return _array->isEqual(*other->_array,prec);
+}
+
+void MEDCouplingTimeDiscretization::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
+{
+  if(_array)
+    {
+      tinyInfo.push_back(_array->getNumberOfTuples());
+      tinyInfo.push_back(_array->getNumberOfComponents());
+    }
+  else
+    {
+      tinyInfo.push_back(-1);
+      tinyInfo.push_back(-1);
+    }
+}
+
+void MEDCouplingTimeDiscretization::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
+{
+  arrays.resize(1);
+  if(_array!=0)
+    _array->decrRef();
+  DataArrayDouble *arr=0;
+  if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
+    {
+      arr=DataArrayDouble::New();
+      arr->alloc(tinyInfoI[0],tinyInfoI[1]);
+    }
+  _array=arr;
+  arrays[0]=arr;
+}
+
+void MEDCouplingTimeDiscretization::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
+{
+  _time_tolerance=tinyInfoD[0];
+  int nbOfCompo=_array->getNumberOfComponents();
+  for(int i=0;i<nbOfCompo;i++)
+    _array->setInfoOnComponent(i,tinyInfoS[i].c_str());
+}
+
+void MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
+{
+  tinyInfo.push_back(_time_tolerance);
+}
+
+void MEDCouplingTimeDiscretization::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
+{
+  int nbOfCompo=_array->getNumberOfComponents();
+  for(int i=0;i<nbOfCompo;i++)
+    tinyInfo.push_back(_array->getInfoOnComponent(i));
+}
+
 MEDCouplingTimeDiscretization::MEDCouplingTimeDiscretization():_time_tolerance(TIME_TOLERANCE_DFT),_array(0)
 {
 }
@@ -110,6 +172,14 @@ MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel(const MEDCouplingTimeDiscretizati
 {
 }
 
+bool MEDCouplingNoTimeLabel::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
+{
+  const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
+  if(!otherC)
+    return false;
+  return MEDCouplingTimeDiscretization::isEqual(other,prec);
+}
+
 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::performCpy(bool deepCpy) const
 {
   return new MEDCouplingNoTimeLabel(*this,deepCpy);
@@ -174,6 +244,41 @@ MEDCouplingWithTimeStep::MEDCouplingWithTimeStep():_time(0.),_dt(-1),_it(-1)
 {
 }
 
+void MEDCouplingWithTimeStep::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
+{
+  MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
+  tinyInfo.push_back(_dt);
+  tinyInfo.push_back(_it);
+}
+
+void MEDCouplingWithTimeStep::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
+{
+  MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
+  tinyInfo.push_back(_time);
+}
+
+void MEDCouplingWithTimeStep::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
+{
+  MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
+  _time=tinyInfoD[1];
+  _dt=tinyInfoI[2];
+  _it=tinyInfoI[3];
+}
+
+bool MEDCouplingWithTimeStep::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
+{
+  const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
+  if(!otherC)
+    return false;
+  if(_dt!=otherC->_dt)
+    return false;
+  if(_it!=otherC->_it)
+    return false;
+  if(std::fabs(_time-otherC->_time)>_time_tolerance)
+    return false;
+  return MEDCouplingTimeDiscretization::isEqual(other,prec);
+}
+
 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::performCpy(bool deepCpy) const
 {
   return new MEDCouplingWithTimeStep(*this,deepCpy);
@@ -260,3 +365,39 @@ void MEDCouplingTwoTimeSteps::getArrays(std::vector<DataArrayDouble *>& arrays)
   arrays[0]=_array;
   arrays[1]=_end_array;
 }
+
+void MEDCouplingTwoTimeSteps::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
+{
+  arrays.resize(2);
+  if(_array!=0)
+    _array->decrRef();
+  if(_end_array!=0)
+    _end_array->decrRef();
+  DataArrayDouble *arr=0;
+  if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
+    {
+      arr=DataArrayDouble::New();
+      arr->alloc(tinyInfoI[0],tinyInfoI[1]);
+    }
+  _array=arr;
+  arrays[0]=arr;
+  arr=0;
+  if(tinyInfoI[2]!=-1 && tinyInfoI[3]!=-1)
+    {
+      arr=DataArrayDouble::New();
+      arr->alloc(tinyInfoI[2],tinyInfoI[3]);
+    }
+  _end_array=arr;
+  arrays[1]=arr;
+}
+
+void MEDCouplingTwoTimeSteps::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
+{
+  MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
+  _start_time=tinyInfoD[1];
+  _end_time=tinyInfoD[2];
+  _start_dt=tinyInfoI[2];
+  _end_dt=tinyInfoI[3];
+  _start_it=tinyInfoI[4];
+  _end_it=tinyInfoI[5];
+}
index 9128f070254d480912b8debfed3f331237617444..6764689ff54caba119fe39609f33bb7ea48deaf5 100644 (file)
@@ -20,7 +20,7 @@
 #define __MEDCOUPLINGTIMEDISCRETIZATION_HXX__
 
 #include "MEDCoupling.hxx"
-#include "RefCountObject.hxx"
+#include "MEDCouplingRefCountObject.hxx"
 #include "InterpKernelException.hxx"
 
 #include <vector>
@@ -37,6 +37,13 @@ namespace ParaMEDMEM
     MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCpy);
   public:
     static MEDCouplingTimeDiscretization *New(TypeOfTimeDiscretization type);
+    virtual bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
+    virtual TypeOfTimeDiscretization getEnum() const = 0;
+    virtual void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
+    virtual void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
+    virtual void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
+    virtual void resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays);
+    virtual void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
     virtual MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const = 0;
     void setTimeTolerance(double val);
     double getTimeTolerance() const { return _time_tolerance; }
@@ -72,6 +79,8 @@ namespace ParaMEDMEM
   public:
     MEDCouplingNoTimeLabel();
     MEDCouplingNoTimeLabel(const MEDCouplingTimeDiscretization& other, bool deepCpy);
+    TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
+    bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
     MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
     void checkNoTimePresence() const throw(INTERP_KERNEL::Exception) { }
     void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
@@ -96,6 +105,11 @@ namespace ParaMEDMEM
     MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCpy);
   public:
     MEDCouplingWithTimeStep();
+    TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
+    bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
+    void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
+    void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
+    void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
     MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
     void checkNoTimePresence() const throw(INTERP_KERNEL::Exception);
     void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
@@ -130,6 +144,8 @@ namespace ParaMEDMEM
     void setEndTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception) { _end_time=time; _end_dt=dt; _end_it=it; }
     double getStartTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception) { dt=_start_dt; it=_start_it; return _start_time; }
     double getEndTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception) { dt=_end_dt; it=_end_it; return _end_time; }
+    void resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays);
+    void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
   protected:
     double _start_time;
     double _end_time;
@@ -143,6 +159,7 @@ namespace ParaMEDMEM
   class MEDCOUPLING_EXPORT MEDCouplingLinearTime : public MEDCouplingTwoTimeSteps
   {
   public:
+    TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
     static const TypeOfTimeDiscretization DISCRETIZATION=LINEAR_TIME;
   };
 }
diff --git a/src/MEDCoupling/MEDCouplingTimeLabel.cxx b/src/MEDCoupling/MEDCouplingTimeLabel.cxx
new file mode 100644 (file)
index 0000000..52e33f5
--- /dev/null
@@ -0,0 +1,48 @@
+//  Copyright (C) 2007-2008  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.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include "MEDCouplingTimeLabel.hxx"
+
+using namespace ParaMEDMEM;
+
+unsigned int TimeLabel::GLOBAL_TIME=0;
+
+TimeLabel::TimeLabel():_time(GLOBAL_TIME++)
+{
+}
+
+TimeLabel::~TimeLabel()
+{
+}
+
+ TimeLabel& TimeLabel::operator=(const TimeLabel& other)
+{
+  _time=GLOBAL_TIME++;
+  return *this;
+}
+
+void TimeLabel::declareAsNew()
+{
+  _time=GLOBAL_TIME++;
+}
+
+void TimeLabel::updateTimeWith(const TimeLabel& other)
+{
+  if(_time<other._time)
+    _time=other._time;
+}
diff --git a/src/MEDCoupling/MEDCouplingTimeLabel.hxx b/src/MEDCoupling/MEDCouplingTimeLabel.hxx
new file mode 100644 (file)
index 0000000..d87791c
--- /dev/null
@@ -0,0 +1,48 @@
+//  Copyright (C) 2007-2008  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.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef __PARAMEDMEM_TIMELABEL_HXX__
+#define __PARAMEDMEM_TIMELABEL_HXX__
+
+#include "MEDCoupling.hxx"
+
+namespace ParaMEDMEM
+{
+  /*!
+   * Class representing a label of time of the lastely modified part of this.
+   * More _time is high more the object has been modified recently.
+   */
+  class MEDCOUPLING_EXPORT TimeLabel
+  {
+  public:
+    TimeLabel& operator=(const TimeLabel& other);
+    //! This method should be called when write access has been done on this.
+    void declareAsNew();
+    //! This method should be called on high level classes as Field or Mesh to take into acount modifications done in aggragates objects.
+    virtual void updateTime() = 0;
+  protected:
+    TimeLabel();
+    virtual ~TimeLabel();
+    void updateTimeWith(const TimeLabel& other);
+  private:
+    static unsigned int GLOBAL_TIME;
+    unsigned int _time;
+  };
+}
+
+#endif
index d4427d7c4e078c5bbb8e2a645e0bb4edcea7aed3..552a96d02bdfd86a1c9640cf210025a9970b5a11 100644 (file)
@@ -32,6 +32,14 @@ MEDCouplingUMesh *MEDCouplingUMesh::New()
   return new MEDCouplingUMesh;
 }
 
+MEDCouplingUMesh *MEDCouplingUMesh::New(const char *meshName, int meshDim)
+{
+  MEDCouplingUMesh *ret=new MEDCouplingUMesh;
+  ret->setName(meshName);
+  ret->setMeshDimension(meshDim);
+  return ret;
+}
+
 MEDCouplingUMesh *MEDCouplingUMesh::clone(bool recDeepCpy) const
 {
   return new MEDCouplingUMesh(*this,recDeepCpy);
@@ -50,13 +58,15 @@ void MEDCouplingUMesh::updateTime()
     }
 }
 
-MEDCouplingUMesh::MEDCouplingUMesh():_iterator(-1),_mesh_dim(-1),
+MEDCouplingUMesh::MEDCouplingUMesh():_iterator(-1),_mesh_dim(-2),
                                      _nodal_connec(0),_nodal_connec_index(0)
 {
 }
 
 void MEDCouplingUMesh::checkCoherency() const throw(INTERP_KERNEL::Exception)
 {
+  if(_mesh_dim<-1)
+    throw INTERP_KERNEL::Exception("No mesh dimension specified !");
   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator iter=_types.begin();iter!=_types.end();iter++)
     {
       if(INTERP_KERNEL::CellModel::getCellModel(*iter).getDimension()!=_mesh_dim)
@@ -68,8 +78,10 @@ void MEDCouplingUMesh::checkCoherency() const throw(INTERP_KERNEL::Exception)
     }
 }
 
-void MEDCouplingUMesh::setMeshDimension(unsigned meshDim)
+void MEDCouplingUMesh::setMeshDimension(int meshDim)
 {
+  if(meshDim<-1)
+    throw INTERP_KERNEL::Exception("Invalid meshDim specified ! Must be greater or equal to -1 !");
   _mesh_dim=meshDim;
   declareAsNew();
 }
@@ -118,11 +130,11 @@ void MEDCouplingUMesh::finishInsertingCells()
 
 bool MEDCouplingUMesh::isEqual(const MEDCouplingMesh *other, double prec) const
 {
-  checkFullyDefined();
+  //checkFullyDefined();
   const MEDCouplingUMesh *otherC=dynamic_cast<const MEDCouplingUMesh *>(other);
   if(!otherC)
     return false;
-  otherC->checkFullyDefined();
+  //otherC->checkFullyDefined();
   if(!MEDCouplingMesh::isEqual(other,prec))
     return false;
   if(_mesh_dim!=otherC->_mesh_dim)
@@ -131,6 +143,18 @@ bool MEDCouplingUMesh::isEqual(const MEDCouplingMesh *other, double prec) const
     return false;
   if(!areCoordsEqual(*otherC,prec))
     return false;
+  if(_nodal_connec!=0 || otherC->_nodal_connec!=0)
+    if(_nodal_connec==0 || otherC->_nodal_connec==0)
+      return false;
+  if(_nodal_connec!=otherC->_nodal_connec)
+    if(!_nodal_connec->isEqual(*otherC->_nodal_connec))
+      return false;
+  if(_nodal_connec_index!=0 || otherC->_nodal_connec_index!=0)
+    if(_nodal_connec_index==0 || otherC->_nodal_connec_index==0)
+      return false;
+  if(_nodal_connec_index!=otherC->_nodal_connec_index)
+    if(!_nodal_connec_index->isEqual(*otherC->_nodal_connec_index))
+      return false;
   return true;
 }
 
@@ -352,7 +376,17 @@ int MEDCouplingUMesh::getNumberOfCells() const
     else
       return _iterator;
   else
-    throw INTERP_KERNEL::Exception("Unable to get number of cells because no connectivity specified !");
+    if(_mesh_dim==-1)
+      return 1;
+    else
+      throw INTERP_KERNEL::Exception("Unable to get number of cells because no connectivity specified !");
+}
+
+int MEDCouplingUMesh::getMeshDimension() const
+{
+  if(_mesh_dim<-1)
+    throw INTERP_KERNEL::Exception("No mesh dimension specified !");
+  return _mesh_dim;
 }
 
 int MEDCouplingUMesh::getMeshLength() const
@@ -360,60 +394,65 @@ int MEDCouplingUMesh::getMeshLength() const
   return _nodal_connec->getNbOfElems();
 }
 
-void MEDCouplingUMesh::getTinySerializationInformation(std::vector<int>& tinyInfo) const
+void MEDCouplingUMesh::getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
 {
-  tinyInfo.resize(5);
-  tinyInfo[0] = getSpaceDimension();
-  tinyInfo[1] = getMeshDimension();
-  tinyInfo[2] = getNumberOfNodes();
-  tinyInfo[3] = getNumberOfCells();
-  tinyInfo[4] = getMeshLength();
+  MEDCouplingPointSet::getTinySerializationInformation(tinyInfo,littleStrings);
+  tinyInfo.push_back(getMeshDimension());
+  tinyInfo.push_back(getNumberOfCells());
+  if(_nodal_connec)
+    tinyInfo.push_back(getMeshLength());
+  else
+    tinyInfo.push_back(-1);
 }
 
 /*!
  * @param tinyInfo must be equal to the result given by getTinySerializationInformation method.
  */
-void MEDCouplingUMesh::resizeForSerialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2)
+void MEDCouplingUMesh::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings)
 {
-  a1->alloc(tinyInfo[4]+tinyInfo[3]+1,1);
-  a2->alloc(tinyInfo[2],tinyInfo[0]);
+  MEDCouplingPointSet::resizeForUnserialization(tinyInfo,a1,a2,littleStrings);
+  if(tinyInfo[5]!=-1)
+    a1->alloc(tinyInfo[5]+tinyInfo[4]+1,1);
 }
 
-void MEDCouplingUMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2)
+void MEDCouplingUMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const
 {
-  a1=DataArrayInt::New();
-  a1->alloc(getMeshLength()+getNumberOfCells()+1,1);
-  int *ptA1=a1->getPointer();
-  const int *conn=getNodalConnectivity()->getConstPointer();
-  const int *index=getNodalConnectivityIndex()->getConstPointer();
-  ptA1=std::copy(index,index+getNumberOfCells()+1,ptA1);
-  std::copy(conn,conn+getMeshLength(),ptA1);
-  a2=getCoords();
-  a2->incrRef();
+  MEDCouplingPointSet::serialize(a1,a2);
+  if(getMeshDimension()>-1)
+    {
+      a1=DataArrayInt::New();
+      a1->alloc(getMeshLength()+getNumberOfCells()+1,1);
+      int *ptA1=a1->getPointer();
+      const int *conn=getNodalConnectivity()->getConstPointer();
+      const int *index=getNodalConnectivityIndex()->getConstPointer();
+      ptA1=std::copy(index,index+getNumberOfCells()+1,ptA1);
+      std::copy(conn,conn+getMeshLength(),ptA1);
+    }
+  else
+    a1=0;
 }
 
 /*!
  * @param tinyInfo must be equal to the result given by getTinySerializationInformation method.
  */
-MEDCouplingPointSet *MEDCouplingUMesh::buildObjectFromUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2)
-{
-  MEDCouplingUMesh* meshing = MEDCouplingUMesh::New() ;
-  // Coordinates
-  meshing->setCoords(a2);
-  // Connectivity
-  const int *recvBuffer=a1->getConstPointer();
-  DataArrayInt* myConnecIndex=DataArrayInt::New();
-  myConnecIndex->alloc(tinyInfo[3]+1,1);
-  std::copy(recvBuffer,recvBuffer+tinyInfo[3]+1,myConnecIndex->getPointer());
-  DataArrayInt* myConnec=DataArrayInt::New();
-  myConnec->alloc(tinyInfo[4],1);
-  std::copy(recvBuffer+tinyInfo[3]+1,recvBuffer+tinyInfo[3]+1+tinyInfo[4],myConnec->getPointer());
-  meshing->setConnectivity(myConnec, myConnecIndex) ;
-  myConnec->decrRef();
-  myConnecIndex->decrRef();
-  //
-  meshing->setMeshDimension(tinyInfo[1]);
-  return meshing;
+void MEDCouplingUMesh::unserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
+{
+  MEDCouplingPointSet::unserialization(tinyInfo,a1,a2,littleStrings);
+  setMeshDimension(tinyInfo[3]);
+  if(tinyInfo[5]!=-1)
+    {
+      // Connectivity
+      const int *recvBuffer=a1->getConstPointer();
+      DataArrayInt* myConnecIndex=DataArrayInt::New();
+      myConnecIndex->alloc(tinyInfo[4]+1,1);
+      std::copy(recvBuffer,recvBuffer+tinyInfo[4]+1,myConnecIndex->getPointer());
+      DataArrayInt* myConnec=DataArrayInt::New();
+      myConnec->alloc(tinyInfo[5],1);
+      std::copy(recvBuffer+tinyInfo[4]+1,recvBuffer+tinyInfo[4]+1+tinyInfo[5],myConnec->getPointer());
+      setConnectivity(myConnec, myConnecIndex) ;
+      myConnec->decrRef();
+      myConnecIndex->decrRef();
+    }
 }
 
 MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoords(const int *start, const int *end) const
index 714fb865b6158a9b82edc1ad1b89e0b3d86b2e7e..1c065e2d1b17784e5e864d89af118d984824f087 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "MEDCoupling.hxx"
 #include "MEDCouplingPointSet.hxx"
-#include "MemArray.hxx"
+#include "MEDCouplingMemArray.hxx"
 
 #include <set>
 
@@ -31,11 +31,13 @@ namespace ParaMEDMEM
   {
   public:
     static MEDCouplingUMesh *New();
+    static MEDCouplingUMesh *New(const char *meshName, int meshDim);
     MEDCouplingUMesh *clone(bool recDeepCpy) const;
     void updateTime();
+    MEDCouplingMeshType getType() const { return UNSTRUCTURED; }
     bool isEqual(const MEDCouplingMesh *other, double prec) const;
     void checkCoherency() const throw(INTERP_KERNEL::Exception);
-    void setMeshDimension(unsigned meshDim);
+    void setMeshDimension(int meshDim);
     void allocateCells(int nbOfCells);
     void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell);
     void finishInsertingCells();
@@ -46,13 +48,14 @@ namespace ParaMEDMEM
     INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const;
     int getNumberOfNodesInCell(int cellId) const;
     int getNumberOfCells() const;
-    int getMeshDimension() const { return _mesh_dim; }
+    int getMeshDimension() const;
     int getMeshLength() const;
     //! size of returned tinyInfo must be always the same.
-    void getTinySerializationInformation(std::vector<int>& tinyInfo) const;
-    void resizeForSerialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2);
-    void serialize(DataArrayInt *&a1, DataArrayDouble *&a2);
-    MEDCouplingPointSet *buildObjectFromUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2);
+    void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
+    void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings);
+    void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
+    void unserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2,
+                         const std::vector<std::string>& littleStrings);
     //tools
     void zipCoords();
     DataArrayInt *zipCoordsTraducer();
@@ -71,7 +74,7 @@ namespace ParaMEDMEM
   private:
     //! this iterator stores current position in _nodal_connec array.
     mutable int _iterator;
-    unsigned _mesh_dim;
+    int _mesh_dim;
     DataArrayInt *_nodal_connec;
     DataArrayInt *_nodal_connec_index;
     std::set<INTERP_KERNEL::NormalizedCellType> _types;
index 71d4d1faafb90a04178f869399812d45fecf4fa5..995e3f77b16b7480bcb8762e000de48b12422b55 100644 (file)
@@ -18,7 +18,7 @@
 //
 #include "MEDCouplingUMeshDesc.hxx"
 #include "CellModel.hxx"
-#include "MemArray.hxx"
+#include "MEDCouplingMemArray.hxx"
 
 using namespace ParaMEDMEM;
 
@@ -44,6 +44,14 @@ MEDCouplingUMeshDesc *MEDCouplingUMeshDesc::New()
   return new MEDCouplingUMeshDesc;
 }
 
+MEDCouplingUMeshDesc *MEDCouplingUMeshDesc::New(const char *meshName, int meshDim)
+{
+  MEDCouplingUMeshDesc *ret=new MEDCouplingUMeshDesc;
+  ret->setName(meshName);
+  ret->setMeshDimension(meshDim);
+  return ret;
+}
+
 void MEDCouplingUMeshDesc::checkCoherency() const throw(INTERP_KERNEL::Exception)
 {
   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator iter=_types.begin();iter!=_types.end();iter++)
@@ -98,26 +106,28 @@ void MEDCouplingUMeshDesc::setConnectivity(DataArrayInt *descConn, DataArrayInt
   computeTypes();
 }
 
-void MEDCouplingUMeshDesc::getTinySerializationInformation(std::vector<int>& tinyInfo) const
+void MEDCouplingUMeshDesc::getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
 {
-  tinyInfo.resize(7);
-  tinyInfo[0]=getSpaceDimension();
-  tinyInfo[1]=getMeshDimension();
-  tinyInfo[2]=getNumberOfNodes();
-  tinyInfo[3]=getNumberOfCells();
-  tinyInfo[4]=getCellMeshLength();
-  tinyInfo[5]=getNumberOfFaces();
-  tinyInfo[6]=getFaceMeshLength();
+  MEDCouplingPointSet::getTinySerializationInformation(tinyInfo,littleStrings);
+  tinyInfo.push_back(getMeshDimension());
+  tinyInfo.push_back(getNumberOfNodes());
+  tinyInfo.push_back(getNumberOfCells());
+  tinyInfo.push_back(getCellMeshLength());
+  tinyInfo.push_back(getNumberOfFaces());
+  tinyInfo.push_back(getFaceMeshLength());
 }
 
-void MEDCouplingUMeshDesc::resizeForSerialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2)
+void MEDCouplingUMeshDesc::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings)
 {
-  a1->alloc(tinyInfo[4]+tinyInfo[3]+1+tinyInfo[6]+tinyInfo[5]+1,1);
-  a2->alloc(tinyInfo[2],tinyInfo[0]);
+  std::vector<int> tinyInfoTmp(tinyInfo.begin()+1,tinyInfo.end());
+  MEDCouplingPointSet::resizeForUnserialization(tinyInfoTmp,a1,a2,littleStrings);
+  a1->alloc(tinyInfo[5]+tinyInfo[4]+1+tinyInfo[7]+tinyInfo[6]+1,1);
 }
 
-void MEDCouplingUMeshDesc::serialize(DataArrayInt *&a1, DataArrayDouble *&a2)
+void MEDCouplingUMeshDesc::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const
 {
+  MEDCouplingPointSet::serialize(a1,a2);
+  //
   a1=DataArrayInt::New();
   a1->alloc(getCellMeshLength()+getNumberOfCells()+1+getFaceMeshLength()+getNumberOfFaces()+1,1);
   int *ptA1=a1->getPointer();
@@ -129,35 +139,33 @@ void MEDCouplingUMeshDesc::serialize(DataArrayInt *&a1, DataArrayDouble *&a2)
   ptA1=std::copy(descConnIndex,descConnIndex+getNumberOfCells()+1,ptA1);
   ptA1=std::copy(faceConn,faceConn+getFaceMeshLength(),ptA1);
   std::copy(faceConnIndex,faceConnIndex+getNumberOfFaces()+1,ptA1);
-  a2=getCoords();
-  a2->incrRef();
 }
 
-MEDCouplingPointSet *MEDCouplingUMeshDesc::buildObjectFromUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2)
+void MEDCouplingUMeshDesc::unserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
 {
-  MEDCouplingUMeshDesc *meshing=MEDCouplingUMeshDesc::New();
-  meshing->setCoords(a2);
+  std::vector<int> tinyInfoTmp(tinyInfo.begin()+1,tinyInfo.end());
+  MEDCouplingPointSet::unserialization(tinyInfoTmp,a1,a2,littleStrings);
+  //
   const int *recvBuffer=a1->getConstPointer();
   DataArrayInt *descConn=DataArrayInt::New();
-  descConn->alloc(tinyInfo[4],1);
-  std::copy(recvBuffer,recvBuffer+tinyInfo[4],descConn->getPointer());
+  descConn->alloc(tinyInfo[5],1);
+  std::copy(recvBuffer,recvBuffer+tinyInfo[5],descConn->getPointer());
   DataArrayInt *descConnIndex=DataArrayInt::New();
-  descConnIndex->alloc(tinyInfo[3]+1,1);
-  std::copy(recvBuffer+tinyInfo[4],recvBuffer+tinyInfo[4]+tinyInfo[3]+1,descConnIndex->getPointer());
+  descConnIndex->alloc(tinyInfo[4]+1,1);
+  std::copy(recvBuffer+tinyInfo[5],recvBuffer+tinyInfo[5]+tinyInfo[4]+1,descConnIndex->getPointer());
   DataArrayInt *faceConn=DataArrayInt::New();
-  faceConn->alloc(tinyInfo[6],1);
-  std::copy(recvBuffer+tinyInfo[4]+tinyInfo[3]+1,recvBuffer+tinyInfo[4]+tinyInfo[3]+1+tinyInfo[6],faceConn->getPointer());
+  faceConn->alloc(tinyInfo[7],1);
+  std::copy(recvBuffer+tinyInfo[5]+tinyInfo[4]+1,recvBuffer+tinyInfo[5]+tinyInfo[4]+1+tinyInfo[7],faceConn->getPointer());
   DataArrayInt *faceConnIndex=DataArrayInt::New();
-  faceConnIndex->alloc(tinyInfo[5]+1,1);
-  std::copy(recvBuffer+tinyInfo[4]+tinyInfo[3]+1+tinyInfo[6],
-            recvBuffer+tinyInfo[4]+tinyInfo[3]+1+tinyInfo[6]+tinyInfo[5]+1,faceConnIndex->getPointer());
-  meshing->setConnectivity(descConn,descConnIndex,faceConn,faceConnIndex);
+  faceConnIndex->alloc(tinyInfo[6]+1,1);
+  std::copy(recvBuffer+tinyInfo[5]+tinyInfo[4]+1+tinyInfo[7],
+            recvBuffer+tinyInfo[5]+tinyInfo[5]+1+tinyInfo[7]+tinyInfo[6]+1,faceConnIndex->getPointer());
+  setConnectivity(descConn,descConnIndex,faceConn,faceConnIndex);
   descConn->decrRef();
   descConnIndex->decrRef();
   faceConn->decrRef();
   faceConnIndex->decrRef();
-  meshing->setMeshDimension(tinyInfo[1]);
-  return meshing;
+  setMeshDimension(tinyInfo[2]);
 }
 
 void MEDCouplingUMeshDesc::giveElemsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems)
@@ -178,8 +186,9 @@ void MEDCouplingUMeshDesc::giveElemsInBoundingBox(const double *bbox, double eps
           elem_bb[i*2+1]=-std::numeric_limits<double>::max();
         }
 
-      for (int iface=conn_index[ielem]+1; iface<conn_index[ielem+1]; iface++)//+1 due to offset of cell type.
+      for (int jface=conn_index[ielem]+1; jface<conn_index[ielem+1]; jface++)//+1 due to offset of cell type.
         {
+          int iface=conn[jface];
           for(int inode=face_index[iface]+1;inode<face_index[iface+1];inode++)
             {
               int node=face[inode];
index 04267f63ab85b76c75aebe5b46d382d27179296b..79641fe6749095fd48cb66af1aa1156ec8a0a2b2 100644 (file)
@@ -31,6 +31,7 @@ namespace ParaMEDMEM
   {
   public:
     static MEDCouplingUMeshDesc *New();
+    static MEDCouplingUMeshDesc *New(const char *meshName, int meshDim);
     void checkCoherency() const throw(INTERP_KERNEL::Exception);
     void setMeshDimension(unsigned meshDim);
     int getNumberOfCells() const;
@@ -38,12 +39,14 @@ namespace ParaMEDMEM
     int getCellMeshLength() const;
     int getFaceMeshLength() const;
     int getMeshDimension() const { return _mesh_dim; }
+    MEDCouplingMeshType getType() const { return UNSTRUCTURED_DESC; }
     void setConnectivity(DataArrayInt *descConn, DataArrayInt *descConnIndex, DataArrayInt *nodalFaceConn, DataArrayInt *nodalFaceConnIndx);
     //tools to overload
-    void getTinySerializationInformation(std::vector<int>& tinyInfo) const;
-    void resizeForSerialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2);
-    void serialize(DataArrayInt *&a1, DataArrayDouble *&a2);
-    MEDCouplingPointSet *buildObjectFromUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2);
+    void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
+    void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings);
+    void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
+    void unserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2,
+                         const std::vector<std::string>& littleStrings);
     void giveElemsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems);
     MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const;
     MEDCouplingFieldDouble *getMeasureField() const;
index 60e83b9c2b814d31810baf0034322a7ff02db73d..4b3dd4bc53e0cc4edaa597a164e8b929525fc41b 100644 (file)
@@ -28,20 +28,20 @@ lib_LTLIBRARIES = libmedcoupling.la
 
 
 salomeinclude_HEADERS = MEDCoupling.hxx \
-MEDCouplingFieldDouble.hxx  MEDCouplingMesh.hxx MEDCouplingUMesh.hxx TimeLabel.hxx \
-MEDCouplingField.hxx MEDCouplingNormalizedUnstructuredMesh.hxx MemArray.hxx        \
-MEDCouplingNormalizedUnstructuredMesh.txx  MemArray.txx RefCountObject.hxx         \
-MEDCouplingRMesh.hxx MEDCouplingTimeDiscretization.hxx                             \
-MEDCouplingFieldDiscretization.hxx MEDCouplingPointSet.hxx                         \
-MEDCouplingUMeshDesc.hxx
+MEDCouplingFieldDouble.hxx  MEDCouplingMesh.hxx MEDCouplingUMesh.hxx MEDCouplingTimeLabel.hxx     \
+MEDCouplingField.hxx MEDCouplingNormalizedUnstructuredMesh.hxx MEDCouplingMemArray.hxx            \
+MEDCouplingNormalizedUnstructuredMesh.txx  MEDCouplingMemArray.txx MEDCouplingRefCountObject.hxx  \
+MEDCouplingCMesh.hxx MEDCouplingTimeDiscretization.hxx                                            \
+MEDCouplingFieldDiscretization.hxx MEDCouplingPointSet.hxx                                        \
+MEDCouplingUMeshDesc.hxx MEDCouplingNatureOfField.hxx
 
 # Libraries targets
 
 dist_libmedcoupling_la_SOURCES = \
-       MEDCouplingField.cxx  MEDCouplingFieldDouble.cxx       \
-       MEDCouplingUMesh.cxx  MemArray.cxx  TimeLabel.cxx      \
-       MEDCouplingRMesh.cxx MEDCouplingTimeDiscretization.cxx \
-       MEDCouplingFieldDiscretization.cxx                     \
+       MEDCouplingField.cxx  MEDCouplingFieldDouble.cxx                          \
+       MEDCouplingUMesh.cxx  MEDCouplingMemArray.cxx  MEDCouplingTimeLabel.cxx   \
+       MEDCouplingCMesh.cxx MEDCouplingTimeDiscretization.cxx                    \
+       MEDCouplingFieldDiscretization.cxx MEDCouplingRefCountObject.cxx          \
        MEDCouplingPointSet.cxx MEDCouplingUMeshDesc.cxx
 
 libmedcoupling_la_LDFLAGS= 
@@ -64,13 +64,14 @@ EXTRA_DIST += \
        MEDCouplingFieldDiscretization.hxx        \
         MEDCouplingMesh.hxx                       \
         MEDCouplingUMesh.hxx                      \
-        MEDCouplingRMesh.hxx                      \
-        TimeLabel.hxx                             \
+        MEDCouplingCMesh.hxx                      \
+        MEDCouplingTimeLabel.hxx                  \
        MEDCouplingField.hxx                      \
        MEDCouplingNormalizedUnstructuredMesh.hxx \
-       MemArray.hxx                              \
+       MEDCouplingMemArray.hxx                   \
        MEDCouplingNormalizedUnstructuredMesh.txx \
-       MemArray.txx                              \
-       RefCountObject.hxx                        \
+       MEDCouplingMemArray.txx                   \
+       MEDCouplingRefCountObject.hxx             \
        MEDCouplingPointSet.hxx                   \
-       MEDCouplingUMeshDesc.hxx
+       MEDCouplingUMeshDesc.hxx                  \
+       MEDCouplingNatureOfField.hxx
diff --git a/src/MEDCoupling/MemArray.cxx b/src/MEDCoupling/MemArray.cxx
deleted file mode 100644 (file)
index 6240b21..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-//  Copyright (C) 2007-2008  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.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "MemArray.txx"
-
-using namespace ParaMEDMEM;
-
-void DataArray::setName(const char *name)
-{
-  _name=name;
-}
-
-DataArrayDouble *DataArrayDouble::New()
-{
-  return new DataArrayDouble;
-}
-
-DataArrayDouble *DataArrayDouble::deepCopy() const
-{
-  return new DataArrayDouble(*this);
-}
-
-DataArrayDouble *DataArrayDouble::performCpy(bool deepCpy) const
-{
-  if(deepCpy)
-    return deepCopy();
-  else
-    {
-      incrRef();
-      return const_cast<DataArrayDouble *>(this);
-    }
-}
-
-void DataArrayDouble::alloc(int nbOfTuple, int nbOfCompo)
-{
-  _nb_of_tuples=nbOfTuple;
-  _info_on_compo.resize(nbOfCompo);
-  _mem.alloc(nbOfCompo*_nb_of_tuples);
-  declareAsNew();
-}
-
-bool DataArrayDouble::isEqual(DataArrayDouble *other, double prec) const
-{
-  return true;
-}
-
-void DataArrayDouble::reAlloc(int nbOfTuples)
-{
-  _mem.reAlloc(_info_on_compo.size()*nbOfTuples);
-  _nb_of_tuples=nbOfTuples;
-  declareAsNew();
-}
-
-void DataArrayDouble::setArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet)
-{
-  if(newArray!=arrayToSet)
-    {
-      if(arrayToSet)
-        arrayToSet->decrRef();
-      arrayToSet=newArray;
-      if(arrayToSet)
-        arrayToSet->incrRef();
-    }
-}
-
-void DataArrayDouble::useArray(const double *array, bool ownership,  DeallocType type, int nbOfTuple, int nbOfCompo)
-{
-  _nb_of_tuples=nbOfTuple;
-  _info_on_compo.resize(nbOfCompo);
-  _mem.useArray(array,ownership,type,nbOfTuple*nbOfCompo);
-  declareAsNew();
-}
-
-DataArrayInt *DataArrayInt::New()
-{
-  return new DataArrayInt;
-}
-
-DataArrayInt *DataArrayInt::deepCopy() const
-{
-  return new DataArrayInt(*this);
-}
-
-DataArrayInt *DataArrayInt::performCpy(bool deepCpy) const
-{
-  if(deepCpy)
-    return deepCopy();
-  else
-    {
-      incrRef();
-      return const_cast<DataArrayInt *>(this);
-    }
-}
-
-void DataArrayInt::alloc(int nbOfTuple, int nbOfCompo)
-{
-  _nb_of_tuples=nbOfTuple;
-  _info_on_compo.resize(nbOfCompo);
-  _mem.alloc(nbOfCompo*_nb_of_tuples);
-  declareAsNew();
-}
-
-void DataArrayInt::useArray(const int *array, bool ownership,  DeallocType type, int nbOfTuple, int nbOfCompo)
-{
-  _nb_of_tuples=nbOfTuple;
-  _info_on_compo.resize(nbOfCompo);
-  _mem.useArray(array,ownership,type,nbOfTuple*nbOfCompo);
-  declareAsNew();
-}
-
-void DataArrayInt::reAlloc(int nbOfTuples)
-{
-  _mem.reAlloc(_info_on_compo.size()*nbOfTuples);
-  _nb_of_tuples=nbOfTuples;
-  declareAsNew();
-}
-
-void DataArrayInt::setArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet)
-{
-  if(newArray!=arrayToSet)
-    {
-      if(arrayToSet)
-        arrayToSet->decrRef();
-      arrayToSet=newArray;
-      if(arrayToSet)
-        arrayToSet->incrRef();
-    }
-}
diff --git a/src/MEDCoupling/MemArray.hxx b/src/MEDCoupling/MemArray.hxx
deleted file mode 100644 (file)
index fcfbd02..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-//  Copyright (C) 2007-2008  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.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef __PARAMEDMEM_MEMARRAY_HXX__
-#define __PARAMEDMEM_MEMARRAY_HXX__
-
-#include "MEDCoupling.hxx"
-#include "RefCountObject.hxx"
-#include "InterpKernelException.hxx"
-
-#include <string>
-#include <vector>
-
-namespace ParaMEDMEM
-{
-  template<class T>
-  class MEDCouplingPointer
-  {
-  public:
-    MEDCouplingPointer():_internal(0),_external(0) { }
-    void null() { _internal=0; _external=0; }
-    bool isNull() const { return _internal==0 && _external==0; }
-    void setInternal(T *pointer);
-    void setExternal(const T *pointer);
-    const T *getConstPointer() const { if(_internal) return _internal; else return _external; }
-    const T *getConstPointerLoc(int offset) const { if(_internal) return _internal+offset; else return _external+offset; }
-    T *getPointer() const { if(_internal) return _internal; throw INTERP_KERNEL::Exception("Trying to write on an external pointer."); }
-  private:
-    T *_internal;
-    const T *_external;
-  };
-
-  template<class T>
-  class MemArray
-  {
-  public:
-    MemArray():_nb_of_elem(-1),_ownership(false),_dealloc(CPP_DEALLOC) { }
-    MemArray(const MemArray<T>& other);
-    const T *getConstPointerLoc(int offset) const { return _pointer.getConstPointerLoc(offset); }
-    const T *getConstPointer() const { return _pointer.getConstPointer(); }
-    T *getPointer() const { return _pointer.getPointer(); }
-    MemArray<T> &operator=(const MemArray<T>& other);
-    T operator[](int id) const { return _pointer.getConstPointer()[id]; }
-    T& operator[](int id) { return _pointer.getPointer()[id]; }
-    void alloc(int nbOfElements);
-    void reAlloc(int newNbOfElements);
-    void useArray(const T *array, bool ownership, DeallocType type, int nbOfElem);
-    void writeOnPlace(int id, T element0, const T *others, int sizeOfOthers);
-    ~MemArray() { destroy(); }
-  private:
-    void destroy();
-    static void destroyPointer(T *pt, DeallocType type);
-  private:
-    int _nb_of_elem;
-    bool _ownership;
-    MEDCouplingPointer<T> _pointer;
-    //T *_pointer;
-    DeallocType _dealloc;
-  };
-
-  class MEDCOUPLING_EXPORT DataArray : public RefCountObject
-  {
-  public:
-    void setName(const char *name);
-    std::string getName() const { return _name; }
-    std::string getInfoOnComponent(int i) const { return _info_on_compo[i]; }
-    void setInfoOnComponent(int i, const char *info) { _info_on_compo[i]=info; }
-    int getNumberOfComponents() const { return _info_on_compo.size(); }
-    int getNumberOfTuples() const { return _nb_of_tuples; }
-    int getNbOfElems() const { return _info_on_compo.size()*_nb_of_tuples; }
-  protected:
-    DataArray():_nb_of_tuples(-1) { }
-  protected:
-    int _nb_of_tuples;
-    std::string _name;
-    std::vector<std::string> _info_on_compo;
-  };
-}
-
-#include "MemArray.txx"
-
-namespace ParaMEDMEM
-{
-  class MEDCOUPLING_EXPORT DataArrayDouble : public DataArray
-  {
-  public:
-    static DataArrayDouble *New();
-    DataArrayDouble *deepCopy() const;
-    DataArrayDouble *performCpy(bool deepCpy) const;
-    void alloc(int nbOfTuple, int nbOfCompo);
-    bool isEqual(DataArrayDouble *other, double prec) const;
-    //!alloc or useArray should have been called before.
-    void reAlloc(int nbOfTuples);
-    void getTuple(int tupleId, double *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
-    double getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
-    void setIJ(int tupleId, int compoId, double newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
-    double *getPointer() const { return _mem.getPointer(); }
-    static void setArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet);
-    const double *getConstPointer() const { return _mem.getConstPointer(); }
-    void useArray(const double *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
-    void writeOnPlace(int id, double element0, const double *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
-    //! nothing to do here because this class does not aggregate any TimeLabel instance.
-    void updateTime() { }
-  private:
-    DataArrayDouble() { }
-  private:
-    MemArray<double> _mem;
-  };
-
-  class MEDCOUPLING_EXPORT DataArrayInt : public DataArray
-  {
-  public:
-    static DataArrayInt *New();
-    DataArrayInt *deepCopy() const;
-    DataArrayInt *performCpy(bool deepCpy) const;
-    void alloc(int nbOfTuple, int nbOfCompo);
-    //!alloc or useArray should have been called before.
-    void reAlloc(int nbOfTuples);
-    void getTuple(int tupleId, int *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
-    int getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
-    void setIJ(int tupleId, int compoId, int newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
-    int *getPointer() const { return _mem.getPointer(); }
-    static void setArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet);
-    const int *getConstPointer() const { return _mem.getConstPointer(); }
-    void useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
-    void writeOnPlace(int id, int element0, const int *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
-    //! nothing to do here because this class does not aggregate any TimeLabel instance.
-    void updateTime() { }
-  private:
-    DataArrayInt() { }
-  private:
-    MemArray<int> _mem;
-  };
-}
-
-#endif
diff --git a/src/MEDCoupling/MemArray.txx b/src/MEDCoupling/MemArray.txx
deleted file mode 100644 (file)
index c326543..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-//  Copyright (C) 2007-2008  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.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef __PARAMEDMEM_MEMARRAY_TXX__
-#define __PARAMEDMEM_MEMARRAY_TXX__
-
-#include "MemArray.hxx"
-#include "NormalizedUnstructuredMesh.hxx"
-#include "InterpKernelException.hxx"
-
-#include <sstream>
-#include <algorithm>
-
-namespace ParaMEDMEM
-{
-  template<class T>
-  void MEDCouplingPointer<T>::setInternal(T *pointer)
-  {
-    _internal=pointer;
-    _external=0;
-  }
-
-  template<class T>
-  void MEDCouplingPointer<T>::setExternal(const T *pointer)
-  {
-    _external=pointer;
-    _internal=0;
-  }
-
-  template<class T>
-  MemArray<T>::MemArray(const MemArray<T>& other):_nb_of_elem(-1),_ownership(false),_dealloc(CPP_DEALLOC)
-  {
-    if(!other._pointer.isNull())
-      {
-        T *pointer=new T[other._nb_of_elem];
-        std::copy(other._pointer.getConstPointer(),other._pointer.getConstPointer()+other._nb_of_elem,pointer);
-        useArray(pointer,true,CPP_DEALLOC,other._nb_of_elem);
-      }
-  }
-
-  template<class T>
-  void MemArray<T>::useArray(const T *array, bool ownership, DeallocType type, int nbOfElem)
-  {
-    _nb_of_elem=nbOfElem;
-    destroy();
-    if(ownership)
-      _pointer.setInternal((T *)array);
-    else
-      _pointer.setExternal(array);
-    _ownership=ownership;
-    _dealloc=type;
-  }
-
-  template<class T>
-  void MemArray<T>::writeOnPlace(int id, T element0, const T *others, int sizeOfOthers)
-  {
-    if(id+sizeOfOthers>=_nb_of_elem)
-      reAlloc(2*_nb_of_elem+sizeOfOthers+1);
-    T *pointer=_pointer.getPointer();
-    pointer[id]=element0;
-    std::copy(others,others+sizeOfOthers,pointer+id+1);
-  }
-
-  template<class T>
-  void MemArray<T>::alloc(int nbOfElements)
-  {
-    destroy();
-    _nb_of_elem=nbOfElements;
-    _pointer.setInternal(new T[_nb_of_elem]);
-    _ownership=true;
-    _dealloc=CPP_DEALLOC;
-  }
-  
-  template<class T>
-  void MemArray<T>::reAlloc(int newNbOfElements)
-  {
-    T *pointer=new T[newNbOfElements];
-    std::copy(_pointer.getConstPointer(),_pointer.getConstPointer()+std::min<int>(_nb_of_elem,newNbOfElements),pointer);
-    if(_ownership)
-      destroyPointer((T *)_pointer.getConstPointer(),_dealloc);
-    _pointer.setInternal(pointer);
-    _nb_of_elem=newNbOfElements;
-    _ownership=true;
-    _dealloc=CPP_DEALLOC;
-  }
-
-  template<class T>
-  void MemArray<T>::destroyPointer(T *pt, DeallocType type)
-  {
-    switch(type)
-      {
-      case CPP_DEALLOC:
-        {
-          delete [] pt;
-          return ;
-        }
-      case C_DEALLOC:
-        {
-          free(pt);
-          return ;
-        }
-      default:
-        std::stringstream stream;
-        stream << "Invalid deallocation requested for pointer " << pt;
-        throw INTERP_KERNEL::Exception(stream.str().c_str());
-      }
-  }
-
-  template<class T>
-  void MemArray<T>::destroy()
-  {
-    if(_ownership)
-      destroyPointer((T *)_pointer.getConstPointer(),_dealloc);
-    _pointer.null();
-    _ownership=false;
-  }
-  
-  template<class T>
-  MemArray<T> &MemArray<T>::operator=(const MemArray<T>& other)
-  {
-    alloc(other._nb_of_elem);
-    std::copy(other._pointer.getConstPointer(),other._pointer.getConstPointer()+_nb_of_elem,_pointer.getPointer());
-    return *this;
-  }
-}
-
-#endif
diff --git a/src/MEDCoupling/RefCountObject.hxx b/src/MEDCoupling/RefCountObject.hxx
deleted file mode 100644 (file)
index 16a2f0b..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-//  Copyright (C) 2007-2008  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.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef __PARAMEDMEM_REFCOUNTOBJECT_HXX__
-#define __PARAMEDMEM_REFCOUNTOBJECT_HXX__
-
-#include "TimeLabel.hxx"
-
-namespace ParaMEDMEM
-{
-  typedef enum
-    {
-      C_DEALLOC = 2,
-      CPP_DEALLOC = 3
-    } DeallocType;
-
-  typedef enum
-    {
-      ON_CELLS = 0,
-      ON_NODES = 1
-    } TypeOfField;
-
-  typedef enum
-    {
-      NO_TIME = 4,
-      ONE_TIME = 5,
-      LINEAR_TIME = 6
-    } TypeOfTimeDiscretization;
-
-  class RefCountObject : public TimeLabel
-  {
-  protected:
-    RefCountObject():_cnt(1) { }
-    RefCountObject(const RefCountObject& other):_cnt(1) { }
-  public:
-    bool decrRef() { bool ret=((--_cnt)==0); if(ret)delete this; return ret; }
-    void incrRef() const { _cnt++; }
-  protected:
-    virtual ~RefCountObject() { }
-  private:
-    mutable int _cnt;
-  };
-}
-
-#endif
index 15087df5ef05a7e82b3b165657299f52ef00d9d6..031acfd26cc7864f8749a52691b15f6b5b214837 100644 (file)
@@ -19,7 +19,7 @@
 #include "MEDCouplingBasicsTest.hxx"
 #include "MEDCouplingUMesh.hxx"
 #include "MEDCouplingFieldDouble.hxx"
-#include "MemArray.hxx"
+#include "MEDCouplingMemArray.hxx"
 #include "Interpolation2D.txx"
 #include "Interpolation3DSurf.txx"
 #include "Interpolation3D.txx"
@@ -226,6 +226,38 @@ void MEDCouplingBasicsTest::testMeshPointsCloud()
   targetMesh->decrRef();
 }
 
+void MEDCouplingBasicsTest::testMeshM1D()
+{
+  MEDCouplingUMesh *meshM1D=MEDCouplingUMesh::New();
+  CPPUNIT_ASSERT_THROW(meshM1D->getMeshDimension(),INTERP_KERNEL::Exception);
+  CPPUNIT_ASSERT_THROW(meshM1D->getNumberOfNodes(),INTERP_KERNEL::Exception);
+  CPPUNIT_ASSERT_THROW(meshM1D->getNumberOfCells(),INTERP_KERNEL::Exception);
+  CPPUNIT_ASSERT_THROW(meshM1D->setMeshDimension(-2),INTERP_KERNEL::Exception);
+  CPPUNIT_ASSERT_THROW(meshM1D->setMeshDimension(-10),INTERP_KERNEL::Exception);
+  CPPUNIT_ASSERT_THROW(meshM1D->checkCoherency(),INTERP_KERNEL::Exception);
+  meshM1D->setMeshDimension(-1);
+  meshM1D->checkCoherency();
+  CPPUNIT_ASSERT_EQUAL(-1,meshM1D->getMeshDimension());
+  CPPUNIT_ASSERT_EQUAL(1,meshM1D->getNumberOfCells());
+  CPPUNIT_ASSERT_THROW(meshM1D->getNumberOfNodes(),INTERP_KERNEL::Exception);
+  CPPUNIT_ASSERT_THROW(meshM1D->getSpaceDimension(),INTERP_KERNEL::Exception);
+  MEDCouplingUMesh *cpy=meshM1D->clone(true);
+  CPPUNIT_ASSERT(cpy->isEqual(meshM1D,1e-12));
+  cpy->decrRef();
+  MEDCouplingFieldDouble *fieldOnCells=MEDCouplingFieldDouble::New(ON_CELLS);
+  fieldOnCells->setMesh(meshM1D);
+  DataArrayDouble *array=DataArrayDouble::New();
+  array->alloc(1,6);
+  fieldOnCells->setArray(array);
+  double *tmp=array->getPointer();
+  array->decrRef();
+  fill(tmp,tmp+6,7.);
+  fieldOnCells->checkCoherency();
+  //
+  fieldOnCells->decrRef();
+  meshM1D->decrRef();
+}
+
 void MEDCouplingBasicsTest::testDeepCopy()
 {
   DataArrayDouble *array=DataArrayDouble::New();
@@ -383,12 +415,160 @@ void MEDCouplingBasicsTest::testEqualMesh()
   MEDCouplingUMesh *mesh1=build2DTargetMesh_1();
   MEDCouplingUMesh *mesh2=build2DTargetMesh_1();
   //
-  
+  CPPUNIT_ASSERT(mesh1->isEqual(mesh1,1e-12));
+  //
+  CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12));
+  CPPUNIT_ASSERT(mesh2->isEqual(mesh1,1e-12));
+  double *pt=mesh2->getCoords()->getPointer();
+  double tmp=pt[1];
+  pt[1]=5.999;
+  CPPUNIT_ASSERT(!mesh1->isEqual(mesh2,1e-12));
+  CPPUNIT_ASSERT(!mesh2->isEqual(mesh1,1e-12));
+  pt[1]=tmp;
+  CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12));
+  CPPUNIT_ASSERT(mesh2->isEqual(mesh1,1e-12));
+  //
+  int *pt2=mesh1->getNodalConnectivity()->getPointer();
+  pt2[5]++;
+  CPPUNIT_ASSERT(!mesh1->isEqual(mesh2,1e-12));
+  CPPUNIT_ASSERT(!mesh2->isEqual(mesh1,1e-12));
+  pt2[5]--;
+  CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12));
+  CPPUNIT_ASSERT(mesh2->isEqual(mesh1,1e-12));
+  //
+  pt2=mesh1->getNodalConnectivityIndex()->getPointer();
+  pt2[1]++;
+  CPPUNIT_ASSERT(!mesh1->isEqual(mesh2,1e-12));
+  CPPUNIT_ASSERT(!mesh2->isEqual(mesh1,1e-12));
+  pt2[1]--;
+  CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12));
+  CPPUNIT_ASSERT(mesh2->isEqual(mesh1,1e-12));
+  //
+  std::string tmp3=mesh1->getName();
+  mesh1->setName("lllll");
+  CPPUNIT_ASSERT(!mesh1->isEqual(mesh2,1e-12));
+  CPPUNIT_ASSERT(!mesh2->isEqual(mesh1,1e-12));
+  mesh1->setName(tmp3.c_str());
+  CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12));
+  CPPUNIT_ASSERT(mesh2->isEqual(mesh1,1e-12));
+  //
+  tmp3=mesh2->getCoords()->getInfoOnComponent(1);
+  mesh2->getCoords()->setInfoOnComponent(1,"kkkkkk");
+  CPPUNIT_ASSERT(!mesh1->isEqual(mesh2,1e-12));
+  CPPUNIT_ASSERT(!mesh2->isEqual(mesh1,1e-12));
+  mesh2->getCoords()->setInfoOnComponent(1,tmp3.c_str());
+  CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12));
+  CPPUNIT_ASSERT(mesh2->isEqual(mesh1,1e-12));
+  //
+  mesh1->decrRef();
+  mesh2->decrRef();
+}
+
+void MEDCouplingBasicsTest::testEqualFieldDouble()
+{
+  MEDCouplingUMesh *mesh1=build2DTargetMesh_1();
+  MEDCouplingUMesh *mesh2=build2DTargetMesh_1();
+  //
+  MEDCouplingFieldDouble *fieldOnCells1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
+  fieldOnCells1->setMesh(mesh1);
+  MEDCouplingFieldDouble *fieldOnCells2=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
+  fieldOnCells2->setMesh(mesh2);
+  //
+  CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
+  CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15));
+  fieldOnCells2->decrRef();
+  //
+  MEDCouplingFieldDouble *fieldOnNodes1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
+  CPPUNIT_ASSERT(!fieldOnCells1->isEqual(fieldOnNodes1,1e-12,1e-15));
+  CPPUNIT_ASSERT(!fieldOnNodes1->isEqual(fieldOnCells1,1e-12,1e-15));
+  fieldOnNodes1->decrRef();
+  //
+  fieldOnCells2=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+  CPPUNIT_ASSERT(!fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
+  CPPUNIT_ASSERT(!fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15));
+  fieldOnCells1->decrRef();
+  fieldOnCells1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+  CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
+  CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15));
+  fieldOnCells1->setTime(4.,6,7);
+  CPPUNIT_ASSERT(!fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
+  CPPUNIT_ASSERT(!fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15));
+  fieldOnCells2->setTime(4.,6,7);
+  CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
+  CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15));
+  fieldOnCells1->setName("Power");
+  CPPUNIT_ASSERT(!fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
+  CPPUNIT_ASSERT(!fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15));
+  fieldOnCells2->setName("Power");
+  CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
+  CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15));
+  //
+  fieldOnCells1->setMesh(mesh1);
+  CPPUNIT_ASSERT(!fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
+  CPPUNIT_ASSERT(!fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15));
+  fieldOnCells2->setMesh(mesh1);
+  CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
+  CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15));
+  DataArrayDouble *arr=DataArrayDouble::New();
+  arr->setName("popo");
+  arr->alloc(mesh1->getNumberOfCells(),3);
+  double *pt=arr->getPointer();
+  std::fill(pt,pt+mesh1->getNumberOfCells()*3,6.);
+  fieldOnCells1->setArray(arr);
+  CPPUNIT_ASSERT(!fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
+  CPPUNIT_ASSERT(!fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15));
+  fieldOnCells2->setArray(arr);
+  arr->decrRef();
+  CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
+  CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15));
+  //
+  DataArrayDouble *arr2=arr->deepCopy();
+  fieldOnCells2->setArray(arr2);
+  arr2->decrRef();
+  CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
+  CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15));
+  pt[4]=6.1;
+  CPPUNIT_ASSERT(!fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
+  CPPUNIT_ASSERT(!fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15));
+  pt[4]=6.;
+  CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
+  CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15));
+  arr2->setName("popo2");
+  CPPUNIT_ASSERT(!fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
+  CPPUNIT_ASSERT(!fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15));
+  //
+  arr2->setName("popo");
+  CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
+  CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15));
+  //
+  arr2->setInfoOnComponent(2,"jjj");
+  CPPUNIT_ASSERT(!fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
+  CPPUNIT_ASSERT(!fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15));
+  arr->setInfoOnComponent(2,"jjj");
+  CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
+  CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15));
+  //
+  fieldOnCells1->decrRef();
+  fieldOnCells2->decrRef();
   //
   mesh1->decrRef();
   mesh2->decrRef();
 }
 
+void MEDCouplingBasicsTest::testNatureChecking()
+{
+  MEDCouplingFieldDouble *field=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
+  field->setNature(Integral);
+  field->setNature(ConservativeVolumic);
+  field->setNature(IntegralGlobConstraint);
+  field->decrRef();
+  field=MEDCouplingFieldDouble::New(ON_NODES,NO_TIME);
+  field->setNature(ConservativeVolumic);
+  CPPUNIT_ASSERT_THROW(field->setNature(Integral),INTERP_KERNEL::Exception);
+  CPPUNIT_ASSERT_THROW(field->setNature(IntegralGlobConstraint),INTERP_KERNEL::Exception);
+  field->decrRef();
+}
+
 void MEDCouplingBasicsTest::test2DInterpP0P0_1()
 {
   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
@@ -793,8 +973,7 @@ MEDCouplingUMesh *MEDCouplingBasicsTest::build2DSourceMesh_1()
 {
   double sourceCoords[8]={-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7};
   int sourceConn[6]={0,3,1,0,2,3};
-  MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
-  sourceMesh->setMeshDimension(2);
+  MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New("my name of mesh 2D",2);
   sourceMesh->allocateCells(2);
   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn);
   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn+3);
index 85a903541766639c896d6d27695d15e9b204de66..167e64e22026a387161bb1bebe27e473b7f1bea5 100644 (file)
@@ -34,11 +34,14 @@ namespace ParaMEDMEM
     CPPUNIT_TEST( testArray );
     CPPUNIT_TEST( testMesh );
     CPPUNIT_TEST( testMeshPointsCloud );
+    CPPUNIT_TEST( testMeshM1D );
     CPPUNIT_TEST( testDeepCopy );
     CPPUNIT_TEST( testRevNodal );
     CPPUNIT_TEST( testBuildPartOfMySelf );
     CPPUNIT_TEST( testZipCoords );
     CPPUNIT_TEST( testEqualMesh );
+    CPPUNIT_TEST( testEqualFieldDouble );
+    CPPUNIT_TEST( testNatureChecking );
     CPPUNIT_TEST( test2DInterpP0P0_1 );
     CPPUNIT_TEST( test2DInterpP0P1_1 );
     CPPUNIT_TEST( test2DInterpP1P0_1 );
@@ -54,11 +57,14 @@ namespace ParaMEDMEM
     void testArray();
     void testMesh();
     void testMeshPointsCloud();
+    void testMeshM1D();
     void testDeepCopy();
     void testRevNodal();
     void testBuildPartOfMySelf();
     void testZipCoords();
     void testEqualMesh();
+    void testEqualFieldDouble();
+    void testNatureChecking();
     void test2DInterpP0P0_1();
     void test2DInterpP0P1_1();
     void test2DInterpP1P0_1();
diff --git a/src/MEDCoupling/TimeLabel.cxx b/src/MEDCoupling/TimeLabel.cxx
deleted file mode 100644 (file)
index df03416..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-//  Copyright (C) 2007-2008  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.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "TimeLabel.hxx"
-
-using namespace ParaMEDMEM;
-
-unsigned int TimeLabel::GLOBAL_TIME=0;
-
-TimeLabel::TimeLabel():_time(GLOBAL_TIME++)
-{
-}
-
- TimeLabel& TimeLabel::operator=(const TimeLabel& other)
-{
-  _time=GLOBAL_TIME++;
-  return *this;
-}
-
-void TimeLabel::declareAsNew()
-{
-  _time=GLOBAL_TIME++;
-}
-
-void TimeLabel::updateTimeWith(const TimeLabel& other)
-{
-  if(_time<other._time)
-    _time=other._time;
-}
diff --git a/src/MEDCoupling/TimeLabel.hxx b/src/MEDCoupling/TimeLabel.hxx
deleted file mode 100644 (file)
index cafa408..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-//  Copyright (C) 2007-2008  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.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef __PARAMEDMEM_TIMELABEL_HXX__
-#define __PARAMEDMEM_TIMELABEL_HXX__
-
-#include "MEDCoupling.hxx"
-
-namespace ParaMEDMEM
-{
-  /*!
-   * Class representing a label of time of the lastely modified part of this.
-   * More _time is high more the object has been modified recently.
-   */
-  class MEDCOUPLING_EXPORT TimeLabel
-  {
-  public:
-    TimeLabel& operator=(const TimeLabel& other);
-    //! This method should be called when write access has been done on this.
-    void declareAsNew();
-    //! This method should be called on high level classes as Field or Mesh to take into acount modifications done in aggragates objects.
-    virtual void updateTime() = 0;
-  protected:
-    TimeLabel();
-    void updateTimeWith(const TimeLabel& other);
-  private:
-    static unsigned int GLOBAL_TIME;
-    unsigned int _time;
-  };
-}
-
-#endif
index c8bb7c4b128464b8b3bc2b5507a73af56a9c3ea2..4a977858f94bcb9faa775087f7011a8abdecf47a 100644 (file)
@@ -17,8 +17,8 @@
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 #include "BlockTopology.hxx"
-#include "MemArray.hxx"
-#include "MEDCouplingRMesh.hxx"
+#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingCMesh.hxx"
 #include "CommInterface.hxx"
 #include "ProcessorGroup.hxx"
 #include "MPIProcessorGroup.hxx"
@@ -123,7 +123,7 @@ namespace ParaMEDMEM
    * instead of making the best choice with respect to the 
    * values of the different axes. 
    */
-  BlockTopology::BlockTopology(const ProcessorGroup& group, MEDCouplingRMesh *grid):
+  BlockTopology::BlockTopology(const ProcessorGroup& group, MEDCouplingCMesh *grid):
     _proc_group(&group), _dimension(grid->getSpaceDimension()), _owns_processor_group(false)
   {
     vector <int> axis_length(_dimension);
index 5ce27bc13d6b3c70664639c3835c27a8504731ef..440d6f1f79d546e929435196bbf7926b39928cfa 100644 (file)
@@ -27,7 +27,7 @@
 namespace ParaMEDMEM
 {
   class ComponentTopology;
-  class MEDCouplingRMesh;
+  class MEDCouplingCMesh;
 
   typedef enum{Block,Cycle} CYCLE_TYPE; 
 
@@ -35,7 +35,7 @@ namespace ParaMEDMEM
   {
   public:
     BlockTopology() { }
-    BlockTopology(const ProcessorGroup& group, MEDCouplingRMesh *grid); 
+    BlockTopology(const ProcessorGroup& group, MEDCouplingCMesh *grid); 
     BlockTopology(const BlockTopology& geom_topo, const ComponentTopology& comp_topo);
     BlockTopology(const ProcessorGroup& group, int nb_elem);
     virtual ~BlockTopology();
index 11ba8a0ee5cb793a37fa02f417bc92961214e495..2d243a4c23a3859bab540db38f26c5e3ba692f37 100644 (file)
@@ -181,7 +181,10 @@ namespace ParaMEDMEM
     // First stage : exchanging sizes
     // ------------------------------
     vector<int> tinyInfoLocal,tinyInfoDistant;
-    local_mesh->getTinySerializationInformation(tinyInfoLocal);
+    vector<string> tinyInfoLocalS;
+    //Getting tiny info of local mesh to allow the distant proc to initialize and allocate
+    //the transmitted mesh.
+    local_mesh->getTinySerializationInformation(tinyInfoLocal,tinyInfoLocalS);
     tinyInfoLocal.push_back(local_mesh->getNumberOfCells());
     tinyInfoDistant.resize(tinyInfoLocal.size());
     std::fill(tinyInfoDistant.begin(),tinyInfoDistant.end(),0);
@@ -201,8 +204,12 @@ namespace ParaMEDMEM
     DataArrayDouble *v2Local=0;
     DataArrayInt *v1Distant=DataArrayInt::New();
     DataArrayDouble *v2Distant=DataArrayDouble::New();
+    //serialization of local mesh to send data to distant proc.
     local_mesh->serialize(v1Local,v2Local);
-    local_mesh->resizeForSerialization(tinyInfoDistant,v1Distant,v2Distant);
+    //Building the right instance of copy of distant mesh.
+    MEDCouplingPointSet *distant_mesh_tmp=MEDCouplingPointSet::buildInstanceFromMeshType((MEDCouplingMeshType)tinyInfoDistant[0]);
+    std::vector<std::string> unusedTinyDistantSts;
+    distant_mesh_tmp->resizeForUnserialization(tinyInfoDistant,v1Distant,v2Distant,unusedTinyDistantSts);
     comm_interface.sendRecv(v1Local->getPointer(), v1Local->getNbOfElems(), MPI_INT,
                             iprocdistant_in_union, 1111,
                             v1Distant->getPointer(), v1Distant->getNbOfElems(), MPI_INT,
@@ -215,8 +222,12 @@ namespace ParaMEDMEM
                             *comm, &status);
     if(v1Distant->getNbOfElems()>0)
       {
-        distant_mesh=local_mesh->buildObjectFromUnserialization(tinyInfoDistant,v1Distant,v2Distant);
+        distant_mesh=distant_mesh_tmp;
+        //finish unserialization
+        distant_mesh->unserialization(tinyInfoDistant,v1Distant,v2Distant,unusedTinyDistantSts);
       }
+    else
+      distant_mesh_tmp->decrRef();
     distant_ids_recv=new int[tinyInfoDistant.back()];
     comm_interface.sendRecv((void *)distant_ids_send,tinyInfoLocal.back(), MPI_INT,
                             iprocdistant_in_union, 1113,
index b0c241db0a4ec632da4fb57f1144b5f4fe0740cc..5b89e2e8fb68d2339fb9708e1cbe1a1bdca0fe91 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef __PARAFIELD_HXX__
 #define __PARAFIELD_HXX__
 
-#include "RefCountObject.hxx"
+#include "MEDCouplingRefCountObject.hxx"
 
 namespace ParaMEDMEM
 {
index ce36ce3168899da9763c279e21bca30867ee9c17..86c94d96a0a3ec9d375b2403b05f794b16d55dc3 100644 (file)
@@ -19,8 +19,8 @@
 #include "ParaGRID.hxx"
 #include "Topology.hxx"
 #include "BlockTopology.hxx"
-#include "MemArray.hxx"
-#include "MEDCouplingRMesh.hxx"
+#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingCMesh.hxx"
 #include "InterpKernelUtilities.hxx"
 
 #include <iostream>
@@ -30,7 +30,7 @@ using namespace std;
 namespace ParaMEDMEM
 {
   
-  ParaGRID::ParaGRID(MEDCouplingRMesh* global_grid, Topology* topology) throw(INTERP_KERNEL::Exception)
+  ParaGRID::ParaGRID(MEDCouplingCMesh* global_grid, Topology* topology) throw(INTERP_KERNEL::Exception)
   {
   
     _block_topology = dynamic_cast<BlockTopology*>(topology);
@@ -59,7 +59,7 @@ namespace ParaMEDMEM
       coordinates_names.push_back(array->getName());
       coordinates_units.push_back(array->getInfoOnComponentAt(0));
       }
-      _grid=MEDCouplingRMesh::New();
+      _grid=MEDCouplingCMesh::New();
       _grid->set(xyz_array, coordinates_names,coordinates_units);
       _grid->setName(global_grid->getName());
       _grid->setDescription(global_grid->getDescription());*/
index 8bb5a5f5fd701e0c632710a832ed68f0707bab19..7738d39dafccbd1861caa9cba2949c5db4f47a1c 100644 (file)
@@ -27,17 +27,17 @@ namespace ParaMEDMEM
 {
   class Topology;
   class BlockTopology;
-  class MEDCouplingRMesh;
+  class MEDCouplingCMesh;
 
   class ParaGRID
   {
   public:
-    ParaGRID(MEDCouplingRMesh* global_grid, Topology* topology) throw(INTERP_KERNEL::Exception);
+    ParaGRID(MEDCouplingCMesh* global_grid, Topology* topology) throw(INTERP_KERNEL::Exception);
     BlockTopology * getBlockTopology() const { return _block_topology; }
     virtual ~ParaGRID();
-    MEDCouplingRMesh* getGrid() const { return _grid; }
+    MEDCouplingCMesh* getGrid() const { return _grid; }
   private:
-    MEDCouplingRMesh* _grid;
+    MEDCouplingCMesh* _grid;
     // structured grid topology
     ParaMEDMEM::BlockTopology* _block_topology;
     // stores the x,y,z axes on the global grid
index 755ab3bfbb145c6fa5209fd7bbdc1d1358689b09..9bc8c6266ea46e863ca71f6402edb54fe807a7e8 100644 (file)
@@ -21,7 +21,7 @@
 #include "MPIProcessorGroup.hxx"
 #include "Topology.hxx"
 #include "BlockTopology.hxx"
-#include "MemArray.hxx"
+#include "MEDCouplingMemArray.hxx"
 
 #include <fstream>
 #include <vector>
index bf3ef434509f449d955f14d11f82583ba5b8ced3..2de2f67595659f58059b22eab2f88a221eae8df4 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "MEDCouplingPointSet.hxx"
 #include "ProcessorGroup.hxx"
-#include "MemArray.hxx"
+#include "MEDCouplingMemArray.hxx"
 
 #include <string>
 #include <vector>
index be29e0f51ec743077c845fbf0e539a686ca451f2..12afe8f4f21618627a5f502a3da8719b8389fbd2 100644 (file)
@@ -105,23 +105,23 @@ void ParaMEDMEMTest::testMEDLoaderRead1()
   std::transform(field0->getArray()->getPointer(),field0->getArray()->getPointer()+16,expectedValues,diffValue,std::minus<double>());
   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue,diffValue+16),1e-12);
   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue,diffValue+16),1e-12);
-  mesh=dynamic_cast<MEDCouplingUMesh *>(field0->getMesh());
-  CPPUNIT_ASSERT(mesh);
-  CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
-  CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension());
-  CPPUNIT_ASSERT_EQUAL(16,mesh->getNumberOfCells());
-  CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes());
-  CPPUNIT_ASSERT_EQUAL(3,(int)mesh->getAllTypes().size());
+  const MEDCouplingUMesh *constMesh=dynamic_cast<const MEDCouplingUMesh *>(field0->getMesh());
+  CPPUNIT_ASSERT(constMesh);
+  CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension());
+  CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension());
+  CPPUNIT_ASSERT_EQUAL(16,constMesh->getNumberOfCells());
+  CPPUNIT_ASSERT_EQUAL(19,constMesh->getNumberOfNodes());
+  CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size());
   for(int i=0;i<12;i++)
-    CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(i));
+    CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i));
   for(int i=12;i<14;i++)
-    CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,mesh->getTypeOfCell(i));
+    CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(i));
   for(int i=14;i<16;i++)
-    CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(i));
-  CPPUNIT_ASSERT_EQUAL(90,mesh->getNodalConnectivity()->getNbOfElems());
-  CPPUNIT_ASSERT_EQUAL(701,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+90,0));
-  CPPUNIT_ASSERT_EQUAL(711,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+17,0));
-  CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12);
+    CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(i));
+  CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+90,0));
+  CPPUNIT_ASSERT_EQUAL(711,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+17,0));
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+57,0),1e-12);
   field0->decrRef();
   //
   MEDCouplingFieldDouble *field1=MEDLoader::ReadFieldDoubleCell(fileName,meshNames[0].c_str(),0,fieldsName[1].c_str(),its1[0].first,its1[0].second);
@@ -134,23 +134,23 @@ void ParaMEDMEMTest::testMEDLoaderRead1()
   std::transform(field1->getArray()->getPointer(),field1->getArray()->getPointer()+48,expectedValues2,diffValue2,std::minus<double>());
   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue2,diffValue2+48),1e-12);
   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue2,diffValue2+48),1e-12);
-  mesh=dynamic_cast<MEDCouplingUMesh *>(field1->getMesh());
-  CPPUNIT_ASSERT(mesh);
-  CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
-  CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension());
-  CPPUNIT_ASSERT_EQUAL(16,mesh->getNumberOfCells());
-  CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes());
-  CPPUNIT_ASSERT_EQUAL(3,(int)mesh->getAllTypes().size());
+  constMesh=dynamic_cast<const MEDCouplingUMesh *>(field1->getMesh());
+  CPPUNIT_ASSERT(constMesh);
+  CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension());
+  CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension());
+  CPPUNIT_ASSERT_EQUAL(16,constMesh->getNumberOfCells());
+  CPPUNIT_ASSERT_EQUAL(19,constMesh->getNumberOfNodes());
+  CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size());
   for(int i=0;i<12;i++)
-    CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(i));
+    CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i));
   for(int i=12;i<14;i++)
-    CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,mesh->getTypeOfCell(i));
+    CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(i));
   for(int i=14;i<16;i++)
-    CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(i));
-  CPPUNIT_ASSERT_EQUAL(90,mesh->getNodalConnectivity()->getNbOfElems());
-  CPPUNIT_ASSERT_EQUAL(701,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+90,0));
-  CPPUNIT_ASSERT_EQUAL(711,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+17,0));
-  CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12);
+    CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(i));
+  CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+90,0));
+  CPPUNIT_ASSERT_EQUAL(711,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+17,0));
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+57,0),1e-12);
   field1->decrRef();
   //fields on nodes
   std::vector<std::string> fieldsNameNode=MEDLoader::GetNodeFieldNamesOnMesh(fileName,meshNames[0].c_str());
@@ -175,8 +175,8 @@ void ParaMEDMEMTest::testMEDLoaderRead1()
   std::transform(field0Nodes->getArray()->getPointer(),field0Nodes->getArray()->getPointer()+19,expectedValues3,diffValue3,std::minus<double>());
   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue3,diffValue3+19),1e-12);
   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue3,diffValue3+19),1e-12);
-  mesh=dynamic_cast<MEDCouplingUMesh *>(field0Nodes->getMesh());
-  CPPUNIT_ASSERT(mesh);
+  constMesh=dynamic_cast<const MEDCouplingUMesh *>(field0Nodes->getMesh());
+  CPPUNIT_ASSERT(constMesh);
   field0Nodes->decrRef();
   //
   field0Nodes=MEDLoader::ReadFieldDoubleNode(fileName,meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[1].first,its0Node[1].second);
@@ -188,23 +188,23 @@ void ParaMEDMEMTest::testMEDLoaderRead1()
   std::transform(field0Nodes->getArray()->getPointer(),field0Nodes->getArray()->getPointer()+19,expectedValues4,diffValue3,std::minus<double>());
   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue3,diffValue3+19),1e-12);
   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue3,diffValue3+19),1e-12);
-  mesh=dynamic_cast<MEDCouplingUMesh *>(field0Nodes->getMesh());
-  CPPUNIT_ASSERT(mesh);
-  CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
-  CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension());
-  CPPUNIT_ASSERT_EQUAL(16,mesh->getNumberOfCells());
-  CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes());
-  CPPUNIT_ASSERT_EQUAL(3,(int)mesh->getAllTypes().size());
+  constMesh=dynamic_cast<const MEDCouplingUMesh *>(field0Nodes->getMesh());
+  CPPUNIT_ASSERT(constMesh);
+  CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension());
+  CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension());
+  CPPUNIT_ASSERT_EQUAL(16,constMesh->getNumberOfCells());
+  CPPUNIT_ASSERT_EQUAL(19,constMesh->getNumberOfNodes());
+  CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size());
   for(int i=0;i<12;i++)
-    CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(i));
+    CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i));
   for(int i=12;i<14;i++)
-    CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,mesh->getTypeOfCell(i));
+    CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(i));
   for(int i=14;i<16;i++)
-    CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(i));
-  CPPUNIT_ASSERT_EQUAL(90,mesh->getNodalConnectivity()->getNbOfElems());
-  CPPUNIT_ASSERT_EQUAL(701,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+90,0));
-  CPPUNIT_ASSERT_EQUAL(711,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+17,0));
-  CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12);
+    CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(i));
+  CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+90,0));
+  CPPUNIT_ASSERT_EQUAL(711,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+17,0));
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+57,0),1e-12);
   field0Nodes->decrRef();
   //
   field0Nodes=MEDLoader::ReadFieldDoubleNode(fileName,meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[2].first,its0Node[2].second);
@@ -216,23 +216,23 @@ void ParaMEDMEMTest::testMEDLoaderRead1()
   std::transform(field0Nodes->getArray()->getPointer(),field0Nodes->getArray()->getPointer()+19,expectedValues5,diffValue3,std::minus<double>());
   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue3,diffValue3+19),1e-12);
   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue3,diffValue3+19),1e-12);
-  mesh=dynamic_cast<MEDCouplingUMesh *>(field0Nodes->getMesh());
-  CPPUNIT_ASSERT(mesh);
-  CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
-  CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension());
-  CPPUNIT_ASSERT_EQUAL(16,mesh->getNumberOfCells());
-  CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes());
-  CPPUNIT_ASSERT_EQUAL(3,(int)mesh->getAllTypes().size());
+  constMesh=dynamic_cast<const MEDCouplingUMesh *>(field0Nodes->getMesh());
+  CPPUNIT_ASSERT(constMesh);
+  CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension());
+  CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension());
+  CPPUNIT_ASSERT_EQUAL(16,constMesh->getNumberOfCells());
+  CPPUNIT_ASSERT_EQUAL(19,constMesh->getNumberOfNodes());
+  CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size());
   for(int i=0;i<12;i++)
-    CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(i));
+    CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i));
   for(int i=12;i<14;i++)
-    CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,mesh->getTypeOfCell(i));
+    CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(i));
   for(int i=14;i<16;i++)
-    CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(i));
-  CPPUNIT_ASSERT_EQUAL(90,mesh->getNodalConnectivity()->getNbOfElems());
-  CPPUNIT_ASSERT_EQUAL(701,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+90,0));
-  CPPUNIT_ASSERT_EQUAL(711,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+17,0));
-  CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12);
+    CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(i));
+  CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+90,0));
+  CPPUNIT_ASSERT_EQUAL(711,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+17,0));
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+57,0),1e-12);
   field0Nodes->decrRef();
 }
 
@@ -278,24 +278,24 @@ void ParaMEDMEMTest::testMEDLoaderPolygonRead()
   CPPUNIT_ASSERT(field->getName()==fieldsName[0]);
   CPPUNIT_ASSERT_EQUAL(1,field->getNumberOfComponents());
   CPPUNIT_ASSERT_EQUAL(538,field->getNumberOfTuples());
-  mesh=dynamic_cast<MEDCouplingUMesh *>(field->getMesh());
-  CPPUNIT_ASSERT(mesh);
-  CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
-  CPPUNIT_ASSERT_EQUAL(2,mesh->getMeshDimension());
-  CPPUNIT_ASSERT_EQUAL(538,mesh->getNumberOfCells());
-  CPPUNIT_ASSERT_EQUAL(579,mesh->getNumberOfNodes());
-  CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size());
+  const MEDCouplingUMesh *constMesh=dynamic_cast<const MEDCouplingUMesh *>(field->getMesh());
+  CPPUNIT_ASSERT(constMesh);
+  CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension());
+  CPPUNIT_ASSERT_EQUAL(2,constMesh->getMeshDimension());
+  CPPUNIT_ASSERT_EQUAL(538,constMesh->getNumberOfCells());
+  CPPUNIT_ASSERT_EQUAL(579,constMesh->getNumberOfNodes());
+  CPPUNIT_ASSERT_EQUAL(2,(int)constMesh->getAllTypes().size());
   for(int i=0;i<514;i++)
-    CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(i));
+    CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,constMesh->getTypeOfCell(i));
   for(int i=514;i<538;i++)
-    CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(i));
-  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+1737,0),1e-12);
-  std::transform(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+12,expectedVals1,diffValue1,std::minus<double>());
+    CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,constMesh->getTypeOfCell(i));
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+1737,0),1e-12);
+  std::transform(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+12,expectedVals1,diffValue1,std::minus<double>());
   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue1,diffValue1+12),1e-12);
   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue1,diffValue1+12),1e-12);
-  CPPUNIT_ASSERT_EQUAL(2768,mesh->getNodalConnectivity()->getNbOfElems());
-  CPPUNIT_ASSERT_EQUAL(651050,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+2768,0));
-  CPPUNIT_ASSERT_EQUAL(725943,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+539,0));
+  CPPUNIT_ASSERT_EQUAL(2768,constMesh->getNodalConnectivity()->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(651050,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+2768,0));
+  CPPUNIT_ASSERT_EQUAL(725943,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+539,0));
   const double *values=field->getArray()->getPointer();
   CPPUNIT_ASSERT_DOUBLES_EQUAL(2.87214203182918,std::accumulate(values,values+538,0.),1e-12);
   field->decrRef();