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());
+ }
+}
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; }
/*!
* 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);
}
}
{
_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
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);
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);
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);
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);
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);
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()):
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)