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,255,255,255,255,10,14,13,255,12,255,24,255,16,27,255,26,255,29,255,255,25,42,36,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::getHeapMemorySizeWithoutChildren() 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 std::vector<const BigMemoryObject *> MEDFileMeshStruct::getDirectChildren() const
50 return std::vector<const BigMemoryObject *>();
53 MEDFileMeshStruct::MEDFileMeshStruct(const MEDFileMesh *mesh):_mesh(mesh)
55 std::vector<int> levs(mesh->getNonEmptyLevels());
56 _name=mesh->getName();
57 _nb_nodes=mesh->getNumberOfNodes();
60 _geo_types_distrib.resize(-(*std::min_element(levs.begin(),levs.end()))+1);
61 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
62 _geo_types_distrib[-(*lev)]=mesh->getDistributionOfTypes(*lev);
66 int MEDFileMeshStruct::getLevelOfGeoType(INTERP_KERNEL::NormalizedCellType t) const
69 for(std::vector< std::vector<int> >::const_iterator it1=_geo_types_distrib.begin();it1!=_geo_types_distrib.end();it1++,j--)
71 std::size_t sz=(*it1).size();
73 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getLevelOfGeoType : internal error in code !");
74 std::size_t nbGeo=sz/3;
75 for(std::size_t i=0;i<nbGeo;i++)
76 if((*it1)[3*i]==(int)t)
79 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getLevelOfGeoType : The specified geometric type is not present in the mesh structure !");
82 int MEDFileMeshStruct::getNumberOfElemsOfGeoType(INTERP_KERNEL::NormalizedCellType t) const
84 for(std::vector< std::vector<int> >::const_iterator it1=_geo_types_distrib.begin();it1!=_geo_types_distrib.end();it1++)
86 std::size_t sz=(*it1).size();
88 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfElemsOfGeoType : internal error in code !");
89 std::size_t nbGeo=sz/3;
90 for(std::size_t i=0;i<nbGeo;i++)
91 if((*it1)[3*i]==(int)t)
94 throw INTERP_KERNEL::Exception("The specified geometric type is not present in the mesh structure !");
97 int MEDFileMeshStruct::getNumberOfLevs() const
99 return (int)_geo_types_distrib.size();
102 int MEDFileMeshStruct::getNumberOfGeoTypesInLev(int relativeLev) const
104 int pos(-relativeLev);
105 if(pos<0 || pos>=(int)_geo_types_distrib.size())
106 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfGeoTypesInLev : invalid level specified !");
107 std::size_t sz=_geo_types_distrib[pos].size();
109 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfGeoTypesInLev : internal error in code !");
115 std::size_t MEDMeshMultiLev::getHeapMemorySizeWithoutChildren() const
120 std::vector<const BigMemoryObject *> MEDMeshMultiLev::getDirectChildren() const
122 return std::vector<const BigMemoryObject *>();
125 MEDMeshMultiLev *MEDMeshMultiLev::New(const MEDFileMesh *m, const std::vector<int>& levs)
128 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New : null input pointer !");
129 const MEDFileUMesh *um(dynamic_cast<const MEDFileUMesh *>(m));
131 return MEDUMeshMultiLev::New(um,levs);
132 const MEDFileCMesh *cm(dynamic_cast<const MEDFileCMesh *>(m));
134 return MEDCMeshMultiLev::New(cm,levs);
135 const MEDFileCurveLinearMesh *clm(dynamic_cast<const MEDFileCurveLinearMesh *>(m));
137 return MEDCurveLinearMeshMultiLev::New(clm,levs);
138 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New : unrecognized type of mesh ! Must be in [MEDFileUMesh,MEDFileCMesh,MEDFileCurveLinearMesh] !");
141 MEDMeshMultiLev *MEDMeshMultiLev::New(const MEDFileMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities)
144 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New 2 : null input pointer !");
145 const MEDFileUMesh *um(dynamic_cast<const MEDFileUMesh *>(m));
147 return MEDUMeshMultiLev::New(um,gts,pfls,nbEntities);
148 const MEDFileCMesh *cm(dynamic_cast<const MEDFileCMesh *>(m));
150 return MEDCMeshMultiLev::New(cm,gts,pfls,nbEntities);
151 const MEDFileCurveLinearMesh *clm(dynamic_cast<const MEDFileCurveLinearMesh *>(m));
153 return MEDCurveLinearMeshMultiLev::New(clm,gts,pfls,nbEntities);
154 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New 2 : unrecognized type of mesh ! Must be in [MEDFileUMesh,MEDFileCMesh,MEDFileCurveLinearMesh] !");
157 MEDMeshMultiLev *MEDMeshMultiLev::NewOnlyOnNode(const MEDFileMesh *m, const DataArrayInt *pflOnNode)
159 MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> ret(MEDMeshMultiLev::New(m,m->getNonEmptyLevels()));
160 ret->selectPartOfNodes(pflOnNode);
164 void MEDMeshMultiLev::setNodeReduction(const DataArrayInt *nr)
168 _node_reduction=const_cast<DataArrayInt*>(nr);
171 bool MEDMeshMultiLev::isFastlyTheSameStruct(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs) const
173 if(fst.getType()==ON_NODES)
175 if(fst.getNumberOfItems()!=1)
176 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::isFastlyTheSameStruct : unexpected situation for nodes !");
177 const MEDFileField1TSStructItem2& p(fst[0]);
178 std::string pflName(p.getPflName());
179 const DataArrayInt *nr(_node_reduction);
180 if(pflName.empty() && !nr)
182 if(!pflName.empty() && !nr)
184 if(pflName==nr->getName())
190 std::size_t sz(fst.getNumberOfItems());
191 if(sz!=_geo_types.size())
194 for(std::size_t i=0;i<sz;i++)
196 const MEDFileField1TSStructItem2& p(fst[i]);
197 if(!p.isFastlyEqual(strt,_geo_types[i],getPflNameOfId(i).c_str()))
204 DataArray *MEDMeshMultiLev::buildDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const
206 MEDCouplingAutoRefCountObjectPtr<DataArray> ret(const_cast<DataArray *>(vals)); ret->incrRef();
207 if(isFastlyTheSameStruct(fst,globs))
210 return constructDataArray(fst,globs,vals);
214 * \param [out] famIds - Can be null. If not null the instance has to be dealt by the caller (decrRef).
215 * \param [out] isWithoutCopy - When true the returned instance \a famIds if not null is directly those in the data structure.
217 void MEDMeshMultiLev::retrieveFamilyIdsOnCells(DataArrayInt *& famIds, bool& isWithoutCopy) const
219 const DataArrayInt *fids(_cell_fam_ids);
221 { famIds=0; isWithoutCopy=true; return ; }
222 std::size_t sz(_geo_types.size());
223 bool presenceOfPfls(false);
224 for(std::size_t i=0;i<sz && !presenceOfPfls;i++)
226 const DataArrayInt *pfl(_pfls[i]);
231 { famIds=const_cast<DataArrayInt *>(fids); famIds->incrRef(); isWithoutCopy=_cell_fam_ids_nocpy; return ; }
232 //bad luck the slowest part
234 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > retSafe(sz);
235 std::vector< const DataArrayInt *> ret(sz);
237 for(std::size_t i=0;i<sz;i++)
239 const DataArrayInt *pfl(_pfls[i]);
240 int lgth(_nb_entities[i]);
243 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(fids->selectByTupleId2(start,start+lgth,1));
244 retSafe[i]=tmp->selectByTupleIdSafe(pfl->begin(),pfl->end());
248 retSafe[i]=fids->selectByTupleId2(start,start+lgth,1);
253 famIds=DataArrayInt::Aggregate(ret);
257 * \param [out] numIds - Can be null. If not null the instance has to be dealt by the caller (decrRef).
258 * \param [out] isWithoutCopy - When true the returned instance \a numIds if not null is directly those in the data structure.
260 void MEDMeshMultiLev::retrieveNumberIdsOnCells(DataArrayInt *& numIds, bool& isWithoutCopy) const
262 const DataArrayInt *nids(_cell_num_ids);
264 { numIds=0; isWithoutCopy=true; return ; }
265 std::size_t sz(_geo_types.size());
266 bool presenceOfPfls(false);
267 for(std::size_t i=0;i<sz && !presenceOfPfls;i++)
269 const DataArrayInt *pfl(_pfls[i]);
274 { numIds=const_cast<DataArrayInt *>(nids); numIds->incrRef(); isWithoutCopy=_cell_num_ids_nocpy; return ; }
275 //bad luck the slowest part
277 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > retSafe(sz);
278 std::vector< const DataArrayInt *> ret(sz);
280 for(std::size_t i=0;i<sz;i++)
282 const DataArrayInt *pfl(_pfls[i]);
283 int lgth(_nb_entities[i]);
286 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(nids->selectByTupleId2(start,start+lgth,1));
287 retSafe[i]=tmp->selectByTupleIdSafe(pfl->begin(),pfl->end());
291 retSafe[i]=nids->selectByTupleId2(start,start+lgth,1);
296 numIds=DataArrayInt::Aggregate(ret);
300 * \param [out] famIds - Can be null. If not null the instance has to be dealt by the caller (decrRef).
301 * \param [out] isWithoutCopy - When true the returned instance \a famIds if not null is directly those in the data structure.
303 void MEDMeshMultiLev::retrieveFamilyIdsOnNodes(DataArrayInt *& famIds, bool& isWithoutCopy) const
305 const DataArrayInt *fids(_node_fam_ids);
307 { famIds=0; isWithoutCopy=true; return ; }
308 const DataArrayInt *nr(_node_reduction);
312 famIds=fids->selectByTupleIdSafe(nr->begin(),nr->end());
316 isWithoutCopy=_node_fam_ids_nocpy;
317 famIds=const_cast<DataArrayInt *>(fids); famIds->incrRef();
322 * \param [out] numIds - Can be null. If not null the instance has to be dealt by the caller (decrRef).
323 * \param [out] isWithoutCopy - When true the returned instance \a numIds if not null is directly those in the data structure.
325 void MEDMeshMultiLev::retrieveNumberIdsOnNodes(DataArrayInt *& numIds, bool& isWithoutCopy) const
327 const DataArrayInt *fids(_node_num_ids);
329 { numIds=0; isWithoutCopy=true; return ; }
330 const DataArrayInt *nr(_node_reduction);
334 numIds=fids->selectByTupleIdSafe(nr->begin(),nr->end());
338 isWithoutCopy=_node_num_ids_nocpy;
339 numIds=const_cast<DataArrayInt *>(fids); numIds->incrRef();
343 void MEDMeshMultiLev::setFamilyIdsOnCells(DataArrayInt *famIds, bool isNoCopy)
345 _cell_fam_ids=famIds;
348 _cell_fam_ids_nocpy=isNoCopy;
351 void MEDMeshMultiLev::setNumberIdsOnCells(DataArrayInt *numIds, bool isNoCopy)
353 _cell_num_ids=numIds;
356 _cell_num_ids_nocpy=isNoCopy;
359 void MEDMeshMultiLev::setFamilyIdsOnNodes(DataArrayInt *famIds, bool isNoCopy)
361 _node_fam_ids=famIds;
364 _node_fam_ids_nocpy=isNoCopy;
367 void MEDMeshMultiLev::setNumberIdsOnNodes(DataArrayInt *numIds, bool isNoCopy)
369 _node_num_ids=numIds;
372 _node_num_ids_nocpy=isNoCopy;
375 std::string MEDMeshMultiLev::getPflNameOfId(int id) const
377 std::size_t sz(_pfls.size());
378 if(id<0 || id>=(int)sz)
379 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::getPflNameOfId : invalid input id !");
380 const DataArrayInt *pfl(_pfls[id]);
382 return std::string("");
383 return pfl->getName();
387 * Returns the number of cells having geometric type \a t.
388 * The profiles are **NOT** taken into account here.
390 int MEDMeshMultiLev::getNumberOfCells(INTERP_KERNEL::NormalizedCellType t) const
392 std::size_t sz(_nb_entities.size());
393 for(std::size_t i=0;i<sz;i++)
395 return _nb_entities[i];
396 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::getNumberOfCells : not existing geometric type in this !");
399 int MEDMeshMultiLev::getNumberOfNodes() const
404 DataArray *MEDMeshMultiLev::constructDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const
406 if(fst.getType()==ON_NODES)
408 if(fst.getNumberOfItems()!=1)
409 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes !");
410 const MEDFileField1TSStructItem2& p(fst[0]);
411 std::string pflName(p.getPflName());
412 const DataArrayInt *nr(_node_reduction);
413 if(pflName.empty() && !nr)
414 return vals->deepCpy();
415 if(pflName.empty() && nr)
416 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 2 !");
417 if(!pflName.empty() && nr)
419 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(globs->getProfile(pflName.c_str())->deepCpy());
420 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p2(nr->deepCpy());
421 p1->sort(true); p2->sort(true);
422 if(!p1->isEqualWithoutConsideringStr(*p2))
423 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : it appears that a profile on nodes does not cover the cells correctly !");
424 p1=DataArrayInt::FindPermutationFromFirstToSecond(globs->getProfile(pflName.c_str()),nr);
425 MEDCouplingAutoRefCountObjectPtr<DataArray> ret(vals->deepCpy());
426 ret->renumberInPlace(p1->begin());
429 if(!pflName.empty() && !nr)
431 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(globs->getProfile(pflName.c_str())->deepCpy());
433 if(!p1->isIdentity() || p1->getNumberOfTuples()!=getNumberOfNodes())
434 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 4 !");
435 MEDCouplingAutoRefCountObjectPtr<DataArray> ret(vals->deepCpy());
436 ret->renumberInPlace(globs->getProfile(pflName.c_str())->begin());
439 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 5 !");
443 std::size_t sz(fst.getNumberOfItems());
444 std::set<INTERP_KERNEL::NormalizedCellType> s(_geo_types.begin(),_geo_types.end());
445 if(s.size()!=_geo_types.size())
446 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 2 !");
447 std::vector< const DataArray *> arr(s.size());
448 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArray> > arrSafe(s.size());
450 int nc(vals->getNumberOfComponents());
451 std::vector<std::string> compInfo(vals->getInfoOnComponents());
452 for(std::vector< INTERP_KERNEL::NormalizedCellType >::const_iterator it=_geo_types.begin();it!=_geo_types.end();it++,iii++)
454 const DataArrayInt *thisP(_pfls[iii]);
455 std::vector<const MEDFileField1TSStructItem2 *> ps;
456 for(std::size_t i=0;i<sz;i++)
458 const MEDFileField1TSStructItem2& p(fst[i]);
463 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 1 !");
466 int nbi(ps[0]->getNbOfIntegrationPts(globs));
467 const DataArrayInt *otherP(ps[0]->getPfl(globs));
468 const std::pair<int,int>& strtStop(ps[0]->getStartStop());
469 MEDCouplingAutoRefCountObjectPtr<DataArray> ret(vals->selectByTupleId2(strtStop.first,strtStop.second,1));
470 if(!thisP && !otherP)
472 arrSafe[iii]=ret; arr[iii]=ret;
477 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(otherP->invertArrayN2O2O2N(getNumberOfCells(ps[0]->getGeo())));
478 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p2(thisP->deepCpy());
479 p2->transformWithIndArr(p1->begin(),p1->end());
480 //p1=p2->getIdsNotEqual(-1);
481 //p1=p2->selectByTupleIdSafe(p1->begin(),p1->end());
482 ret->rearrange(nbi*nc); ret=ret->selectByTupleIdSafe(p2->begin(),p2->end()); ret->rearrange(nc); ret->setInfoOnComponents(compInfo);
483 arrSafe[iii]=ret; arr[iii]=ret;
488 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(otherP->deepCpy());
490 p1->checkAllIdsInRange(0,getNumberOfCells(ps[0]->getGeo()));
491 p1=DataArrayInt::FindPermutationFromFirstToSecond(otherP,p1);
492 ret->rearrange(nbi*nc); ret->renumberInPlace(p1->begin()); ret->rearrange(nc); ret->setInfoOnComponents(compInfo);
493 arrSafe[iii]=ret; arr[iii]=ret;
496 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 3 !");
500 std::vector< const DataArrayInt * >otherPS(ps.size());
501 std::vector< const DataArray * > arr2(ps.size());
502 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArray> > arr2Safe(ps.size());
503 std::vector< const DataArrayInt * > nbis(ps.size());
504 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > nbisSafe(ps.size());
506 for(std::vector<const MEDFileField1TSStructItem2 *>::const_iterator it2=ps.begin();it2!=ps.end();it2++,jj++)
508 int nbi((*it2)->getNbOfIntegrationPts(globs));
509 const DataArrayInt *otherPfl((*it2)->getPfl(globs));
510 const std::pair<int,int>& strtStop((*it2)->getStartStop());
511 MEDCouplingAutoRefCountObjectPtr<DataArray> ret2(vals->selectByTupleId2(strtStop.first,strtStop.second,1));
513 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 4 !");
514 arr2[jj]=ret2; arr2Safe[jj]=ret2; otherPS[jj]=otherPfl;
515 nbisSafe[jj]=DataArrayInt::New(); nbisSafe[jj]->alloc(otherPfl->getNumberOfTuples(),1); nbisSafe[jj]->fillWithValue(nbi);
516 nbis[jj]=nbisSafe[jj];
518 MEDCouplingAutoRefCountObjectPtr<DataArray> arr3(DataArray::Aggregate(arr2));
519 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> otherP(DataArrayInt::Aggregate(otherPS));
520 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> zenbis(DataArrayInt::Aggregate(nbis));
521 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> otherPN(otherP->invertArrayN2O2O2N(getNumberOfCells(*it)));
522 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1;
524 p1=DataArrayInt::FindPermutationFromFirstToSecond(otherP,thisP);
526 p1=otherP->deepCpy();
527 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> zenbisN(zenbis->renumber(p1->begin()));
528 zenbisN->computeOffsets2();
530 for(std::vector<const MEDFileField1TSStructItem2 *>::const_iterator it2=ps.begin();it2!=ps.end();it2++,jj++)
532 //int nbi((*it2)->getNbOfIntegrationPts(globs));
533 const DataArrayInt *otherPfl((*it2)->getPfl(globs));
534 const std::pair<int,int>& strtStop((*it2)->getStartStop());
535 MEDCouplingAutoRefCountObjectPtr<DataArray> ret2(vals->selectByTupleId2(strtStop.first,strtStop.second,1));
537 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p2(otherPfl->deepCpy());
538 p2->transformWithIndArr(otherPN->begin(),otherPN->end());
539 p2->transformWithIndArr(p1->begin(),p1->end());
540 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsN(p2->buildExplicitArrByRanges(zenbisN));
541 arr3->setPartOfValuesBase3(ret2,idsN->begin(),idsN->end(),0,nc,1);
543 arrSafe[iii]=arr3; arr[iii]=arr3;
547 return DataArray::Aggregate(arr);
552 * This method is called to add NORM_POINT1 cells in \a this so that orphan nodes in \a verticesToAdd will be fetched.
554 void MEDMeshMultiLev::appendVertices(const DataArrayInt *verticesToAdd, DataArrayInt *nr)
556 int nbOfVertices(verticesToAdd->getNumberOfTuples());
557 std::size_t sz(_pfls.size());
559 _geo_types.resize(sz+1,INTERP_KERNEL::NORM_POINT1);
560 _nb_entities.resize(sz+1,nbOfVertices);
561 _node_reduction=nr; nr->incrRef();
562 _nb_nodes+=nbOfVertices;
563 const DataArrayInt *cf(_cell_fam_ids),*cn(_cell_num_ids),*nf(_node_fam_ids),*nn(_node_num_ids);
566 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp;
567 std::vector<const DataArrayInt *> a(2);
570 tmp=nf->selectByTupleIdSafe(verticesToAdd->begin(),verticesToAdd->end());
573 tmp=DataArrayInt::New(); tmp->alloc(nbOfVertices,1); tmp->fillWithZero();
576 _cell_fam_ids=DataArrayInt::Aggregate(a);
577 _cell_fam_ids_nocpy=false;
581 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp;
582 std::vector<const DataArrayInt *> a(2);
585 tmp=nn->selectByTupleIdSafe(verticesToAdd->begin(),verticesToAdd->end());
588 tmp=DataArrayInt::New(); tmp->alloc(nbOfVertices,1); tmp->fillWithZero();
591 _cell_num_ids=DataArrayInt::Aggregate(a);
592 _cell_num_ids_nocpy=false;
596 MEDMeshMultiLev::MEDMeshMultiLev():_nb_nodes(0),_cell_fam_ids_nocpy(false)
600 MEDMeshMultiLev::MEDMeshMultiLev(int nbNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):_geo_types(gts),_nb_entities(nbEntities),_nb_nodes(nbNodes),_cell_fam_ids_nocpy(false),_cell_num_ids_nocpy(false),_node_fam_ids_nocpy(false),_node_num_ids_nocpy(false)
602 std::size_t sz(_geo_types.size());
603 if(sz!=pfls.size() || sz!=nbEntities.size())
604 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::MEDMeshMultiLev : input vector must have the same size !");
606 for(std::size_t i=0;i<sz;i++)
610 _pfls[i]=const_cast<DataArrayInt *>(pfls[i]);
614 MEDMeshMultiLev::MEDMeshMultiLev(const MEDMeshMultiLev& other):RefCountObject(other),_pfls(other._pfls),_geo_types(other._geo_types),_nb_entities(other._nb_entities),_node_reduction(other._node_reduction),_nb_nodes(other._nb_nodes),_cell_fam_ids(other._cell_fam_ids),_cell_fam_ids_nocpy(other._cell_fam_ids_nocpy),_cell_num_ids(other._cell_num_ids),_cell_num_ids_nocpy(other._cell_num_ids_nocpy),_node_fam_ids(other._node_fam_ids),_node_fam_ids_nocpy(other._node_fam_ids_nocpy),_node_num_ids(other._node_num_ids),_node_num_ids_nocpy(other._node_num_ids_nocpy)
620 MEDUMeshMultiLev *MEDUMeshMultiLev::New(const MEDFileUMesh *m, const std::vector<int>& levs)
622 return new MEDUMeshMultiLev(m,levs);
625 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<int>& levs)
628 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev constructor : null input pointer !");
629 std::vector<MEDCoupling1GTUMesh *> v;
630 for(std::vector<int>::const_iterator it=levs.begin();it!=levs.end();it++)
632 std::vector<MEDCoupling1GTUMesh *> vTmp(m->getDirectUndergroundSingleGeoTypeMeshes(*it));
633 v.insert(v.end(),vTmp.begin(),vTmp.end());
635 std::size_t sz(v.size());
638 _coords=m->getCoords(); _coords->incrRef();
642 _geo_types.resize(sz);
643 _nb_entities.resize(sz);
644 for(std::size_t i=0;i<sz;i++)
646 MEDCoupling1GTUMesh *obj(v[i]);
650 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev constructor : presence of a null pointer !");
652 _geo_types[i]=obj->getCellModelEnum();
653 _nb_entities[i]=obj->getNumberOfCells();
655 // ids fields management
656 _cell_fam_ids_nocpy=(levs.size()==1);
657 if(_cell_fam_ids_nocpy)
659 const DataArrayInt *tmp(m->getFamilyFieldAtLevel(levs[0]));
663 _cell_fam_ids=(const_cast<DataArrayInt *>(tmp));
668 std::vector<const DataArrayInt *> tmps(levs.size());
670 for(std::size_t i=0;i<levs.size();i++)
672 tmps[i]=m->getFamilyFieldAtLevel(levs[i]);
676 if(f && !tmps.empty())
677 _cell_fam_ids=DataArrayInt::Aggregate(tmps);
679 _cell_num_ids_nocpy=(levs.size()==1);
680 if(_cell_num_ids_nocpy)
682 const DataArrayInt *tmp(m->getNumberFieldAtLevel(levs[0]));
686 _cell_num_ids=(const_cast<DataArrayInt *>(tmp));
691 std::vector<const DataArrayInt *> tmps(levs.size());
693 for(std::size_t i=0;i<levs.size();i++)
695 tmps[i]=m->getNumberFieldAtLevel(levs[i]);
699 if(n && !tmps.empty())
700 _cell_num_ids=DataArrayInt::Aggregate(tmps);
703 _node_fam_ids_nocpy=true;
705 const DataArrayInt *tmp(m->getFamilyFieldAtLevel(1));
709 _node_fam_ids=(const_cast<DataArrayInt *>(tmp));
712 _node_num_ids_nocpy=true;
714 const DataArrayInt *tmp(m->getNumberFieldAtLevel(1));
718 _node_num_ids=(const_cast<DataArrayInt *>(tmp));
723 MEDUMeshMultiLev *MEDUMeshMultiLev::New(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities)
725 return new MEDUMeshMultiLev(m,gts,pfls,nbEntities);
728 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDMeshMultiLev(m->getNumberOfNodes(),gts,pfls,nbEntities)
730 std::size_t sz(gts.size());
732 throw INTERP_KERNEL::Exception("constructor of MEDUMeshMultiLev : number of different geo type must be >= 1 !");
733 unsigned dim(INTERP_KERNEL::CellModel::GetCellModel(gts[0]).getDimension());
735 bool isSameDim(true),isNoPfl(true);
736 for(std::size_t i=0;i<sz;i++)
738 MEDCoupling1GTUMesh *elt(m->getDirectUndergroundSingleGeoTypeMesh(gts[i]));
739 if(INTERP_KERNEL::CellModel::GetCellModel(gts[i]).getDimension()!=dim)
747 // ids fields management
748 int lev((int)dim-m->getMeshDimension());
749 if(isSameDim && isNoPfl && m->getGeoTypesAtLevel(lev)==gts)//optimized part
751 _cell_fam_ids_nocpy=true;
752 const DataArrayInt *famIds(m->getFamilyFieldAtLevel(lev));
754 { _cell_fam_ids=const_cast<DataArrayInt*>(famIds); famIds->incrRef(); }
755 _cell_num_ids_nocpy=true;
756 const DataArrayInt *numIds(m->getNumberFieldAtLevel(lev));
758 { _cell_num_ids=const_cast<DataArrayInt*>(numIds); numIds->incrRef(); }
759 _node_fam_ids_nocpy=true;
760 famIds=m->getFamilyFieldAtLevel(1);
762 { _node_fam_ids=const_cast<DataArrayInt*>(famIds); famIds->incrRef(); }
763 _node_num_ids_nocpy=true;
764 numIds=m->getNumberFieldAtLevel(1);
766 { _node_num_ids=const_cast<DataArrayInt*>(numIds); numIds->incrRef(); }
770 _cell_fam_ids_nocpy=false;
771 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > famIdsSafe(sz);
772 std::vector<const DataArrayInt *> famIds(sz);
774 for(std::size_t i=0;i<sz;i++)
776 famIdsSafe[i]=m->extractFamilyFieldOnGeoType(gts[i]);
777 famIds[i]=famIdsSafe[i];
782 _cell_fam_ids=DataArrayInt::Aggregate(famIds);
783 _cell_num_ids_nocpy=false;
784 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > numIdsSafe(sz);
785 std::vector<const DataArrayInt *> numIds(sz);
787 for(std::size_t i=0;i<sz;i++)
789 numIdsSafe[i]=m->extractNumberFieldOnGeoType(gts[i]);
790 numIds[i]=numIdsSafe[i];
795 _cell_num_ids=DataArrayInt::Aggregate(numIds);
796 // node ids management
797 _node_fam_ids_nocpy=true;
798 const DataArrayInt *nodeFamIds(m->getFamilyFieldAtLevel(1));
800 { _node_fam_ids=const_cast<DataArrayInt*>(nodeFamIds); nodeFamIds->incrRef(); }
801 _node_num_ids_nocpy=true;
802 const DataArrayInt *nodeNumIds(m->getNumberFieldAtLevel(1));
804 { _node_num_ids=const_cast<DataArrayInt*>(nodeNumIds); nodeNumIds->incrRef(); }
807 void MEDUMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes)
809 if(!pflNodes || !pflNodes->isAllocated())
811 std::size_t sz(_parts.size());
812 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > a(sz);
813 std::vector< const DataArrayInt *> aa(sz);
814 for(std::size_t i=0;i<sz;i++)
816 const DataArrayInt *pfl(_pfls[i]);
817 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> m(_parts[i]);
819 m=dynamic_cast<MEDCoupling1GTUMesh *>(_parts[i]->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
820 DataArrayInt *cellIds=0;
821 m->fillCellIdsToKeepFromNodeIds(pflNodes->begin(),pflNodes->end(),true,cellIds);
822 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIdsSafe(cellIds);
823 MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> m2(m->buildPartOfMySelfKeepCoords(cellIds->begin(),cellIds->end()));
825 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n(m2->getNodeIdsInUse(tmp));
826 a[i]=o2n->invertArrayO2N2N2O(tmp); aa[i]=a[i];
828 _pfls[i]=pfl->selectByTupleIdSafe(cellIds->begin(),cellIds->end());
830 _pfls[i]=cellIdsSafe;
833 _node_reduction=DataArrayInt::Aggregate(aa);//general case
835 _node_reduction=pflNodes->deepCpy();//case where no cells in read mesh.
836 _node_reduction->sort(true);
837 _node_reduction=_node_reduction->buildUnique();
838 if(_node_reduction->getNumberOfTuples()==pflNodes->getNumberOfTuples())
839 return ;//This is the classical case where the input node profile corresponds perfectly to a subset of cells in _parts
840 if(_node_reduction->getNumberOfTuples()>pflNodes->getNumberOfTuples())
841 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::selectPartOfNodes : internal error in MEDCoupling during cell select from a list of nodes !");
842 // Here the cells available in _parts is not enough to cover all the nodes in pflNodes. So adding vertices cells in _parts...
843 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pflNodes2(pflNodes->deepCpy());
844 pflNodes2->sort(true);
845 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diff(pflNodes2->buildSubstractionOptimized(_node_reduction));
846 appendVertices(diff,pflNodes2);
849 MEDMeshMultiLev *MEDUMeshMultiLev::prepare() const
851 return new MEDUMeshMultiLev(*this);
854 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDUMeshMultiLev& other):MEDMeshMultiLev(other),_parts(other._parts),_coords(other._coords)
858 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDStructuredMeshMultiLev& other, const MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh>& part):MEDMeshMultiLev(other)
862 _geo_types.resize(1); _geo_types[0]=part->getCellModelEnum();
863 _nb_entities.resize(1); _nb_entities[0]=part->getNumberOfCells();
864 _pfls.resize(1); _pfls[0]=0;
868 * If returned value is false output pointer \a coords is not the internal pointer. If returned value is true output pointer \a coords is directly the internal pointer.
869 * If true is returned, the \a coords output parameter should be used with care (non const method call) to avoid to change the internal state of MEDFileUMesh instance.
871 bool MEDUMeshMultiLev::buildVTUArrays(DataArrayDouble *& coords, DataArrayByte *&types, DataArrayInt *&cellLocations, DataArrayInt *& cells, DataArrayInt *&faceLocations, DataArrayInt *&faces) const
873 const DataArrayDouble *tmp(0);
877 tmp=_parts[0]->getCoords();
879 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : the coordinates are null !");
880 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> a(const_cast<DataArrayDouble *>(tmp)); tmp->incrRef();
881 int szBCE(0),szD(0),szF(0);
884 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_parts.begin();it!=_parts.end();it++,iii++)
886 const MEDCoupling1GTUMesh *cur(*it);
888 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : a part is null !");
890 const DataArrayInt *pfl(_pfls[iii]);
891 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> cur2;
893 { cur2=const_cast<MEDCoupling1GTUMesh *>(cur); cur2->incrRef(); }
895 { cur2=dynamic_cast<MEDCoupling1GTUMesh *>(cur->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end())); cur=cur2; }
897 int curNbCells(cur->getNumberOfCells());
899 if((*it)->getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED)
900 szD+=cur->getNodalConnectivity()->getNumberOfTuples()+curNbCells;
904 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp2(cur->computeEffectiveNbOfNodesPerCell());
905 szD+=tmp2->accumulate(0)+curNbCells;
906 szF+=2*curNbCells+cur->getNodalConnectivity()->getNumberOfTuples();
909 MEDCouplingAutoRefCountObjectPtr<DataArrayByte> b(DataArrayByte::New()); b->alloc(szBCE,1); char *bPtr(b->getPointer());
910 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c(DataArrayInt::New()); c->alloc(szBCE,1); int *cPtr(c->getPointer());
911 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d(DataArrayInt::New()); d->alloc(szD,1); int *dPtr(d->getPointer());
912 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> e(DataArrayInt::New()),f(DataArrayInt::New()); int *ePtr(0),*fPtr(0);
914 { e->alloc(szBCE,1); ePtr=e->getPointer(); f->alloc(szF,1); fPtr=f->getPointer(); }
917 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_parts.begin();it!=_parts.end();it++,iii++)
919 const MEDCoupling1GTUMesh *cur(*it);
921 const DataArrayInt *pfl(_pfls[iii]);
922 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> cur2;
924 { cur2=const_cast<MEDCoupling1GTUMesh *>(cur); cur2->incrRef(); }
926 { cur2=dynamic_cast<MEDCoupling1GTUMesh *>(cur->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end())); cur=cur2; }
928 int curNbCells(cur->getNumberOfCells());
929 int gt((int)cur->getCellModelEnum());
930 if(gt<0 || gt>=PARAMEDMEM_2_VTKTYPE_LGTH)
931 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : invalid geometric type !");
932 unsigned char gtvtk(PARAMEDMEM_2_VTKTYPE[gt]);
934 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : no VTK type for the requested INTERP_KERNEL geometric type !");
935 std::fill(bPtr,bPtr+curNbCells,gtvtk); bPtr+=curNbCells;
936 const MEDCoupling1SGTUMesh *scur(dynamic_cast<const MEDCoupling1SGTUMesh *>(cur));
937 const MEDCoupling1DGTUMesh *dcur(dynamic_cast<const MEDCoupling1DGTUMesh *>(cur));
938 const int *connPtr(cur->getNodalConnectivity()->begin());
940 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : internal error !");
943 int nnpc(scur->getNumberOfNodesPerCell());
944 for(int i=0;i<curNbCells;i++,connPtr+=nnpc)
947 dPtr=std::copy(connPtr,connPtr+nnpc,dPtr);
948 *cPtr++=k; k+=nnpc+1;
951 { std::fill(ePtr,ePtr+curNbCells,-1); ePtr+=curNbCells; }
955 const int *connIPtr(dcur->getNodalConnectivityIndex()->begin());
956 if(cur->getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED)
958 for(int i=0;i<curNbCells;i++,connIPtr++)
960 *dPtr++=connIPtr[1]-connIPtr[0];
961 dPtr=std::copy(connPtr+connIPtr[0],connPtr+connIPtr[1],dPtr);
962 *cPtr++=k; k+=connIPtr[1]-connIPtr[0];
967 for(int i=0;i<curNbCells;i++,connIPtr++)
969 std::set<int> s(connPtr+connIPtr[0],connPtr+connIPtr[1]); s.erase(-1);
970 *dPtr++=(int)s.size();
971 dPtr=std::copy(s.begin(),s.end(),dPtr);
972 *cPtr++=k; k+=(int)s.size()+1;
977 connIPtr=dcur->getNodalConnectivityIndex()->begin();
978 if(cur->getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED)
979 { std::fill(ePtr,ePtr+curNbCells,-1); ePtr+=curNbCells; }
983 for(int i=0;i<curNbCells;i++,connIPtr++)
985 int nbFace(std::count(connPtr+connIPtr[0],connPtr+connIPtr[1],-1)+1);
987 const int *work(connPtr+connIPtr[0]);
988 for(int j=0;j<nbFace;j++)
990 const int *work2=std::find(work,connPtr+connIPtr[1],-1);
991 *fPtr++=std::distance(work,work2);
992 fPtr=std::copy(work,work2,fPtr);
995 *ePtr++=kk; kk+=connIPtr[1]-connIPtr[0]+2;
1002 reorderNodesIfNecessary(a,d,0);
1004 reorderNodesIfNecessary(a,d,f);
1005 if(a->getNumberOfComponents()!=3)
1006 a=a->changeNbOfComponents(3,0.);
1007 coords=a.retn(); types=b.retn(); cellLocations=c.retn(); cells=d.retn();
1009 { faceLocations=0; faces=0; }
1011 { faceLocations=e.retn(); faces=f.retn(); }
1012 return tmp==((DataArrayDouble *)a);
1015 void MEDUMeshMultiLev::reorderNodesIfNecessary(MEDCouplingAutoRefCountObjectPtr<DataArrayDouble>& coords, DataArrayInt *nodalConnVTK, DataArrayInt *polyhedNodalConnVTK) const
1017 const DataArrayInt *nr(_node_reduction);
1020 if(nodalConnVTK->empty() && !polyhedNodalConnVTK)
1022 coords=(coords->selectByTupleIdSafe(nr->begin(),nr->end()));
1025 int sz(coords->getNumberOfTuples());
1026 std::vector<bool> b(sz,false);
1027 const int *work(nodalConnVTK->begin()),*endW(nodalConnVTK->end());
1031 for(int i=0;i<nb && work!=endW;i++,work++)
1033 if(*work>=0 && *work<sz)
1036 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::reorderNodesIfNecessary : internal error !");
1039 if(polyhedNodalConnVTK)
1041 work=polyhedNodalConnVTK->begin(); endW=polyhedNodalConnVTK->end();
1045 for(int i=0;i<nb && work!=endW;i++)
1048 for(int j=0;j<nb2 && work!=endW;j++,work++)
1050 if(*work>=0 && *work<sz)
1053 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::reorderNodesIfNecessary : internal error #2 !");
1058 int szExp(std::count(b.begin(),b.end(),true));
1059 if(szExp!=nr->getNumberOfTuples())
1060 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::reorderNodesIfNecessary : internal error #3 !");
1062 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n(DataArrayInt::New()); o2n->alloc(sz,1);
1063 int *o2nPtr(o2n->getPointer());
1065 for(int i=0;i<sz;i++,o2nPtr++)
1066 if(b[i]) *o2nPtr=newId++; else *o2nPtr=-1;
1067 const int *o2nPtrc(o2n->begin());
1068 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> n2o(o2n->invertArrayO2N2N2O(nr->getNumberOfTuples()));
1069 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> perm(DataArrayInt::FindPermutationFromFirstToSecond(n2o,nr));
1070 const int *permPtr(perm->begin());
1071 int *work2(nodalConnVTK->getPointer()),*endW2(nodalConnVTK->getPointer()+nodalConnVTK->getNumberOfTuples());
1075 for(int i=0;i<nb && work2!=endW2;i++,work2++)
1076 *work2=permPtr[o2nPtrc[*work2]];
1078 if(polyhedNodalConnVTK)
1080 work2=polyhedNodalConnVTK->getPointer(); endW2=polyhedNodalConnVTK->getPointer()+polyhedNodalConnVTK->getNumberOfTuples();
1084 for(int i=0;i<nb && work2!=endW2;i++)
1087 for(int j=0;j<nb2 && work2!=endW2;j++,work2++)
1088 *work2=permPtr[o2nPtrc[*work2]];
1092 coords=(coords->selectByTupleIdSafe(nr->begin(),nr->end()));
1096 void MEDUMeshMultiLev::appendVertices(const DataArrayInt *verticesToAdd, DataArrayInt *nr)
1098 int nbOfCells(verticesToAdd->getNumberOfTuples());//it is not a bug cells are NORM_POINT1
1099 MEDMeshMultiLev::appendVertices(verticesToAdd,nr);
1100 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> elt(MEDCoupling1SGTUMesh::New("",INTERP_KERNEL::NORM_POINT1));
1101 elt->allocateCells(nbOfCells);
1102 for(int i=0;i<nbOfCells;i++)
1104 int pt(verticesToAdd->getIJ(i,0));
1105 elt->insertNextCell(&pt,&pt+1);
1108 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::appendVertices : parts are empty !");
1109 elt->setCoords(_parts[0]->getCoords());
1110 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> elt2((MEDCoupling1SGTUMesh *)elt); elt2->incrRef();
1111 _parts.push_back(elt2);
1116 MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev():_is_internal(true)
1120 MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector<int>& lev):_is_internal(true)
1122 // ids fields management
1123 _cell_fam_ids_nocpy=true; _cell_num_ids_nocpy=true;
1124 const DataArrayInt *tmp(0);
1125 tmp=m->getFamilyFieldAtLevel(0);
1129 _cell_fam_ids=const_cast<DataArrayInt *>(tmp);
1131 tmp=m->getNumberFieldAtLevel(0);
1135 _cell_num_ids=const_cast<DataArrayInt *>(tmp);
1138 _node_fam_ids_nocpy=true; _node_num_ids_nocpy=true;
1140 tmp=m->getFamilyFieldAtLevel(1);
1144 _node_fam_ids=const_cast<DataArrayInt *>(tmp);
1146 tmp=m->getNumberFieldAtLevel(1);
1150 _node_num_ids=const_cast<DataArrayInt *>(tmp);
1154 MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, int nbOfNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDMeshMultiLev(nbOfNodes,gts,pfls,nbEntities),_is_internal(true)
1156 // ids fields management
1157 _cell_fam_ids_nocpy=true; _cell_num_ids_nocpy=true;
1158 const DataArrayInt *tmp(0);
1159 tmp=m->getFamilyFieldAtLevel(0);
1163 _cell_fam_ids=const_cast<DataArrayInt *>(tmp);
1165 tmp=m->getNumberFieldAtLevel(0);
1169 _cell_num_ids=const_cast<DataArrayInt *>(tmp);
1172 _node_fam_ids_nocpy=true; _node_num_ids_nocpy=true;
1174 tmp=m->getFamilyFieldAtLevel(1);
1178 _node_fam_ids=const_cast<DataArrayInt *>(tmp);
1180 tmp=m->getNumberFieldAtLevel(1);
1184 _node_num_ids=const_cast<DataArrayInt *>(tmp);
1188 MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other):MEDMeshMultiLev(other),_is_internal(true)
1192 void MEDStructuredMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes)
1194 if(!pflNodes || !pflNodes->isAllocated())
1196 std::vector<int> ngs(getNodeGridStructure());
1197 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(MEDCouplingStructuredMesh::Build1GTNodalConnectivity(&ngs[0],&ngs[0]+ngs.size()));
1198 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> m(MEDCoupling1SGTUMesh::New("",MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(ngs.size())));
1199 m->setNodalConnectivity(conn);
1200 const DataArrayInt *pfl(_pfls[0]);
1203 m=dynamic_cast<MEDCoupling1SGTUMesh *>(m->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
1205 DataArrayInt *cellIds=0;
1206 m->fillCellIdsToKeepFromNodeIds(pflNodes->begin(),pflNodes->end(),true,cellIds);
1207 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIdsSafe(cellIds);
1208 MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> m2(m->buildPartOfMySelfKeepCoords(cellIds->begin(),cellIds->end()));
1210 _node_reduction=m2->getNodeIdsInUse(tmp);
1212 _pfls[0]=pfl->selectByTupleIdSafe(cellIds->begin(),cellIds->end());
1214 _pfls[0]=cellIdsSafe;
1219 MEDCMeshMultiLev *MEDCMeshMultiLev::New(const MEDFileCMesh *m, const std::vector<int>& levs)
1221 return new MEDCMeshMultiLev(m,levs);
1224 MEDCMeshMultiLev *MEDCMeshMultiLev::New(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities)
1226 return new MEDCMeshMultiLev(m,gts,pfls,nbEntities);
1229 MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<int>& levs):MEDStructuredMeshMultiLev(m,levs)
1232 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor : null input pointer !");
1233 if(levs.size()!=1 || levs[0]!=0)
1234 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor : levels supported is 0 only !");
1235 int sdim(m->getSpaceDimension());
1236 _coords.resize(sdim);
1237 for(int i=0;i<sdim;i++)
1239 DataArrayDouble *elt(const_cast<DataArrayDouble *>(m->getMesh()->getCoordsAt(i)));
1241 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : presence of null pointer for an vector of double along an axis !");
1247 MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDStructuredMeshMultiLev(m,m->getNumberOfNodes(),gts,pfls,nbEntities)
1250 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : null input pointer !");
1251 if(gts.size()!=1 || pfls.size()!=1)
1252 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : lengthes of gts and pfls must be equal to one !");
1253 int mdim(m->getMeshDimension());
1254 INTERP_KERNEL::NormalizedCellType gt(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(mdim));
1256 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : the unique geo type is invalid regarding meshdim !");
1257 _coords.resize(mdim);
1258 for(int i=0;i<mdim;i++)
1260 DataArrayDouble *elt(const_cast<DataArrayDouble *>(m->getMesh()->getCoordsAt(i)));
1262 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : presence of null pointer for an vector of double along an axis !");
1263 _coords[i]=elt; _coords[i]->incrRef();
1267 MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDCMeshMultiLev& other):MEDStructuredMeshMultiLev(other),_coords(other._coords)
1271 std::vector<int> MEDCMeshMultiLev::getNodeGridStructure() const
1273 std::vector<int> ret(_coords.size());
1274 for(std::size_t i=0;i<_coords.size();i++)
1275 ret[i]=_coords[i]->getNumberOfTuples();
1279 MEDMeshMultiLev *MEDCMeshMultiLev::prepare() const
1281 const DataArrayInt *pfl(0),*nr(_node_reduction);
1284 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nnr;
1285 std::vector<int> cgs,ngs(getNodeGridStructure());
1286 cgs.resize(ngs.size());
1287 std::transform(ngs.begin(),ngs.end(),cgs.begin(),std::bind2nd(std::plus<int>(),-1));
1290 std::vector< std::pair<int,int> > cellParts;
1291 MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> ret2;
1292 if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts))
1294 MEDCouplingAutoRefCountObjectPtr<MEDCMeshMultiLev> ret(new MEDCMeshMultiLev(*this));
1295 ret->_is_internal=false;
1297 { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1298 ret->_nb_entities[0]=pfl->getNumberOfTuples();
1300 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > coords(_coords.size());
1301 for(std::size_t i=0;i<_coords.size();i++)
1302 coords[i]=_coords[i]->selectByTupleId2(cellParts[i].first,cellParts[i].second+1,1);
1303 ret->_coords=coords;
1304 ret2=(MEDCMeshMultiLev *)ret; ret2->incrRef();
1308 MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> m(MEDCouplingCMesh::New());
1309 for(std::size_t i=0;i<ngs.size();i++)
1310 m->setCoordsAt(i,_coords[i]);
1311 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> m2(m->build1SGTUnstructured());
1312 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> m3=dynamic_cast<MEDCoupling1GTUMesh *>(m2->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
1313 MEDCouplingAutoRefCountObjectPtr<MEDUMeshMultiLev> ret(new MEDUMeshMultiLev(*this,m3));
1315 { m3->zipCoords(); nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1316 ret2=(MEDUMeshMultiLev *)ret; ret2->incrRef();
1318 const DataArrayInt *famIds(_cell_fam_ids),*numIds(_cell_num_ids);
1321 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(famIds->selectByTupleIdSafe(pfl->begin(),pfl->end()));
1322 ret2->setFamilyIdsOnCells(tmp,false);
1326 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(numIds->selectByTupleIdSafe(pfl->begin(),pfl->end()));
1327 ret2->setNumberIdsOnCells(tmp,false);
1334 MEDCouplingAutoRefCountObjectPtr<MEDCMeshMultiLev> ret(new MEDCMeshMultiLev(*this));
1336 { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1342 * \a param [out] isInternal if true the returned pointers are those in main data structure. If false those pointers have been built espacially for that method.
1344 std::vector< DataArrayDouble * > MEDCMeshMultiLev::buildVTUArrays(bool& isInternal) const
1346 isInternal=_is_internal;
1347 std::size_t sz(_coords.size());
1348 std::vector< DataArrayDouble * > ret(sz);
1349 for(std::size_t i=0;i<sz;i++)
1351 ret[i]=const_cast<DataArrayDouble *>((const DataArrayDouble *)_coords[i]);
1359 MEDCurveLinearMeshMultiLev *MEDCurveLinearMeshMultiLev::New(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs)
1361 return new MEDCurveLinearMeshMultiLev(m,levs);
1364 MEDCurveLinearMeshMultiLev *MEDCurveLinearMeshMultiLev::New(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities)
1366 return new MEDCurveLinearMeshMultiLev(m,gts,pfls,nbEntities);
1369 MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs):MEDStructuredMeshMultiLev(m,levs)
1372 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor : null input pointer !");
1373 if(levs.size()!=1 || levs[0]!=0)
1374 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor : levels supported is 0 only !");
1375 DataArrayDouble *coords(const_cast<DataArrayDouble *>(m->getMesh()->getCoords()));
1377 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : no coords set !");
1380 _structure=m->getMesh()->getNodeGridStructure();
1383 MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDStructuredMeshMultiLev(m,m->getNumberOfNodes(),gts,pfls,nbEntities)
1386 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : null input pointer !");
1387 if(gts.size()!=1 || pfls.size()!=1)
1388 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : lengthes of gts and pfls must be equal to one !");
1389 int mdim(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(m->getMeshDimension()));
1391 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : the unique geo type is invalid regarding meshdim !");
1392 DataArrayDouble *coords(const_cast<DataArrayDouble *>(m->getMesh()->getCoords()));
1394 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : no coords set !");
1397 _structure=m->getMesh()->getNodeGridStructure();
1400 MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDCurveLinearMeshMultiLev& other):MEDStructuredMeshMultiLev(other),_coords(other._coords),_structure(other._structure)
1404 std::vector<int> MEDCurveLinearMeshMultiLev::getNodeGridStructure() const
1409 MEDMeshMultiLev *MEDCurveLinearMeshMultiLev::prepare() const
1411 const DataArrayInt *pfl(0),*nr(_node_reduction);
1414 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nnr;
1415 std::vector<int> cgs,ngs(getNodeGridStructure());
1416 cgs.resize(ngs.size());
1417 std::transform(ngs.begin(),ngs.end(),cgs.begin(),std::bind2nd(std::plus<int>(),-1));
1420 std::vector< std::pair<int,int> > cellParts,nodeParts;
1421 MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> ret2;
1422 if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts))
1424 nodeParts=cellParts;
1425 std::vector<int> st(ngs.size());
1426 for(std::size_t i=0;i<ngs.size();i++)
1428 nodeParts[i].second++;
1429 st[i]=nodeParts[i].second-nodeParts[i].first;
1431 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p(MEDCouplingStructuredMesh::BuildExplicitIdsFrom(ngs,nodeParts));
1432 MEDCouplingAutoRefCountObjectPtr<MEDCurveLinearMeshMultiLev> ret(new MEDCurveLinearMeshMultiLev(*this));
1433 ret->_is_internal=false;
1435 { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1436 ret->_nb_entities[0]=pfl->getNumberOfTuples();
1438 ret->_coords=_coords->selectByTupleIdSafe(p->begin(),p->end());
1440 ret2=(MEDCurveLinearMeshMultiLev *)ret; ret2->incrRef();
1444 MEDCouplingAutoRefCountObjectPtr<MEDCouplingCurveLinearMesh> m(MEDCouplingCurveLinearMesh::New());
1445 m->setCoords(_coords); m->setNodeGridStructure(&_structure[0],&_structure[0]+_structure.size());
1446 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> m2(m->build1SGTUnstructured());
1447 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> m3=dynamic_cast<MEDCoupling1GTUMesh *>(m2->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
1448 MEDCouplingAutoRefCountObjectPtr<MEDUMeshMultiLev> ret(new MEDUMeshMultiLev(*this,m3));
1450 { m3->zipCoords(); nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1451 ret2=(MEDUMeshMultiLev *)ret; ret2->incrRef();
1453 const DataArrayInt *famIds(_cell_fam_ids),*numIds(_cell_num_ids);
1456 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(famIds->selectByTupleIdSafe(pfl->begin(),pfl->end()));
1457 ret2->setFamilyIdsOnCells(tmp,false);
1461 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(numIds->selectByTupleIdSafe(pfl->begin(),pfl->end()));
1462 ret2->setNumberIdsOnCells(tmp,false);
1468 MEDCouplingAutoRefCountObjectPtr<MEDCurveLinearMeshMultiLev> ret(new MEDCurveLinearMeshMultiLev(*this));
1470 { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1475 void MEDCurveLinearMeshMultiLev::buildVTUArrays(DataArrayDouble *&coords, std::vector<int>& nodeStrct, bool& isInternal) const
1477 isInternal=_is_internal;
1478 nodeStrct=_structure;
1479 const DataArrayDouble *coo(_coords);
1481 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev::buildVTUArrays : null pointer on coordinates !");
1482 coords=const_cast<DataArrayDouble *>(coo); coords->incrRef();
1487 MEDFileField1TSStructItem2::MEDFileField1TSStructItem2()
1491 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)
1493 _pfl->setName(c.c_str());
1496 void MEDFileField1TSStructItem2::checkWithMeshStructForCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
1498 int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
1499 checkInRange(nbOfEnt,1,globs);
1502 void MEDFileField1TSStructItem2::checkWithMeshStructForGaussNE(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
1504 int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
1505 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1506 checkInRange(nbOfEnt,(int)cm.getNumberOfNodes(),globs);
1509 void MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
1512 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT : no globals specified !");
1514 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT : no localization specified !");
1515 const MEDFileFieldLoc& loc=globs->getLocalization(_loc.c_str());
1516 int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
1517 checkInRange(nbOfEnt,loc.getNumberOfGaussPoints(),globs);
1520 int MEDFileField1TSStructItem2::getNbOfIntegrationPts(const MEDFileFieldGlobsReal *globs) const
1524 if(getPflName().empty())
1525 return (_start_end.second-_start_end.first)/_nb_of_entity;
1527 return (_start_end.second-_start_end.first)/getPfl(globs)->getNumberOfTuples();
1531 const MEDFileFieldLoc& loc(globs->getLocalization(_loc.c_str()));
1532 return loc.getNumberOfGaussPoints();
1536 std::string MEDFileField1TSStructItem2::getPflName() const
1538 return _pfl->getName();
1541 const DataArrayInt *MEDFileField1TSStructItem2::getPfl(const MEDFileFieldGlobsReal *globs) const
1543 if(!_pfl->isAllocated())
1545 if(_pfl->getName().empty())
1548 return globs->getProfile(_pfl->getName().c_str());
1555 * \param [in] nbOfEntity - number of entity that can be either cells or nodes. Not other possiblity.
1556 * \param [in] nip - number of integration points. 1 for ON_CELLS and NO_NODES
1558 void MEDFileField1TSStructItem2::checkInRange(int nbOfEntity, int nip, const MEDFileFieldGlobsReal *globs)
1560 _nb_of_entity=nbOfEntity;
1561 if(_pfl->getName().empty())
1563 if(nbOfEntity!=(_start_end.second-_start_end.first)/nip)
1564 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Mismatch between number of entities and size of node field !");
1570 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Presence of a profile on field whereas no globals found in file !");
1571 const DataArrayInt *pfl=globs->getProfile(_pfl->getName().c_str());
1573 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Presence of a profile on field whereas no such profile found in file !");
1574 pfl->checkAllIdsInRange(0,nbOfEntity);
1578 bool MEDFileField1TSStructItem2::isFastlyEqual(int& startExp, INTERP_KERNEL::NormalizedCellType gt, const std::string& pflName) const
1580 if(startExp!=_start_end.first)
1584 if(getPflName()!=pflName)
1586 startExp=_start_end.second;
1590 bool MEDFileField1TSStructItem2::operator==(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception)
1592 //_nb_of_entity is not taken into account here. It is not a bug, because no mesh consideration needed here to perform fast compare.
1593 //idem for _loc. It is not an effective attribute for support comparison.
1594 return _geo_type==other._geo_type && _start_end==other._start_end && _pfl->getName()==other._pfl->getName();
1597 bool MEDFileField1TSStructItem2::isCellSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const
1599 if(_geo_type!=other._geo_type)
1601 if(_nb_of_entity!=other._nb_of_entity)
1603 if((_pfl->getName().empty() && !other._pfl->getName().empty()) || (!_pfl->getName().empty() && other._pfl->getName().empty()))
1605 if(_pfl->getName().empty() && other._pfl->getName().empty())
1607 const DataArrayInt *pfl1(getPfl(globs)),*pfl2(other.getPfl(globs));
1608 return pfl1->isEqualWithoutConsideringStr(*pfl2);
1611 bool MEDFileField1TSStructItem2::isNodeSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const
1613 return isCellSupportEqual(other,globs);
1617 * \a objs must be non empty. \a objs should contain items having same geometric type.
1619 MEDFileField1TSStructItem2 MEDFileField1TSStructItem2::BuildAggregationOf(const std::vector<const MEDFileField1TSStructItem2 *>& objs, const MEDFileFieldGlobsReal *globs)
1622 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : empty input !");
1624 return MEDFileField1TSStructItem2(*objs[0]);
1625 INTERP_KERNEL::NormalizedCellType gt(objs[0]->_geo_type);
1626 int nbEntityRef(objs[0]->_nb_of_entity);
1627 std::size_t sz(objs.size());
1628 std::vector<const DataArrayInt *> arrs(sz);
1629 for(std::size_t i=0;i<sz;i++)
1631 const MEDFileField1TSStructItem2 *obj(objs[i]);
1632 if(gt!=obj->_geo_type)
1633 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : invalid situation ! All input must have the same geo type !");
1634 if(nbEntityRef!=obj->_nb_of_entity)
1635 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : invalid situation ! All input must have the global nb of entity !");
1636 if(obj->_pfl->getName().empty())
1637 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : invalid situation ! Several same geo type chunk must all lie on profiles !");
1638 arrs[i]=globs->getProfile(obj->_pfl->getName().c_str());
1640 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr(DataArrayInt::Aggregate(arrs));
1642 int oldNbTuples(arr->getNumberOfTuples());
1643 arr=arr->buildUnique();
1644 if(oldNbTuples!=arr->getNumberOfTuples())
1645 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : some entities are present several times !");
1646 if(arr->isIdentity() && oldNbTuples==nbEntityRef)
1648 std::pair<int,int> p(0,nbEntityRef);
1650 MEDFileField1TSStructItem2 ret(gt,p,a,b);
1651 ret._nb_of_entity=nbEntityRef;
1656 arr->setName(NEWLY_CREATED_PFL_NAME);
1657 std::pair<int,int> p(0,oldNbTuples);
1659 MEDFileField1TSStructItem2 ret(gt,p,a,b);
1660 ret._nb_of_entity=nbEntityRef;
1666 std::size_t MEDFileField1TSStructItem2::getHeapMemorySizeWithoutChildren() const
1668 std::size_t ret(_loc.capacity());
1672 std::vector<const BigMemoryObject *> MEDFileField1TSStructItem2::getDirectChildren() const
1674 std::vector<const BigMemoryObject *> ret;
1675 const DataArrayInt *pfl(_pfl);
1683 MEDFileField1TSStructItem::MEDFileField1TSStructItem(TypeOfField a, const std::vector< MEDFileField1TSStructItem2 >& b):_computed(false),_type(a),_items(b)
1687 void MEDFileField1TSStructItem::checkWithMeshStruct(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
1693 int nbOfEnt=mst->getNumberOfNodes();
1694 if(_items.size()!=1)
1695 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::checkWithMeshStruct : for nodes field only one subdivision supported !");
1696 _items[0].checkInRange(nbOfEnt,1,globs);
1701 for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
1702 (*it).checkWithMeshStructForCells(mst,globs);
1707 for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
1708 (*it).checkWithMeshStructForGaussNE(mst,globs);
1713 for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
1714 (*it).checkWithMeshStructForGaussPT(mst,globs);
1718 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::checkWithMeshStruct : not managed field type !");
1722 bool MEDFileField1TSStructItem::operator==(const MEDFileField1TSStructItem& other) const throw(INTERP_KERNEL::Exception)
1724 if(_type!=other._type)
1726 if(_items.size()!=other._items.size())
1728 for(std::size_t i=0;i<_items.size();i++)
1729 if(!(_items[i]==other._items[i]))
1734 bool MEDFileField1TSStructItem::isCellSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const
1736 if(_type!=other._type)
1738 if(_items.size()!=other._items.size())
1740 for(std::size_t i=0;i<_items.size();i++)
1741 if(!(_items[i].isCellSupportEqual(other._items[i],globs)))
1746 bool MEDFileField1TSStructItem::isNodeSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const
1748 if(_type!=other._type)
1750 if(_items.size()!=other._items.size())
1752 for(std::size_t i=0;i<_items.size();i++)
1753 if(!(_items[i].isNodeSupportEqual(other._items[i],globs)))
1758 bool MEDFileField1TSStructItem::isEntityCell() const
1769 CmpGeo(INTERP_KERNEL::NormalizedCellType geoTyp):_geo_type(geoTyp) { }
1770 bool operator()(const std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > & v) const { return _geo_type==v.first; }
1772 INTERP_KERNEL::NormalizedCellType _geo_type;
1775 MEDFileField1TSStructItem MEDFileField1TSStructItem::simplifyMeOnCellEntity(const MEDFileFieldGlobsReal *globs) const
1778 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::simplifyMeOnCellEntity : must be on ON_CELLS, ON_GAUSS_NE or ON_GAUSS_PT !");
1779 std::vector< std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > > m;
1781 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++,i++)
1783 std::vector< std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > >::iterator it0(std::find_if(m.begin(),m.end(),CmpGeo((*it).getGeo())));
1785 m.push_back(std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> >((*it).getGeo(),std::vector<std::size_t>(1,i)));
1787 (*it0).second.push_back(i);
1789 if(m.size()==_items.size())
1791 MEDFileField1TSStructItem ret(*this);
1795 std::size_t sz(m.size());
1796 std::vector< MEDFileField1TSStructItem2 > items(sz);
1799 const std::vector<std::size_t>& ids=m[i].second;
1800 std::vector<const MEDFileField1TSStructItem2 *>objs(ids.size());
1801 for(std::size_t j=0;j<ids.size();j++)
1802 objs[j]=&_items[ids[j]];
1803 items[i]=MEDFileField1TSStructItem2::BuildAggregationOf(objs,globs);
1805 MEDFileField1TSStructItem ret(ON_CELLS,items);
1811 * \a this is expected to be ON_CELLS and simplified.
1813 bool MEDFileField1TSStructItem::isCompatibleWithNodesDiscr(const MEDFileField1TSStructItem& other, const MEDFileMeshStruct *meshSt, const MEDFileFieldGlobsReal *globs) const
1815 if(other._type!=ON_NODES)
1816 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isCompatibleWithNodesDiscr : other must be on nodes !");
1817 if(other._items.size()!=1)
1818 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isCompatibleWithNodesDiscr : other is on nodes but number of subparts !");
1819 int theFirstLevFull;
1820 bool ret0=isFullyOnOneLev(meshSt,theFirstLevFull);
1821 const MEDFileField1TSStructItem2& otherNodeIt(other._items[0]);
1822 if(otherNodeIt.getPflName().empty())
1826 return theFirstLevFull==0;
1830 const DataArrayInt *pfl=globs->getProfile(otherNodeIt.getPflName().c_str());
1831 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpyPfl(pfl->deepCpy());
1833 int nbOfNodes(meshSt->getNumberOfNodes());
1834 if(cpyPfl->isIdentity() && cpyPfl->getNumberOfTuples()==nbOfNodes)
1835 {//on all nodes also !
1838 return theFirstLevFull==0;
1840 std::vector<bool> nodesFetched(nbOfNodes,false);
1841 meshSt->getTheMesh()->whichAreNodesFetched(*this,globs,nodesFetched);
1842 return cpyPfl->isFittingWith(nodesFetched);
1846 bool MEDFileField1TSStructItem::isFullyOnOneLev(const MEDFileMeshStruct *meshSt, int& theFirstLevFull) const
1849 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : works only for ON_CELLS discretization !");
1851 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : items vector is empty !");
1852 int nbOfLevs(meshSt->getNumberOfLevs());
1854 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : no levels in input mesh structure !");
1855 std::vector<int> levs(nbOfLevs);
1857 std::set<INTERP_KERNEL::NormalizedCellType> gts;
1858 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++)
1860 if(!(*it).getPflName().empty())
1862 INTERP_KERNEL::NormalizedCellType gt((*it).getGeo());
1863 if(gts.find(gt)!=gts.end())
1864 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : internal error !");
1866 int pos(meshSt->getLevelOfGeoType((*it).getGeo()));
1869 for(int i=0;i<nbOfLevs;i++)
1870 if(meshSt->getNumberOfGeoTypesInLev(-i)==levs[i])
1871 { theFirstLevFull=-i; return true; }
1875 const MEDFileField1TSStructItem2& MEDFileField1TSStructItem::operator[](std::size_t i) const throw(INTERP_KERNEL::Exception)
1877 if(i>=_items.size())
1878 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::operator[] : input is not in valid range !");
1882 std::size_t MEDFileField1TSStructItem::getHeapMemorySizeWithoutChildren() const
1884 std::size_t ret(_items.size()*sizeof(MEDFileField1TSStructItem2));
1888 std::vector<const BigMemoryObject *> MEDFileField1TSStructItem::getDirectChildren() const
1890 std::vector<const BigMemoryObject *> ret;
1891 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++)
1892 ret.push_back(&(*it));
1896 MEDMeshMultiLev *MEDFileField1TSStructItem::buildFromScratchDataSetSupportOnCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const
1898 std::size_t sz(_items.size());
1899 std::vector<INTERP_KERNEL::NormalizedCellType> a0(sz);
1900 std::vector<const DataArrayInt *> a1(sz);
1901 std::vector<int> a2(sz);
1903 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++,i++)
1905 a0[i]=(*it).getGeo();
1906 a1[i]=(*it).getPfl(globs);
1907 a2[i]=mst->getNumberOfElemsOfGeoType((*it).getGeo());
1909 return MEDMeshMultiLev::New(mst->getTheMesh(),a0,a1,a2);
1912 MEDFileField1TSStructItem MEDFileField1TSStructItem::BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt)
1915 std::vector< MEDFileField1TSStructItem2 > anItems;
1917 std::vector< std::vector<std::string> > pfls,locs;
1918 std::vector< std::vector<TypeOfField> > typesF;
1919 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
1920 std::vector< std::vector<std::pair<int,int> > > strtEnds=ref->getFieldSplitedByType(std::string(),geoTypes,typesF,pfls,locs);
1921 std::size_t nbOfGeoTypes(geoTypes.size());
1923 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : not null by empty ref !");
1925 for(std::size_t i=0;i<nbOfGeoTypes;i++)
1927 std::size_t sz=typesF[i].size();
1928 if(strtEnds[i].size()<1 || sz<1 || pfls[i].size()<1)
1929 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : internal error #1 !");
1935 for(std::size_t j=0;j<sz;j++)
1937 if(atype==typesF[i][j])
1938 anItems.push_back(MEDFileField1TSStructItem2(geoTypes[i],strtEnds[i][j],pfls[i][j],locs[i][j]));
1940 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : can be applied only on single spatial discretization fields ! Call SplitPerDiscretization method !");
1943 MEDFileField1TSStructItem ret(atype,anItems);
1944 ret.checkWithMeshStruct(meshSt,ref);
1950 MEDFileField1TSStruct *MEDFileField1TSStruct::New(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst)
1952 return new MEDFileField1TSStruct(ref,mst);
1955 MEDFileField1TSStruct::MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst)
1957 _already_checked.push_back(MEDFileField1TSStructItem::BuildItemFrom(ref,mst));
1960 void MEDFileField1TSStruct::checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
1962 if(_already_checked.empty())
1963 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::checkWithMeshStruct : not correctly initialized !");
1964 _already_checked.back().checkWithMeshStruct(mst,globs);
1967 bool MEDFileField1TSStruct::isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *mst) const
1969 MEDFileField1TSStructItem b(MEDFileField1TSStructItem::BuildItemFrom(other,mst));
1970 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++)
1979 * Not const because \a other structure will be added to the \c _already_checked attribute in case of success.
1981 bool MEDFileField1TSStruct::isSupportSameAs(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt)
1983 if(_already_checked.empty())
1984 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isSupportSameAs : no ref !");
1985 MEDFileField1TSStructItem b(MEDFileField1TSStructItem::BuildItemFrom(other,meshSt));
1986 if(!_already_checked[0].isEntityCell() || !b.isEntityCell())
1987 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isSupportSameAs : only available on cell entities !");
1988 MEDFileField1TSStructItem other1(b.simplifyMeOnCellEntity(other));
1990 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
1991 if((*it).isComputed())
1996 MEDFileField1TSStructItem this1(_already_checked[0].simplifyMeOnCellEntity(other));
1997 ret=this1.isCellSupportEqual(other1,other);
1999 _already_checked.push_back(this1);
2002 ret=_already_checked[found].isCellSupportEqual(other1,other);
2004 _already_checked.push_back(b);
2009 * \param [in] other - a field with only one spatial discretization : ON_NODES.
2011 bool MEDFileField1TSStruct::isCompatibleWithNodesDiscr(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt)
2013 if(_already_checked.empty())
2014 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isCompatibleWithNodesDiscr : no ref !");
2015 MEDFileField1TSStructItem other1(MEDFileField1TSStructItem::BuildItemFrom(other,meshSt));
2016 if(_already_checked[0].isEntityCell())
2019 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
2020 if((*it).isComputed())
2025 MEDFileField1TSStructItem this1(_already_checked[0].simplifyMeOnCellEntity(other));
2026 ret=this1.isCompatibleWithNodesDiscr(other1,meshSt,other);
2028 _already_checked.push_back(this1);
2031 ret=_already_checked[found].isCompatibleWithNodesDiscr(other1,meshSt,other);
2033 _already_checked.push_back(other1);
2037 return _already_checked[0].isNodeSupportEqual(other1,other);
2040 std::size_t MEDFileField1TSStruct::getHeapMemorySizeWithoutChildren() const
2042 std::size_t ret(_already_checked.capacity()*sizeof(MEDFileField1TSStructItem));
2046 std::vector<const BigMemoryObject *> MEDFileField1TSStruct::getDirectChildren() const
2048 std::vector<const BigMemoryObject *> ret;
2049 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++)
2050 ret.push_back(&(*it));
2054 MEDMeshMultiLev *MEDFileField1TSStruct::buildFromScratchDataSetSupport(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const
2056 if(_already_checked.empty())
2057 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::buildFromScratchDataSetSupport : No outline structure in this !");
2058 int pos0(-1),pos1(-1);
2059 if(presenceOfCellDiscr(pos0))
2061 MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> ret(_already_checked[pos0].buildFromScratchDataSetSupportOnCells(mst,globs));
2062 if(presenceOfPartialNodeDiscr(pos1))
2063 ret->setNodeReduction(_already_checked[pos1][0].getPfl(globs));
2068 if(!presenceOfPartialNodeDiscr(pos1))
2069 {//we have only all nodes, no cell definition info -> all existing levels !;
2070 return MEDMeshMultiLev::New(mst->getTheMesh(),mst->getTheMesh()->getNonEmptyLevels());
2073 return MEDMeshMultiLev::NewOnlyOnNode(mst->getTheMesh(),_already_checked[pos1][0].getPfl(globs));
2077 bool MEDFileField1TSStruct::isDataSetSupportFastlyEqualTo(const MEDFileField1TSStruct& other, const MEDFileFieldGlobsReal *globs) const
2080 bool a0(presenceOfCellDiscr(b0)),a1(presenceOfPartialNodeDiscr(b1));
2082 bool c0(other.presenceOfCellDiscr(d0)),c1(other.presenceOfPartialNodeDiscr(d1));
2083 if(a0!=c0 || a1!=c1)
2086 if(!_already_checked[b0].isCellSupportEqual(other._already_checked[d0],globs))
2089 if(!_already_checked[b1].isNodeSupportEqual(other._already_checked[d1],globs))
2095 * Returns true if presence in \a this of discretization ON_CELLS, ON_GAUSS_PT, ON_GAUSS_NE.
2096 * 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.
2098 bool MEDFileField1TSStruct::presenceOfCellDiscr(int& pos) const
2100 std::size_t refSz(std::numeric_limits<std::size_t>::max());
2103 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
2105 if((*it).getType()!=ON_NODES)
2108 std::size_t sz((*it).getNumberOfItems());
2110 { pos=i; refSz=sz; }
2114 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::presenceOfCellDiscr : an element in this on entity CELL is empty !");
2119 * Returns true if presence in \a this of discretization ON_NODES.
2120 * If true is returned the pos of the first element containing the single subpart.
2122 bool MEDFileField1TSStruct::presenceOfPartialNodeDiscr(int& pos) const
2125 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
2127 if((*it).getType()==ON_NODES)
2129 std::size_t sz((*it).getNumberOfItems());
2132 if(!(*it)[0].getPflName().empty())
2133 { pos=i; return true; }
2136 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::presenceOfPartialNodeDiscr : an element in this on entity NODE is split into several parts !");
2144 MEDFileFastCellSupportComparator *MEDFileFastCellSupportComparator::New(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref)
2146 return new MEDFileFastCellSupportComparator(m,ref);
2149 MEDFileFastCellSupportComparator::MEDFileFastCellSupportComparator(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref)
2152 throw INTERP_KERNEL::Exception("MEDFileFastCellSupportComparator constructor : null input mesh struct !");
2153 _mesh_comp=const_cast<MEDFileMeshStruct *>(m); _mesh_comp->incrRef();
2154 int nbPts=ref->getNumberOfTS();
2155 _f1ts_cmps.resize(nbPts);
2156 for(int i=0;i<nbPts;i++)
2158 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt=ref->getTimeStepAtPos(i);
2159 _f1ts_cmps[i]=MEDFileField1TSStruct::New(elt,_mesh_comp);
2160 _f1ts_cmps[i]->checkWithMeshStruct(_mesh_comp,elt);
2164 std::size_t MEDFileFastCellSupportComparator::getHeapMemorySizeWithoutChildren() const
2166 std::size_t ret(_f1ts_cmps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct>));
2170 std::vector<const BigMemoryObject *> MEDFileFastCellSupportComparator::getDirectChildren() const
2172 std::vector<const BigMemoryObject *> ret;
2173 const MEDFileMeshStruct *mst(_mesh_comp);
2176 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct> >::const_iterator it=_f1ts_cmps.begin();it!=_f1ts_cmps.end();it++)
2178 const MEDFileField1TSStruct *cur(*it);
2185 bool MEDFileFastCellSupportComparator::isEqual(const MEDFileAnyTypeFieldMultiTS *other)
2187 int nbPts=other->getNumberOfTS();
2188 if(nbPts!=(int)_f1ts_cmps.size())
2190 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isEqual : unexpected nb of time steps in input ! Should be " << _f1ts_cmps.size() << " it is in reality " << nbPts << " !";
2191 throw INTERP_KERNEL::Exception(oss.str().c_str());
2193 for(int i=0;i<nbPts;i++)
2195 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt=other->getTimeStepAtPos(i);
2196 if(!_f1ts_cmps[i]->isEqualConsideringThePast(elt,_mesh_comp))
2197 if(!_f1ts_cmps[i]->isSupportSameAs(elt,_mesh_comp))
2203 bool MEDFileFastCellSupportComparator::isCompatibleWithNodesDiscr(const MEDFileAnyTypeFieldMultiTS *other)
2205 int nbPts=other->getNumberOfTS();
2206 if(nbPts!=(int)_f1ts_cmps.size())
2208 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isCompatibleWithNodesDiscr : unexpected nb of time steps in input ! Should be " << _f1ts_cmps.size() << " it is in reality " << nbPts << " !";
2209 throw INTERP_KERNEL::Exception(oss.str().c_str());
2211 for(int i=0;i<nbPts;i++)
2213 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt=other->getTimeStepAtPos(i);
2214 if(!_f1ts_cmps[i]->isCompatibleWithNodesDiscr(elt,_mesh_comp))
2220 MEDMeshMultiLev *MEDFileFastCellSupportComparator::buildFromScratchDataSetSupport(int timeStepId, const MEDFileFieldGlobsReal *globs) const
2222 if(timeStepId<0 || timeStepId>=(int)_f1ts_cmps.size())
2224 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::buildFromScratchDataSetSupport : requested time step id #" << timeStepId << " is not in [0," << _f1ts_cmps.size() << ") !";
2225 throw INTERP_KERNEL::Exception(oss.str().c_str());
2227 const MEDFileField1TSStruct *obj(_f1ts_cmps[timeStepId]);
2230 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::buildFromScratchDataSetSupport : at time step id #" << timeStepId << " no field structure overview defined !";
2231 throw INTERP_KERNEL::Exception(oss.str().c_str());
2233 return obj->buildFromScratchDataSetSupport(_mesh_comp,globs);
2236 bool MEDFileFastCellSupportComparator::isDataSetSupportEqualToThePreviousOne(int timeStepId, const MEDFileFieldGlobsReal *globs) const
2238 if(timeStepId<=0 || timeStepId>=(int)_f1ts_cmps.size())
2240 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isDataSetSupportEqualToThePreviousOne : requested time step id #" << timeStepId << " is not in [1," << _f1ts_cmps.size() << ") !";
2241 throw INTERP_KERNEL::Exception(oss.str().c_str());
2243 const MEDFileField1TSStruct *obj(_f1ts_cmps[timeStepId]);
2244 const MEDFileField1TSStruct *objRef(_f1ts_cmps[timeStepId-1]);
2245 return objRef->isDataSetSupportFastlyEqualTo(*obj,globs);