throw INTERP_KERNEL::Exception("Not managed yet for ON_CELLS ON_GAUSS_NE and ON_GAUSS_PT");
_1ts_update_requested=true;
MEDFileAnyTypeField1TSWithoutSDA *ct(_cur_f1ts->contentNotNullBase());
- MEDFileFieldPerMeshPerTypePerDisc *pmtdToModify(ct->getLeafGivenMeshAndTypeAndLocId(_lin->getName(),_gt,pmptpd->getLocId()));
+ int locId(pmptpd->getFather()->locIdOfLeaf(pmptpd));
+ MEDFileFieldPerMeshPerTypePerDisc *pmtdToModify(ct->getLeafGivenMeshAndTypeAndLocId(_lin->getName(),_gt,locId));
std::string pflName(pmptpd->getProfile());
- if(pflName==_pfl)
+ if(pflName==_pfl && _matrix.isNotNull())
{
updateData(pmtdToModify);
return ;
DataArrayInt *nodeConn(allSeg3->getNodalConnectivity());
nodeConn->rearrange(3);
{
- std::vector<int> v(1,1);
+ std::vector<int> v(1,2);
midPts=nodeConn->keepSelectedComponents(v);
}
cellSeg3Ids=DataArrayInt::FindPermutationFromFirstToSecond(midPts,_new_pts_ids);
{
std::vector<int> v(2); v[0]=0; v[1]=1;
MCAuto<DataArrayInt> tmp(nodeConn->keepSelectedComponents(v));
- _matrix=tmp->selectByTupleId(tmp->begin(),tmp->end());
+ _matrix=tmp->selectByTupleId(cellSeg3Ids->begin(),cellSeg3Ids->end());
}
nodeConn->rearrange(1);
}
return ;
MCAuto<MEDFileAnyTypeField1TSWithoutSDA> contentCpy(ts->deepCopy());
MCAuto<MEDFileField1TSWithoutSDA> contentCpy2(DynamicCastSafe<MEDFileAnyTypeField1TSWithoutSDA,MEDFileField1TSWithoutSDA>(contentCpy));
- if(contentCpy2.isNotNull())
+ if(contentCpy2.isNull())
return;
_cur_f1ts=MEDFileField1TS::New(*contentCpy2,true);
_cur_f1ts->shallowCpyGlobs(*_lin_globs);
MCAuto<DataArrayDouble> part0(arr->selectByTupleId(*pts0));
MCAuto<DataArrayDouble> part1(arr->selectByTupleId(*pts1));
res=DataArrayDouble::Add(part0,part1);
- res->applyLin(1.,0.);
+ res->applyLin(0.5,0.);
}
res=DataArrayDouble::Aggregate(arr,res);
_cur_f1ts->setArray(res);
}
}
+ template<class T>
+ void MEDFileField1TSTemplateWithoutSDA<T>::copyTimeInfoFrom(const typename Traits<T>::FieldType *mcf)
+ {
+ if(!mcf)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSTemplateWithoutSDA<T>::copyTimeInfoFrom : input field is nullptr !");
+ int b(0),c(0);
+ double a(mcf->getTime(b,c));
+ setTime(b,c,a);
+ }
+
///////////////////////////////////////////////////////
template<class T>
return ret.retn();
}
+ template<class T>
+ void MEDFileTemplateField1TS<T>::copyTimeInfoFrom(const typename Traits<T>::FieldType *mcf)
+ {
+ contentNotNull()->copyTimeInfoFrom(mcf);
+ }
+
/*!
* This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
* method should be called (getFieldOnMeshAtLevel for example).
MEDLOADER_EXPORT const DataArray *getOrCreateAndGetArray() const;
MEDLOADER_EXPORT DataArray *getUndergroundDataArray() const;
MEDLOADER_EXPORT void aggregate(const typename std::vector< typename MLFieldTraits<T>::F1TSWSDAType const * >& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts);
+ MEDLOADER_EXPORT void copyTimeInfoFrom(const typename Traits<T>::FieldType *mcf);
protected:
MCAuto< typename Traits<T>::ArrayType > _arr;
};
MEDLOADER_EXPORT static MCAuto<typename Traits<T>::FieldType> SetDataArrayInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr);
MEDLOADER_EXPORT static MCAuto<MEDCouplingFieldDouble> ToFieldTemplateWithTime(const typename Traits<T>::FieldType *f);
public:
+ MEDLOADER_EXPORT void copyTimeInfoFrom(const typename Traits<T>::FieldType *mcf);
MEDLOADER_EXPORT typename Traits<T>::FieldType *field(const MEDFileMesh *mesh) const;
MEDLOADER_EXPORT typename Traits<T>::FieldType *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const;
MEDLOADER_EXPORT typename Traits<T>::FieldType *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const;
return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
}
+int MEDFileFieldPerMeshPerTypeCommon::locIdOfLeaf(const MEDFileFieldPerMeshPerTypePerDisc *leaf) const
+{
+ int ret(0);
+ for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,ret++)
+ {
+ const MEDFileFieldPerMeshPerTypePerDisc *cand(*it);
+ if(cand==leaf)
+ return ret;
+ }
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::locIdOfLeaf : not found such a leaf in this !");
+}
+
void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
{
int i=0;
MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenLocId(int locId);
const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenLocId(int locId) const;
int getNumberOfLoc() const { return _field_pm_pt_pd.size(); }
+ int locIdOfLeaf(const MEDFileFieldPerMeshPerTypePerDisc *leaf) const;
void fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
void setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves);
bool keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its);
static MEDFileField1TS *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception);
static MEDFileField1TS *New();
MEDCoupling::MEDFileIntField1TS *convertToInt(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception);
+ void copyTimeInfoFrom(MEDCouplingFieldDouble *mcf) throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *field(const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception);
//
void setFieldNoProfileSBT(const MEDCouplingFieldInt *field) throw(INTERP_KERNEL::Exception);
void setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+ void copyTimeInfoFrom(MEDCouplingFieldInt *mcf) throw(INTERP_KERNEL::Exception);
MEDCouplingFieldInt *field(const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldInt *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldInt *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception);
//
void setFieldNoProfileSBT(const MEDCouplingFieldFloat *field) throw(INTERP_KERNEL::Exception);
void setFieldProfile(const MEDCouplingFieldFloat *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+ void copyTimeInfoFrom(MEDCouplingFieldFloat *mcf) throw(INTERP_KERNEL::Exception);
MEDCouplingFieldFloat *field(const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldFloat *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldFloat *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception);
ff1.setTime(3,4,2.3)
itt,orr,ti=ff1.getTime()
self.assertEqual(3,itt); self.assertEqual(4,orr); self.assertAlmostEqual(2.3,ti,14);
+ f1.setTime(5.5,7,8)
+ ff1.copyTimeInfoFrom(f1)
+ itt,orr,ti=ff1.getTime()
+ self.assertEqual(7,itt); self.assertEqual(8,orr); self.assertAlmostEqual(5.5,ti,14);
da,infos=ff1.getUndergroundDataArrayExt()
f2.getArray().setName(da.getName())#da has the same name than f2
self.assertTrue(da.isEqual(f2.getArray(),1e-12))
interface=CommInterface()
pass
+ def test5(self):
+ f=MEDCouplingFieldDouble(ON_NODES)
+ f.setTime(1.25,3,6)
+ a,b,c=f.getTime()
+ self.assertEqual(b,3) ; self.assertEqual(c,6) ; self.assertAlmostEqual(a,1.25,14);
+ f1ts=MEDFileField1TS()
+ f1ts.setTime(10,13,10.75)
+ f.copyTimeInfoFrom(f1ts)
+ a,b,c=f.getTime()
+ self.assertEqual(b,10) ; self.assertEqual(c,13) ; self.assertAlmostEqual(a,10.75,14);
+ f2=MEDCouplingFieldInt(ON_NODES)
+ f2.copyTimeInfoFrom(f1ts)
+ a,b,c=f2.getTime()
+ self.assertEqual(b,10) ; self.assertEqual(c,13) ; self.assertAlmostEqual(a,10.75,14);
+ f3=MEDCouplingFieldFloat(ON_NODES)
+ f3.copyTimeInfoFrom(f1ts)
+ a,b,c=f3.getTime()
+ self.assertEqual(b,10) ; self.assertEqual(c,13) ; self.assertAlmostEqual(a,10.75,14);
+ pass
+
+
def partitionerTesterHelper(self,algoSelected):
arr=DataArrayDouble(10) ; arr.iota()
m=MEDCouplingCMesh() ; m.setCoords(arr,arr)
def MEDCouplingField_write(self,fileName):
MEDCouplingWriterHelper(self,fileName,WriteField)
+
+def MEDCouplingFieldT_copyTimeInfoFrom(self,mlf1ts):
+ assert(isinstance(mlf1ts,MEDFileAnyTypeField1TS))
+ a,b,c=mlf1ts.getTime()
+ self.setTime(c,a,b)
+ pass
MEDCouplingMesh.write=MEDCouplingMesh_write
del MEDCouplingMesh_write
MEDCouplingField.write=MEDCouplingField_write
del MEDCouplingField_write
-
+MEDCouplingFieldDouble.copyTimeInfoFrom=MEDCouplingFieldT_copyTimeInfoFrom
+MEDCouplingFieldInt.copyTimeInfoFrom=MEDCouplingFieldT_copyTimeInfoFrom
+MEDCouplingFieldFloat.copyTimeInfoFrom=MEDCouplingFieldT_copyTimeInfoFrom
+del MEDCouplingFieldT_copyTimeInfoFrom
%}