}
}
+/*!
+ * 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;
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;
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); }
CPPUNIT_TEST( testUnPolyze1 );
CPPUNIT_TEST( testConvertDegeneratedCells1 );
CPPUNIT_TEST( testGetNodeIdsNearPoints1 );
+ CPPUNIT_TEST( testFieldCopyTinyAttrFrom1 );
//MEDCouplingBasicsTestInterp.cxx
CPPUNIT_TEST( test2DInterpP0P0_1 );
CPPUNIT_TEST( test2DInterpP0P0PL_1 );
void testUnPolyze1();
void testConvertDegeneratedCells1();
void testGetNodeIdsNearPoints1();
+ void testFieldCopyTinyAttrFrom1();
//MEDCouplingBasicsTestInterp.cxx
void test2DInterpP0P0_1();
void test2DInterpP0P0PL_1();
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();
+}
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
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;
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);