From: ageay Date: Wed, 31 Jul 2013 10:58:20 +0000 (+0000) Subject: MEDReader : End of debugging session. X-Git-Tag: B4PolyhIntersect~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=23b0e3c2c72f8c554a356a26aca42775aecad402;p=modules%2Fmed.git MEDReader : End of debugging session. --- diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 4b5b13d31..db929efcd 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -247,6 +247,42 @@ void DataArray::setInfoOnComponents(const std::vector& info) throw( _info_on_compo=info; } +/*! + * This method is only a dispatcher towards DataArrayDouble::setPartOfValues3, DataArrayInt::setPartOfValues3, DataArrayChar::setPartOfValues3 depending on the true + * type of \a this and \a aBase. + * + * \throw If \a aBase and \a this do not have the same type. + * + * \sa DataArrayDouble::setPartOfValues3, DataArrayInt::setPartOfValues3, DataArrayChar::setPartOfValues3. + */ +void DataArray::setPartOfValuesBase3(const DataArray *aBase, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception) +{ + if(!aBase) + throw INTERP_KERNEL::Exception("DataArray::setPartOfValuesBase3 : input aBase object is NULL !"); + DataArrayDouble *this1(dynamic_cast(this)); + DataArrayInt *this2(dynamic_cast(this)); + DataArrayChar *this3(dynamic_cast(this)); + const DataArrayDouble *a1(dynamic_cast(aBase)); + const DataArrayInt *a2(dynamic_cast(aBase)); + const DataArrayChar *a3(dynamic_cast(aBase)); + if(this1 && a1) + { + this1->setPartOfValues3(a1,bgTuples,endTuples,bgComp,endComp,stepComp,strictCompoCompare); + return ; + } + if(this2 && a2) + { + this2->setPartOfValues3(a2,bgTuples,endTuples,bgComp,endComp,stepComp,strictCompoCompare); + return ; + } + if(this3 && a3) + { + this3->setPartOfValues3(a3,bgTuples,endTuples,bgComp,endComp,stepComp,strictCompoCompare); + return ; + } + throw INTERP_KERNEL::Exception("DataArray::setPartOfValuesBase3 : input aBase object and this do not have the same type !"); +} + std::vector DataArray::getVarsOnComponent() const throw(INTERP_KERNEL::Exception) { int nbOfCompo=(int)_info_on_compo.size(); @@ -2631,7 +2667,7 @@ void DataArrayDouble::setPartOfValuesAdv(const DataArrayDouble *a, const DataArr } /*! - * Copy some tuples from another DataArrayDouble (\a a) into contiguous tuples + * Copy some tuples from another DataArrayDouble (\a aBase) into contiguous tuples * of \a this array. Textual data is not copied. Both arrays must have equal number of * components. * The tuples to assign to are defined by index of the first tuple, and @@ -2640,18 +2676,18 @@ void DataArrayDouble::setPartOfValuesAdv(const DataArrayDouble *a, const DataArr * All components of selected tuples are copied. * \param [in] tupleIdStart - index of the first tuple of \a this array to assign * values to. - * \param [in] a - the array to copy values from. + * \param [in] aBase - the array to copy values from. * \param [in] tuplesSelec - the array specifying tuples of \a a to copy. * \throw If \a this is not allocated. - * \throw If \a a is NULL. - * \throw If \a a is not allocated. + * \throw If \a aBase is NULL. + * \throw If \a aBase is not allocated. * \throw If \a tuplesSelec is NULL. * \throw If \a tuplesSelec is not allocated. - * \throw If this->getNumberOfComponents() != a->getNumberOfComponents(). + * \throw If this->getNumberOfComponents() != aBase->getNumberOfComponents(). * \throw If \a tuplesSelec->getNumberOfComponents() != 1. * \throw If tupleIdStart + tuplesSelec->getNumberOfTuples() > this->getNumberOfTuples(). * \throw If any tuple index given by \a tuplesSelec is out of a valid range for - * \a a array. + * \a aBase array. */ void DataArrayDouble::setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception) { @@ -2691,7 +2727,7 @@ void DataArrayDouble::setContigPartOfSelectedValues(int tupleIdStart, const Data } /*! - * Copy some tuples from another DataArrayDouble (\a a) into contiguous tuples + * Copy some tuples from another DataArrayDouble (\a aBase) into contiguous tuples * of \a this array. Textual data is not copied. Both arrays must have equal number of * components. * The tuples to copy are defined by three values similar to parameters of @@ -2701,19 +2737,19 @@ void DataArrayDouble::setContigPartOfSelectedValues(int tupleIdStart, const Data * All components of selected tuples are copied. * \param [in] tupleIdStart - index of the first tuple of \a this array to assign * values to. - * \param [in] a - the array to copy values from. - * \param [in] bg - index of the first tuple to copy of the array \a a. - * \param [in] end2 - index of the tuple of \a a before which the tuples to copy + * \param [in] aBase - the array to copy values from. + * \param [in] bg - index of the first tuple to copy of the array \a aBase. + * \param [in] end2 - index of the tuple of \a aBase before which the tuples to copy * are located. * \param [in] step - index increment to get index of the next tuple to copy. * \throw If \a this is not allocated. - * \throw If \a a is NULL. - * \throw If \a a is not allocated. - * \throw If this->getNumberOfComponents() != a->getNumberOfComponents(). + * \throw If \a aBase is NULL. + * \throw If \a aBase is not allocated. + * \throw If this->getNumberOfComponents() != aBase->getNumberOfComponents(). * \throw If tupleIdStart + len(range(bg,end2,step)) > this->getNumberOfTuples(). * \throw If parameters specifying tuples to copy, do not give a * non-empty range of increasing indices or indices are out of a valid range - * for the array \a a. + * for the array \a aBase. */ void DataArrayDouble::setContigPartOfSelectedValues2(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step) throw(INTERP_KERNEL::Exception) { @@ -7884,7 +7920,7 @@ void DataArrayInt::setPartOfValuesAdv(const DataArrayInt *a, const DataArrayInt } /*! - * Copy some tuples from another DataArrayInt (\a a) into contiguous tuples + * Copy some tuples from another DataArrayInt (\a aBase) into contiguous tuples * of \a this array. Textual data is not copied. Both arrays must have equal number of * components. * The tuples to assign to are defined by index of the first tuple, and @@ -7893,18 +7929,18 @@ void DataArrayInt::setPartOfValuesAdv(const DataArrayInt *a, const DataArrayInt * All components of selected tuples are copied. * \param [in] tupleIdStart - index of the first tuple of \a this array to assign * values to. - * \param [in] a - the array to copy values from. - * \param [in] tuplesSelec - the array specifying tuples of \a a to copy. + * \param [in] aBase - the array to copy values from. + * \param [in] tuplesSelec - the array specifying tuples of \a aBase to copy. * \throw If \a this is not allocated. - * \throw If \a a is NULL. - * \throw If \a a is not allocated. + * \throw If \a aBase is NULL. + * \throw If \a aBase is not allocated. * \throw If \a tuplesSelec is NULL. * \throw If \a tuplesSelec is not allocated. * \throw If this->getNumberOfComponents() != a->getNumberOfComponents(). * \throw If \a tuplesSelec->getNumberOfComponents() != 1. * \throw If tupleIdStart + tuplesSelec->getNumberOfTuples() > this->getNumberOfTuples(). * \throw If any tuple index given by \a tuplesSelec is out of a valid range for - * \a a array. + * \a aBase array. */ void DataArrayInt::setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception) { @@ -7944,7 +7980,7 @@ void DataArrayInt::setContigPartOfSelectedValues(int tupleIdStart, const DataArr } /*! - * Copy some tuples from another DataArrayInt (\a a) into contiguous tuples + * Copy some tuples from another DataArrayInt (\a aBase) into contiguous tuples * of \a this array. Textual data is not copied. Both arrays must have equal number of * components. * The tuples to copy are defined by three values similar to parameters of @@ -7954,19 +7990,19 @@ void DataArrayInt::setContigPartOfSelectedValues(int tupleIdStart, const DataArr * All components of selected tuples are copied. * \param [in] tupleIdStart - index of the first tuple of \a this array to assign * values to. - * \param [in] a - the array to copy values from. - * \param [in] bg - index of the first tuple to copy of the array \a a. - * \param [in] end2 - index of the tuple of \a a before which the tuples to copy + * \param [in] aBase - the array to copy values from. + * \param [in] bg - index of the first tuple to copy of the array \a aBase. + * \param [in] end2 - index of the tuple of \a aBase before which the tuples to copy * are located. * \param [in] step - index increment to get index of the next tuple to copy. * \throw If \a this is not allocated. - * \throw If \a a is NULL. - * \throw If \a a is not allocated. - * \throw If this->getNumberOfComponents() != a->getNumberOfComponents(). + * \throw If \a aBase is NULL. + * \throw If \a aBase is not allocated. + * \throw If this->getNumberOfComponents() != aBase->getNumberOfComponents(). * \throw If tupleIdStart + len(range(bg,end2,step)) > this->getNumberOfTuples(). * \throw If parameters specifying tuples to copy, do not give a * non-empty range of increasing indices or indices are out of a valid range - * for the array \a a. + * for the array \a aBase. */ void DataArrayInt::setContigPartOfSelectedValues2(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step) throw(INTERP_KERNEL::Exception) { diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index 44b83de9a..a3d4611b1 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -134,6 +134,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT std::string getUnitOnComponent(int i) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT int getNumberOfComponents() const { return (int)_info_on_compo.size(); } + MEDCOUPLING_EXPORT void setPartOfValuesBase3(const DataArray *aBase, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT virtual DataArray *deepCpy() const throw(INTERP_KERNEL::Exception) = 0; MEDCOUPLING_EXPORT virtual bool isAllocated() const throw(INTERP_KERNEL::Exception) = 0; MEDCOUPLING_EXPORT virtual void checkAllocated() const throw(INTERP_KERNEL::Exception) = 0; diff --git a/src/MEDCoupling/MEDCouplingMemArrayChar.cxx b/src/MEDCoupling/MEDCouplingMemArrayChar.cxx index 5c827bf8b..d363454bb 100644 --- a/src/MEDCoupling/MEDCouplingMemArrayChar.cxx +++ b/src/MEDCoupling/MEDCouplingMemArrayChar.cxx @@ -1286,7 +1286,7 @@ void DataArrayChar::setPartOfValuesAdv(const DataArrayChar *a, const DataArrayCh } /*! - * Copy some tuples from another DataArrayChar (\a a) into contiguous tuples + * Copy some tuples from another DataArrayChar (\a aBase) into contiguous tuples * of \a this array. Textual data is not copied. Both arrays must have equal number of * components. * The tuples to assign to are defined by index of the first tuple, and @@ -1295,18 +1295,18 @@ void DataArrayChar::setPartOfValuesAdv(const DataArrayChar *a, const DataArrayCh * All components of selected tuples are copied. * \param [in] tupleIdStart - index of the first tuple of \a this array to assign * values to. - * \param [in] a - the array to copy values from. - * \param [in] tuplesSelec - the array specifying tuples of \a a to copy. + * \param [in] aBase - the array to copy values from. + * \param [in] tuplesSelec - the array specifying tuples of \a aBase to copy. * \throw If \a this is not allocated. - * \throw If \a a is NULL. - * \throw If \a a is not allocated. + * \throw If \a aBase is NULL. + * \throw If \a aBase is not allocated. * \throw If \a tuplesSelec is NULL. * \throw If \a tuplesSelec is not allocated. - * \throw If this->getNumberOfComponents() != a->getNumberOfComponents(). + * \throw If this->getNumberOfComponents() != aBase->getNumberOfComponents(). * \throw If \a tuplesSelec->getNumberOfComponents() != 1. * \throw If tupleIdStart + tuplesSelec->getNumberOfTuples() > this->getNumberOfTuples(). * \throw If any tuple index given by \a tuplesSelec is out of a valid range for - * \a a array. + * \a aBase array. */ void DataArrayChar::setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception) { @@ -1346,7 +1346,7 @@ void DataArrayChar::setContigPartOfSelectedValues(int tupleIdStart, const DataAr } /*! - * Copy some tuples from another DataArrayChar (\a a) into contiguous tuples + * Copy some tuples from another DataArrayChar (\a aBase) into contiguous tuples * of \a this array. Textual data is not copied. Both arrays must have equal number of * components. * The tuples to copy are defined by three values similar to parameters of @@ -1356,19 +1356,19 @@ void DataArrayChar::setContigPartOfSelectedValues(int tupleIdStart, const DataAr * All components of selected tuples are copied. * \param [in] tupleIdStart - index of the first tuple of \a this array to assign * values to. - * \param [in] a - the array to copy values from. - * \param [in] bg - index of the first tuple to copy of the array \a a. - * \param [in] end2 - index of the tuple of \a a before which the tuples to copy + * \param [in] aBase - the array to copy values from. + * \param [in] bg - index of the first tuple to copy of the array \a aBase. + * \param [in] end2 - index of the tuple of \a aBase before which the tuples to copy * are located. * \param [in] step - index increment to get index of the next tuple to copy. * \throw If \a this is not allocated. - * \throw If \a a is NULL. - * \throw If \a a is not allocated. - * \throw If this->getNumberOfComponents() != a->getNumberOfComponents(). + * \throw If \a aBase is NULL. + * \throw If \a aBase is not allocated. + * \throw If this->getNumberOfComponents() != aBase->getNumberOfComponents(). * \throw If tupleIdStart + len(range(bg,end2,step)) > this->getNumberOfTuples(). * \throw If parameters specifying tuples to copy, do not give a * non-empty range of increasing indices or indices are out of a valid range - * for the array \a a. + * for the array \a aBase. */ void DataArrayChar::setContigPartOfSelectedValues2(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step) throw(INTERP_KERNEL::Exception) { diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 49c9c1695..a5603445d 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -2811,6 +2811,11 @@ namespace ParaMEDMEM return MEDCoupling1SGTUMesh::New(name,type); } + MEDCoupling1SGTUMesh(const MEDCouplingUMesh *m) throw(INTERP_KERNEL::Exception) + { + return MEDCoupling1SGTUMesh::New(m); + } + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); @@ -2858,6 +2863,11 @@ namespace ParaMEDMEM return MEDCoupling1DGTUMesh::New(name,type); } + MEDCoupling1DGTUMesh(const MEDCouplingUMesh *m) throw(INTERP_KERNEL::Exception) + { + return MEDCoupling1DGTUMesh::New(m); + } + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); diff --git a/src/MEDLoader/MEDFileFieldOverView.cxx b/src/MEDLoader/MEDFileFieldOverView.cxx index 33045557d..95f06ad24 100644 --- a/src/MEDLoader/MEDFileFieldOverView.cxx +++ b/src/MEDLoader/MEDFileFieldOverView.cxx @@ -265,51 +265,108 @@ DataArray *MEDMeshMultiLev::constructDataArray(const MEDFileField1TSStructItem& else { std::size_t sz(fst.getNumberOfItems()); - std::vector< MEDCouplingAutoRefCountObjectPtr > arrSafe(sz); - std::vector< const DataArray *> arr(sz); - for(std::size_t i=0;i s(_geo_types.begin(),_geo_types.end()); + if(s.size()!=_geo_types.size()) + throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 2 !"); + std::vector< const DataArray *> arr(s.size()); + std::vector< MEDCouplingAutoRefCountObjectPtr > arrSafe(s.size()); + int iii(0); + int nc(vals->getNumberOfComponents()); + std::vector compInfo(vals->getInfoOnComponents()); + for(std::vector< INTERP_KERNEL::NormalizedCellType >::const_iterator it=_geo_types.begin();it!=_geo_types.end();it++,iii++) { - const MEDFileField1TSStructItem2& p(fst[i]); - const std::pair& strtStop(p.getStartStop()); - std::vector< INTERP_KERNEL::NormalizedCellType >::const_iterator it(std::find(_geo_types.begin(),_geo_types.end(),p.getGeo())); - if(it==_geo_types.end()) - throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 1 !"); - if(std::find(it+1,_geo_types.end(),p.getGeo())!=_geo_types.end()) - throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 2 !"); - std::size_t pos(std::distance(_geo_types.begin(),it)); - const DataArrayInt *thisP(_pfls[pos]),*otherP(p.getPfl(globs)); - MEDCouplingAutoRefCountObjectPtr ret(vals->selectByTupleId2(strtStop.first,strtStop.second,1)); - std::vector compInfo(vals->getInfoOnComponents()); - if(!thisP && !otherP) + const DataArrayInt *thisP(_pfls[iii]); + std::vector ps; + for(std::size_t i=0;igetNumberOfComponents()); - if(!thisP && otherP) + if(ps.empty()) + throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 1 !"); + if(ps.size()==1) { - MEDCouplingAutoRefCountObjectPtr p1(otherP->deepCpy()); - p1->sort(true); - p1->checkAllIdsInRange(0,getNumberOfCells(p.getGeo())); - p1=DataArrayInt::FindPermutationFromFirstToSecond(otherP,p1); - ret->rearrange(nbi*nc); ret->renumberInPlace(p1->begin()); ret->rearrange(nc); ret->setInfoOnComponents(compInfo); - arrSafe[i]=ret; arr[i]=ret; - continue; + int nbi(ps[0]->getNbOfIntegrationPts(globs)); + const DataArrayInt *otherP(ps[0]->getPfl(globs)); + const std::pair& strtStop(ps[0]->getStartStop()); + MEDCouplingAutoRefCountObjectPtr ret(vals->selectByTupleId2(strtStop.first,strtStop.second,1)); + if(!thisP && !otherP) + { + arrSafe[iii]=ret; arr[iii]=ret; + continue; + } + if(thisP && otherP) + { + MEDCouplingAutoRefCountObjectPtr p1(otherP->invertArrayN2O2O2N(getNumberOfCells(ps[0]->getGeo()))); + MEDCouplingAutoRefCountObjectPtr p2(thisP->deepCpy()); + p2->transformWithIndArr(p1->begin(),p1->end()); + //p1=p2->getIdsNotEqual(-1); + //p1=p2->selectByTupleIdSafe(p1->begin(),p1->end()); + ret->rearrange(nbi*nc); ret=ret->selectByTupleIdSafe(p2->begin(),p2->end()); ret->rearrange(nc); ret->setInfoOnComponents(compInfo); + arrSafe[iii]=ret; arr[iii]=ret; + continue; + } + if(!thisP && otherP) + { + MEDCouplingAutoRefCountObjectPtr p1(otherP->deepCpy()); + p1->sort(true); + p1->checkAllIdsInRange(0,getNumberOfCells(ps[0]->getGeo())); + p1=DataArrayInt::FindPermutationFromFirstToSecond(otherP,p1); + ret->rearrange(nbi*nc); ret->renumberInPlace(p1->begin()); ret->rearrange(nc); ret->setInfoOnComponents(compInfo); + arrSafe[iii]=ret; arr[iii]=ret; + continue; + } + throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 3 !"); } - if(thisP && otherP) + else { - MEDCouplingAutoRefCountObjectPtr p1(otherP->invertArrayN2O2O2N(getNumberOfCells(p.getGeo()))); - MEDCouplingAutoRefCountObjectPtr p2(thisP->deepCpy()); - p2->transformWithIndArr(p1->begin(),p1->end()); - p1=p2->getIdsNotEqual(-1); - p1=p2->selectByTupleIdSafe(p1->begin(),p1->end()); - ret->rearrange(nbi*nc); ret=ret->selectByTupleIdSafe(p1->begin(),p1->end()); ret->rearrange(nc); ret->setInfoOnComponents(compInfo); - arrSafe[i]=ret; arr[i]=ret; + std::vector< const DataArrayInt * >otherPS(ps.size()); + std::vector< const DataArray * > arr2(ps.size()); + std::vector< MEDCouplingAutoRefCountObjectPtr > arr2Safe(ps.size()); + std::vector< const DataArrayInt * > nbis(ps.size()); + std::vector< MEDCouplingAutoRefCountObjectPtr > nbisSafe(ps.size()); + int jj(0); + for(std::vector::const_iterator it2=ps.begin();it2!=ps.end();it2++,jj++) + { + int nbi((*it2)->getNbOfIntegrationPts(globs)); + const DataArrayInt *otherPfl((*it2)->getPfl(globs)); + const std::pair& strtStop((*it2)->getStartStop()); + MEDCouplingAutoRefCountObjectPtr ret2(vals->selectByTupleId2(strtStop.first,strtStop.second,1)); + if(!otherPfl) + throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 4 !"); + arr2[jj]=ret2; arr2Safe[jj]=ret2; otherPS[jj]=otherPfl; + nbisSafe[jj]=DataArrayInt::New(); nbisSafe[jj]->alloc(otherPfl->getNumberOfTuples(),1); nbisSafe[jj]->fillWithValue(nbi); + nbis[jj]=nbisSafe[jj]; + } + MEDCouplingAutoRefCountObjectPtr arr3(DataArray::Aggregate(arr2)); + MEDCouplingAutoRefCountObjectPtr otherP(DataArrayInt::Aggregate(otherPS)); + MEDCouplingAutoRefCountObjectPtr zenbis(DataArrayInt::Aggregate(nbis)); + MEDCouplingAutoRefCountObjectPtr otherPN(otherP->invertArrayN2O2O2N(getNumberOfCells(*it))); + MEDCouplingAutoRefCountObjectPtr p1; + if(thisP) + p1=DataArrayInt::FindPermutationFromFirstToSecond(otherP,thisP); + else + p1=otherP->deepCpy(); + MEDCouplingAutoRefCountObjectPtr zenbisN(zenbis->renumber(p1->begin())); + zenbisN->computeOffsets2(); + jj=0; + for(std::vector::const_iterator it2=ps.begin();it2!=ps.end();it2++,jj++) + { + int nbi((*it2)->getNbOfIntegrationPts(globs)); + const DataArrayInt *otherPfl((*it2)->getPfl(globs)); + const std::pair& strtStop((*it2)->getStartStop()); + MEDCouplingAutoRefCountObjectPtr ret2(vals->selectByTupleId2(strtStop.first,strtStop.second,1)); + // + MEDCouplingAutoRefCountObjectPtr p2(otherPfl->deepCpy()); + p2->transformWithIndArr(otherPN->begin(),otherPN->end()); + p2->transformWithIndArr(p1->begin(),p1->end()); + MEDCouplingAutoRefCountObjectPtr idsN(p2->buildExplicitArrByRanges(zenbisN)); + arr3->setPartOfValuesBase3(ret2,idsN->begin(),idsN->end(),0,nc,1); + } + arrSafe[iii]=arr3; arr[iii]=arr3; continue; } - if(thisP && !otherP) - throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 3 !"); - throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 6 !"); } return DataArray::Aggregate(arr); } diff --git a/src/MEDLoader/Swig/MEDLoaderTest4.py b/src/MEDLoader/Swig/MEDLoaderTest4.py index 99e1018d1..029e00b66 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest4.py +++ b/src/MEDLoader/Swig/MEDLoaderTest4.py @@ -1593,7 +1593,7 @@ class MEDLoaderTest4(unittest.TestCase): def test10(self): """ This test plays with fields only on nodes containing profiles. """ - fname="ForMEDReader9.med" + fname="ForMEDReader10.med" # building a mesh containing 6 tri3 + 5 quad4 m=MEDCouplingUMesh("mesh",2) coords=DataArrayDouble([(0,0),(1,0),(2,0),(3,0),(4,0),(0,1),(1,1),(2,1),(3,1),(4,1),(0,2),(1,2),(2,2),(3,2),(4,2)]) ; coords.setInfoOnComponents(["XX [m]","YYY [km]"]) @@ -1678,6 +1678,211 @@ class MEDLoaderTest4(unittest.TestCase): for i in xrange(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass + for i in xrange(5): + f=allFMTSLeavesPerCommonSupport[0][0][0][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) + f.loadArraysIfNecessary() + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName0) + #self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) # not a bug + vExp=DataArrayDouble(9*2) ; vExp.iota(0+i*1000) ; vExp.rearrange(2) ; vExp.setInfoOnComponents(['Comp1_0 [m]','Com2_0 [s^2]']) + self.assertTrue(v.isEqual(vExp,1e-12)) + # + f=allFMTSLeavesPerCommonSupport[0][0][1][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) + f.loadArraysIfNecessary() + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName1) + #self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) # not a bug + vExp=DataArrayDouble(9*2) ; vExp.iota(100+i*1000) ; vExp.rearrange(2) ; vExp.setInfoOnComponents(['Comp1_1 [m]','Com2_1 [s^2]']) + self.assertTrue(v.isEqual(vExp,1e-12)) + # + f=allFMTSLeavesPerCommonSupport[0][0][2][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) + f.loadArraysIfNecessary() + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName2) + #self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) # not a bug + vExp=DataArrayDouble(9*2) ; vExp.iota(200+i*1000) ; vExp.rearrange(2) ; vExp.setInfoOnComponents(['Comp1_2 [m]','Com2_2 [s^2]']) + self.assertTrue(v.isEqual(vExp,1e-12)) + pass + pass + + def test11(self): + """ This test is the ultimate test for the profiles with gauss points. It tests that even if there is non contiguous parts in definition of gauss points, it works ! + WARNING here, as no other discretizations exists, the priority is given to the field -> the mesh is renumbered to accelerate the build of array of field. + """ + fname="ForMEDReader11.med" + m=MEDCouplingCMesh("mesh") + arr=DataArrayDouble(5) ; arr.iota() + m.setCoords(arr,arr) + m=m.buildUnstructured() ; m.getCoords().setInfoOnComponents(["XX [m]","YYY [km]"]) + mm=MEDFileUMesh() ; mm.setMeshes([m]) + # + fieldName0="zeField0" + fs0=MEDFileFieldMultiTS() + for i in xrange(5): + f=MEDFileField1TS() + fNode=MEDCouplingFieldDouble(ON_GAUSS_PT) ; fNode.setTime(float(i),i,0) + fNode.setName(fieldName0) ; fNode.setMesh(m) + fNode.setGaussLocalizationOnCells([0,2,3,4,7,15],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7],[0.8,0.2]) + fNode.setGaussLocalizationOnCells([1,5,8,9],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3],[0.8,0.05,0.1,0.04,0.01]) + fNode.setGaussLocalizationOnCells([6,10,13],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2],[0.8,0.05,0.1,0.04]) + fNode.setGaussLocalizationOnCells([11,12,14],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.4,0.8,0.8],[0.8,0.05,0.1,0.01,0.02,0.005,0.005]) + arr=DataArrayDouble(2*(2*6+5*4+4*3+7*3)) ; arr.iota(0+1000*i) ; arr.rearrange(2) + fNode.setArray(arr) ; arr.setInfoOnComponents(["Comp1_0 [m]","Com2_0 [s^2]"]) ; fNode.checkCoherency() + f.setFieldNoProfileSBT(fNode) + fs0.pushBackTimeStep(f) + pass + mm.write(fname,2) + fs0.write(fname,0) + a0Exp=mm.getCoords().deepCpy() + del m,mm,fs0,f,fNode + ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values + ms=MEDFileMeshes(fname) + fields=MEDFileFields(fname,False) + fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] + allFMTSLeavesToDisplay=[] + for fields in fields_per_mesh: + allFMTSLeavesToDisplay2=[] + for fmts in fields: + allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + pass + allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) + pass + self.assertEqual(len(allFMTSLeavesToDisplay),1) + self.assertEqual(len(allFMTSLeavesToDisplay[0]),1) + allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[])) + self.assertEqual(len(allFMTSLeavesPerTimeSeries),1) # one time serie here : because the 1 field is defined on the same time steps + self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),1) + allFMTSLeavesPerCommonSupport=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesPerTimeSeries[0],ms[ms.getMeshesNames()[0]]) + self.assertEqual(len(allFMTSLeavesPerCommonSupport),1) + self.assertEqual(len(allFMTSLeavesPerCommonSupport[0][0]),1) + # + mst=MEDFileMeshStruct.New(ms[0]) + # + fcscp=allFMTSLeavesPerCommonSupport[0][1] + mml=fcscp.buildFromScratchDataSetSupport(0,fields) + mml2=mml.prepare() + self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) + a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(a0.isEqual(a0Exp,1e-12)) + self.assertTrue(a1.isEqual(DataArrayByte([9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9]))) + self.assertTrue(a2.isEqual(DataArrayInt([4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64]))) + self.assertTrue(a3.isEqual(DataArrayInt([4,1,0,5,6,4,3,2,7,8,4,4,3,8,9,4,6,5,10,11,4,9,8,13,14,4,19,18,23,24,4,2,1,6,7,4,7,6,11,12,4,11,10,15,16,4,12,11,16,17,4,8,7,12,13,4,13,12,17,18,4,17,16,21,22,4,14,13,18,19,4,16,15,20,21,4,18,17,22,23]))) # <- here the mesh is renumbered : the mesh is equal to m[[0,2,3,4,7,15, 1,5,8,9, 6,10,13, 11,12,14]] + self.assertTrue(a4 is None) + self.assertTrue(a5 is None) + for i in xrange(1,5): + self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) + pass + for i in xrange(5): + f=allFMTSLeavesPerCommonSupport[0][0][0][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) + f.loadArraysIfNecessary() + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName0) + self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) + vExp=DataArrayDouble([0.,1.,2.,3.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.,25.,44.,45.,46.,47.,126.,127.,128.,129.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,26.,27.,28.,29.,30.,31.,32.,33.,34.,35.,48.,49.,50.,51.,52.,53.,54.,55.,56.,57.,58.,59.,60.,61.,62.,63.,64.,65.,66.,67.,36.,37.,38.,39.,40.,41.,42.,43.,68.,69.,70.,71.,72.,73.,74.,75.,104.,105.,106.,107.,108.,109.,110.,111.,76.,77.,78.,79.,80.,81.,82.,83.,84.,85.,86.,87.,88.,89.,90.,91.,92.,93.,94.,95.,96.,97.,98.,99.,100.,101.,102.,103.,112.,113.,114.,115.,116.,117.,118.,119.,120.,121.,122.,123.,124.,125.],65,2) ; vExp.setInfoOnComponents(['Comp1_0 [m]','Com2_0 [s^2]']) + vExp+=i*1000 + self.assertTrue(v.isEqual(vExp,1e-12)) + pass + pass + + def test12(self): + """ This test is the second ultimate test for the profiles with gauss points. + This test is close to test11 but here a 2nd field on cells without profile. So here the mesh is expected to be the same than m. + """ + fname="ForMEDReader12.med" + m=MEDCouplingCMesh("mesh") + arr=DataArrayDouble(5) ; arr.iota() + m.setCoords(arr,arr) + m=m.buildUnstructured() ; m.getCoords().setInfoOnComponents(["XX [m]","YYY [km]"]) + mm=MEDFileUMesh() ; mm.setMeshes([m]) + # + fieldName0="zeField0" + fieldName1="zeField1" + fs0=MEDFileFieldMultiTS() ; fs1=MEDFileFieldMultiTS() + for i in xrange(5): + f=MEDFileField1TS() + fNode=MEDCouplingFieldDouble(ON_GAUSS_PT) ; fNode.setTime(float(i),i,0) + fNode.setName(fieldName0) ; fNode.setMesh(m) + fNode.setGaussLocalizationOnCells([0,2,3,4,7,15],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7],[0.8,0.2]) + fNode.setGaussLocalizationOnCells([1,5,8,9],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3],[0.8,0.05,0.1,0.04,0.01]) + fNode.setGaussLocalizationOnCells([6,10,13],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2],[0.8,0.05,0.1,0.04]) + fNode.setGaussLocalizationOnCells([11,12,14],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.4,0.8,0.8],[0.8,0.05,0.1,0.01,0.02,0.005,0.005]) + arr=DataArrayDouble(2*(2*6+5*4+4*3+7*3)) ; arr.iota(0+1000*i) ; arr.rearrange(2) + fNode.setArray(arr) ; arr.setInfoOnComponents(["Comp1_0 [m]","Com2_0 [s^2]"]) ; fNode.checkCoherency() + f.setFieldNoProfileSBT(fNode) + fs0.pushBackTimeStep(f) + # + f=MEDFileField1TS() + fNode=MEDCouplingFieldDouble(ON_CELLS) ; fNode.setTime(float(i),i,0) + fNode.setName(fieldName1) ; fNode.setMesh(m) + arr=DataArrayDouble(2*16) ; arr.iota(300+1000*i) ; arr.rearrange(2) + fNode.setArray(arr) ; arr.setInfoOnComponents(["Comp1_1 [m]","Com2_1 [s^2]"]) ; fNode.checkCoherency() + f.setFieldNoProfileSBT(fNode) + fs1.pushBackTimeStep(f) + pass + mm.write(fname,2) + fs0.write(fname,0) ; fs1.write(fname,0) + a0Exp=mm.getCoords().deepCpy() + del m,mm,fs0,fs1,f,fNode + ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values + ms=MEDFileMeshes(fname) + fields=MEDFileFields(fname,False) + fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] + allFMTSLeavesToDisplay=[] + for fields in fields_per_mesh: + allFMTSLeavesToDisplay2=[] + for fmts in fields: + allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + pass + allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) + pass + self.assertEqual(len(allFMTSLeavesToDisplay),1) + self.assertEqual(len(allFMTSLeavesToDisplay[0]),2) + allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[])) + self.assertEqual(len(allFMTSLeavesPerTimeSeries),1) # one time serie here : because the 2 fields are defined on the same time steps + self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),2) + allFMTSLeavesPerCommonSupport=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesPerTimeSeries[0],ms[ms.getMeshesNames()[0]]) + self.assertEqual(len(allFMTSLeavesPerCommonSupport),1) + self.assertEqual(len(allFMTSLeavesPerCommonSupport[0][0]),2) + # + mst=MEDFileMeshStruct.New(ms[0]) + # + fcscp=allFMTSLeavesPerCommonSupport[0][1] + mml=fcscp.buildFromScratchDataSetSupport(0,fields) + mml2=mml.prepare() + self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) + a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(a0.isEqual(a0Exp,1e-12)) + self.assertTrue(a1.isEqual(DataArrayByte([9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9]))) + self.assertTrue(a2.isEqual(DataArrayInt([4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64]))) + self.assertTrue(a3.isEqual(DataArrayInt([4,1,0,5,6,4,2,1,6,7,4,3,2,7,8,4,4,3,8,9,4,6,5,10,11,4,7,6,11,12,4,8,7,12,13,4,9,8,13,14,4,11,10,15,16,4,12,11,16,17,4,13,12,17,18,4,14,13,18,19,4,16,15,20,21,4,17,16,21,22,4,18,17,22,23,4,19,18,23,24]))) # <- here the mesh is NOT renumbered : the mesh is equal to m + self.assertTrue(a4 is None) + self.assertTrue(a5 is None) + for i in xrange(1,5): + self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) + pass + for i in xrange(5): + f=allFMTSLeavesPerCommonSupport[0][0][0][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) + f.loadArraysIfNecessary() + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName0) + #self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) # not a bug : huge reordering performed ! + vExp=DataArrayDouble(65*2) ; vExp.iota(0+i*1000) ; vExp.rearrange(2) ; vExp.setInfoOnComponents(['Comp1_0 [m]','Com2_0 [s^2]']) + self.assertTrue(v.isEqual(vExp,1e-12)) + # + f=allFMTSLeavesPerCommonSupport[0][0][1][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) + f.loadArraysIfNecessary() + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName1) + self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) # not a bug : huge reordering performed ! + vExp=DataArrayDouble(16*2) ; vExp.iota(300+i*1000) ; vExp.rearrange(2) ; vExp.setInfoOnComponents(['Comp1_1 [m]','Com2_1 [s^2]']) + self.assertTrue(v.isEqual(vExp,1e-12)) + pass pass pass