1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDFileFieldOverView.hxx"
22 #include "MEDFileField.hxx"
23 #include "MEDFileMesh.hxx"
25 #include "CellModel.hxx"
27 using namespace ParaMEDMEM;
29 const unsigned char MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE[MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE_LGTH]=
30 {1,3,21,5,9,7,22,34,23,28,-1,-1,-1,-1,10,14,13,-1,12,-1,24,-1,16,27,-1,26,-1,29,-1,-1,25,42,-1,4};
32 const char MEDFileField1TSStructItem2::NEWLY_CREATED_PFL_NAME[]="???";
34 MEDFileMeshStruct *MEDFileMeshStruct::New(const MEDFileMesh *mesh)
36 return new MEDFileMeshStruct(mesh);
39 std::size_t MEDFileMeshStruct::getHeapMemorySize() const
42 for(std::vector< std::vector<int> >::const_iterator it0=_geo_types_distrib.begin();it0!=_geo_types_distrib.end();it0++)
43 ret+=(*it0).capacity()*sizeof(int);
44 ret+=_geo_types_distrib.capacity()*sizeof(std::vector<int>);
48 MEDFileMeshStruct::MEDFileMeshStruct(const MEDFileMesh *mesh):_mesh(mesh)
50 std::vector<int> levs=mesh->getNonEmptyLevels();
51 _name=mesh->getName();
52 _nb_nodes=mesh->getNumberOfNodes();
53 _geo_types_distrib.resize(levs.size());
54 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
56 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mLev=mesh->getGenMeshAtLevel(*lev);
57 _geo_types_distrib[-(*lev)]=mLev->getDistributionOfTypes();
61 int MEDFileMeshStruct::getLevelOfGeoType(INTERP_KERNEL::NormalizedCellType t) const throw(INTERP_KERNEL::Exception)
64 for(std::vector< std::vector<int> >::const_iterator it1=_geo_types_distrib.begin();it1!=_geo_types_distrib.end();it1++,j--)
66 std::size_t sz=(*it1).size();
68 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getLevelOfGeoType : internal error in code !");
69 std::size_t nbGeo=sz/3;
70 for(std::size_t i=0;i<nbGeo;i++)
71 if((*it1)[3*i]==(int)t)
74 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getLevelOfGeoType : The specified geometric type is not present in the mesh structure !");
77 int MEDFileMeshStruct::getNumberOfElemsOfGeoType(INTERP_KERNEL::NormalizedCellType t) const throw(INTERP_KERNEL::Exception)
79 for(std::vector< std::vector<int> >::const_iterator it1=_geo_types_distrib.begin();it1!=_geo_types_distrib.end();it1++)
81 std::size_t sz=(*it1).size();
83 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfElemsOfGeoType : internal error in code !");
84 std::size_t nbGeo=sz/3;
85 for(std::size_t i=0;i<nbGeo;i++)
86 if((*it1)[3*i]==(int)t)
89 throw INTERP_KERNEL::Exception("The specified geometric type is not present in the mesh structure !");
92 int MEDFileMeshStruct::getNumberOfLevs() const
94 return (int)_geo_types_distrib.size();
97 int MEDFileMeshStruct::getNumberOfGeoTypesInLev(int relativeLev) const throw(INTERP_KERNEL::Exception)
99 int pos(-relativeLev);
100 if(pos<0 || pos>=_geo_types_distrib.size())
101 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfGeoTypesInLev : invalid level specified !");
102 std::size_t sz=_geo_types_distrib[pos].size();
104 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfGeoTypesInLev : internal error in code !");
110 MEDFileField1TSStructItem2::MEDFileField1TSStructItem2()
114 MEDFileField1TSStructItem2::MEDFileField1TSStructItem2(INTERP_KERNEL::NormalizedCellType a, const std::pair<int,int>& b, const std::string& c, const std::string& d):_geo_type(a),_start_end(b),_pfl(DataArrayInt::New()),_loc(d),_nb_of_entity(-1)
116 _pfl->setName(c.c_str());
119 void MEDFileField1TSStructItem2::checkWithMeshStructForCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception)
121 int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
122 checkInRange(nbOfEnt,1,globs);
125 void MEDFileField1TSStructItem2::checkWithMeshStructForGaussNE(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception)
127 int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
128 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
129 checkInRange(nbOfEnt,(int)cm.getNumberOfNodes(),globs);
132 void MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception)
135 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT : no globals specified !");
137 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT : no localization specified !");
138 const MEDFileFieldLoc& loc=globs->getLocalization(_loc.c_str());
139 int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
140 checkInRange(nbOfEnt,loc.getNumberOfGaussPoints(),globs);
143 int MEDFileField1TSStructItem2::getNbOfIntegrationPts(const MEDFileFieldGlobsReal *globs) const
147 if(getPflName().empty())
148 return (_start_end.second-_start_end.first)/_nb_of_entity;
150 return (_start_end.second-_start_end.first)/getPfl(globs)->getNumberOfTuples();
154 const MEDFileFieldLoc& loc(globs->getLocalization(_loc.c_str()));
155 return loc.getNumberOfGaussPoints();
159 std::string MEDFileField1TSStructItem2::getPflName() const
161 return _pfl->getName();
164 const DataArrayInt *MEDFileField1TSStructItem2::getPfl(const MEDFileFieldGlobsReal *globs) const
166 if(!_pfl->isAllocated())
168 if(_pfl->getName().empty())
171 return globs->getProfile(_pfl->getName().c_str());
178 * \param [in] nbOfEntity - number of entity that can be either cells or nodes. Not other possiblity.
179 * \param [in] nip - number of integration points. 1 for ON_CELLS and NO_NODES
181 void MEDFileField1TSStructItem2::checkInRange(int nbOfEntity, int nip, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception)
183 _nb_of_entity=nbOfEntity;
184 if(_pfl->getName().empty())
186 if(nbOfEntity!=(_start_end.second-_start_end.first)/nip)
187 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Mismatch between number of entities and size of node field !");
193 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Presence of a profile on field whereas no globals found in file !");
194 const DataArrayInt *pfl=globs->getProfile(_pfl->getName().c_str());
196 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Presence of a profile on field whereas no such profile found in file !");
197 pfl->checkAllIdsInRange(0,nbOfEntity);
201 bool MEDFileField1TSStructItem2::isFastlyEqual(int& startExp, INTERP_KERNEL::NormalizedCellType gt, const char *pflName) const
203 if(startExp!=_start_end.first)
207 if(getPflName()!=pflName)
209 startExp=_start_end.second;
213 bool MEDFileField1TSStructItem2::operator==(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception)
215 //_nb_of_entity is not taken into account here. It is not a bug, because no mesh consideration needed here to perform fast compare.
216 //idem for _loc. It is not an effective attribute for support comparison.
217 return _geo_type==other._geo_type && _start_end==other._start_end && _pfl->getName()==other._pfl->getName();
220 bool MEDFileField1TSStructItem2::isCellSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
222 if(_geo_type!=other._geo_type)
224 if(_nb_of_entity!=other._nb_of_entity)
226 if((_pfl->getName().empty() && !other._pfl->getName().empty()) || (!_pfl->getName().empty() && other._pfl->getName().empty()))
228 if(_pfl->getName().empty() && other._pfl->getName().empty())
230 const DataArrayInt *pfl1(getPfl(globs)),*pfl2(other.getPfl(globs));
231 return pfl1->isEqualWithoutConsideringStr(*pfl2);
234 bool MEDFileField1TSStructItem2::isNodeSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
236 return isCellSupportEqual(other,globs);
240 * \a objs must be non empty. \a objs should contain items having same geometric type.
242 MEDFileField1TSStructItem2 MEDFileField1TSStructItem2::BuildAggregationOf(const std::vector<const MEDFileField1TSStructItem2 *>& objs, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception)
245 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : empty input !");
247 return MEDFileField1TSStructItem2(*objs[0]);
248 INTERP_KERNEL::NormalizedCellType gt(objs[0]->_geo_type);
249 int nbEntityRef(objs[0]->_nb_of_entity);
250 std::size_t sz(objs.size());
251 std::vector<const DataArrayInt *> arrs(sz);
252 for(std::size_t i=0;i<sz;i++)
254 const MEDFileField1TSStructItem2 *obj(objs[i]);
255 if(gt!=obj->_geo_type)
256 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : invalid situation ! All input must have the same geo type !");
257 if(nbEntityRef!=obj->_nb_of_entity)
258 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : invalid situation ! All input must have the global nb of entity !");
259 if(obj->_pfl->getName().empty())
260 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : invalid situation ! Several same geo type chunk must all lie on profiles !");
261 arrs[i]=globs->getProfile(obj->_pfl->getName().c_str());
263 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr(DataArrayInt::Aggregate(arrs));
265 int oldNbTuples(arr->getNumberOfTuples());
266 arr=arr->buildUnique();
267 if(oldNbTuples!=arr->getNumberOfTuples())
268 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : some entities are present several times !");
269 if(arr->isIdentity() && oldNbTuples==nbEntityRef)
271 std::pair<int,int> p(0,nbEntityRef);
273 MEDFileField1TSStructItem2 ret(gt,p,a,b);
274 ret._nb_of_entity=nbEntityRef;
279 arr->setName(NEWLY_CREATED_PFL_NAME);
280 std::pair<int,int> p(0,oldNbTuples);
282 MEDFileField1TSStructItem2 ret(gt,p,a,b);
283 ret._nb_of_entity=nbEntityRef;
289 std::size_t MEDFileField1TSStructItem2::getHeapMemorySize() const
292 const DataArrayInt *pfl(_pfl);
294 ret+=pfl->getHeapMemorySize();
295 ret+=_loc.capacity();
301 MEDFileField1TSStructItem::MEDFileField1TSStructItem(TypeOfField a, const std::vector< MEDFileField1TSStructItem2 >& b):_computed(false),_type(a),_items(b)
305 void MEDFileField1TSStructItem::checkWithMeshStruct(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception)
311 int nbOfEnt=mst->getNumberOfNodes();
313 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::checkWithMeshStruct : for nodes field only one subdivision supported !");
314 _items[0].checkInRange(nbOfEnt,1,globs);
319 for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
320 (*it).checkWithMeshStructForCells(mst,globs);
325 for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
326 (*it).checkWithMeshStructForGaussNE(mst,globs);
331 for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
332 (*it).checkWithMeshStructForGaussPT(mst,globs);
336 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::checkWithMeshStruct : not managed field type !");
340 bool MEDFileField1TSStructItem::operator==(const MEDFileField1TSStructItem& other) const throw(INTERP_KERNEL::Exception)
342 if(_type!=other._type)
344 if(_items.size()!=other._items.size())
346 for(std::size_t i=0;i<_items.size();i++)
347 if(!(_items[i]==other._items[i]))
352 bool MEDFileField1TSStructItem::isCellSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
354 if(_type!=other._type)
356 if(_items.size()!=other._items.size())
358 for(std::size_t i=0;i<_items.size();i++)
359 if(!(_items[i].isCellSupportEqual(other._items[i],globs)))
364 bool MEDFileField1TSStructItem::isNodeSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
366 if(_type!=other._type)
368 if(_items.size()!=other._items.size())
370 for(std::size_t i=0;i<_items.size();i++)
371 if(!(_items[i].isNodeSupportEqual(other._items[i],globs)))
376 bool MEDFileField1TSStructItem::isEntityCell() const
387 CmpGeo(INTERP_KERNEL::NormalizedCellType geoTyp):_geo_type(geoTyp) { }
388 bool operator()(const std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > & v) const { return _geo_type==v.first; }
390 INTERP_KERNEL::NormalizedCellType _geo_type;
393 MEDFileField1TSStructItem MEDFileField1TSStructItem::simplifyMeOnCellEntity(const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
396 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::simplifyMeOnCellEntity : must be on ON_CELLS, ON_GAUSS_NE or ON_GAUSS_PT !");
397 std::vector< std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > > m;
399 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++,i++)
401 std::vector< std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > >::iterator it0(std::find_if(m.begin(),m.end(),CmpGeo((*it).getGeo())));
403 m.push_back(std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> >((*it).getGeo(),std::vector<std::size_t>(1,i)));
405 (*it0).second.push_back(i);
407 if(m.size()==_items.size())
409 MEDFileField1TSStructItem ret(*this);
413 std::size_t sz(m.size());
414 std::vector< MEDFileField1TSStructItem2 > items(sz);
417 const std::vector<std::size_t>& ids=m[i].second;
418 std::vector<const MEDFileField1TSStructItem2 *>objs(ids.size());
419 for(std::size_t j=0;j<ids.size();j++)
420 objs[j]=&_items[ids[j]];
421 items[i]=MEDFileField1TSStructItem2::BuildAggregationOf(objs,globs);
423 MEDFileField1TSStructItem ret(ON_CELLS,items);
429 * \a this is expected to be ON_CELLS and simplified.
431 bool MEDFileField1TSStructItem::isCompatibleWithNodesDiscr(const MEDFileField1TSStructItem& other, const MEDFileMeshStruct *meshSt, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
433 if(other._type!=ON_NODES)
434 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isCompatibleWithNodesDiscr : other must be on nodes !");
435 if(other._items.size()!=1)
436 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isCompatibleWithNodesDiscr : other is on nodes but number of subparts !");
438 bool ret0=isFullyOnOneLev(meshSt,theFirstLevFull);
439 const MEDFileField1TSStructItem2& otherNodeIt(other._items[0]);
440 if(otherNodeIt.getPflName().empty())
444 return theFirstLevFull==0;
448 const DataArrayInt *pfl=globs->getProfile(otherNodeIt.getPflName().c_str());
449 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpyPfl(pfl->deepCpy());
451 int nbOfNodes(meshSt->getNumberOfNodes());
452 if(cpyPfl->isIdentity() && cpyPfl->getNumberOfTuples()==nbOfNodes)
453 {//on all nodes also !
456 return theFirstLevFull==0;
458 std::vector<bool> nodesFetched(nbOfNodes,false);
459 meshSt->getTheMesh()->whichAreNodesFetched(*this,globs,nodesFetched);
460 return cpyPfl->isFittingWith(nodesFetched);
464 bool MEDFileField1TSStructItem::isFullyOnOneLev(const MEDFileMeshStruct *meshSt, int& theFirstLevFull) const throw(INTERP_KERNEL::Exception)
467 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : works only for ON_CELLS discretization !");
469 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : items vector is empty !");
470 int nbOfLevs(meshSt->getNumberOfLevs());
472 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : no levels in input mesh structure !");
473 std::vector<int> levs(nbOfLevs);
476 std::set<INTERP_KERNEL::NormalizedCellType> gts;
477 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++)
479 if(!(*it).getPflName().empty())
481 INTERP_KERNEL::NormalizedCellType gt((*it).getGeo());
482 if(gts.find(gt)!=gts.end())
483 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : internal error !");
485 int pos(meshSt->getLevelOfGeoType((*it).getGeo()));
488 for(int i=0;i<nbOfLevs;i++)
489 if(meshSt->getNumberOfGeoTypesInLev(-i)==levs[i])
490 { theFirstLevFull=-i; return true; }
494 const MEDFileField1TSStructItem2& MEDFileField1TSStructItem::operator[](std::size_t i) const throw(INTERP_KERNEL::Exception)
496 if(i<0 || i>=_items.size())
497 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::operator[] : input is not in valid range !");
501 std::size_t MEDFileField1TSStructItem::getHeapMemorySize() const
504 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++)
505 ret+=(*it).getHeapMemorySize();
506 ret+=_items.size()*sizeof(MEDFileField1TSStructItem2);
510 MEDMeshMultiLev *MEDFileField1TSStructItem::buildFromScratchDataSetSupportOnCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
512 std::vector<INTERP_KERNEL::NormalizedCellType> a0;
513 std::vector<const DataArrayInt *> a1;
516 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++,i++)
518 a0[i]=(*it).getGeo();
519 a1[i]=(*it).getPfl(globs);
520 a2[i]=mst->getNumberOfElemsOfGeoType((*it).getGeo());
522 return MEDMeshMultiLev::New(mst->getTheMesh(),a0,a1,a2);
527 MEDFileField1TSStruct *MEDFileField1TSStruct::New(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst) throw(INTERP_KERNEL::Exception)
529 return new MEDFileField1TSStruct(ref,mst);
532 MEDFileField1TSStruct::MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst)
534 _already_checked.push_back(BuildItemFrom(ref,mst));
537 void MEDFileField1TSStruct::checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception)
539 if(_already_checked.empty())
540 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::checkWithMeshStruct : not correctly initialized !");
541 _already_checked.back().checkWithMeshStruct(mst,globs);
544 bool MEDFileField1TSStruct::isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *mst) const throw(INTERP_KERNEL::Exception)
546 MEDFileField1TSStructItem b(BuildItemFrom(other,mst));
547 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++)
556 * Not const because \a other structure will be added to the \c _already_checked attribute in case of success.
558 bool MEDFileField1TSStruct::isSupportSameAs(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception)
560 if(_already_checked.empty())
561 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isSupportSameAs : no ref !");
562 MEDFileField1TSStructItem b(BuildItemFrom(other,meshSt));
563 if(!_already_checked[0].isEntityCell() || !b.isEntityCell())
564 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isSupportSameAs : only available on cell entities !");
565 MEDFileField1TSStructItem other1(b.simplifyMeOnCellEntity(other));
567 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
568 if((*it).isComputed())
573 MEDFileField1TSStructItem this1(_already_checked[0].simplifyMeOnCellEntity(other));
574 ret=this1.isCellSupportEqual(other1,other);
576 _already_checked.push_back(this1);
579 ret=_already_checked[found].isCellSupportEqual(other1,other);
581 _already_checked.push_back(b);
585 bool MEDFileField1TSStruct::isCompatibleWithNodesDiscr(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception)
587 if(_already_checked.empty())
588 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isCompatibleWithNodesDiscr : no ref !");
589 if(!_already_checked[0].isEntityCell())
590 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isCompatibleWithNodesDiscr : only available on cell entities !");
591 MEDFileField1TSStructItem other1(BuildItemFrom(other,meshSt));
594 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
595 if((*it).isComputed())
600 MEDFileField1TSStructItem this1(_already_checked[0].simplifyMeOnCellEntity(other));
601 ret=this1.isCompatibleWithNodesDiscr(other1,meshSt,other);
603 _already_checked.push_back(this1);
606 ret=_already_checked[found].isCompatibleWithNodesDiscr(other1,meshSt,other);
608 _already_checked.push_back(other1);
612 std::size_t MEDFileField1TSStruct::getHeapMemorySize() const
615 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++)
616 ret+=(*it).getHeapMemorySize();
617 ret+=_already_checked.capacity()*sizeof(MEDFileField1TSStructItem);
621 MEDFileField1TSStructItem MEDFileField1TSStruct::BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt)
624 std::vector< MEDFileField1TSStructItem2 > anItems;
626 std::vector< std::vector<std::string> > pfls,locs;
627 std::vector< std::vector<TypeOfField> > typesF;
628 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
629 std::vector< std::vector<std::pair<int,int> > > strtEnds=ref->getFieldSplitedByType(0,geoTypes,typesF,pfls,locs);
630 std::size_t nbOfGeoTypes(geoTypes.size());
632 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : not null by empty ref !");
634 for(std::size_t i=0;i<nbOfGeoTypes;i++)
636 std::size_t sz=typesF[i].size();
637 if(strtEnds[i].size()<1 || sz<1 || pfls[i].size()<1)
638 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : internal error #1 !");
644 for(std::size_t j=0;j<sz;j++)
646 if(atype==typesF[i][j])
647 anItems.push_back(MEDFileField1TSStructItem2(geoTypes[i],strtEnds[i][j],pfls[i][j],locs[i][j]));
649 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : can be applied only on single spatial discretization fields ! Call SplitPerDiscretization method !");
652 MEDFileField1TSStructItem ret(atype,anItems);
653 ret.checkWithMeshStruct(meshSt,ref);
657 MEDMeshMultiLev *MEDFileField1TSStruct::buildFromScratchDataSetSupport(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
659 if(_already_checked.empty())
660 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::buildFromScratchDataSetSupport : No outline structure in this !");
661 int pos0(-1),pos1(-1);
662 if(presenceOfCellDiscr(pos0))
664 MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> ret(_already_checked[pos0].buildFromScratchDataSetSupportOnCells(mst,globs));
665 if(presenceOfPartialNodeDiscr(pos1))
666 ret->setNodeReduction(_already_checked[pos1][0].getPfl(globs));
671 if(!presenceOfPartialNodeDiscr(pos1))
672 {//we have only all nodes, no cell definition info -> level 0;
673 std::vector<int> levs(1,0);
674 return MEDMeshMultiLev::New(mst->getTheMesh(),levs);
677 return MEDMeshMultiLev::NewOnlyOnNode(mst->getTheMesh(),_already_checked[pos1][0].getPfl(globs));
681 bool MEDFileField1TSStruct::isDataSetSupportFastlyEqualTo(const MEDFileField1TSStruct& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
684 bool a0(presenceOfCellDiscr(b0)),a1(presenceOfPartialNodeDiscr(b1));
686 bool c0(other.presenceOfCellDiscr(d0)),c1(other.presenceOfPartialNodeDiscr(d1));
690 if(!_already_checked[b0].isCellSupportEqual(other._already_checked[d0],globs))
693 if(!_already_checked[b1].isNodeSupportEqual(other._already_checked[d1],globs))
699 * Returns true if presence in \a this of discretization ON_CELLS, ON_GAUSS_PT, ON_GAUSS_NE.
700 * If true is returned the pos of the easiest is returned. The easiest is the first element in \a this having the less splitted subparts.
702 bool MEDFileField1TSStruct::presenceOfCellDiscr(int& pos) const throw(INTERP_KERNEL::Exception)
704 std::size_t refSz(std::numeric_limits<std::size_t>::max());
707 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
709 if((*it).getType()!=ON_NODES)
712 std::size_t sz((*it).getNumberOfItems());
718 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::presenceOfCellDiscr : an element in this on entity CELL is empty !");
723 * Returns true if presence in \a this of discretization ON_NODES.
724 * If true is returned the pos of the first element containing the single subpart.
726 bool MEDFileField1TSStruct::presenceOfPartialNodeDiscr(int& pos) const throw(INTERP_KERNEL::Exception)
729 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
731 if((*it).getType()==ON_NODES)
733 std::size_t sz((*it).getNumberOfItems());
736 if(!(*it)[0].getPflName().empty())
737 { pos=i; return true; }
740 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::presenceOfPartialNodeDiscr : an element in this on entity NODE is split into several parts !");
748 MEDFileFastCellSupportComparator *MEDFileFastCellSupportComparator::New(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref) throw(INTERP_KERNEL::Exception)
750 return new MEDFileFastCellSupportComparator(m,ref);
753 MEDFileFastCellSupportComparator::MEDFileFastCellSupportComparator(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref)
756 throw INTERP_KERNEL::Exception("MEDFileFastCellSupportComparator constructor : null input mesh struct !");
757 _mesh_comp=const_cast<MEDFileMeshStruct *>(m); _mesh_comp->incrRef();
758 int nbPts=ref->getNumberOfTS();
759 _f1ts_cmps.resize(nbPts);
760 for(int i=0;i<nbPts;i++)
762 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt=ref->getTimeStepAtPos(i);
763 _f1ts_cmps[i]=MEDFileField1TSStruct::New(elt,_mesh_comp);
764 _f1ts_cmps[i]->checkWithMeshStruct(_mesh_comp,elt);
768 std::size_t MEDFileFastCellSupportComparator::getHeapMemorySize() const
771 const MEDFileMeshStruct *mst(_mesh_comp);
773 ret+=mst->getHeapMemorySize();
774 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct> >::const_iterator it=_f1ts_cmps.begin();it!=_f1ts_cmps.end();it++)
776 const MEDFileField1TSStruct *cur(*it);
778 ret+=cur->getHeapMemorySize()+sizeof(MEDFileField1TSStruct);
780 ret+=_f1ts_cmps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct>);
784 bool MEDFileFastCellSupportComparator::isEqual(const MEDFileAnyTypeFieldMultiTS *other) throw(INTERP_KERNEL::Exception)
786 int nbPts=other->getNumberOfTS();
787 if(nbPts!=(int)_f1ts_cmps.size())
789 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isEqual : unexpected nb of time steps in input ! Should be " << _f1ts_cmps.size() << " it is in reality " << nbPts << " !";
790 throw INTERP_KERNEL::Exception(oss.str().c_str());
792 for(int i=0;i<nbPts;i++)
794 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt=other->getTimeStepAtPos(i);
795 if(!_f1ts_cmps[i]->isEqualConsideringThePast(elt,_mesh_comp))
796 if(!_f1ts_cmps[i]->isSupportSameAs(elt,_mesh_comp))
802 bool MEDFileFastCellSupportComparator::isCompatibleWithNodesDiscr(const MEDFileAnyTypeFieldMultiTS *other) throw(INTERP_KERNEL::Exception)
804 int nbPts=other->getNumberOfTS();
805 if(nbPts!=(int)_f1ts_cmps.size())
807 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isCompatibleWithNodesDiscr : unexpected nb of time steps in input ! Should be " << _f1ts_cmps.size() << " it is in reality " << nbPts << " !";
808 throw INTERP_KERNEL::Exception(oss.str().c_str());
810 for(int i=0;i<nbPts;i++)
812 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt=other->getTimeStepAtPos(i);
813 if(!_f1ts_cmps[i]->isCompatibleWithNodesDiscr(elt,_mesh_comp))
819 MEDMeshMultiLev *MEDFileFastCellSupportComparator::buildFromScratchDataSetSupport(int timeStepId, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
821 if(timeStepId<0 || timeStepId>=(int)_f1ts_cmps.size())
823 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::buildFromScratchDataSetSupport : requested time step id #" << timeStepId << " is not in [0," << _f1ts_cmps.size() << ") !";
824 throw INTERP_KERNEL::Exception(oss.str().c_str());
826 const MEDFileField1TSStruct *obj(_f1ts_cmps[timeStepId]);
829 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::buildFromScratchDataSetSupport : at time step id #" << timeStepId << " no field structure overview defined !";
830 throw INTERP_KERNEL::Exception(oss.str().c_str());
832 return obj->buildFromScratchDataSetSupport(_mesh_comp,globs);
835 bool MEDFileFastCellSupportComparator::isDataSetSupportEqualToThePreviousOne(int timeStepId, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
837 if(timeStepId<=0 || timeStepId>=(int)_f1ts_cmps.size())
839 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isDataSetSupportEqualToThePreviousOne : requested time step id #" << timeStepId << " is not in [1," << _f1ts_cmps.size() << ") !";
840 throw INTERP_KERNEL::Exception(oss.str().c_str());
842 const MEDFileField1TSStruct *obj(_f1ts_cmps[timeStepId]);
843 const MEDFileField1TSStruct *objRef(_f1ts_cmps[timeStepId-1]);
844 return objRef->isDataSetSupportFastlyEqualTo(*obj,globs);
849 std::size_t MEDMeshMultiLev::getHeapMemorySize() const
854 MEDMeshMultiLev *MEDMeshMultiLev::New(const MEDFileMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception)
857 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New : null input pointer !");
858 const MEDFileUMesh *um(dynamic_cast<const MEDFileUMesh *>(m));
860 return MEDUMeshMultiLev::New(um,levs);
861 const MEDFileCMesh *cm(dynamic_cast<const MEDFileCMesh *>(m));
863 return MEDCMeshMultiLev::New(cm,levs);
864 const MEDFileCurveLinearMesh *clm(dynamic_cast<const MEDFileCurveLinearMesh *>(m));
866 return MEDCurveLinearMeshMultiLev::New(clm,levs);
867 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New : unrecognized type of mesh ! Must be in [MEDFileUMesh,MEDFileCMesh,MEDFileCurveLinearMesh] !");
870 MEDMeshMultiLev *MEDMeshMultiLev::New(const MEDFileMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities) throw(INTERP_KERNEL::Exception)
873 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New 2 : null input pointer !");
874 const MEDFileUMesh *um(dynamic_cast<const MEDFileUMesh *>(m));
876 return MEDUMeshMultiLev::New(um,gts,pfls,nbEntities);
877 const MEDFileCMesh *cm(dynamic_cast<const MEDFileCMesh *>(m));
879 return MEDCMeshMultiLev::New(cm,gts,pfls,nbEntities);
880 const MEDFileCurveLinearMesh *clm(dynamic_cast<const MEDFileCurveLinearMesh *>(m));
882 return MEDCurveLinearMeshMultiLev::New(clm,gts,pfls,nbEntities);
883 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New 2 : unrecognized type of mesh ! Must be in [MEDFileUMesh,MEDFileCMesh,MEDFileCurveLinearMesh] !");
886 MEDMeshMultiLev *MEDMeshMultiLev::NewOnlyOnNode(const MEDFileMesh *m, const DataArrayInt *pflOnNode) throw(INTERP_KERNEL::Exception)
888 std::vector<int> levs(1,0);
889 MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> ret(MEDMeshMultiLev::New(m,levs));
890 ret->selectPartOfNodes(pflOnNode);
894 void MEDMeshMultiLev::setNodeReduction(const DataArrayInt *nr)
898 _node_reduction=const_cast<DataArrayInt*>(nr);
901 bool MEDMeshMultiLev::isFastlyTheSameStruct(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
903 if(fst.getType()==ON_NODES)
905 if(fst.getNumberOfItems()!=1)
906 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::isFastlyTheSameStruct : unexpected situation for nodes !");
907 const MEDFileField1TSStructItem2& p(fst[0]);
908 std::string pflName(p.getPflName());
909 const DataArrayInt *nr(_node_reduction);
910 if(pflName.empty() && !nr)
912 if(pflName==nr->getName())
918 std::size_t sz(fst.getNumberOfItems());
919 if(sz!=_geo_types.size())
922 for(std::size_t i=0;i<sz;i++)
924 const MEDFileField1TSStructItem2& p(fst[i]);
925 if(!p.isFastlyEqual(strt,_geo_types[i],getPflNameOfId(i).c_str()))
932 DataArray *MEDMeshMultiLev::buildDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const throw(INTERP_KERNEL::Exception)
934 MEDCouplingAutoRefCountObjectPtr<DataArray> ret(const_cast<DataArray *>(vals)); ret->incrRef();
935 if(isFastlyTheSameStruct(fst,globs))
938 return constructDataArray(fst,globs,vals);
941 std::string MEDMeshMultiLev::getPflNameOfId(int id) const
943 std::size_t sz(_pfls.size());
945 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::getPflNameOfId : invalid input id !");
946 const DataArrayInt *pfl(_pfls[id]);
948 return std::string("");
949 return pfl->getName();
952 DataArray *MEDMeshMultiLev::constructDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const throw(INTERP_KERNEL::Exception)
954 if(fst.getType()==ON_NODES)
956 if(fst.getNumberOfItems()!=1)
957 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes !");
958 const MEDFileField1TSStructItem2& p(fst[0]);
959 std::string pflName(p.getPflName());
960 const DataArrayInt *nr(_node_reduction);
961 if(pflName.empty() && !nr)
962 return vals->deepCpy();
963 if(pflName.empty() && nr)
964 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 2 !");
965 if(!pflName.empty() && nr)
967 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(globs->getProfile(pflName.c_str())->deepCpy());
968 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p2(nr->deepCpy());
969 p1->sort(true); p2->sort(true);
970 if(!p1->isEqualWithoutConsideringStr(*p2))
971 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 3 !");
972 p1=DataArrayInt::FindPermutationFromFirstToSecond(globs->getProfile(pflName.c_str()),nr);
973 MEDCouplingAutoRefCountObjectPtr<DataArray> ret(vals->deepCpy());
974 ret->renumberInPlace(p1->begin());
977 if(!pflName.empty() && !nr)
979 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(globs->getProfile(pflName.c_str())->deepCpy());
981 if(!p1->isIdentity() || p1->getNumberOfTuples()!=p.getNbEntity())
982 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 4 !");
983 MEDCouplingAutoRefCountObjectPtr<DataArray> ret(vals->deepCpy());
984 ret->renumberInPlace(globs->getProfile(pflName.c_str())->begin());
987 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 5 !");
991 std::size_t sz(fst.getNumberOfItems());
992 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArray> > arrSafe(sz);
993 std::vector< const DataArray *> arr(sz);
994 for(std::size_t i=0;i<sz;i++)
996 const MEDFileField1TSStructItem2& p(fst[i]);
997 const std::pair<int,int>& strtStop(p.getStartStop());
998 std::vector< INTERP_KERNEL::NormalizedCellType >::const_iterator it(std::find(_geo_types.begin(),_geo_types.end(),p.getGeo()));
999 if(it==_geo_types.end())
1000 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 1 !");
1001 if(std::find(it+1,_geo_types.end(),p.getGeo())!=_geo_types.end())
1002 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 2 !");
1003 std::size_t pos(std::distance(_geo_types.begin(),it));
1004 const DataArrayInt *thisP(_pfls[pos]),*otherP(p.getPfl(globs));
1005 MEDCouplingAutoRefCountObjectPtr<DataArray> ret(vals->selectByTupleId2(strtStop.first,strtStop.second,1));
1006 if(!thisP && !otherP)
1008 arrSafe[i]=ret; arr[i]=ret;
1011 int nbi(p.getNbOfIntegrationPts(globs)),nc(ret->getNumberOfComponents());
1012 if(!thisP && otherP)
1014 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(otherP->deepCpy());
1016 if(!p1->isIdentity() || p1->getNumberOfTuples()!=p.getNbEntity())
1017 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 3 !");
1018 ret->rearrange(nbi*nc); ret->renumberInPlace(otherP->begin()); ret->rearrange(nc);
1019 arrSafe[i]=ret; arr[i]=ret;
1024 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(otherP->deepCpy());
1025 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p2(thisP->deepCpy());
1026 p1->sort(true); p2->sort(true);
1027 if(!p1->isEqualWithoutConsideringStr(*p2))
1028 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 4 !");
1029 p1=DataArrayInt::FindPermutationFromFirstToSecond(otherP,thisP);
1030 ret->rearrange(nbi*nc); ret->renumberInPlace(p1->begin()); ret->rearrange(nc);
1033 if(thisP && !otherP)
1035 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(thisP->deepCpy());
1037 if(!p1->isIdentity() || p1->getNumberOfTuples()!=p.getNbEntity())
1038 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 3 !");
1039 ret->rearrange(nbi*nc); ret->renumberInPlaceR(otherP->begin()); ret->rearrange(nc);
1040 arrSafe[i]=ret; arr[i]=ret;
1043 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 6 !");
1045 return DataArray::Aggregate(arr);
1049 MEDMeshMultiLev::MEDMeshMultiLev()
1053 MEDMeshMultiLev::MEDMeshMultiLev(const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):_geo_types(gts),_nb_entities(nbEntities)
1055 std::size_t sz(_geo_types.size());
1056 if(sz!=pfls.size() || sz!=nbEntities.size())
1057 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::MEDMeshMultiLev : input vector must have the same size !");
1059 for(std::size_t i=0;i<sz;i++)
1063 _pfls[i]=const_cast<DataArrayInt *>(pfls[i]);
1067 MEDMeshMultiLev::MEDMeshMultiLev(const MEDMeshMultiLev& other):_pfls(other._pfls),_geo_types(other._geo_types),_nb_entities(other._nb_entities),_node_reduction(other._node_reduction)
1073 MEDUMeshMultiLev *MEDUMeshMultiLev::New(const MEDFileUMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception)
1075 return new MEDUMeshMultiLev(m,levs);
1078 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<int>& levs)
1081 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev constructor : null input pointer !");
1082 std::vector<MEDCoupling1GTUMesh *> v;
1083 for(std::vector<int>::const_iterator it=levs.begin();it!=levs.end();it++)
1085 std::vector<MEDCoupling1GTUMesh *> vTmp(m->getDirectUndergroundSingleGeoTypeMeshes(*it));
1086 v.insert(v.end(),vTmp.begin(),vTmp.end());
1088 std::size_t sz(v.size());
1091 _geo_types.resize(sz);
1092 for(std::size_t i=0;i<sz;i++)
1094 MEDCoupling1GTUMesh *obj(v[i]);
1098 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev constructor : presence of a null pointer !");
1100 _geo_types[i]=obj->getCellModelEnum();
1104 MEDUMeshMultiLev *MEDUMeshMultiLev::New(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities) throw(INTERP_KERNEL::Exception)
1106 return new MEDUMeshMultiLev(m,gts,pfls,nbEntities);
1109 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDMeshMultiLev(gts,pfls,nbEntities)
1111 std::size_t sz(gts.size());
1113 for(std::size_t i=0;i<sz;i++)
1115 MEDCoupling1GTUMesh *elt(m->getDirectUndergroundSingleGeoTypeMesh(gts[i]));
1122 void MEDUMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes) throw(INTERP_KERNEL::Exception)
1124 if(!pflNodes || !pflNodes->isAllocated())
1126 std::size_t sz(_parts.size());
1127 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > a(sz);
1128 std::vector< const DataArrayInt *> aa(sz);
1129 for(std::size_t i=0;i<sz;i++)
1132 const DataArrayInt *pfl(_pfls[i]);
1133 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> m(_parts[i]);
1135 m=dynamic_cast<MEDCoupling1GTUMesh *>(_parts[i]->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
1136 DataArrayInt *cellIds=0;
1137 m->fillCellIdsToKeepFromNodeIds(pflNodes->begin(),pflNodes->end(),true,cellIds);
1138 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIdsSafe(cellIds);
1139 MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> m2(m->buildPartOfMySelfKeepCoords(cellIds->begin(),cellIds->end()));
1141 a[i]=m2->getNodeIdsInUse(tmp); aa[i]=a[i];
1143 _pfls[i]=pfl->selectByTupleIdSafe(cellIds->begin(),cellIds->end());
1145 _pfls[i]=cellIdsSafe;
1147 _node_reduction=DataArrayInt::Aggregate(aa);
1148 _node_reduction->sort(true);
1149 _node_reduction=_node_reduction->buildUnique();
1152 MEDMeshMultiLev *MEDUMeshMultiLev::prepare() const throw(INTERP_KERNEL::Exception)
1154 return new MEDUMeshMultiLev(*this);
1157 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDUMeshMultiLev& other):MEDMeshMultiLev(other),_parts(other._parts)
1161 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDStructuredMeshMultiLev& other, const MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh>& part):MEDMeshMultiLev(other)
1167 void MEDUMeshMultiLev::buildVTUArrays(DataArrayDouble *& coords, DataArrayByte *&types, DataArrayInt *&cellLocations, DataArrayInt *& cells, DataArrayInt *&faceLocations, DataArrayInt *&faces) const throw(INTERP_KERNEL::Exception)
1170 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : empty array !");
1171 if(!(const MEDCoupling1GTUMesh *)_parts[0])
1172 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : first part is null !");
1173 const DataArrayDouble *tmp(_parts[0]->getCoords());
1175 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : the coordinates are null !");
1176 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> a(const_cast<DataArrayDouble *>(tmp)); tmp->incrRef();
1177 int szBCE(0),szD(0),szF(0);
1178 bool isPolyh(false);
1179 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_parts.begin();it!=_parts.end();it++)
1181 const MEDCoupling1GTUMesh *cur(*it);
1183 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : a part is null !");
1184 int curNbCells(cur->getNumberOfCells());
1186 if((*it)->getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED)
1187 szD=(*it)->getNodalConnectivity()->getNumberOfTuples()+curNbCells;
1191 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp((*it)->computeEffectiveNbOfNodesPerCell());
1192 szD+=tmp->accumulate(0)+curNbCells;
1193 szF+=2*curNbCells+(*it)->getNodalConnectivity()->getNumberOfTuples();
1196 MEDCouplingAutoRefCountObjectPtr<DataArrayByte> b(DataArrayByte::New()); b->alloc(szBCE,1); char *bPtr(b->getPointer());
1197 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c(DataArrayInt::New()); c->alloc(szBCE,1); int *cPtr(c->getPointer());
1198 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d(DataArrayInt::New()); d->alloc(szD,1); int *dPtr(d->getPointer());
1199 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> e(DataArrayInt::New()),f(DataArrayInt::New()); int *ePtr(0),*fPtr(0);
1201 { e->alloc(szBCE,1); ePtr=e->getPointer(); f->alloc(szF,1); fPtr=f->getPointer(); }
1203 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_parts.begin();it!=_parts.end();it++)
1205 const MEDCoupling1GTUMesh *cur(*it);
1206 int curNbCells(cur->getNumberOfCells());
1207 int gt((int)cur->getCellModelEnum());
1208 if(gt<0 || gt>=PARAMEDMEM_2_VTKTYPE_LGTH)
1209 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : invalid geometric type !");
1210 unsigned char gtvtk(PARAMEDMEM_2_VTKTYPE[gt]);
1212 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : no VTK type for the requested INTERP_KERNEL geometric type !");
1213 std::fill(bPtr,bPtr+curNbCells,gtvtk); bPtr+=curNbCells;
1214 const MEDCoupling1SGTUMesh *scur(dynamic_cast<const MEDCoupling1SGTUMesh *>(cur));
1215 const MEDCoupling1DGTUMesh *dcur(dynamic_cast<const MEDCoupling1DGTUMesh *>(cur));
1216 const int *connPtr(cur->getNodalConnectivity()->begin());
1218 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : internal error !");
1221 int nnpc(scur->getNumberOfNodesPerCell());
1222 for(int i=0;i<curNbCells;i++,connPtr+=nnpc)
1225 dPtr=std::copy(connPtr,connPtr+nnpc,dPtr);
1226 *cPtr=k+nnpc; k=*cPtr++;
1229 { std::fill(ePtr,ePtr+curNbCells,-1); ePtr+=curNbCells; }
1233 const int *connIPtr(dcur->getNodalConnectivityIndex()->begin());
1234 if(cur->getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED)
1236 for(int i=0;i<curNbCells;i++,connIPtr++)
1238 *dPtr++=connIPtr[1]-connIPtr[0];
1239 dPtr=std::copy(connPtr+connIPtr[0],connPtr+connIPtr[1],dPtr);
1240 *cPtr=k+connIPtr[1]-connIPtr[0]; k=*cPtr++;
1245 for(int i=0;i<curNbCells;i++,connIPtr++)
1247 std::set<int> s(connPtr+connIPtr[0],connPtr+connIPtr[1]);
1248 *dPtr++=(int)s.size();
1249 dPtr=std::copy(s.begin(),s.end(),dPtr);
1250 *cPtr=k+(int)s.size(); k=*cPtr++;
1255 connIPtr=dcur->getNodalConnectivityIndex()->begin();
1256 if(cur->getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED)
1257 { std::fill(ePtr,ePtr+curNbCells,-1); ePtr+=curNbCells; }
1261 for(int i=0;i<curNbCells;i++,connIPtr++)
1263 int nbFace(std::count(connPtr+connIPtr[0],connPtr+connIPtr[1],-1)+1);
1265 const int *work(connPtr+connIPtr[0]);
1266 for(int j=0;j<nbFace;j++)
1268 const int *work2=std::find(work,connPtr+connIPtr[1],-1);
1269 *fPtr++=std::distance(work,work2);
1270 fPtr=std::copy(work,work2,fPtr);
1273 *ePtr=kk; kk+=connIPtr[1]-connIPtr[0]+2;
1280 reorderNodesIfNecessary(a,d,0);
1282 reorderNodesIfNecessary(a,d,f);
1283 coords=a.retn(); types=b.retn(); cellLocations=c.retn(); cells=d.retn();
1285 { faceLocations=0; faces=0; }
1287 { faceLocations=e.retn(); faces=f.retn(); }
1290 void MEDUMeshMultiLev::reorderNodesIfNecessary(DataArrayDouble *coords, DataArrayInt *nodalConnVTK, DataArrayInt *polyhedNodalConnVTK) const throw(INTERP_KERNEL::Exception)
1292 const DataArrayInt *nr(_node_reduction);
1295 int sz(coords->getNumberOfTuples());
1296 std::vector<bool> b(sz,false);
1297 const int *work(nodalConnVTK->begin()),*endW(nodalConnVTK->end());
1301 for(int i=0;i<nb && work!=endW;i++,work++)
1303 if(*work>=0 && *work<sz)
1306 throw INTERP_KERNEL::Exception("MEDStructuredMeshMultiLev::reorderNodesIfNecessary : internal error !");
1309 if(polyhedNodalConnVTK)
1311 work=polyhedNodalConnVTK->begin(); endW=polyhedNodalConnVTK->end();
1315 for(int i=0;i<nb && work!=endW;i++)
1318 for(int j=0;j<nb2 && work!=endW;j++,work++)
1320 if(*work>=0 && *work<sz)
1323 throw INTERP_KERNEL::Exception("MEDStructuredMeshMultiLev::reorderNodesIfNecessary : internal error #2 !");
1328 int szExp(std::count(b.begin(),b.end(),true));
1329 if(szExp!=nr->getNumberOfTuples())
1330 throw INTERP_KERNEL::Exception("MEDStructuredMeshMultiLev::reorderNodesIfNecessary : internal error #3 !");
1332 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n(DataArrayInt::New()); o2n->alloc(sz,1);
1333 int *o2nPtr(o2n->getPointer());
1335 for(int i=0;i<sz;i++,o2nPtr++)
1336 if(b[i]) *o2nPtr=newId++; else *o2nPtr=-1;
1337 //tony you have to finish
1338 /*MEDCouplingAutoRefCountObjectPtr<DataArrayInt> n2o(o2n->invertO2N2N2O(nr->getNumberOfTuples()));
1340 const int *o2nc(o2n->begin());
1341 int *work2(nodalConnVTK->getPointer()),*endW2(nodalConnVTK->getPointer());
1342 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coo(coords->selectByTupleIdSafe(nr->begin(),nr->end()));*/
1347 MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev()
1351 MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDMeshMultiLev(gts,pfls,nbEntities)
1355 void MEDStructuredMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes) throw(INTERP_KERNEL::Exception)
1357 if(!pflNodes || !pflNodes->isAllocated())
1359 std::vector<int> ngs(getNodeGridStructure());
1360 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(MEDCouplingStructuredMesh::Build1GTNodalConnectivity(&ngs[0],&ngs[0]+ngs.size()));
1361 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> m(MEDCoupling1SGTUMesh::New("",MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(ngs.size())));
1362 m->setNodalConnectivity(conn);
1363 const DataArrayInt *pfl(_pfls[0]);
1366 m=dynamic_cast<MEDCoupling1SGTUMesh *>(m->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
1368 DataArrayInt *cellIds=0;
1369 m->fillCellIdsToKeepFromNodeIds(pflNodes->begin(),pflNodes->end(),true,cellIds);
1370 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIdsSafe(cellIds);
1371 MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> m2(m->buildPartOfMySelfKeepCoords(cellIds->begin(),cellIds->end()));
1373 _node_reduction=m2->getNodeIdsInUse(tmp);
1375 _pfls[0]=pfl->selectByTupleIdSafe(cellIds->begin(),cellIds->end());
1377 _pfls[0]=cellIdsSafe;
1380 MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other):MEDMeshMultiLev(other)
1386 MEDCMeshMultiLev *MEDCMeshMultiLev::New(const MEDFileCMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception)
1388 return new MEDCMeshMultiLev(m,levs);
1391 MEDCMeshMultiLev *MEDCMeshMultiLev::New(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities) throw(INTERP_KERNEL::Exception)
1393 return new MEDCMeshMultiLev(m,gts,pfls,nbEntities);
1396 MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<int>& levs)
1399 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor : null input pointer !");
1400 if(levs.size()!=1 || levs[0]!=0)
1401 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor : levels supported is 0 only !");
1402 int mdim(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(m->getMeshDimension()));
1403 _coords.resize(mdim);
1404 for(int i=0;i<mdim;i++)
1406 DataArrayDouble *elt(const_cast<DataArrayDouble *>(m->getMesh()->getCoordsAt(i)));
1408 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : presence of null pointer for an vector of double along an axis !");
1413 MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDStructuredMeshMultiLev(gts,pfls,nbEntities)
1416 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : null input pointer !");
1417 if(gts.size()!=1 || pfls.size()!=1)
1418 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : lengthes of gts and pfls must be equal to one !");
1419 int mdim(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(m->getMeshDimension()));
1421 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : the unique geo type is invalid regarding meshdim !");
1422 _coords.resize(mdim);
1423 for(int i=0;i<mdim;i++)
1425 DataArrayDouble *elt(const_cast<DataArrayDouble *>(m->getMesh()->getCoordsAt(i)));
1427 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : presence of null pointer for an vector of double along an axis !");
1432 MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDCMeshMultiLev& other):MEDStructuredMeshMultiLev(other)
1436 std::vector<int> MEDCMeshMultiLev::getNodeGridStructure() const throw(INTERP_KERNEL::Exception)
1438 std::vector<int> ret(_coords.size());
1439 for(std::size_t i=0;i<_coords.size();i++)
1440 ret[i]=_coords[i]->getNumberOfTuples();
1444 MEDMeshMultiLev *MEDCMeshMultiLev::prepare() const throw(INTERP_KERNEL::Exception)
1446 const DataArrayInt *pfl(_pfls[0]),*nr(_node_reduction);
1447 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nnr;
1448 std::vector<int> cgs,ngs(getNodeGridStructure());
1449 cgs.resize(ngs.size());
1450 std::transform(ngs.begin(),ngs.end(),cgs.begin(),std::bind2nd(std::plus<int>(),-1));
1453 std::vector< std::pair<int,int> > cellParts;
1454 if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts))
1456 MEDCouplingAutoRefCountObjectPtr<MEDCMeshMultiLev> ret(new MEDCMeshMultiLev(*this));
1458 { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1459 ret->_nb_entities[0]=pfl->getNumberOfTuples();
1461 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > coords(_coords.size());
1462 for(std::size_t i=0;i<_coords.size();i++)
1463 coords[i]=_coords[i]->selectByTupleId2(cellParts[i].first,cellParts[i].second+1,1);
1464 ret->_coords=coords;
1469 MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> m(MEDCouplingCMesh::New());
1470 for(std::size_t i=0;i<ngs.size();i++)
1471 m->setCoordsAt(i,_coords[i]);
1472 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> m2(m->build1SGTUnstructured());
1473 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> m3=dynamic_cast<MEDCoupling1GTUMesh *>(m2->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
1474 MEDCouplingAutoRefCountObjectPtr<MEDUMeshMultiLev> ret(new MEDUMeshMultiLev(*this,m3));
1476 { m3->zipCoords(); nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1482 MEDCouplingAutoRefCountObjectPtr<MEDCMeshMultiLev> ret(new MEDCMeshMultiLev(*this));
1484 { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1491 MEDCurveLinearMeshMultiLev *MEDCurveLinearMeshMultiLev::New(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception)
1493 return new MEDCurveLinearMeshMultiLev(m,levs);
1496 MEDCurveLinearMeshMultiLev *MEDCurveLinearMeshMultiLev::New(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities) throw(INTERP_KERNEL::Exception)
1498 return new MEDCurveLinearMeshMultiLev(m,gts,pfls,nbEntities);
1501 MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs)
1504 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor : null input pointer !");
1505 if(levs.size()!=1 || levs[0]!=0)
1506 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor : levels supported is 0 only !");
1507 DataArrayDouble *coords(const_cast<DataArrayDouble *>(m->getMesh()->getCoords()));
1509 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : no coords set !");
1512 _structure=m->getMesh()->getNodeGridStructure();
1515 MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDStructuredMeshMultiLev(gts,pfls,nbEntities)
1518 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : null input pointer !");
1519 if(gts.size()!=1 || pfls.size()!=1)
1520 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : lengthes of gts and pfls must be equal to one !");
1521 int mdim(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(m->getMeshDimension()));
1523 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : the unique geo type is invalid regarding meshdim !");
1524 DataArrayDouble *coords(const_cast<DataArrayDouble *>(m->getMesh()->getCoords()));
1526 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : no coords set !");
1529 _structure=m->getMesh()->getNodeGridStructure();
1532 MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDCurveLinearMeshMultiLev& other):MEDStructuredMeshMultiLev(other),_coords(other._coords),_structure(other._structure)
1536 std::vector<int> MEDCurveLinearMeshMultiLev::getNodeGridStructure() const throw(INTERP_KERNEL::Exception)
1541 MEDMeshMultiLev *MEDCurveLinearMeshMultiLev::prepare() const throw(INTERP_KERNEL::Exception)
1543 const DataArrayInt *pfl(_pfls[0]),*nr(_node_reduction);
1544 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nnr;
1545 std::vector<int> cgs,ngs(getNodeGridStructure());
1546 cgs.resize(ngs.size());
1547 std::transform(ngs.begin(),ngs.end(),cgs.begin(),std::bind2nd(std::plus<int>(),-1));
1550 std::vector< std::pair<int,int> > cellParts,nodeParts;
1551 if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts))
1553 nodeParts=cellParts;
1554 std::vector<int> st(ngs.size());
1555 for(std::size_t i=0;i<ngs.size();i++)
1557 nodeParts[i].second++;
1558 st[i]=nodeParts[i].second-nodeParts[i].first;
1560 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p(MEDCouplingStructuredMesh::BuildExplicitIdsFrom(ngs,nodeParts));
1561 MEDCouplingAutoRefCountObjectPtr<MEDCurveLinearMeshMultiLev> ret(new MEDCurveLinearMeshMultiLev(*this));
1563 { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1564 ret->_nb_entities[0]=pfl->getNumberOfTuples();
1566 ret->_coords=_coords->selectByTupleIdSafe(p->begin(),p->end());
1572 MEDCouplingAutoRefCountObjectPtr<MEDCouplingCurveLinearMesh> m(MEDCouplingCurveLinearMesh::New());
1573 m->setCoords(_coords); m->setNodeGridStructure(&_structure[0],&_structure[0]+_structure.size());
1574 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> m2(m->build1SGTUnstructured());
1575 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> m3=dynamic_cast<MEDCoupling1GTUMesh *>(m2->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
1576 MEDCouplingAutoRefCountObjectPtr<MEDUMeshMultiLev> ret(new MEDUMeshMultiLev(*this,m3));
1578 { m3->zipCoords(); nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1584 MEDCouplingAutoRefCountObjectPtr<MEDCurveLinearMeshMultiLev> ret(new MEDCurveLinearMeshMultiLev(*this));
1586 { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }