]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
MEDCouplingFieldDouble::copyAllTinyAttrFrom
authorageay <ageay>
Wed, 13 Feb 2013 07:52:46 +0000 (07:52 +0000)
committerageay <ageay>
Wed, 13 Feb 2013 07:52:46 +0000 (07:52 +0000)
src/MEDCoupling/MEDCouplingField.cxx
src/MEDCoupling/MEDCouplingField.hxx
src/MEDCoupling/MEDCouplingFieldDouble.cxx
src/MEDCoupling/MEDCouplingFieldDouble.hxx
src/MEDCoupling/MEDCouplingRemapper.cxx
src/MEDCoupling_Swig/MEDCouplingCommon.i
src/MEDCoupling_Swig/MEDCouplingRemapperTest.py

index da93e7a6e1d555a5e33489db2ddc15ec0c1d89a5..7a11d759def74c3c7a530d7ad37a5a0c42e8656b 100644 (file)
@@ -395,3 +395,15 @@ int MEDCouplingField::getNumberOfMeshPlacesExpected() const throw(INTERP_KERNEL:
   else
     throw INTERP_KERNEL::Exception("MEDCouplingField::getNumberOfMeshPlacesExpected : Empty mesh !");
 }
+
+/*!
+ * Copy tiny info (component names, name, description) but warning the underlying mesh is not renamed (for safety reason).
+ */
+void MEDCouplingField::copyTinyStringsFrom(const MEDCouplingField *other) throw(INTERP_KERNEL::Exception)
+{
+  if(other)
+    {
+      setName(other->_name.c_str());
+      setDescription(other->_desc.c_str());    
+    }
+}
index 6dbe8bfddaf92747ce9a655719dce9a424d45942..06f5f59697db32edc929bc7f092ef4609700f466 100644 (file)
@@ -50,6 +50,7 @@ namespace ParaMEDMEM
     virtual bool isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec, std::string& reason) const throw(INTERP_KERNEL::Exception);
     virtual bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
     virtual bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
+    virtual void copyTinyStringsFrom(const MEDCouplingField *other) throw(INTERP_KERNEL::Exception);
     void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh);
     const ParaMEDMEM::MEDCouplingMesh *getMesh() const { return _mesh; }
     void setName(const char *name) { _name=name; }
index f2fb7e1bda84e3c35bcf7b6a0e68bdce61ecf409..03d44c8d0cc452cfd9266bb0f6c6235ef5592a4a 100644 (file)
@@ -176,13 +176,13 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildNewTimeReprFromThis(TypeOfT
 /*!
  * Copy tiny info (component names, name, description) but warning the underlying mesh is not renamed (for safety reason).
  */
-void MEDCouplingFieldDouble::copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception)
+void MEDCouplingFieldDouble::copyTinyStringsFrom(const MEDCouplingField *other) throw(INTERP_KERNEL::Exception)
 {
-  if(other)
+  MEDCouplingField::copyTinyStringsFrom(other);
+  const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
+  if(otherC)
     {
-      setName(other->_name.c_str());
-      setDescription(other->_desc.c_str());
-      _time_discr->copyTinyStringsFrom(*other->_time_discr);
+      _time_discr->copyTinyStringsFrom(*otherC->_time_discr);
     }
 }
 
@@ -196,6 +196,13 @@ void MEDCouplingFieldDouble::copyTinyAttrFrom(const MEDCouplingFieldDouble *othe
     {
       _time_discr->copyTinyAttrFrom(*other->_time_discr);
     }
+  
+}
+
+void MEDCouplingFieldDouble::copyAllTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception)
+{
+  copyTinyStringsFrom(other);
+  copyTinyAttrFrom(other);
 }
 
 std::string MEDCouplingFieldDouble::simpleRepr() const
index 3b275f9de53cefab76674719e72295cad39aef41..da5e01ba0cf7a034fecc14ae3a2e8b23dc95bbf7 100644 (file)
@@ -38,8 +38,9 @@ namespace ParaMEDMEM
     void setTimeUnit(const char *unit);
     const char *getTimeUnit() const;
     void synchronizeTimeWithSupport() throw(INTERP_KERNEL::Exception);
-    void copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
+    void copyTinyStringsFrom(const MEDCouplingField *other) throw(INTERP_KERNEL::Exception);
     void copyTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
+    void copyAllTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
     std::string simpleRepr() const;
     std::string advancedRepr() const;
     void writeVTK(const char *fileName) const throw(INTERP_KERNEL::Exception);
index 01e5d031904203c431d7d61cc4bc26a235e8c62c..033fe91b2a9239d2d4b4505cae1fc3ef0378222b 100644 (file)
@@ -138,7 +138,7 @@ MEDCouplingFieldDouble *MEDCouplingRemapper::transferField(const MEDCouplingFiel
   if(_src_method!=srcField->getDiscretization()->getStringRepr())
     throw INTERP_KERNEL::Exception("Incoherency with prepare call for source field");
   MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(MEDCouplingFieldDiscretization::getTypeOfFieldFromStringRepr(_target_method.c_str()),srcField->getTimeDiscretization());
-  ret->copyTinyAttrFrom(srcField);
+  ret->copyAllTinyAttrFrom(srcField);
   ret->setNature(srcField->getNature());
   ret->setMesh(_target_mesh);
   transfer(srcField,ret,dftValue);
@@ -150,7 +150,7 @@ MEDCouplingFieldDouble *MEDCouplingRemapper::reverseTransferField(const MEDCoupl
   if(_target_method!=targetField->getDiscretization()->getStringRepr())
     throw INTERP_KERNEL::Exception("Incoherency with prepare call for target field");
   MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(MEDCouplingFieldDiscretization::getTypeOfFieldFromStringRepr(_src_method.c_str()),targetField->getTimeDiscretization());
-  ret->copyTinyAttrFrom(targetField);
+  ret->copyAllTinyAttrFrom(targetField);
   ret->setNature(targetField->getNature());
   ret->setMesh(_src_mesh);
   reverseTransfer(ret,targetField,dftValue);
index 8f47503cfd3c4b6864ab58ff992a0bf74aaf84c4..08f54bc2380e6deb60ecf551228ce870efe13d33 100644 (file)
@@ -6353,6 +6353,7 @@ namespace ParaMEDMEM
     virtual bool areCompatibleForMerge(const MEDCouplingField *other) const throw(INTERP_KERNEL::Exception);
     virtual bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const throw(INTERP_KERNEL::Exception);
     virtual bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const throw(INTERP_KERNEL::Exception);
+    virtual void copyTinyStringsFrom(const MEDCouplingField *other) throw(INTERP_KERNEL::Exception);
     void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
     void setName(const char *name) throw(INTERP_KERNEL::Exception);
     const char *getDescription() const throw(INTERP_KERNEL::Exception);
@@ -6503,8 +6504,8 @@ namespace ParaMEDMEM
     void setTimeUnit(const char *unit);
     const char *getTimeUnit() const;
     void synchronizeTimeWithSupport() throw(INTERP_KERNEL::Exception);
-    void copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
     void copyTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
+    void copyAllTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
     std::string simpleRepr() const;
     std::string advancedRepr() const;
     void writeVTK(const char *fileName) const throw(INTERP_KERNEL::Exception);
index 6472477ec37db13d8c676ea90054ad11fb906223..b22ebf533db3efe3f6f39fd674d23fec78d9a315 100644 (file)
@@ -40,7 +40,15 @@ class MEDCouplingBasicsTest(unittest.TestCase):
             pass
         array.setValues(ptr,sourceMesh.getNumberOfCells(),1);
         srcField.setArray(array);
+        srcField.setName("abc") ; srcField.setDescription("def")
+        srcField.setTime(7.7,9,10)
         trgfield=remapper.transferField(srcField,4.57);
+        self.assertEqual("abc",trgfield.getName())
+        self.assertEqual("def",trgfield.getDescription())
+        a,b,c=trgfield.getTime()
+        self.assertAlmostEqual(7.7,a,14)
+        self.assertEqual(b,9)
+        self.assertEqual(c,10)
         values=trgfield.getArray().getValues();
         valuesExpected=[7.5 ,7. ,7.,8.,7.5];
         for i in xrange(targetMesh.getNumberOfCells()):
@@ -330,10 +338,17 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         f.setArray(f.getArray()[n2o])
         f.checkCoherency()
         f.setNature(ConservativeVolumic)
+        f.setTime(5.6,7,8)
+        f.setName("toto") ; f.setDescription("aDescription")
         p=MEDCouplingRemapper()
         p.setP1P0BaryMethod(True)
         p.prepare(um,um,"P1P0")
         fNode=p.reverseTransferField(f,1e300)
+        self.assertEqual("toto",fNode.getName())
+        self.assertEqual("aDescription",fNode.getDescription())
+        a,b,c=fNode.getTime()
+        self.assertAlmostEqual(5.6,a,14)
+        self.assertEqual(7,b) ; self.assertEqual(8,c)
         #
         integExpected=34.328125
         self.assertAlmostEqual(fNode.integral(False)[0],integExpected,14)