From: ageay Date: Tue, 30 Nov 2010 10:11:22 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2f00e8ba05090a05797128c619a97f9397bd0c61;p=tools%2Fmedcoupling.git *** empty log message *** --- diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx index 2c62b3f44..8246d9569 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.cxx @@ -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; diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.hxx b/src/MEDCoupling/MEDCouplingFieldDouble.hxx index 48c0bace0..bcbc385de 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.hxx @@ -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); } diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx index 163380099..d63643fd0 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx @@ -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(); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx index 8f58aabd3..71b962a94 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx @@ -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(); +} diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 51537f9ee..7a07eeacf 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -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 diff --git a/src/MEDCoupling_Swig/libMEDCoupling_Swig.i b/src/MEDCoupling_Swig/libMEDCoupling_Swig.i index 2261651f7..afc8335a9 100644 --- a/src/MEDCoupling_Swig/libMEDCoupling_Swig.i +++ b/src/MEDCoupling_Swig/libMEDCoupling_Swig.i @@ -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);