]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
*** empty log message ***
authorageay <ageay>
Tue, 30 Nov 2010 10:11:22 +0000 (10:11 +0000)
committerageay <ageay>
Tue, 30 Nov 2010 10:11:22 +0000 (10:11 +0000)
src/MEDCoupling/MEDCouplingFieldDouble.cxx
src/MEDCoupling/MEDCouplingFieldDouble.hxx
src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx
src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py
src/MEDCoupling_Swig/libMEDCoupling_Swig.i

index 2c62b3f44913fe14dcf21b0d64354380a9295011..8246d9569f0bac10a6526b23c9a336cf423d74fb 100644 (file)
@@ -75,6 +75,17 @@ void MEDCouplingFieldDouble::copyTinyStringsFrom(const MEDCouplingFieldDouble *o
     }
 }
 
+/*!
+ * Copy only times, order, iteration from other. The underlying mesh is not impacted by this method.
+ */
+void MEDCouplingFieldDouble::copyTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception)
+{
+  if(other)
+    {
+      _time_discr->copyTinyAttrFrom(*other->_time_discr);
+    }
+}
+
 std::string MEDCouplingFieldDouble::simpleRepr() const
 {
   std::ostringstream ret;
index 48c0bace0db8b96f447ecb9cfeeff11d272d6bc8..bcbc385de07da00ef877030980f8ae9d35f5768b 100644 (file)
@@ -33,6 +33,7 @@ namespace ParaMEDMEM
   public:
     static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=NO_TIME);
     void copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
+    void copyTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
     std::string simpleRepr() const;
     std::string advancedRepr() const;
     bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
@@ -54,6 +55,8 @@ namespace ParaMEDMEM
     void checkCoherency() const throw(INTERP_KERNEL::Exception);
     NatureOfField getNature() const { return _nature; }
     void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception);
+    void setTimeTolerance(double val) { _time_discr->setTimeTolerance(val); }
+    double getTimeTolerance() const { return _time_discr->getTimeTolerance(); }
     void setTime(double val, int iteration, int order) { _time_discr->setTime(val,iteration,order); }
     void setStartTime(double val, int iteration, int order) { _time_discr->setStartTime(val,iteration,order); }
     void setEndTime(double val, int iteration, int order) { _time_discr->setEndTime(val,iteration,order); }
index 163380099d4cae8402c7d4a0bd732f8e3ba61b3d..d63643fd049af9d64b35d0e26a601653b97b589a 100644 (file)
@@ -154,6 +154,7 @@ namespace ParaMEDMEM
     CPPUNIT_TEST( testUnPolyze1 );
     CPPUNIT_TEST( testConvertDegeneratedCells1 );
     CPPUNIT_TEST( testGetNodeIdsNearPoints1 );
+    CPPUNIT_TEST( testFieldCopyTinyAttrFrom1 );
     //MEDCouplingBasicsTestInterp.cxx
     CPPUNIT_TEST( test2DInterpP0P0_1 );
     CPPUNIT_TEST( test2DInterpP0P0PL_1 );
@@ -336,6 +337,7 @@ namespace ParaMEDMEM
     void testUnPolyze1();
     void testConvertDegeneratedCells1();
     void testGetNodeIdsNearPoints1();
+    void testFieldCopyTinyAttrFrom1();
     //MEDCouplingBasicsTestInterp.cxx
     void test2DInterpP0P0_1();
     void test2DInterpP0P0PL_1();
index 8f58aabd3a8a40e6eaf05214c392892fffc66406..71b962a949b23583b4c3c5cee9e6493fb66f88cf 100644 (file)
@@ -3258,3 +3258,96 @@ void MEDCouplingBasicsTest::testGetNodeIdsNearPoints1()
   CPPUNIT_ASSERT_EQUAL(4,cI[3]);
   mesh->decrRef();
 }
+
+void MEDCouplingBasicsTest::testFieldCopyTinyAttrFrom1()
+{
+  MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+  f1->setName("f1");
+  f1->setTimeTolerance(1.e-5);
+  f1->setDescription("f1Desc");
+  f1->setTime(1.23,4,5);
+  MEDCouplingFieldDouble *f2=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+  f2->setName("f2");
+  f2->setDescription("f2Desc");
+  f2->setTime(6.78,9,10);
+  f2->setTimeTolerance(4.556e-12);
+  //
+  int dt,it;
+  f1->copyTinyAttrFrom(f2);
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(4.556e-12,f1->getTimeTolerance(),1e-24);
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(6.78,f1->getTime(dt,it),1e-12);
+  CPPUNIT_ASSERT_EQUAL(9,dt);
+  CPPUNIT_ASSERT_EQUAL(10,it);
+  CPPUNIT_ASSERT(std::string(f1->getName())=="f1");//name unchanged
+  CPPUNIT_ASSERT(std::string(f1->getDescription())=="f1Desc");//description unchanged
+  f1->decrRef();
+  f2->decrRef();
+  //
+  f1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
+  f1->setName("f1");
+  f1->setTimeTolerance(1.e-5);
+  f1->setDescription("f1Desc");
+  f2=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
+  f2->setName("f2");
+  f2->setDescription("f2Desc");
+  f2->setTimeTolerance(4.556e-12);
+  //
+  f1->copyTinyAttrFrom(f2);
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(4.556e-12,f1->getTimeTolerance(),1e-24);
+  CPPUNIT_ASSERT(std::string(f1->getName())=="f1");//name unchanged
+  CPPUNIT_ASSERT(std::string(f1->getDescription())=="f1Desc");//description unchanged
+  f1->decrRef();
+  f2->decrRef();
+  //
+  f1=MEDCouplingFieldDouble::New(ON_CELLS,CONST_ON_TIME_INTERVAL);
+  f1->setName("f1");
+  f1->setTimeTolerance(1.e-5);
+  f1->setDescription("f1Desc");
+  f1->setTime(1.23,4,5);
+  f1->setEndTime(5.43,2,1);
+  f2=MEDCouplingFieldDouble::New(ON_CELLS,CONST_ON_TIME_INTERVAL);
+  f2->setName("f2");
+  f2->setDescription("f2Desc");
+  f2->setTimeTolerance(4.556e-12);
+  f2->setTime(6.78,9,10);
+  f2->setEndTime(10.98,7,6);
+  //
+  f1->copyTinyAttrFrom(f2);
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(4.556e-12,f1->getTimeTolerance(),1e-24);
+  CPPUNIT_ASSERT(std::string(f1->getName())=="f1");//name unchanged
+  CPPUNIT_ASSERT(std::string(f1->getDescription())=="f1Desc");//description unchanged
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(6.78,f1->getTime(dt,it),1e-12);
+  CPPUNIT_ASSERT_EQUAL(9,dt);
+  CPPUNIT_ASSERT_EQUAL(10,it);
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(10.98,f1->getEndTime(dt,it),1e-12);
+  CPPUNIT_ASSERT_EQUAL(7,dt);
+  CPPUNIT_ASSERT_EQUAL(6,it);
+  f1->decrRef();
+  f2->decrRef();
+  //
+  f1=MEDCouplingFieldDouble::New(ON_CELLS,LINEAR_TIME);
+  f1->setName("f1");
+  f1->setTimeTolerance(1.e-5);
+  f1->setDescription("f1Desc");
+  f1->setTime(1.23,4,5);
+  f1->setEndTime(5.43,2,1);
+  f2=MEDCouplingFieldDouble::New(ON_CELLS,LINEAR_TIME);
+  f2->setName("f2");
+  f2->setDescription("f2Desc");
+  f2->setTimeTolerance(4.556e-12);
+  f2->setTime(6.78,9,10);
+  f2->setEndTime(10.98,7,6);
+  //
+  f1->copyTinyAttrFrom(f2);
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(4.556e-12,f1->getTimeTolerance(),1e-24);
+  CPPUNIT_ASSERT(std::string(f1->getName())=="f1");//name unchanged
+  CPPUNIT_ASSERT(std::string(f1->getDescription())=="f1Desc");//description unchanged
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(6.78,f1->getTime(dt,it),1e-12);
+  CPPUNIT_ASSERT_EQUAL(9,dt);
+  CPPUNIT_ASSERT_EQUAL(10,it);
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(10.98,f1->getEndTime(dt,it),1e-12);
+  CPPUNIT_ASSERT_EQUAL(7,dt);
+  CPPUNIT_ASSERT_EQUAL(6,it);
+  f1->decrRef();
+  f2->decrRef();
+}
index 51537f9ee363ebc54642df9450bf51c7ffa17851..7a07eeacf6c95cdbdb08ec6d429e3da4071813f7 100644 (file)
@@ -4872,6 +4872,94 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         self.assertEqual([0,3,3,4],cI);
         self.assertEqual([4,9,11,6],c);
         pass
+
+    def testFieldCopyTinyAttrFrom1(self):
+        f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+        f1.setName("f1");
+        f1.setTimeTolerance(1.e-5);
+        f1.setDescription("f1Desc");
+        f1.setTime(1.23,4,5);
+        f2=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+        f2.setName("f2");
+        f2.setDescription("f2Desc");
+        f2.setTime(6.78,9,10);
+        f2.setTimeTolerance(4.556e-12);
+        #
+        f1.copyTinyAttrFrom(f2);
+        self.assertAlmostEqual(4.556e-12,f1.getTimeTolerance(),24);
+        t,dt,it=f1.getTime()
+        self.assertAlmostEqual(6.78,t,12);
+        self.assertEqual(9,dt);
+        self.assertEqual(10,it);
+        self.assertTrue(f1.getName()=="f1");#name unchanged
+        self.assertTrue(f1.getDescription()=="f1Desc");#description unchanged
+        #
+        f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
+        f1.setName("f1");
+        f1.setTimeTolerance(1.e-5);
+        f1.setDescription("f1Desc");
+        f2=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
+        f2.setName("f2");
+        f2.setDescription("f2Desc");
+        f2.setTimeTolerance(4.556e-12);
+        #
+        f1.copyTinyAttrFrom(f2);
+        self.assertAlmostEqual(4.556e-12,f1.getTimeTolerance(),24);
+        self.assertTrue(f1.getName()=="f1");#name unchanged
+        self.assertTrue(f1.getDescription()=="f1Desc");#description unchanged
+        #
+        f1=MEDCouplingFieldDouble.New(ON_CELLS,CONST_ON_TIME_INTERVAL);
+        f1.setName("f1");
+        f1.setTimeTolerance(1.e-5);
+        f1.setDescription("f1Desc");
+        f1.setTime(1.23,4,5);
+        f1.setEndTime(5.43,2,1);
+        f2=MEDCouplingFieldDouble.New(ON_CELLS,CONST_ON_TIME_INTERVAL);
+        f2.setName("f2");
+        f2.setDescription("f2Desc");
+        f2.setTimeTolerance(4.556e-12);
+        f2.setTime(6.78,9,10);
+        f2.setEndTime(10.98,7,6);
+        #
+        f1.copyTinyAttrFrom(f2);
+        self.assertAlmostEqual(4.556e-12,f1.getTimeTolerance(),24);
+        self.assertTrue(f1.getName()=="f1");#name unchanged
+        self.assertTrue(f1.getDescription()=="f1Desc");#description unchanged
+        t,dt,it=f1.getTime()
+        self.assertAlmostEqual(6.78,t,12);
+        self.assertEqual(9,dt);
+        self.assertEqual(10,it);
+        t,dt,it=f1.getEndTime()
+        self.assertAlmostEqual(10.98,t,12);
+        self.assertEqual(7,dt);
+        self.assertEqual(6,it);
+        #
+        f1=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME);
+        f1.setName("f1");
+        f1.setTimeTolerance(1.e-5);
+        f1.setDescription("f1Desc");
+        f1.setTime(1.23,4,5);
+        f1.setEndTime(5.43,2,1);
+        f2=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME);
+        f2.setName("f2");
+        f2.setDescription("f2Desc");
+        f2.setTimeTolerance(4.556e-12);
+        f2.setTime(6.78,9,10);
+        f2.setEndTime(10.98,7,6);
+        #
+        f1.copyTinyAttrFrom(f2);
+        self.assertAlmostEqual(4.556e-12,f1.getTimeTolerance(),24);
+        self.assertTrue(f1.getName()=="f1");#name unchanged
+        self.assertTrue(f1.getDescription()=="f1Desc");#description unchanged
+        t,dt,it=f1.getTime()
+        self.assertAlmostEqual(6.78,t,12);
+        self.assertEqual(9,dt);
+        self.assertEqual(10,it);
+        t,dt,it=f1.getEndTime()
+        self.assertAlmostEqual(10.98,t,12);
+        self.assertEqual(7,dt);
+        self.assertEqual(6,it);
+        pass
     
     def setUp(self):
         pass
index 2261651f7d8593b66e30dc5ddcb8739287c2b490..afc8335a97dfde2561af787485c0bcf9820f788e 100644 (file)
@@ -1202,6 +1202,7 @@ namespace ParaMEDMEM
   public:
     static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=NO_TIME);
     void copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
+    void copyTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
     std::string simpleRepr() const;
     std::string advancedRepr() const;
     MEDCouplingFieldDouble *clone(bool recDeepCpy) const;
@@ -1224,6 +1225,8 @@ namespace ParaMEDMEM
     int getNumberOfValues() const throw(INTERP_KERNEL::Exception);
     NatureOfField getNature() const { return _nature; }
     void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception);
+    void setTimeTolerance(double val);
+    double getTimeTolerance() const;
     void updateTime();
     void changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception);
     void substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception);