1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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 "MEDCouplingFieldDiscretization.hxx"
26 #include "CellModel.hxx"
28 using namespace MEDCoupling;
30 const unsigned char MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE[MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE_LGTH]=
31 {1,3,21,5,9,7,22,34,23,28,35,255,255,255,10,14,13,255,12,255,24,255,16,27,255,26,255,29,255,255,25,42,36,4};
33 const unsigned char MEDMeshMultiLev::HEXA27_PERM_ARRAY[27]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,24,22,21,23,20,25,26};
35 const char MEDFileField1TSStructItem2::NEWLY_CREATED_PFL_NAME[]="???";
37 MEDFileMeshStruct *MEDFileMeshStruct::New(const MEDFileMesh *mesh)
39 return new MEDFileMeshStruct(mesh);
42 std::size_t MEDFileMeshStruct::getHeapMemorySizeWithoutChildren() const
45 for(std::vector< std::vector<int> >::const_iterator it0=_geo_types_distrib.begin();it0!=_geo_types_distrib.end();it0++)
46 ret+=(*it0).capacity()*sizeof(int);
47 ret+=_geo_types_distrib.capacity()*sizeof(std::vector<int>);
51 std::vector<const BigMemoryObject *> MEDFileMeshStruct::getDirectChildrenWithNull() const
53 return std::vector<const BigMemoryObject *>();
56 MEDFileMeshStruct::MEDFileMeshStruct(const MEDFileMesh *mesh):_mesh(mesh)
58 std::vector<int> levs(mesh->getNonEmptyLevels());
59 _name=mesh->getName();
60 _nb_nodes=mesh->getNumberOfNodes();
63 _geo_types_distrib.resize(-(*std::min_element(levs.begin(),levs.end()))+1);
64 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
65 _geo_types_distrib[-(*lev)]=mesh->getDistributionOfTypes(*lev);
69 int MEDFileMeshStruct::getLevelOfGeoType(INTERP_KERNEL::NormalizedCellType t) const
72 for(std::vector< std::vector<int> >::const_iterator it1=_geo_types_distrib.begin();it1!=_geo_types_distrib.end();it1++,j--)
74 std::size_t sz=(*it1).size();
76 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getLevelOfGeoType : internal error in code !");
77 std::size_t nbGeo=sz/3;
78 for(std::size_t i=0;i<nbGeo;i++)
79 if((*it1)[3*i]==(int)t)
82 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getLevelOfGeoType : The specified geometric type is not present in the mesh structure !");
86 * \sa MEDFileMeshStruct::doesManageGeoType
88 int MEDFileMeshStruct::getNumberOfElemsOfGeoType(INTERP_KERNEL::NormalizedCellType t) const
90 for(std::vector< std::vector<int> >::const_iterator it1=_geo_types_distrib.begin();it1!=_geo_types_distrib.end();it1++)
92 std::size_t sz=(*it1).size();
94 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfElemsOfGeoType : internal error in code !");
95 std::size_t nbGeo=sz/3;
96 for(std::size_t i=0;i<nbGeo;i++)
97 if((*it1)[3*i]==(int)t)
100 throw INTERP_KERNEL::Exception("The specified geometric type is not present in the mesh structure !");
104 * \sa MEDFileMeshStruct::getNumberOfElemsOfGeoType
106 bool MEDFileMeshStruct::doesManageGeoType(INTERP_KERNEL::NormalizedCellType t) const
108 for(std::vector< std::vector<int> >::const_iterator it1=_geo_types_distrib.begin();it1!=_geo_types_distrib.end();it1++)
110 std::size_t sz=(*it1).size();
112 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::doesManageGeoType : internal error in code !");
113 std::size_t nbGeo=sz/3;
114 for(std::size_t i=0;i<nbGeo;i++)
115 if((*it1)[3*i]==(int)t)
121 void MEDFileMeshStruct::appendIfImplicitType(INTERP_KERNEL::NormalizedCellType t)
123 if(!_mesh->hasImplicitPart())
124 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::appendIfImplicitType : by default no implicit geo type can be appended !");
125 static const char MSG[]="MEDFileMeshStruct::appendIfImplicitType : the distribution does not looks like structured standard !";
126 if(_geo_types_distrib.size()!=1)
127 throw INTERP_KERNEL::Exception(MSG);
128 std::size_t sz(_geo_types_distrib[0].size());
130 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::appendIfImplicitType : internal error in code !");
131 std::size_t nbGeo(sz/3);
133 throw INTERP_KERNEL::Exception(MSG);
134 std::vector<int> arr(3); arr[0]=(int)t; arr[1]=_mesh->buildImplicitPartIfAny(t); arr[2]=-1;
135 _geo_types_distrib.push_back(arr);
139 int MEDFileMeshStruct::getNumberOfLevs() const
141 return (int)_geo_types_distrib.size();
144 int MEDFileMeshStruct::getNumberOfGeoTypesInLev(int relativeLev) const
146 int pos(-relativeLev);
147 if(pos<0 || pos>=(int)_geo_types_distrib.size())
148 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfGeoTypesInLev : invalid level specified !");
149 std::size_t sz=_geo_types_distrib[pos].size();
151 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfGeoTypesInLev : internal error in code !");
157 std::size_t MEDMeshMultiLev::getHeapMemorySizeWithoutChildren() const
162 std::vector<const BigMemoryObject *> MEDMeshMultiLev::getDirectChildrenWithNull() const
164 return std::vector<const BigMemoryObject *>();
167 MEDMeshMultiLev *MEDMeshMultiLev::New(const MEDFileMesh *m, const std::vector<int>& levs)
170 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New : null input pointer !");
171 const MEDFileUMesh *um(dynamic_cast<const MEDFileUMesh *>(m));
173 return MEDUMeshMultiLev::New(um,levs);
174 const MEDFileCMesh *cm(dynamic_cast<const MEDFileCMesh *>(m));
176 return MEDCMeshMultiLev::New(cm,levs);
177 const MEDFileCurveLinearMesh *clm(dynamic_cast<const MEDFileCurveLinearMesh *>(m));
179 return MEDCurveLinearMeshMultiLev::New(clm,levs);
180 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New : unrecognized type of mesh ! Must be in [MEDFileUMesh,MEDFileCMesh,MEDFileCurveLinearMesh] !");
183 MEDMeshMultiLev *MEDMeshMultiLev::New(const MEDFileMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities)
186 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New 2 : null input pointer !");
187 const MEDFileUMesh *um(dynamic_cast<const MEDFileUMesh *>(m));
189 return MEDUMeshMultiLev::New(um,gts,pfls,nbEntities);
190 const MEDFileCMesh *cm(dynamic_cast<const MEDFileCMesh *>(m));
192 return MEDCMeshMultiLev::New(cm,gts,pfls,nbEntities);
193 const MEDFileCurveLinearMesh *clm(dynamic_cast<const MEDFileCurveLinearMesh *>(m));
195 return MEDCurveLinearMeshMultiLev::New(clm,gts,pfls,nbEntities);
196 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New 2 : unrecognized type of mesh ! Must be in [MEDFileUMesh,MEDFileCMesh,MEDFileCurveLinearMesh] !");
199 MEDMeshMultiLev *MEDMeshMultiLev::NewOnlyOnNode(const MEDFileMesh *m, const DataArrayInt *pflOnNode)
201 MCAuto<MEDMeshMultiLev> ret(MEDMeshMultiLev::New(m,m->getNonEmptyLevels()));
202 ret->selectPartOfNodes(pflOnNode);
206 void MEDMeshMultiLev::setNodeReduction(const DataArrayInt *nr)
210 _node_reduction=const_cast<DataArrayInt*>(nr);
213 void MEDMeshMultiLev::setCellReduction(const DataArrayInt *cr)
216 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::setCellReduction : can be used only for single geo type mesh !");
217 _pfls[0]=const_cast<DataArrayInt*>(cr);
222 bool MEDMeshMultiLev::isFastlyTheSameStruct(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs) const
224 if(fst.getType()==ON_NODES)
226 if(fst.getNumberOfItems()!=1)
227 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::isFastlyTheSameStruct : unexpected situation for nodes !");
228 const MEDFileField1TSStructItem2& p(fst[0]);
229 std::string pflName(p.getPflName());
230 const DataArrayInt *nr(_node_reduction);
231 if(pflName.empty() && !nr)
233 if(!pflName.empty() && !nr)
235 if(pflName==nr->getName())
241 std::size_t sz(fst.getNumberOfItems());
242 if(sz!=_geo_types.size())
245 for(std::size_t i=0;i<sz;i++)
247 const MEDFileField1TSStructItem2& p(fst[i]);
248 if(!p.isFastlyEqual(strt,_geo_types[i],getPflNameOfId(i).c_str()))
255 DataArray *MEDMeshMultiLev::buildDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const
257 MCAuto<DataArray> ret(const_cast<DataArray *>(vals)); ret->incrRef();
258 if(isFastlyTheSameStruct(fst,globs))
261 return constructDataArray(fst,globs,vals);
265 * \param [out] famIds - Can be null. If not null the instance has to be dealt by the caller (decrRef).
266 * \param [out] isWithoutCopy - When true the returned instance \a famIds if not null is directly those in the data structure.
268 void MEDMeshMultiLev::retrieveFamilyIdsOnCells(DataArrayInt *& famIds, bool& isWithoutCopy) const
270 const DataArrayInt *fids(_cell_fam_ids);
272 { famIds=0; isWithoutCopy=true; return ; }
273 std::size_t sz(_geo_types.size());
274 bool presenceOfPfls(false);
275 for(std::size_t i=0;i<sz && !presenceOfPfls;i++)
277 const DataArrayInt *pfl(_pfls[i]);
282 { famIds=const_cast<DataArrayInt *>(fids); famIds->incrRef(); isWithoutCopy=_mesh->isObjectInTheProgeny(famIds); return ; }
283 //bad luck the slowest part
285 std::vector< MCAuto<DataArrayInt> > retSafe(sz);
286 std::vector< const DataArrayInt *> ret(sz);
288 for(std::size_t i=0;i<sz;i++)
290 const DataArrayInt *pfl(_pfls[i]);
291 int lgth(_nb_entities[i]);
294 MCAuto<DataArrayInt> tmp(fids->selectByTupleIdSafeSlice(start,start+lgth,1));
295 retSafe[i]=tmp->selectByTupleIdSafe(pfl->begin(),pfl->end());
299 retSafe[i]=fids->selectByTupleIdSafeSlice(start,start+lgth,1);
304 famIds=DataArrayInt::Aggregate(ret);
308 * \param [out] numIds - Can be null. If not null the instance has to be dealt by the caller (decrRef).
309 * \param [out] isWithoutCopy - When true the returned instance \a numIds if not null is directly those in the data structure.
311 void MEDMeshMultiLev::retrieveNumberIdsOnCells(DataArrayInt *& numIds, bool& isWithoutCopy) const
313 const DataArrayInt *nids(_cell_num_ids);
315 { numIds=0; isWithoutCopy=true; return ; }
316 std::size_t sz(_geo_types.size());
317 bool presenceOfPfls(false);
318 for(std::size_t i=0;i<sz && !presenceOfPfls;i++)
320 const DataArrayInt *pfl(_pfls[i]);
325 { numIds=const_cast<DataArrayInt *>(nids); numIds->incrRef(); isWithoutCopy=_mesh->isObjectInTheProgeny(numIds); return ; }
326 //bad luck the slowest part
328 std::vector< MCAuto<DataArrayInt> > retSafe(sz);
329 std::vector< const DataArrayInt *> ret(sz);
331 for(std::size_t i=0;i<sz;i++)
333 const DataArrayInt *pfl(_pfls[i]);
334 int lgth(_nb_entities[i]);
337 MCAuto<DataArrayInt> tmp(nids->selectByTupleIdSafeSlice(start,start+lgth,1));
338 retSafe[i]=tmp->selectByTupleIdSafe(pfl->begin(),pfl->end());
342 retSafe[i]=nids->selectByTupleIdSafeSlice(start,start+lgth,1);
347 numIds=DataArrayInt::Aggregate(ret);
351 * \param [out] famIds - Can be null. If not null the instance has to be dealt by the caller (decrRef).
352 * \param [out] isWithoutCopy - When true the returned instance \a famIds if not null is directly those in the data structure.
354 void MEDMeshMultiLev::retrieveFamilyIdsOnNodes(DataArrayInt *& famIds, bool& isWithoutCopy) const
356 const DataArrayInt *fids(_node_fam_ids);
358 { famIds=0; isWithoutCopy=true; return ; }
359 const DataArrayInt *nr(_node_reduction);
363 famIds=fids->selectByTupleIdSafe(nr->begin(),nr->end());
367 famIds=const_cast<DataArrayInt *>(fids); famIds->incrRef();
368 isWithoutCopy=_mesh->isObjectInTheProgeny(famIds);
373 * \param [out] numIds - Can be null. If not null the instance has to be dealt by the caller (decrRef).
374 * \param [out] isWithoutCopy - When true the returned instance \a numIds if not null is directly those in the data structure.
376 void MEDMeshMultiLev::retrieveNumberIdsOnNodes(DataArrayInt *& numIds, bool& isWithoutCopy) const
378 const DataArrayInt *fids(_node_num_ids);
380 { numIds=0; isWithoutCopy=true; return ; }
381 const DataArrayInt *nr(_node_reduction);
385 numIds=fids->selectByTupleIdSafe(nr->begin(),nr->end());
389 numIds=const_cast<DataArrayInt *>(fids); numIds->incrRef();
390 isWithoutCopy=_mesh->isObjectInTheProgeny(numIds);
395 * This method returns, if any, a new object containing the global node ids **BUT CONTRARY TO OTHER RETRIEVE METHODS** the returned object is always a NON AGGREGATED object. So the returned object if not null
396 * can be used as this safely.
398 DataArrayInt *MEDMeshMultiLev::retrieveGlobalNodeIdsIfAny() const
400 const MEDFileUMesh *umesh(dynamic_cast<const MEDFileUMesh *>(_mesh));
403 const PartDefinition *pd(umesh->getPartDefAtLevel(1));
406 MCAuto<DataArrayInt> tmp(pd->toDAI());
407 const DataArrayInt *tmpCpp(tmp);
411 const DataArrayInt *nr(_node_reduction);
413 return tmp->selectByTupleIdSafe(nr->begin(),nr->end());
415 return tmp->deepCopy();// Yes a deep copy is needed because this method has to return a non aggregated object !
418 std::vector< INTERP_KERNEL::NormalizedCellType > MEDMeshMultiLev::getGeoTypes() const
423 void MEDMeshMultiLev::setFamilyIdsOnCells(DataArrayInt *famIds)
425 _cell_fam_ids=famIds;
430 void MEDMeshMultiLev::setNumberIdsOnCells(DataArrayInt *numIds)
432 _cell_num_ids=numIds;
437 void MEDMeshMultiLev::setFamilyIdsOnNodes(DataArrayInt *famIds)
439 _node_fam_ids=famIds;
444 void MEDMeshMultiLev::setNumberIdsOnNodes(DataArrayInt *numIds)
446 _node_num_ids=numIds;
451 std::string MEDMeshMultiLev::getPflNameOfId(int id) const
453 std::size_t sz(_pfls.size());
454 if(id<0 || id>=(int)sz)
455 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::getPflNameOfId : invalid input id !");
456 const DataArrayInt *pfl(_pfls[id]);
458 return std::string("");
459 return pfl->getName();
463 * Returns the number of cells having geometric type \a t.
464 * The profiles are **NOT** taken into account here.
466 int MEDMeshMultiLev::getNumberOfCells(INTERP_KERNEL::NormalizedCellType t) const
468 std::size_t sz(_nb_entities.size());
469 for(std::size_t i=0;i<sz;i++)
471 return _nb_entities[i];
472 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::getNumberOfCells : not existing geometric type in this !");
475 int MEDMeshMultiLev::getNumberOfNodes() const
480 DataArray *MEDMeshMultiLev::constructDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const
482 if(fst.getType()==ON_NODES)
484 if(fst.getNumberOfItems()!=1)
485 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes !");
486 const MEDFileField1TSStructItem2& p(fst[0]);
487 std::string pflName(p.getPflName());
488 const DataArrayInt *nr(_node_reduction);
489 if(pflName.empty() && !nr)
490 return vals->deepCopy();
491 if(pflName.empty() && nr)
492 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 2 !");
493 if(!pflName.empty() && nr)
495 MCAuto<DataArrayInt> p1(globs->getProfile(pflName.c_str())->deepCopy());
496 MCAuto<DataArrayInt> p2(nr->deepCopy());
497 p1->sort(true); p2->sort(true);
498 if(!p1->isEqualWithoutConsideringStr(*p2))
499 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : it appears that a profile on nodes does not cover the cells correctly !");
500 p1=DataArrayInt::FindPermutationFromFirstToSecond(globs->getProfile(pflName.c_str()),nr);
501 MCAuto<DataArray> ret(vals->deepCopy());
502 ret->renumberInPlace(p1->begin());
505 if(!pflName.empty() && !nr)
507 MCAuto<DataArrayInt> p1(globs->getProfile(pflName.c_str())->deepCopy());
509 if(!p1->isIota(getNumberOfNodes()))
510 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 4 !");
511 MCAuto<DataArray> ret(vals->deepCopy());
512 ret->renumberInPlace(globs->getProfile(pflName.c_str())->begin());
515 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 5 !");
519 std::size_t sz(fst.getNumberOfItems());
520 std::set<INTERP_KERNEL::NormalizedCellType> s(_geo_types.begin(),_geo_types.end());
521 if(s.size()!=_geo_types.size())
522 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 2 !");
523 std::vector< const DataArray *> arr(s.size());
524 std::vector< MCAuto<DataArray> > arrSafe(s.size());
526 int nc(vals->getNumberOfComponents());
527 std::vector<std::string> compInfo(vals->getInfoOnComponents());
528 for(std::vector< INTERP_KERNEL::NormalizedCellType >::const_iterator it=_geo_types.begin();it!=_geo_types.end();it++,iii++)
530 const DataArrayInt *thisP(_pfls[iii]);
531 std::vector<const MEDFileField1TSStructItem2 *> ps;
532 for(std::size_t i=0;i<sz;i++)
534 const MEDFileField1TSStructItem2& p(fst[i]);
539 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 1 !");
542 int nbi(ps[0]->getNbOfIntegrationPts(globs));
543 const DataArrayInt *otherP(ps[0]->getPfl(globs));
544 const std::pair<int,int>& strtStop(ps[0]->getStartStop());
545 MCAuto<DataArray> ret(vals->selectByTupleIdSafeSlice(strtStop.first,strtStop.second,1));
546 if(!thisP && !otherP)
548 arrSafe[iii]=ret; arr[iii]=ret;
553 MCAuto<DataArrayInt> p1(otherP->invertArrayN2O2O2N(getNumberOfCells(ps[0]->getGeo())));
554 MCAuto<DataArrayInt> p2(thisP->deepCopy());
555 p2->transformWithIndArr(p1->begin(),p1->end());
556 //p1=p2->findIdsNotEqual(-1);
557 //p1=p2->selectByTupleIdSafe(p1->begin(),p1->end());
558 ret->rearrange(nbi*nc); ret=ret->selectByTupleIdSafe(p2->begin(),p2->end()); ret->rearrange(nc); ret->setInfoOnComponents(compInfo);
559 arrSafe[iii]=ret; arr[iii]=ret;
564 MCAuto<DataArrayInt> p1(otherP->deepCopy());
566 p1->checkAllIdsInRange(0,getNumberOfCells(ps[0]->getGeo()));
567 p1=DataArrayInt::FindPermutationFromFirstToSecond(otherP,p1);
568 ret->rearrange(nbi*nc); ret->renumberInPlace(p1->begin()); ret->rearrange(nc); ret->setInfoOnComponents(compInfo);
569 arrSafe[iii]=ret; arr[iii]=ret;
572 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 3 !");
576 std::vector< const DataArrayInt * >otherPS(ps.size());
577 std::vector< const DataArray * > arr2(ps.size());
578 std::vector< MCAuto<DataArray> > arr2Safe(ps.size());
579 std::vector< const DataArrayInt * > nbis(ps.size());
580 std::vector< MCAuto<DataArrayInt> > nbisSafe(ps.size());
582 for(std::vector<const MEDFileField1TSStructItem2 *>::const_iterator it2=ps.begin();it2!=ps.end();it2++,jj++)
584 int nbi((*it2)->getNbOfIntegrationPts(globs));
585 const DataArrayInt *otherPfl((*it2)->getPfl(globs));
586 const std::pair<int,int>& strtStop((*it2)->getStartStop());
587 MCAuto<DataArray> ret2(vals->selectByTupleIdSafeSlice(strtStop.first,strtStop.second,1));
589 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 4 !");
590 arr2[jj]=ret2; arr2Safe[jj]=ret2; otherPS[jj]=otherPfl;
591 nbisSafe[jj]=DataArrayInt::New(); nbisSafe[jj]->alloc(otherPfl->getNumberOfTuples(),1); nbisSafe[jj]->fillWithValue(nbi);
592 nbis[jj]=nbisSafe[jj];
594 MCAuto<DataArray> arr3(DataArray::Aggregate(arr2));
595 MCAuto<DataArrayInt> otherP(DataArrayInt::Aggregate(otherPS));
596 MCAuto<DataArrayInt> zenbis(DataArrayInt::Aggregate(nbis));
597 MCAuto<DataArrayInt> otherPN(otherP->invertArrayN2O2O2N(getNumberOfCells(*it)));
598 MCAuto<DataArrayInt> p1;
600 p1=DataArrayInt::FindPermutationFromFirstToSecond(otherP,thisP);
602 p1=otherP->deepCopy();
603 MCAuto<DataArrayInt> zenbisN(zenbis->renumber(p1->begin()));
604 zenbisN->computeOffsetsFull();
606 for(std::vector<const MEDFileField1TSStructItem2 *>::const_iterator it2=ps.begin();it2!=ps.end();it2++,jj++)
608 //int nbi((*it2)->getNbOfIntegrationPts(globs));
609 const DataArrayInt *otherPfl((*it2)->getPfl(globs));
610 const std::pair<int,int>& strtStop((*it2)->getStartStop());
611 MCAuto<DataArray> ret2(vals->selectByTupleIdSafeSlice(strtStop.first,strtStop.second,1));
613 MCAuto<DataArrayInt> p2(otherPfl->deepCopy());
614 p2->transformWithIndArr(otherPN->begin(),otherPN->end());
615 p2->transformWithIndArr(p1->begin(),p1->end());
616 MCAuto<DataArrayInt> idsN(p2->buildExplicitArrByRanges(zenbisN));
617 arr3->setPartOfValuesBase3(ret2,idsN->begin(),idsN->end(),0,nc,1);
619 arrSafe[iii]=arr3; arr[iii]=arr3;
623 return DataArray::Aggregate(arr);
628 * This method is called to add NORM_POINT1 cells in \a this so that orphan nodes in \a verticesToAdd will be fetched.
630 void MEDMeshMultiLev::appendVertices(const DataArrayInt *verticesToAdd, DataArrayInt *nr)
632 int nbOfVertices(verticesToAdd->getNumberOfTuples());
633 std::size_t sz(_pfls.size());
635 _geo_types.resize(sz+1,INTERP_KERNEL::NORM_POINT1);
636 _nb_entities.resize(sz+1,nbOfVertices);
637 _node_reduction=nr; nr->incrRef();
638 _nb_nodes+=nbOfVertices;
639 const DataArrayInt *cf(_cell_fam_ids),*cn(_cell_num_ids),*nf(_node_fam_ids),*nn(_node_num_ids);
642 MCAuto<DataArrayInt> tmp;
643 std::vector<const DataArrayInt *> a(2);
646 tmp=nf->selectByTupleIdSafe(verticesToAdd->begin(),verticesToAdd->end());
649 tmp=DataArrayInt::New(); tmp->alloc(nbOfVertices,1); tmp->fillWithZero();
652 _cell_fam_ids=DataArrayInt::Aggregate(a);
656 MCAuto<DataArrayInt> tmp;
657 std::vector<const DataArrayInt *> a(2);
660 tmp=nn->selectByTupleIdSafe(verticesToAdd->begin(),verticesToAdd->end());
663 tmp=DataArrayInt::New(); tmp->alloc(nbOfVertices,1); tmp->fillWithZero();
666 _cell_num_ids=DataArrayInt::Aggregate(a);
670 MEDMeshMultiLev::MEDMeshMultiLev(const MEDFileMesh *mesh):_mesh(mesh),_nb_nodes(0)
674 MEDMeshMultiLev::MEDMeshMultiLev(const MEDFileMesh *mesh, int nbNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):_mesh(mesh),_geo_types(gts),_nb_entities(nbEntities),_nb_nodes(nbNodes)
676 std::size_t sz(_geo_types.size());
677 if(sz!=pfls.size() || sz!=nbEntities.size())
678 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::MEDMeshMultiLev : input vector must have the same size !");
680 for(std::size_t i=0;i<sz;i++)
684 _pfls[i]=const_cast<DataArrayInt *>(pfls[i]);
688 MEDMeshMultiLev::MEDMeshMultiLev(const MEDMeshMultiLev& other):RefCountObject(other),_mesh(other._mesh),_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_num_ids(other._cell_num_ids),_node_fam_ids(other._node_fam_ids),_node_num_ids(other._node_num_ids)
694 MEDUMeshMultiLev *MEDUMeshMultiLev::New(const MEDFileUMesh *m, const std::vector<int>& levs)
696 return new MEDUMeshMultiLev(m,levs);
699 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<int>& levs):MEDMeshMultiLev(m)
702 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev constructor : null input pointer !");
703 std::vector<MEDCoupling1GTUMesh *> v;
704 for(std::vector<int>::const_iterator it=levs.begin();it!=levs.end();it++)
706 std::vector<MEDCoupling1GTUMesh *> vTmp(m->getDirectUndergroundSingleGeoTypeMeshes(*it));
707 v.insert(v.end(),vTmp.begin(),vTmp.end());
709 std::size_t sz(v.size());
712 _coords=m->getCoords(); _coords->incrRef();
716 _geo_types.resize(sz);
717 _nb_entities.resize(sz);
718 for(std::size_t i=0;i<sz;i++)
720 MEDCoupling1GTUMesh *obj(v[i]);
724 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev constructor : presence of a null pointer !");
726 _geo_types[i]=obj->getCellModelEnum();
727 _nb_entities[i]=obj->getNumberOfCells();
729 // ids fields management
730 bool cellFamIdsNoCpy(levs.size()==1);
733 const DataArrayInt *tmp(m->getFamilyFieldAtLevel(levs[0]));
737 _cell_fam_ids=(const_cast<DataArrayInt *>(tmp));
742 std::vector<const DataArrayInt *> tmps(levs.size());
744 for(std::size_t i=0;i<levs.size();i++)
746 tmps[i]=m->getFamilyFieldAtLevel(levs[i]);
750 if(f && !tmps.empty())
751 _cell_fam_ids=DataArrayInt::Aggregate(tmps);
753 bool cellNumIdsNoCpy(levs.size()==1);
756 const DataArrayInt *tmp(m->getNumberFieldAtLevel(levs[0]));
760 _cell_num_ids=(const_cast<DataArrayInt *>(tmp));
765 std::vector<const DataArrayInt *> tmps(levs.size());
767 for(std::size_t i=0;i<levs.size();i++)
769 tmps[i]=m->getNumberFieldAtLevel(levs[i]);
773 if(n && !tmps.empty())
774 _cell_num_ids=DataArrayInt::Aggregate(tmps);
778 const DataArrayInt *tmp(m->getFamilyFieldAtLevel(1));
782 _node_fam_ids=(const_cast<DataArrayInt *>(tmp));
786 const DataArrayInt *tmp(m->getNumberFieldAtLevel(1));
790 _node_num_ids=(const_cast<DataArrayInt *>(tmp));
795 MEDUMeshMultiLev *MEDUMeshMultiLev::New(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities)
797 return new MEDUMeshMultiLev(m,gts,pfls,nbEntities);
800 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,m->getNumberOfNodes(),gts,pfls,nbEntities)
802 std::size_t sz(gts.size());
804 throw INTERP_KERNEL::Exception("constructor of MEDUMeshMultiLev : number of different geo type must be >= 1 !");
805 unsigned dim(INTERP_KERNEL::CellModel::GetCellModel(gts[0]).getDimension());
807 bool isSameDim(true),isNoPfl(true);
808 for(std::size_t i=0;i<sz;i++)
810 MEDCoupling1GTUMesh *elt(m->getDirectUndergroundSingleGeoTypeMesh(gts[i]));
811 if(INTERP_KERNEL::CellModel::GetCellModel(gts[i]).getDimension()!=dim)
819 // ids fields management
820 int lev((int)dim-m->getMeshDimension());
821 if(isSameDim && isNoPfl && m->getGeoTypesAtLevel(lev)==gts)//optimized part
823 const DataArrayInt *famIds(m->getFamilyFieldAtLevel(lev));
825 { _cell_fam_ids=const_cast<DataArrayInt*>(famIds); famIds->incrRef(); }
826 const DataArrayInt *numIds(m->getNumberFieldAtLevel(lev));
828 { _cell_num_ids=const_cast<DataArrayInt*>(numIds); numIds->incrRef(); }
829 famIds=m->getFamilyFieldAtLevel(1);
831 { _node_fam_ids=const_cast<DataArrayInt*>(famIds); famIds->incrRef(); }
832 numIds=m->getNumberFieldAtLevel(1);
834 { _node_num_ids=const_cast<DataArrayInt*>(numIds); numIds->incrRef(); }
838 std::vector< MCAuto<DataArrayInt> > famIdsSafe(sz);
839 std::vector<const DataArrayInt *> famIds(sz);
841 for(std::size_t i=0;i<sz;i++)
843 famIdsSafe[i]=m->extractFamilyFieldOnGeoType(gts[i]);
844 famIds[i]=famIdsSafe[i];
849 _cell_fam_ids=DataArrayInt::Aggregate(famIds);
850 std::vector< MCAuto<DataArrayInt> > numIdsSafe(sz);
851 std::vector<const DataArrayInt *> numIds(sz);
853 for(std::size_t i=0;i<sz;i++)
855 numIdsSafe[i]=m->extractNumberFieldOnGeoType(gts[i]);
856 numIds[i]=numIdsSafe[i];
861 _cell_num_ids=DataArrayInt::Aggregate(numIds);
862 // node ids management
863 const DataArrayInt *nodeFamIds(m->getFamilyFieldAtLevel(1));
865 { _node_fam_ids=const_cast<DataArrayInt*>(nodeFamIds); nodeFamIds->incrRef(); }
866 const DataArrayInt *nodeNumIds(m->getNumberFieldAtLevel(1));
868 { _node_num_ids=const_cast<DataArrayInt*>(nodeNumIds); nodeNumIds->incrRef(); }
871 void MEDUMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes)
873 if(!pflNodes || !pflNodes->isAllocated())
875 std::size_t sz(_parts.size());
876 std::vector< MCAuto<DataArrayInt> > a(sz);
877 std::vector< const DataArrayInt *> aa(sz);
878 for(std::size_t i=0;i<sz;i++)
880 const DataArrayInt *pfl(_pfls[i]);
881 MCAuto<MEDCoupling1GTUMesh> m(_parts[i]);
883 m=dynamic_cast<MEDCoupling1GTUMesh *>(_parts[i]->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
884 DataArrayInt *cellIds=0;
885 m->fillCellIdsToKeepFromNodeIds(pflNodes->begin(),pflNodes->end(),true,cellIds);
886 MCAuto<DataArrayInt> cellIdsSafe(cellIds);
887 MCAuto<MEDCouplingPointSet> m2(m->buildPartOfMySelfKeepCoords(cellIds->begin(),cellIds->end()));
889 MCAuto<DataArrayInt> o2n(m2->getNodeIdsInUse(tmp));
890 a[i]=o2n->invertArrayO2N2N2O(tmp); aa[i]=a[i];
892 _pfls[i]=pfl->selectByTupleIdSafe(cellIds->begin(),cellIds->end());
894 _pfls[i]=cellIdsSafe;
897 _node_reduction=DataArrayInt::Aggregate(aa);//general case
899 _node_reduction=pflNodes->deepCopy();//case where no cells in read mesh.
900 _node_reduction->sort(true);
901 _node_reduction=_node_reduction->buildUnique();
902 if(_node_reduction->getNumberOfTuples()==pflNodes->getNumberOfTuples())
903 return ;//This is the classical case where the input node profile corresponds perfectly to a subset of cells in _parts
904 if(_node_reduction->getNumberOfTuples()>pflNodes->getNumberOfTuples())
905 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::selectPartOfNodes : internal error in MEDCoupling during cell select from a list of nodes !");
906 // Here the cells available in _parts is not enough to cover all the nodes in pflNodes. So adding vertices cells in _parts...
907 MCAuto<DataArrayInt> pflNodes2(pflNodes->deepCopy());
908 pflNodes2->sort(true);
909 MCAuto<DataArrayInt> diff(pflNodes2->buildSubstractionOptimized(_node_reduction));
910 appendVertices(diff,pflNodes2);
913 MEDMeshMultiLev *MEDUMeshMultiLev::prepare() const
915 return new MEDUMeshMultiLev(*this);
918 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDUMeshMultiLev& other):MEDMeshMultiLev(other),_parts(other._parts),_coords(other._coords)
922 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDStructuredMeshMultiLev& other, const MCAuto<MEDCoupling1GTUMesh>& part):MEDMeshMultiLev(other)
926 _geo_types.resize(1); _geo_types[0]=part->getCellModelEnum();
927 _nb_entities.resize(1); _nb_entities[0]=part->getNumberOfCells();
928 _pfls.resize(1); _pfls[0]=0;
932 * To be called only once ! Because due to some optimizations (sometimes aggressive) the internal state can be changed...
933 * 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.
934 * 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.
936 bool MEDUMeshMultiLev::buildVTUArrays(DataArrayDouble *& coords, DataArrayByte *&types, DataArrayInt *&cellLocations, DataArrayInt *& cells, DataArrayInt *&faceLocations, DataArrayInt *&faces) const
938 const DataArrayDouble *tmp(0);
942 tmp=_parts[0]->getCoords();
944 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : the coordinates are null !");
945 MCAuto<DataArrayDouble> a(const_cast<DataArrayDouble *>(tmp)); tmp->incrRef();
946 int szBCE(0),szD(0),szF(0);
949 for(std::vector< MCAuto<MEDCoupling1GTUMesh> >::const_iterator it=_parts.begin();it!=_parts.end();it++,iii++)
951 const MEDCoupling1GTUMesh *cur(*it);
953 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : a part is null !");
955 const DataArrayInt *pfl(_pfls[iii]);
956 MCAuto<MEDCoupling1GTUMesh> cur2;
958 { cur2=const_cast<MEDCoupling1GTUMesh *>(cur); cur2->incrRef(); }
960 { cur2=dynamic_cast<MEDCoupling1GTUMesh *>(cur->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end())); cur=cur2; }
962 int curNbCells(cur->getNumberOfCells());
964 if((*it)->getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED)
965 szD+=cur->getNodalConnectivity()->getNumberOfTuples()+curNbCells;
969 MCAuto<DataArrayInt> tmp2(cur->computeEffectiveNbOfNodesPerCell());
970 szD+=tmp2->accumulate(0)+curNbCells;
971 szF+=2*curNbCells+cur->getNodalConnectivity()->getNumberOfTuples();
974 MCAuto<DataArrayByte> b(DataArrayByte::New()); b->alloc(szBCE,1); char *bPtr(b->getPointer());
975 MCAuto<DataArrayInt> c(DataArrayInt::New()); c->alloc(szBCE,1); int *cPtr(c->getPointer());
976 MCAuto<DataArrayInt> d(DataArrayInt::New()); d->alloc(szD,1); int *dPtr(d->getPointer());
977 MCAuto<DataArrayInt> e(DataArrayInt::New()),f(DataArrayInt::New()); int *ePtr(0),*fPtr(0);
979 { e->alloc(szBCE,1); ePtr=e->getPointer(); f->alloc(szF,1); fPtr=f->getPointer(); }
982 for(std::vector< MCAuto<MEDCoupling1GTUMesh> >::const_iterator it=_parts.begin();it!=_parts.end();it++,iii++)
984 const MEDCoupling1GTUMesh *cur(*it);
986 const DataArrayInt *pfl(_pfls[iii]);
987 MCAuto<MEDCoupling1GTUMesh> cur2;
989 { cur2=const_cast<MEDCoupling1GTUMesh *>(cur); cur2->incrRef(); }
991 { cur2=dynamic_cast<MEDCoupling1GTUMesh *>(cur->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end())); cur=cur2; }
993 int curNbCells(cur->getNumberOfCells());
994 int gt((int)cur->getCellModelEnum());
995 if(gt<0 || gt>=PARAMEDMEM_2_VTKTYPE_LGTH)
996 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : invalid geometric type !");
997 unsigned char gtvtk(PARAMEDMEM_2_VTKTYPE[gt]);
999 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : no VTK type for the requested INTERP_KERNEL geometric type !");
1000 std::fill(bPtr,bPtr+curNbCells,gtvtk); bPtr+=curNbCells;
1001 const MEDCoupling1SGTUMesh *scur(dynamic_cast<const MEDCoupling1SGTUMesh *>(cur));
1002 const MEDCoupling1DGTUMesh *dcur(dynamic_cast<const MEDCoupling1DGTUMesh *>(cur));
1003 const int *connPtr(cur->getNodalConnectivity()->begin());
1005 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : internal error !");
1008 if(cur->getCellModelEnum()!=INTERP_KERNEL::NORM_HEXA27)
1010 int nnpc(scur->getNumberOfNodesPerCell());
1011 for(int i=0;i<curNbCells;i++,connPtr+=nnpc)
1014 dPtr=std::copy(connPtr,connPtr+nnpc,dPtr);
1015 *cPtr++=k; k+=nnpc+1;
1020 for(int i=0;i<curNbCells;i++,connPtr+=27)
1023 for(int j=0;j<27;j++,dPtr++)
1024 *dPtr=connPtr[HEXA27_PERM_ARRAY[j]];
1029 { std::fill(ePtr,ePtr+curNbCells,-1); ePtr+=curNbCells; }
1033 const int *connIPtr(dcur->getNodalConnectivityIndex()->begin());
1034 if(cur->getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED)
1036 for(int i=0;i<curNbCells;i++,connIPtr++)
1038 *dPtr++=connIPtr[1]-connIPtr[0];
1039 dPtr=std::copy(connPtr+connIPtr[0],connPtr+connIPtr[1],dPtr);
1040 *cPtr++=k; k+=connIPtr[1]-connIPtr[0]+1;
1045 for(int i=0;i<curNbCells;i++,connIPtr++)
1047 std::set<int> s(connPtr+connIPtr[0],connPtr+connIPtr[1]); s.erase(-1);
1048 *dPtr++=(int)s.size();
1049 dPtr=std::copy(s.begin(),s.end(),dPtr);
1050 *cPtr++=k; k+=(int)s.size()+1;
1055 connIPtr=dcur->getNodalConnectivityIndex()->begin();
1056 if(cur->getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED)
1057 { std::fill(ePtr,ePtr+curNbCells,-1); ePtr+=curNbCells; }
1061 for(int i=0;i<curNbCells;i++,connIPtr++)
1063 int nbFace(std::count(connPtr+connIPtr[0],connPtr+connIPtr[1],-1)+1);
1065 const int *work(connPtr+connIPtr[0]);
1066 for(int j=0;j<nbFace;j++)
1068 const int *work2=std::find(work,connPtr+connIPtr[1],-1);
1069 *fPtr++=std::distance(work,work2);
1070 fPtr=std::copy(work,work2,fPtr);
1073 *ePtr++=kk; kk+=connIPtr[1]-connIPtr[0]+2;
1080 reorderNodesIfNecessary(a,d,0);
1082 reorderNodesIfNecessary(a,d,f);
1083 if(a->getNumberOfComponents()!=3)
1084 a=a->changeNbOfComponents(3,0.);
1085 coords=a.retn(); types=b.retn(); cellLocations=c.retn(); cells=d.retn();
1087 { faceLocations=0; faces=0; }
1089 { faceLocations=e.retn(); faces=f.retn(); }
1090 return _mesh->isObjectInTheProgeny(coords);
1093 void MEDUMeshMultiLev::reorderNodesIfNecessary(MCAuto<DataArrayDouble>& coords, DataArrayInt *nodalConnVTK, DataArrayInt *polyhedNodalConnVTK) const
1095 const DataArrayInt *nr(_node_reduction);
1098 if(nodalConnVTK->empty() && !polyhedNodalConnVTK)
1100 coords=(coords->selectByTupleIdSafe(nr->begin(),nr->end()));
1103 int sz(coords->getNumberOfTuples());
1104 std::vector<bool> b(sz,false);
1105 const int *work(nodalConnVTK->begin()),*endW(nodalConnVTK->end());
1109 for(int i=0;i<nb && work!=endW;i++,work++)
1111 if(*work>=0 && *work<sz)
1114 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::reorderNodesIfNecessary : internal error !");
1117 if(polyhedNodalConnVTK)
1119 work=polyhedNodalConnVTK->begin(); endW=polyhedNodalConnVTK->end();
1123 for(int i=0;i<nb && work!=endW;i++)
1126 for(int j=0;j<nb2 && work!=endW;j++,work++)
1128 if(*work>=0 && *work<sz)
1131 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::reorderNodesIfNecessary : internal error #2 !");
1136 int szExp(std::count(b.begin(),b.end(),true));
1137 if(szExp!=nr->getNumberOfTuples())
1138 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::reorderNodesIfNecessary : internal error #3 !");
1140 MCAuto<DataArrayInt> o2n(DataArrayInt::New()); o2n->alloc(sz,1);
1141 int *o2nPtr(o2n->getPointer());
1143 for(int i=0;i<sz;i++,o2nPtr++)
1144 if(b[i]) *o2nPtr=newId++; else *o2nPtr=-1;
1145 const int *o2nPtrc(o2n->begin());
1146 MCAuto<DataArrayInt> n2o(o2n->invertArrayO2N2N2O(nr->getNumberOfTuples()));
1147 MCAuto<DataArrayInt> perm(DataArrayInt::FindPermutationFromFirstToSecond(n2o,nr));
1148 const int *permPtr(perm->begin());
1149 int *work2(nodalConnVTK->getPointer()),*endW2(nodalConnVTK->getPointer()+nodalConnVTK->getNumberOfTuples());
1153 for(int i=0;i<nb && work2!=endW2;i++,work2++)
1154 *work2=permPtr[o2nPtrc[*work2]];
1156 if(polyhedNodalConnVTK)
1158 work2=polyhedNodalConnVTK->getPointer(); endW2=polyhedNodalConnVTK->getPointer()+polyhedNodalConnVTK->getNumberOfTuples();
1162 for(int i=0;i<nb && work2!=endW2;i++)
1165 for(int j=0;j<nb2 && work2!=endW2;j++,work2++)
1166 *work2=permPtr[o2nPtrc[*work2]];
1170 coords=(coords->selectByTupleIdSafe(nr->begin(),nr->end()));
1174 void MEDUMeshMultiLev::appendVertices(const DataArrayInt *verticesToAdd, DataArrayInt *nr)
1176 int nbOfCells(verticesToAdd->getNumberOfTuples());//it is not a bug cells are NORM_POINT1
1177 MEDMeshMultiLev::appendVertices(verticesToAdd,nr);
1178 MCAuto<MEDCoupling1SGTUMesh> elt(MEDCoupling1SGTUMesh::New("",INTERP_KERNEL::NORM_POINT1));
1179 elt->allocateCells(nbOfCells);
1180 for(int i=0;i<nbOfCells;i++)
1182 int pt(verticesToAdd->getIJ(i,0));
1183 elt->insertNextCell(&pt,&pt+1);
1186 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::appendVertices : parts are empty !");
1187 elt->setCoords(_parts[0]->getCoords());
1188 MCAuto<MEDCoupling1GTUMesh> elt2((MEDCoupling1SGTUMesh *)elt); elt2->incrRef();
1189 _parts.push_back(elt2);
1194 MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector<int>& lev):MEDMeshMultiLev(m),_is_internal(true)
1196 initStdFieldOfIntegers(m);
1199 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(m,nbOfNodes,gts,pfls,nbEntities),_is_internal(true)
1201 initStdFieldOfIntegers(m);
1204 MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other):MEDMeshMultiLev(other),_is_internal(true),_face_fam_ids(other._face_fam_ids),_face_num_ids(other._face_num_ids)
1208 void MEDStructuredMeshMultiLev::initStdFieldOfIntegers(const MEDFileStructuredMesh *m)
1210 // ids fields management
1211 const DataArrayInt *tmp(0);
1212 tmp=m->getFamilyFieldAtLevel(0);
1216 _cell_fam_ids=const_cast<DataArrayInt *>(tmp);
1218 tmp=m->getNumberFieldAtLevel(0);
1222 _cell_num_ids=const_cast<DataArrayInt *>(tmp);
1226 tmp=m->getFamilyFieldAtLevel(1);
1230 _node_fam_ids=const_cast<DataArrayInt *>(tmp);
1232 tmp=m->getNumberFieldAtLevel(1);
1236 _node_num_ids=const_cast<DataArrayInt *>(tmp);
1239 tmp=m->getFamilyFieldAtLevel(-1);
1243 _face_fam_ids=const_cast<DataArrayInt *>(tmp);
1245 tmp=m->getNumberFieldAtLevel(-1);
1249 _face_num_ids=const_cast<DataArrayInt *>(tmp);
1253 void MEDStructuredMeshMultiLev::moveFaceToCell() const
1255 const_cast<MEDStructuredMeshMultiLev *>(this)->_cell_fam_ids=_face_fam_ids; const_cast<MEDStructuredMeshMultiLev *>(this)->_face_fam_ids=0;
1256 const_cast<MEDStructuredMeshMultiLev *>(this)->_cell_num_ids=_face_num_ids; const_cast<MEDStructuredMeshMultiLev *>(this)->_face_num_ids=0;
1259 bool MEDStructuredMeshMultiLev::prepareForImplicitUnstructuredMeshCase(MEDMeshMultiLev *&ret) const
1262 if(_geo_types.empty())
1264 if(_geo_types.size()!=1)
1265 throw INTERP_KERNEL::Exception("MEDStructuredMeshMultiLev::prepareForImplicitUnstructuredMeshCase only one geo types supported at most supported for the moment !");
1266 INTERP_KERNEL::NormalizedCellType gt(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(_mesh->getMeshDimension()));
1267 if(_geo_types[0]==gt)
1269 MEDCoupling1GTUMesh *facesIfPresent((static_cast<const MEDFileStructuredMesh *>(_mesh))->getImplicitFaceMesh());
1272 const DataArrayInt *pfl(0),*nr(_node_reduction);
1275 MCAuto<MEDCoupling1GTUMesh> facesIfPresent2(facesIfPresent); facesIfPresent->incrRef();
1277 MCAuto<MEDUMeshMultiLev> ret2(new MEDUMeshMultiLev(*this,facesIfPresent2));
1279 ret2->setCellReduction(pfl);
1281 throw INTERP_KERNEL::Exception("MEDStructuredMeshMultiLev::prepareForImplicitUnstructuredMeshCase : case is not treated yet for node reduction on implicit unstructured mesh.");
1286 void MEDStructuredMeshMultiLev::dealWithImplicitUnstructuredMesh(const MEDFileMesh *m)
1288 const DataArrayInt *tmp(0);
1289 tmp=m->getFamilyFieldAtLevel(-1);
1293 _cell_fam_ids=const_cast<DataArrayInt *>(tmp);
1295 tmp=m->getNumberFieldAtLevel(-1);
1299 _cell_num_ids=const_cast<DataArrayInt *>(tmp);
1303 void MEDStructuredMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes)
1305 if(!pflNodes || !pflNodes->isAllocated())
1307 std::vector<int> ngs(getNodeGridStructure());
1308 MCAuto<DataArrayInt> conn(MEDCouplingStructuredMesh::Build1GTNodalConnectivity(&ngs[0],&ngs[0]+ngs.size()));
1309 MCAuto<MEDCoupling1SGTUMesh> m(MEDCoupling1SGTUMesh::New("",MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(ngs.size())));
1310 m->setNodalConnectivity(conn);
1311 const DataArrayInt *pfl(_pfls[0]);
1314 m=dynamic_cast<MEDCoupling1SGTUMesh *>(m->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
1316 DataArrayInt *cellIds=0;
1317 m->fillCellIdsToKeepFromNodeIds(pflNodes->begin(),pflNodes->end(),true,cellIds);
1318 MCAuto<DataArrayInt> cellIdsSafe(cellIds);
1319 MCAuto<MEDCouplingPointSet> m2(m->buildPartOfMySelfKeepCoords(cellIds->begin(),cellIds->end()));
1321 _node_reduction=m2->getNodeIdsInUse(tmp);
1323 _pfls[0]=pfl->selectByTupleIdSafe(cellIds->begin(),cellIds->end());
1325 _pfls[0]=cellIdsSafe;
1330 MEDCMeshMultiLev *MEDCMeshMultiLev::New(const MEDFileCMesh *m, const std::vector<int>& levs)
1332 return new MEDCMeshMultiLev(m,levs);
1335 MEDCMeshMultiLev *MEDCMeshMultiLev::New(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities)
1337 return new MEDCMeshMultiLev(m,gts,pfls,nbEntities);
1340 MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<int>& levs):MEDStructuredMeshMultiLev(m,levs)
1343 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor : null input pointer !");
1344 if(levs.size()!=1 || levs[0]!=0)
1345 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor : levels supported is 0 only !");
1346 int sdim(m->getSpaceDimension());
1347 _coords.resize(sdim);
1348 for(int i=0;i<sdim;i++)
1350 DataArrayDouble *elt(const_cast<DataArrayDouble *>(m->getMesh()->getCoordsAt(i)));
1352 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : presence of null pointer for an vector of double along an axis !");
1358 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)
1361 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : null input pointer !");
1362 if(gts.size()!=1 || pfls.size()!=1)
1363 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : lengthes of gts and pfls must be equal to one !");
1364 int mdim(m->getMeshDimension());
1365 INTERP_KERNEL::NormalizedCellType gt(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(mdim));
1368 _coords.resize(mdim);
1369 for(int i=0;i<mdim;i++)
1371 DataArrayDouble *elt(const_cast<DataArrayDouble *>(m->getMesh()->getCoordsAt(i)));
1373 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : presence of null pointer for an vector of double along an axis !");
1374 _coords[i]=elt; _coords[i]->incrRef();
1378 dealWithImplicitUnstructuredMesh(m);
1381 MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDCMeshMultiLev& other):MEDStructuredMeshMultiLev(other),_coords(other._coords)
1385 std::vector<int> MEDCMeshMultiLev::getNodeGridStructure() const
1387 std::vector<int> ret(_coords.size());
1388 for(std::size_t i=0;i<_coords.size();i++)
1389 ret[i]=_coords[i]->getNumberOfTuples();
1393 MEDMeshMultiLev *MEDCMeshMultiLev::prepare() const
1395 MEDMeshMultiLev *retSpecific(0);
1396 if(prepareForImplicitUnstructuredMeshCase(retSpecific))
1398 const DataArrayInt *pfl(0),*nr(_node_reduction);
1401 MCAuto<DataArrayInt> nnr;
1402 std::vector<int> cgs,ngs(getNodeGridStructure());
1403 cgs.resize(ngs.size());
1404 std::transform(ngs.begin(),ngs.end(),cgs.begin(),std::bind2nd(std::plus<int>(),-1));
1407 std::vector< std::pair<int,int> > cellParts;
1408 MCAuto<MEDMeshMultiLev> ret2;
1409 if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts))
1411 MCAuto<MEDCMeshMultiLev> ret(new MEDCMeshMultiLev(*this));
1412 ret->_is_internal=false;
1414 { nnr=nr->deepCopy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1415 ret->_nb_entities[0]=pfl->getNumberOfTuples();
1417 std::vector< MCAuto<DataArrayDouble> > coords(_coords.size());
1418 for(std::size_t i=0;i<_coords.size();i++)
1419 coords[i]=_coords[i]->selectByTupleIdSafeSlice(cellParts[i].first,cellParts[i].second+1,1);
1420 ret->_coords=coords;
1421 ret2=(MEDCMeshMultiLev *)ret; ret2->incrRef();
1425 MCAuto<MEDCouplingCMesh> m(MEDCouplingCMesh::New());
1426 for(std::size_t i=0;i<ngs.size();i++)
1427 m->setCoordsAt(i,_coords[i]);
1428 MCAuto<MEDCoupling1SGTUMesh> m2(m->build1SGTUnstructured());
1429 MCAuto<MEDCoupling1GTUMesh> m3=dynamic_cast<MEDCoupling1GTUMesh *>(m2->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
1430 MCAuto<MEDUMeshMultiLev> ret(new MEDUMeshMultiLev(*this,m3));
1432 { m3->zipCoords(); nnr=nr->deepCopy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1433 ret2=(MEDUMeshMultiLev *)ret; ret2->incrRef();
1435 const DataArrayInt *famIds(_cell_fam_ids),*numIds(_cell_num_ids);
1438 MCAuto<DataArrayInt> tmp(famIds->selectByTupleIdSafe(pfl->begin(),pfl->end()));
1439 ret2->setFamilyIdsOnCells(tmp);
1443 MCAuto<DataArrayInt> tmp(numIds->selectByTupleIdSafe(pfl->begin(),pfl->end()));
1444 ret2->setNumberIdsOnCells(tmp);
1451 MCAuto<MEDCMeshMultiLev> ret(new MEDCMeshMultiLev(*this));
1453 { nnr=nr->deepCopy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1459 * \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.
1461 std::vector< DataArrayDouble * > MEDCMeshMultiLev::buildVTUArrays(bool& isInternal) const
1463 isInternal=_is_internal;
1464 std::size_t sz(_coords.size());
1465 std::vector< DataArrayDouble * > ret(sz);
1466 for(std::size_t i=0;i<sz;i++)
1468 ret[i]=const_cast<DataArrayDouble *>((const DataArrayDouble *)_coords[i]);
1476 MEDCurveLinearMeshMultiLev *MEDCurveLinearMeshMultiLev::New(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs)
1478 return new MEDCurveLinearMeshMultiLev(m,levs);
1481 MEDCurveLinearMeshMultiLev *MEDCurveLinearMeshMultiLev::New(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities)
1483 return new MEDCurveLinearMeshMultiLev(m,gts,pfls,nbEntities);
1486 MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs):MEDStructuredMeshMultiLev(m,levs)
1489 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor : null input pointer !");
1490 if(levs.size()!=1 || levs[0]!=0)
1491 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor : levels supported is 0 only !");
1492 DataArrayDouble *coords(const_cast<DataArrayDouble *>(m->getMesh()->getCoords()));
1494 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : no coords set !");
1497 _structure=m->getMesh()->getNodeGridStructure();
1500 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)
1503 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : null input pointer !");
1504 if(gts.size()!=1 || pfls.size()!=1)
1505 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : lengthes of gts and pfls must be equal to one !");
1506 INTERP_KERNEL::NormalizedCellType gt(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(m->getMeshDimension()));
1509 DataArrayDouble *coords(const_cast<DataArrayDouble *>(m->getMesh()->getCoords()));
1511 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : no coords set !");
1514 _structure=m->getMesh()->getNodeGridStructure();
1517 dealWithImplicitUnstructuredMesh(m);
1520 MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDCurveLinearMeshMultiLev& other):MEDStructuredMeshMultiLev(other),_coords(other._coords),_structure(other._structure)
1524 std::vector<int> MEDCurveLinearMeshMultiLev::getNodeGridStructure() const
1529 MEDMeshMultiLev *MEDCurveLinearMeshMultiLev::prepare() const
1531 MEDMeshMultiLev *retSpecific(0);
1532 if(prepareForImplicitUnstructuredMeshCase(retSpecific))
1534 const DataArrayInt *pfl(0),*nr(_node_reduction);
1537 MCAuto<DataArrayInt> nnr;
1538 std::vector<int> cgs,ngs(getNodeGridStructure());
1539 cgs.resize(ngs.size());
1540 std::transform(ngs.begin(),ngs.end(),cgs.begin(),std::bind2nd(std::plus<int>(),-1));
1543 std::vector< std::pair<int,int> > cellParts,nodeParts;
1544 MCAuto<MEDMeshMultiLev> ret2;
1545 if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts))
1547 nodeParts=cellParts;
1548 std::vector<int> st(ngs.size());
1549 for(std::size_t i=0;i<ngs.size();i++)
1551 nodeParts[i].second++;
1552 st[i]=nodeParts[i].second-nodeParts[i].first;
1554 MCAuto<DataArrayInt> p(MEDCouplingStructuredMesh::BuildExplicitIdsFrom(ngs,nodeParts));
1555 MCAuto<MEDCurveLinearMeshMultiLev> ret(new MEDCurveLinearMeshMultiLev(*this));
1556 ret->_is_internal=false;
1558 { nnr=nr->deepCopy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1559 ret->_nb_entities[0]=pfl->getNumberOfTuples();
1561 ret->_coords=_coords->selectByTupleIdSafe(p->begin(),p->end());
1563 ret2=(MEDCurveLinearMeshMultiLev *)ret; ret2->incrRef();
1567 MCAuto<MEDCouplingCurveLinearMesh> m(MEDCouplingCurveLinearMesh::New());
1568 m->setCoords(_coords); m->setNodeGridStructure(&_structure[0],&_structure[0]+_structure.size());
1569 MCAuto<MEDCoupling1SGTUMesh> m2(m->build1SGTUnstructured());
1570 MCAuto<MEDCoupling1GTUMesh> m3=dynamic_cast<MEDCoupling1GTUMesh *>(m2->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
1571 MCAuto<MEDUMeshMultiLev> ret(new MEDUMeshMultiLev(*this,m3));
1573 { m3->zipCoords(); nnr=nr->deepCopy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1574 ret2=(MEDUMeshMultiLev *)ret; ret2->incrRef();
1576 const DataArrayInt *famIds(_cell_fam_ids),*numIds(_cell_num_ids);
1579 MCAuto<DataArrayInt> tmp(famIds->selectByTupleIdSafe(pfl->begin(),pfl->end()));
1580 ret2->setFamilyIdsOnCells(tmp);
1584 MCAuto<DataArrayInt> tmp(numIds->selectByTupleIdSafe(pfl->begin(),pfl->end()));
1585 ret2->setNumberIdsOnCells(tmp);
1591 MCAuto<MEDCurveLinearMeshMultiLev> ret(new MEDCurveLinearMeshMultiLev(*this));
1593 { nnr=nr->deepCopy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1598 void MEDCurveLinearMeshMultiLev::buildVTUArrays(DataArrayDouble *&coords, std::vector<int>& nodeStrct, bool& isInternal) const
1600 isInternal=_is_internal;
1601 nodeStrct=_structure;
1602 const DataArrayDouble *coo(_coords);
1604 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev::buildVTUArrays : null pointer on coordinates !");
1605 coords=const_cast<DataArrayDouble *>(coo); coords->incrRef();
1610 MEDFileField1TSStructItem2::MEDFileField1TSStructItem2()
1614 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)
1616 _pfl->setName(c.c_str());
1619 void MEDFileField1TSStructItem2::checkWithMeshStructForCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
1621 if(!mst->doesManageGeoType(_geo_type))
1623 MEDFileMeshStruct *mstUnConstCasted(const_cast<MEDFileMeshStruct *>(mst));
1624 mstUnConstCasted->appendIfImplicitType(_geo_type);
1626 int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
1627 checkInRange(nbOfEnt,1,globs);
1630 void MEDFileField1TSStructItem2::checkWithMeshStructForGaussNE(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
1632 int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
1633 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1634 checkInRange(nbOfEnt,(int)cm.getNumberOfNodes(),globs);
1637 void MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
1640 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT : no globals specified !");
1642 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT : no localization specified !");
1643 const MEDFileFieldLoc& loc=globs->getLocalization(_loc.c_str());
1644 int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
1645 checkInRange(nbOfEnt,loc.getNumberOfGaussPoints(),globs);
1648 int MEDFileField1TSStructItem2::getNbOfIntegrationPts(const MEDFileFieldGlobsReal *globs) const
1652 if(getPflName().empty())
1653 return (_start_end.second-_start_end.first)/_nb_of_entity;
1655 return (_start_end.second-_start_end.first)/getPfl(globs)->getNumberOfTuples();
1659 const MEDFileFieldLoc& loc(globs->getLocalization(_loc.c_str()));
1660 return loc.getNumberOfGaussPoints();
1664 std::string MEDFileField1TSStructItem2::getPflName() const
1666 return _pfl->getName();
1669 const DataArrayInt *MEDFileField1TSStructItem2::getPfl(const MEDFileFieldGlobsReal *globs) const
1671 if(!_pfl->isAllocated())
1673 if(_pfl->getName().empty())
1676 return globs->getProfile(_pfl->getName().c_str());
1683 * \param [in] nbOfEntity - number of entity that can be either cells or nodes. Not other possiblity.
1684 * \param [in] nip - number of integration points. 1 for ON_CELLS and NO_NODES
1686 void MEDFileField1TSStructItem2::checkInRange(int nbOfEntity, int nip, const MEDFileFieldGlobsReal *globs)
1688 _nb_of_entity=nbOfEntity;
1689 if(_pfl->getName().empty())
1691 if(nbOfEntity!=(_start_end.second-_start_end.first)/nip)
1692 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Mismatch between number of entities and size of field !");
1698 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Presence of a profile on field whereas no globals found in file !");
1699 const DataArrayInt *pfl=globs->getProfile(_pfl->getName().c_str());
1701 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Presence of a profile on field whereas no such profile found in file !");
1702 pfl->checkAllIdsInRange(0,nbOfEntity);
1706 bool MEDFileField1TSStructItem2::isFastlyEqual(int& startExp, INTERP_KERNEL::NormalizedCellType gt, const std::string& pflName) const
1708 if(startExp!=_start_end.first)
1712 if(getPflName()!=pflName)
1714 startExp=_start_end.second;
1718 bool MEDFileField1TSStructItem2::operator==(const MEDFileField1TSStructItem2& other) const
1720 //_nb_of_entity is not taken into account here. It is not a bug, because no mesh consideration needed here to perform fast compare.
1721 //idem for _loc. It is not an effective attribute for support comparison.
1722 return _geo_type==other._geo_type && _start_end==other._start_end && _pfl->getName()==other._pfl->getName();
1725 bool MEDFileField1TSStructItem2::isCellSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const
1727 if(_geo_type!=other._geo_type)
1729 if(_nb_of_entity!=other._nb_of_entity)
1731 if((_pfl->getName().empty() && !other._pfl->getName().empty()) || (!_pfl->getName().empty() && other._pfl->getName().empty()))
1733 if(_pfl->getName().empty() && other._pfl->getName().empty())
1735 const DataArrayInt *pfl1(getPfl(globs)),*pfl2(other.getPfl(globs));
1736 return pfl1->isEqualWithoutConsideringStr(*pfl2);
1739 bool MEDFileField1TSStructItem2::isNodeSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const
1741 return isCellSupportEqual(other,globs);
1745 * \a objs must be non empty. \a objs should contain items having same geometric type.
1747 MEDFileField1TSStructItem2 MEDFileField1TSStructItem2::BuildAggregationOf(const std::vector<const MEDFileField1TSStructItem2 *>& objs, const MEDFileFieldGlobsReal *globs)
1750 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : empty input !");
1752 return MEDFileField1TSStructItem2(*objs[0]);
1753 INTERP_KERNEL::NormalizedCellType gt(objs[0]->_geo_type);
1754 int nbEntityRef(objs[0]->_nb_of_entity);
1755 std::size_t sz(objs.size());
1756 std::vector<const DataArrayInt *> arrs(sz);
1757 for(std::size_t i=0;i<sz;i++)
1759 const MEDFileField1TSStructItem2 *obj(objs[i]);
1760 if(gt!=obj->_geo_type)
1761 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : invalid situation ! All input must have the same geo type !");
1762 if(nbEntityRef!=obj->_nb_of_entity)
1763 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : invalid situation ! All input must have the global nb of entity !");
1764 if(obj->_pfl->getName().empty())
1765 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : invalid situation ! Several same geo type chunk must all lie on profiles !");
1766 arrs[i]=globs->getProfile(obj->_pfl->getName().c_str());
1768 MCAuto<DataArrayInt> arr(DataArrayInt::Aggregate(arrs));
1770 int oldNbTuples(arr->getNumberOfTuples());
1771 arr=arr->buildUnique();
1772 if(oldNbTuples!=arr->getNumberOfTuples())
1773 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : some entities are present several times !");
1774 if(arr->isIota(nbEntityRef))
1776 std::pair<int,int> p(0,nbEntityRef);
1778 MEDFileField1TSStructItem2 ret(gt,p,a,b);
1779 ret._nb_of_entity=nbEntityRef;
1784 arr->setName(NEWLY_CREATED_PFL_NAME);
1785 std::pair<int,int> p(0,oldNbTuples);
1787 MEDFileField1TSStructItem2 ret(gt,p,a,b);
1788 ret._nb_of_entity=nbEntityRef;
1794 std::size_t MEDFileField1TSStructItem2::getHeapMemorySizeWithoutChildren() const
1796 std::size_t ret(_loc.capacity());
1800 std::vector<const BigMemoryObject *> MEDFileField1TSStructItem2::getDirectChildrenWithNull() const
1802 std::vector<const BigMemoryObject *> ret;
1803 ret.push_back((const DataArrayInt *)_pfl);
1809 MEDFileField1TSStructItem::MEDFileField1TSStructItem(TypeOfField a, const std::vector< MEDFileField1TSStructItem2 >& b):_computed(false),_type(a),_items(b)
1813 void MEDFileField1TSStructItem::checkWithMeshStruct(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
1819 int nbOfEnt=mst->getNumberOfNodes();
1820 if(_items.size()!=1)
1821 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::checkWithMeshStruct : for nodes field only one subdivision supported !");
1822 _items[0].checkInRange(nbOfEnt,1,globs);
1827 for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
1828 (*it).checkWithMeshStructForCells(mst,globs);
1833 for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
1834 (*it).checkWithMeshStructForGaussNE(mst,globs);
1839 for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
1840 (*it).checkWithMeshStructForGaussPT(mst,globs);
1844 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::checkWithMeshStruct : not managed field type !");
1848 bool MEDFileField1TSStructItem::operator==(const MEDFileField1TSStructItem& other) const
1850 if(_type!=other._type)
1852 if(_items.size()!=other._items.size())
1854 for(std::size_t i=0;i<_items.size();i++)
1855 if(!(_items[i]==other._items[i]))
1860 bool MEDFileField1TSStructItem::isCellSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const
1862 if(_type!=other._type)
1864 if(_items.size()!=other._items.size())
1866 for(std::size_t i=0;i<_items.size();i++)
1867 if(!(_items[i].isCellSupportEqual(other._items[i],globs)))
1872 bool MEDFileField1TSStructItem::isNodeSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const
1874 if(_type!=other._type)
1876 if(_items.size()!=other._items.size())
1878 for(std::size_t i=0;i<_items.size();i++)
1879 if(!(_items[i].isNodeSupportEqual(other._items[i],globs)))
1884 bool MEDFileField1TSStructItem::isEntityCell() const
1895 CmpGeo(INTERP_KERNEL::NormalizedCellType geoTyp):_geo_type(geoTyp) { }
1896 bool operator()(const std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > & v) const { return _geo_type==v.first; }
1898 INTERP_KERNEL::NormalizedCellType _geo_type;
1901 MEDFileField1TSStructItem MEDFileField1TSStructItem::simplifyMeOnCellEntity(const MEDFileFieldGlobsReal *globs) const
1904 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::simplifyMeOnCellEntity : must be on ON_CELLS, ON_GAUSS_NE or ON_GAUSS_PT !");
1905 std::vector< std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > > m;
1907 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++,i++)
1909 std::vector< std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > >::iterator it0(std::find_if(m.begin(),m.end(),CmpGeo((*it).getGeo())));
1911 m.push_back(std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> >((*it).getGeo(),std::vector<std::size_t>(1,i)));
1913 (*it0).second.push_back(i);
1915 if(m.size()==_items.size())
1917 MEDFileField1TSStructItem ret(*this);
1921 std::size_t sz(m.size());
1922 std::vector< MEDFileField1TSStructItem2 > items(sz);
1925 const std::vector<std::size_t>& ids=m[i].second;
1926 std::vector<const MEDFileField1TSStructItem2 *>objs(ids.size());
1927 for(std::size_t j=0;j<ids.size();j++)
1928 objs[j]=&_items[ids[j]];
1929 items[i]=MEDFileField1TSStructItem2::BuildAggregationOf(objs,globs);
1931 MEDFileField1TSStructItem ret(ON_CELLS,items);
1937 * \a this is expected to be ON_CELLS and simplified.
1939 bool MEDFileField1TSStructItem::isCompatibleWithNodesDiscr(const MEDFileField1TSStructItem& other, const MEDFileMeshStruct *meshSt, const MEDFileFieldGlobsReal *globs) const
1941 if(other._type!=ON_NODES)
1942 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isCompatibleWithNodesDiscr : other must be on nodes !");
1943 if(other._items.size()!=1)
1944 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isCompatibleWithNodesDiscr : other is on nodes but number of subparts !");
1945 int theFirstLevFull;
1946 bool ret0=isFullyOnOneLev(meshSt,theFirstLevFull);
1947 const MEDFileField1TSStructItem2& otherNodeIt(other._items[0]);
1948 int nbOfNodes(meshSt->getNumberOfNodes());
1949 if(otherNodeIt.getPflName().empty())
1953 std::vector<bool> nodesFetched(nbOfNodes,false);
1954 meshSt->getTheMesh()->whichAreNodesFetched(*this,globs,nodesFetched);
1955 if(std::find(nodesFetched.begin(),nodesFetched.end(),false)==nodesFetched.end())
1956 return theFirstLevFull==0;
1962 const DataArrayInt *pfl=globs->getProfile(otherNodeIt.getPflName().c_str());
1963 MCAuto<DataArrayInt> cpyPfl(pfl->deepCopy());
1965 if(cpyPfl->isIota(nbOfNodes))
1966 {//on all nodes also !
1969 return theFirstLevFull==0;
1971 std::vector<bool> nodesFetched(nbOfNodes,false);
1972 meshSt->getTheMesh()->whichAreNodesFetched(*this,globs,nodesFetched);
1973 return cpyPfl->isFittingWith(nodesFetched);
1977 bool MEDFileField1TSStructItem::isFullyOnOneLev(const MEDFileMeshStruct *meshSt, int& theFirstLevFull) const
1980 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : works only for ON_CELLS discretization !");
1982 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : items vector is empty !");
1983 int nbOfLevs(meshSt->getNumberOfLevs());
1985 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : no levels in input mesh structure !");
1986 std::vector<int> levs(nbOfLevs);
1988 std::set<INTERP_KERNEL::NormalizedCellType> gts;
1989 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++)
1991 if(!(*it).getPflName().empty())
1993 INTERP_KERNEL::NormalizedCellType gt((*it).getGeo());
1994 if(gts.find(gt)!=gts.end())
1995 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : internal error !");
1997 int pos(meshSt->getLevelOfGeoType((*it).getGeo()));
2000 for(int i=0;i<nbOfLevs;i++)
2001 if(meshSt->getNumberOfGeoTypesInLev(-i)==levs[i])
2002 { theFirstLevFull=-i; return true; }
2006 const MEDFileField1TSStructItem2& MEDFileField1TSStructItem::operator[](std::size_t i) const
2008 if(i>=_items.size())
2009 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::operator[] : input is not in valid range !");
2013 std::size_t MEDFileField1TSStructItem::getHeapMemorySizeWithoutChildren() const
2015 std::size_t ret(_items.size()*sizeof(MEDFileField1TSStructItem2));
2019 std::vector<const BigMemoryObject *> MEDFileField1TSStructItem::getDirectChildrenWithNull() const
2021 std::vector<const BigMemoryObject *> ret;
2022 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++)
2023 ret.push_back(&(*it));
2027 MEDMeshMultiLev *MEDFileField1TSStructItem::buildFromScratchDataSetSupportOnCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const
2029 std::size_t sz(_items.size());
2030 std::vector<INTERP_KERNEL::NormalizedCellType> a0(sz);
2031 std::vector<const DataArrayInt *> a1(sz);
2032 std::vector<int> a2(sz);
2034 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++,i++)
2036 a0[i]=(*it).getGeo();
2037 a1[i]=(*it).getPfl(globs);
2038 a2[i]=mst->getNumberOfElemsOfGeoType((*it).getGeo());
2040 return MEDMeshMultiLev::New(mst->getTheMesh(),a0,a1,a2);
2043 std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileField1TSStructItem::getGeoTypes(const MEDFileMesh *m) const
2045 std::vector<INTERP_KERNEL::NormalizedCellType> ret;
2048 if(!_items.empty() && _items[0].getPflName().empty())
2051 return m->getAllGeoTypes();
2058 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++)
2060 INTERP_KERNEL::NormalizedCellType elt((*it).getGeo());
2061 std::vector<INTERP_KERNEL::NormalizedCellType>::iterator it2(std::find(ret.begin(),ret.end(),elt));
2068 MEDFileField1TSStructItem MEDFileField1TSStructItem::BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt)
2070 std::vector< MEDFileField1TSStructItem2 > anItems;
2072 std::vector< std::vector<std::string> > pfls,locs;
2073 std::vector< std::vector<TypeOfField> > typesF;
2074 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2075 std::vector< std::vector<std::pair<int,int> > > strtEnds=ref->getFieldSplitedByType(std::string(),geoTypes,typesF,pfls,locs);
2076 std::size_t nbOfGeoTypes(geoTypes.size());
2078 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : not null by empty ref !");
2079 if(typesF[0].empty())
2080 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : internal error #1 bis !");
2081 TypeOfField atype(typesF[0][0]);
2082 for(std::size_t i=0;i<nbOfGeoTypes;i++)
2084 std::size_t sz=typesF[i].size();
2085 if(strtEnds[i].size()<1 || sz<1 || pfls[i].size()<1)
2086 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : internal error #1 !");
2088 for(std::size_t j=0;j<sz;j++)
2090 if(atype==typesF[i][j])
2091 anItems.push_back(MEDFileField1TSStructItem2(geoTypes[i],strtEnds[i][j],pfls[i][j],locs[i][j]));
2093 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : can be applied only on single spatial discretization fields ! Call SplitPerDiscretization method !");
2096 MEDFileField1TSStructItem ret(atype,anItems);
2099 ret.checkWithMeshStruct(meshSt,ref);
2101 catch(INTERP_KERNEL::Exception& e)
2103 std::ostringstream oss; oss << e.what() << " (" << MEDCouplingFieldDiscretization::GetTypeOfFieldRepr(ret.getType()) << ")";
2104 throw INTERP_KERNEL::Exception(oss.str().c_str());
2111 MEDFileField1TSStruct *MEDFileField1TSStruct::New(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst)
2113 return new MEDFileField1TSStruct(ref,mst);
2116 MEDFileField1TSStruct::MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst)
2118 _already_checked.push_back(MEDFileField1TSStructItem::BuildItemFrom(ref,mst));
2121 void MEDFileField1TSStruct::checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
2123 if(_already_checked.empty())
2124 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::checkWithMeshStruct : not correctly initialized !");
2125 _already_checked.back().checkWithMeshStruct(mst,globs);
2128 bool MEDFileField1TSStruct::isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *mst) const
2130 MEDFileField1TSStructItem b(MEDFileField1TSStructItem::BuildItemFrom(other,mst));
2131 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++)
2140 * Not const because \a other structure will be added to the \c _already_checked attribute in case of success.
2142 bool MEDFileField1TSStruct::isSupportSameAs(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt)
2144 if(_already_checked.empty())
2145 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isSupportSameAs : no ref !");
2146 MEDFileField1TSStructItem b(MEDFileField1TSStructItem::BuildItemFrom(other,meshSt));
2147 if(!_already_checked[0].isEntityCell() || !b.isEntityCell())
2148 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isSupportSameAs : only available on cell entities !");
2149 MEDFileField1TSStructItem other1(b.simplifyMeOnCellEntity(other));
2151 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
2152 if((*it).isComputed())
2157 MEDFileField1TSStructItem this1(_already_checked[0].simplifyMeOnCellEntity(other));
2158 ret=this1.isCellSupportEqual(other1,other);
2160 _already_checked.push_back(this1);
2163 ret=_already_checked[found].isCellSupportEqual(other1,other);
2165 _already_checked.push_back(b);
2170 * \param [in] other - a field with only one spatial discretization : ON_NODES.
2172 bool MEDFileField1TSStruct::isCompatibleWithNodesDiscr(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt)
2174 if(_already_checked.empty())
2175 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isCompatibleWithNodesDiscr : no ref !");
2176 MEDFileField1TSStructItem other1(MEDFileField1TSStructItem::BuildItemFrom(other,meshSt));
2177 if(_already_checked[0].isEntityCell())
2180 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
2181 if((*it).isComputed())
2186 MEDFileField1TSStructItem this1(_already_checked[0].simplifyMeOnCellEntity(other));
2187 ret=this1.isCompatibleWithNodesDiscr(other1,meshSt,other);
2189 _already_checked.push_back(this1);
2192 ret=_already_checked[found].isCompatibleWithNodesDiscr(other1,meshSt,other);
2194 _already_checked.push_back(other1);
2198 return _already_checked[0].isNodeSupportEqual(other1,other);
2201 std::size_t MEDFileField1TSStruct::getHeapMemorySizeWithoutChildren() const
2203 std::size_t ret(_already_checked.capacity()*sizeof(MEDFileField1TSStructItem));
2207 std::vector<const BigMemoryObject *> MEDFileField1TSStruct::getDirectChildrenWithNull() const
2209 std::vector<const BigMemoryObject *> ret;
2210 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++)
2211 ret.push_back(&(*it));
2215 MEDMeshMultiLev *MEDFileField1TSStruct::buildFromScratchDataSetSupport(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const
2217 if(_already_checked.empty())
2218 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::buildFromScratchDataSetSupport : No outline structure in this !");
2219 int pos0(-1),pos1(-1);
2220 if(presenceOfCellDiscr(pos0))
2222 MCAuto<MEDMeshMultiLev> ret(_already_checked[pos0].buildFromScratchDataSetSupportOnCells(mst,globs));
2223 if(presenceOfPartialNodeDiscr(pos1))
2224 ret->setNodeReduction(_already_checked[pos1][0].getPfl(globs));
2229 if(!presenceOfPartialNodeDiscr(pos1))
2230 {//we have only all nodes, no cell definition info -> all existing levels !;
2231 return MEDMeshMultiLev::New(mst->getTheMesh(),mst->getTheMesh()->getNonEmptyLevels());
2234 return MEDMeshMultiLev::NewOnlyOnNode(mst->getTheMesh(),_already_checked[pos1][0].getPfl(globs));
2238 bool MEDFileField1TSStruct::isDataSetSupportFastlyEqualTo(const MEDFileField1TSStruct& other, const MEDFileFieldGlobsReal *globs) const
2241 bool a0(presenceOfCellDiscr(b0)),a1(presenceOfPartialNodeDiscr(b1));
2243 bool c0(other.presenceOfCellDiscr(d0)),c1(other.presenceOfPartialNodeDiscr(d1));
2244 if(a0!=c0 || a1!=c1)
2247 if(!_already_checked[b0].isCellSupportEqual(other._already_checked[d0],globs))
2250 if(!_already_checked[b1].isNodeSupportEqual(other._already_checked[d1],globs))
2255 std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileField1TSStruct::getGeoTypes(const MEDFileMesh *m) const
2257 std::vector<INTERP_KERNEL::NormalizedCellType> ret;
2258 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++)
2260 std::vector<INTERP_KERNEL::NormalizedCellType> ret2((*it).getGeoTypes(m));
2261 for(std::vector<INTERP_KERNEL::NormalizedCellType>::const_iterator it2=ret2.begin();it2!=ret2.end();it2++)
2263 if(*it2==INTERP_KERNEL::NORM_ERROR)
2265 std::vector<INTERP_KERNEL::NormalizedCellType>::iterator it3(std::find(ret.begin(),ret.end(),*it2));
2267 ret.push_back(*it2);
2274 * Returns true if presence in \a this of discretization ON_CELLS, ON_GAUSS_PT, ON_GAUSS_NE.
2275 * 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.
2277 bool MEDFileField1TSStruct::presenceOfCellDiscr(int& pos) const
2279 std::size_t refSz(std::numeric_limits<std::size_t>::max());
2282 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
2284 if((*it).getType()!=ON_NODES)
2287 std::size_t sz((*it).getNumberOfItems());
2289 { pos=i; refSz=sz; }
2293 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::presenceOfCellDiscr : an element in this on entity CELL is empty !");
2298 * Returns true if presence in \a this of discretization ON_NODES.
2299 * If true is returned the pos of the first element containing the single subpart.
2301 bool MEDFileField1TSStruct::presenceOfPartialNodeDiscr(int& pos) const
2304 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
2306 if((*it).getType()==ON_NODES)
2308 std::size_t sz((*it).getNumberOfItems());
2311 if(!(*it)[0].getPflName().empty())
2312 { pos=i; return true; }
2315 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::presenceOfPartialNodeDiscr : an element in this on entity NODE is split into several parts !");
2323 MEDFileFastCellSupportComparator *MEDFileFastCellSupportComparator::New(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref)
2325 return new MEDFileFastCellSupportComparator(m,ref);
2328 MEDFileFastCellSupportComparator::MEDFileFastCellSupportComparator(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref)
2331 throw INTERP_KERNEL::Exception("MEDFileFastCellSupportComparator constructor : null input mesh struct !");
2332 _mesh_comp=const_cast<MEDFileMeshStruct *>(m); _mesh_comp->incrRef();
2333 int nbPts=ref->getNumberOfTS();
2334 _f1ts_cmps.resize(nbPts);
2335 for(int i=0;i<nbPts;i++)
2337 MCAuto<MEDFileAnyTypeField1TS> elt=ref->getTimeStepAtPos(i);
2340 _f1ts_cmps[i]=MEDFileField1TSStruct::New(elt,_mesh_comp);
2341 _f1ts_cmps[i]->checkWithMeshStruct(_mesh_comp,elt);
2343 catch(INTERP_KERNEL::Exception& e)
2345 std::ostringstream oss; oss << "Problem in field with name \"" << ref->getName() << "\"" << std::endl;
2346 oss << "More Details : " << e.what();
2347 throw INTERP_KERNEL::Exception(oss.str().c_str());
2352 std::size_t MEDFileFastCellSupportComparator::getHeapMemorySizeWithoutChildren() const
2354 std::size_t ret(_f1ts_cmps.capacity()*sizeof(MCAuto<MEDFileField1TSStruct>));
2358 std::vector<const BigMemoryObject *> MEDFileFastCellSupportComparator::getDirectChildrenWithNull() const
2360 std::vector<const BigMemoryObject *> ret;
2361 const MEDFileMeshStruct *mst(_mesh_comp);
2364 for(std::vector< MCAuto<MEDFileField1TSStruct> >::const_iterator it=_f1ts_cmps.begin();it!=_f1ts_cmps.end();it++)
2365 ret.push_back((const MEDFileField1TSStruct *)*it);
2369 bool MEDFileFastCellSupportComparator::isEqual(const MEDFileAnyTypeFieldMultiTS *other)
2371 int nbPts=other->getNumberOfTS();
2372 if(nbPts!=(int)_f1ts_cmps.size())
2374 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isEqual : unexpected nb of time steps in input ! Should be " << _f1ts_cmps.size() << " it is in reality " << nbPts << " !";
2375 throw INTERP_KERNEL::Exception(oss.str().c_str());
2377 for(int i=0;i<nbPts;i++)
2379 MCAuto<MEDFileAnyTypeField1TS> elt=other->getTimeStepAtPos(i);
2380 if(!_f1ts_cmps[i]->isEqualConsideringThePast(elt,_mesh_comp))
2381 if(!_f1ts_cmps[i]->isSupportSameAs(elt,_mesh_comp))
2387 bool MEDFileFastCellSupportComparator::isCompatibleWithNodesDiscr(const MEDFileAnyTypeFieldMultiTS *other)
2389 int nbPts=other->getNumberOfTS();
2390 if(nbPts!=(int)_f1ts_cmps.size())
2392 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isCompatibleWithNodesDiscr : unexpected nb of time steps in input ! Should be " << _f1ts_cmps.size() << " it is in reality " << nbPts << " !";
2393 throw INTERP_KERNEL::Exception(oss.str().c_str());
2395 for(int i=0;i<nbPts;i++)
2397 MCAuto<MEDFileAnyTypeField1TS> elt=other->getTimeStepAtPos(i);
2398 if(!_f1ts_cmps[i]->isCompatibleWithNodesDiscr(elt,_mesh_comp))
2404 MEDMeshMultiLev *MEDFileFastCellSupportComparator::buildFromScratchDataSetSupport(int timeStepId, const MEDFileFieldGlobsReal *globs) const
2406 if(timeStepId<0 || timeStepId>=(int)_f1ts_cmps.size())
2408 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::buildFromScratchDataSetSupport : requested time step id #" << timeStepId << " is not in [0," << _f1ts_cmps.size() << ") !";
2409 throw INTERP_KERNEL::Exception(oss.str().c_str());
2411 const MEDFileField1TSStruct *obj(_f1ts_cmps[timeStepId]);
2414 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::buildFromScratchDataSetSupport : at time step id #" << timeStepId << " no field structure overview defined !";
2415 throw INTERP_KERNEL::Exception(oss.str().c_str());
2417 return obj->buildFromScratchDataSetSupport(_mesh_comp,globs);
2420 bool MEDFileFastCellSupportComparator::isDataSetSupportEqualToThePreviousOne(int timeStepId, const MEDFileFieldGlobsReal *globs) const
2422 if(timeStepId<=0 || timeStepId>=(int)_f1ts_cmps.size())
2424 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isDataSetSupportEqualToThePreviousOne : requested time step id #" << timeStepId << " is not in [1," << _f1ts_cmps.size() << ") !";
2425 throw INTERP_KERNEL::Exception(oss.str().c_str());
2427 const MEDFileField1TSStruct *obj(_f1ts_cmps[timeStepId]);
2428 const MEDFileField1TSStruct *objRef(_f1ts_cmps[timeStepId-1]);
2429 return objRef->isDataSetSupportFastlyEqualTo(*obj,globs);
2432 int MEDFileFastCellSupportComparator::getNumberOfTS() const
2434 return _f1ts_cmps.size();
2437 std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileFastCellSupportComparator::getGeoTypesAt(int timeStepId, const MEDFileMesh *m) const
2439 if(timeStepId<0 || timeStepId>=(int)_f1ts_cmps.size())
2441 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::getGeoTypesAt : requested time step id #" << timeStepId << " is not in [0," << _f1ts_cmps.size() << ") !";
2442 throw INTERP_KERNEL::Exception(oss.str().c_str());
2444 const MEDFileField1TSStruct *elt(_f1ts_cmps[timeStepId]);
2447 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::getGeoTypesAt : requested time step id #" << timeStepId << " points to a NULL pointer !";
2448 throw INTERP_KERNEL::Exception(oss.str().c_str());
2450 return elt->getGeoTypes(m);