1 // Copyright (C) 2007-2014 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 "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 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};
34 const char MEDFileField1TSStructItem2::NEWLY_CREATED_PFL_NAME[]="???";
36 MEDFileMeshStruct *MEDFileMeshStruct::New(const MEDFileMesh *mesh)
38 return new MEDFileMeshStruct(mesh);
41 std::size_t MEDFileMeshStruct::getHeapMemorySizeWithoutChildren() const
44 for(std::vector< std::vector<int> >::const_iterator it0=_geo_types_distrib.begin();it0!=_geo_types_distrib.end();it0++)
45 ret+=(*it0).capacity()*sizeof(int);
46 ret+=_geo_types_distrib.capacity()*sizeof(std::vector<int>);
50 std::vector<const BigMemoryObject *> MEDFileMeshStruct::getDirectChildrenWithNull() const
52 return std::vector<const BigMemoryObject *>();
55 MEDFileMeshStruct::MEDFileMeshStruct(const MEDFileMesh *mesh):_mesh(mesh)
57 std::vector<int> levs(mesh->getNonEmptyLevels());
58 _name=mesh->getName();
59 _nb_nodes=mesh->getNumberOfNodes();
62 _geo_types_distrib.resize(-(*std::min_element(levs.begin(),levs.end()))+1);
63 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
64 _geo_types_distrib[-(*lev)]=mesh->getDistributionOfTypes(*lev);
68 int MEDFileMeshStruct::getLevelOfGeoType(INTERP_KERNEL::NormalizedCellType t) const
71 for(std::vector< std::vector<int> >::const_iterator it1=_geo_types_distrib.begin();it1!=_geo_types_distrib.end();it1++,j--)
73 std::size_t sz=(*it1).size();
75 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getLevelOfGeoType : internal error in code !");
76 std::size_t nbGeo=sz/3;
77 for(std::size_t i=0;i<nbGeo;i++)
78 if((*it1)[3*i]==(int)t)
81 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getLevelOfGeoType : The specified geometric type is not present in the mesh structure !");
85 * \sa MEDFileMeshStruct::doesManageGeoType
87 int MEDFileMeshStruct::getNumberOfElemsOfGeoType(INTERP_KERNEL::NormalizedCellType t) const
89 for(std::vector< std::vector<int> >::const_iterator it1=_geo_types_distrib.begin();it1!=_geo_types_distrib.end();it1++)
91 std::size_t sz=(*it1).size();
93 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfElemsOfGeoType : internal error in code !");
94 std::size_t nbGeo=sz/3;
95 for(std::size_t i=0;i<nbGeo;i++)
96 if((*it1)[3*i]==(int)t)
99 throw INTERP_KERNEL::Exception("The specified geometric type is not present in the mesh structure !");
103 * \sa MEDFileMeshStruct::getNumberOfElemsOfGeoType
105 bool MEDFileMeshStruct::doesManageGeoType(INTERP_KERNEL::NormalizedCellType t) const
107 for(std::vector< std::vector<int> >::const_iterator it1=_geo_types_distrib.begin();it1!=_geo_types_distrib.end();it1++)
109 std::size_t sz=(*it1).size();
111 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::doesManageGeoType : internal error in code !");
112 std::size_t nbGeo=sz/3;
113 for(std::size_t i=0;i<nbGeo;i++)
114 if((*it1)[3*i]==(int)t)
120 void MEDFileMeshStruct::appendIfImplicitType(INTERP_KERNEL::NormalizedCellType t)
122 if(!_mesh->hasImplicitPart())
123 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::appendIfImplicitType : by default no implicit geo type can be appended !");
124 static const char MSG[]="MEDFileMeshStruct::appendIfImplicitType : the distribution does not looks like structured standard !";
125 if(_geo_types_distrib.size()!=1)
126 throw INTERP_KERNEL::Exception(MSG);
127 std::size_t sz(_geo_types_distrib[0].size());
129 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::appendIfImplicitType : internal error in code !");
130 std::size_t nbGeo(sz/3);
132 throw INTERP_KERNEL::Exception(MSG);
133 std::vector<int> arr(3); arr[0]=(int)t; arr[1]=_mesh->buildImplicitPartIfAny(t); arr[2]=-1;
134 _geo_types_distrib.push_back(arr);
138 int MEDFileMeshStruct::getNumberOfLevs() const
140 return (int)_geo_types_distrib.size();
143 int MEDFileMeshStruct::getNumberOfGeoTypesInLev(int relativeLev) const
145 int pos(-relativeLev);
146 if(pos<0 || pos>=(int)_geo_types_distrib.size())
147 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfGeoTypesInLev : invalid level specified !");
148 std::size_t sz=_geo_types_distrib[pos].size();
150 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfGeoTypesInLev : internal error in code !");
156 std::size_t MEDMeshMultiLev::getHeapMemorySizeWithoutChildren() const
161 std::vector<const BigMemoryObject *> MEDMeshMultiLev::getDirectChildrenWithNull() const
163 return std::vector<const BigMemoryObject *>();
166 MEDMeshMultiLev *MEDMeshMultiLev::New(const MEDFileMesh *m, const std::vector<int>& levs)
169 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New : null input pointer !");
170 const MEDFileUMesh *um(dynamic_cast<const MEDFileUMesh *>(m));
172 return MEDUMeshMultiLev::New(um,levs);
173 const MEDFileCMesh *cm(dynamic_cast<const MEDFileCMesh *>(m));
175 return MEDCMeshMultiLev::New(cm,levs);
176 const MEDFileCurveLinearMesh *clm(dynamic_cast<const MEDFileCurveLinearMesh *>(m));
178 return MEDCurveLinearMeshMultiLev::New(clm,levs);
179 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New : unrecognized type of mesh ! Must be in [MEDFileUMesh,MEDFileCMesh,MEDFileCurveLinearMesh] !");
182 MEDMeshMultiLev *MEDMeshMultiLev::New(const MEDFileMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities)
185 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New 2 : null input pointer !");
186 const MEDFileUMesh *um(dynamic_cast<const MEDFileUMesh *>(m));
188 return MEDUMeshMultiLev::New(um,gts,pfls,nbEntities);
189 const MEDFileCMesh *cm(dynamic_cast<const MEDFileCMesh *>(m));
191 return MEDCMeshMultiLev::New(cm,gts,pfls,nbEntities);
192 const MEDFileCurveLinearMesh *clm(dynamic_cast<const MEDFileCurveLinearMesh *>(m));
194 return MEDCurveLinearMeshMultiLev::New(clm,gts,pfls,nbEntities);
195 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New 2 : unrecognized type of mesh ! Must be in [MEDFileUMesh,MEDFileCMesh,MEDFileCurveLinearMesh] !");
198 MEDMeshMultiLev *MEDMeshMultiLev::NewOnlyOnNode(const MEDFileMesh *m, const DataArrayInt *pflOnNode)
200 MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> ret(MEDMeshMultiLev::New(m,m->getNonEmptyLevels()));
201 ret->selectPartOfNodes(pflOnNode);
205 void MEDMeshMultiLev::setNodeReduction(const DataArrayInt *nr)
209 _node_reduction=const_cast<DataArrayInt*>(nr);
212 void MEDMeshMultiLev::setCellReduction(const DataArrayInt *cr)
215 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::setCellReduction : can be used only for single geo type mesh !");
216 _pfls[0]=const_cast<DataArrayInt*>(cr);
221 bool MEDMeshMultiLev::isFastlyTheSameStruct(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs) const
223 if(fst.getType()==ON_NODES)
225 if(fst.getNumberOfItems()!=1)
226 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::isFastlyTheSameStruct : unexpected situation for nodes !");
227 const MEDFileField1TSStructItem2& p(fst[0]);
228 std::string pflName(p.getPflName());
229 const DataArrayInt *nr(_node_reduction);
230 if(pflName.empty() && !nr)
232 if(!pflName.empty() && !nr)
234 if(pflName==nr->getName())
240 std::size_t sz(fst.getNumberOfItems());
241 if(sz!=_geo_types.size())
244 for(std::size_t i=0;i<sz;i++)
246 const MEDFileField1TSStructItem2& p(fst[i]);
247 if(!p.isFastlyEqual(strt,_geo_types[i],getPflNameOfId(i).c_str()))
254 DataArray *MEDMeshMultiLev::buildDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const
256 MEDCouplingAutoRefCountObjectPtr<DataArray> ret(const_cast<DataArray *>(vals)); ret->incrRef();
257 if(isFastlyTheSameStruct(fst,globs))
260 return constructDataArray(fst,globs,vals);
264 * \param [out] famIds - Can be null. If not null the instance has to be dealt by the caller (decrRef).
265 * \param [out] isWithoutCopy - When true the returned instance \a famIds if not null is directly those in the data structure.
267 void MEDMeshMultiLev::retrieveFamilyIdsOnCells(DataArrayInt *& famIds, bool& isWithoutCopy) const
269 const DataArrayInt *fids(_cell_fam_ids);
271 { famIds=0; isWithoutCopy=true; return ; }
272 std::size_t sz(_geo_types.size());
273 bool presenceOfPfls(false);
274 for(std::size_t i=0;i<sz && !presenceOfPfls;i++)
276 const DataArrayInt *pfl(_pfls[i]);
281 { famIds=const_cast<DataArrayInt *>(fids); famIds->incrRef(); isWithoutCopy=_mesh->isObjectInTheProgeny(famIds); return ; }
282 //bad luck the slowest part
284 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > retSafe(sz);
285 std::vector< const DataArrayInt *> ret(sz);
287 for(std::size_t i=0;i<sz;i++)
289 const DataArrayInt *pfl(_pfls[i]);
290 int lgth(_nb_entities[i]);
293 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(fids->selectByTupleId2(start,start+lgth,1));
294 retSafe[i]=tmp->selectByTupleIdSafe(pfl->begin(),pfl->end());
298 retSafe[i]=fids->selectByTupleId2(start,start+lgth,1);
303 famIds=DataArrayInt::Aggregate(ret);
307 * \param [out] numIds - Can be null. If not null the instance has to be dealt by the caller (decrRef).
308 * \param [out] isWithoutCopy - When true the returned instance \a numIds if not null is directly those in the data structure.
310 void MEDMeshMultiLev::retrieveNumberIdsOnCells(DataArrayInt *& numIds, bool& isWithoutCopy) const
312 const DataArrayInt *nids(_cell_num_ids);
314 { numIds=0; isWithoutCopy=true; return ; }
315 std::size_t sz(_geo_types.size());
316 bool presenceOfPfls(false);
317 for(std::size_t i=0;i<sz && !presenceOfPfls;i++)
319 const DataArrayInt *pfl(_pfls[i]);
324 { numIds=const_cast<DataArrayInt *>(nids); numIds->incrRef(); isWithoutCopy=_mesh->isObjectInTheProgeny(numIds); return ; }
325 //bad luck the slowest part
327 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > retSafe(sz);
328 std::vector< const DataArrayInt *> ret(sz);
330 for(std::size_t i=0;i<sz;i++)
332 const DataArrayInt *pfl(_pfls[i]);
333 int lgth(_nb_entities[i]);
336 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(nids->selectByTupleId2(start,start+lgth,1));
337 retSafe[i]=tmp->selectByTupleIdSafe(pfl->begin(),pfl->end());
341 retSafe[i]=nids->selectByTupleId2(start,start+lgth,1);
346 numIds=DataArrayInt::Aggregate(ret);
350 * \param [out] famIds - Can be null. If not null the instance has to be dealt by the caller (decrRef).
351 * \param [out] isWithoutCopy - When true the returned instance \a famIds if not null is directly those in the data structure.
353 void MEDMeshMultiLev::retrieveFamilyIdsOnNodes(DataArrayInt *& famIds, bool& isWithoutCopy) const
355 const DataArrayInt *fids(_node_fam_ids);
357 { famIds=0; isWithoutCopy=true; return ; }
358 const DataArrayInt *nr(_node_reduction);
362 famIds=fids->selectByTupleIdSafe(nr->begin(),nr->end());
366 famIds=const_cast<DataArrayInt *>(fids); famIds->incrRef();
367 isWithoutCopy=_mesh->isObjectInTheProgeny(famIds);
372 * \param [out] numIds - Can be null. If not null the instance has to be dealt by the caller (decrRef).
373 * \param [out] isWithoutCopy - When true the returned instance \a numIds if not null is directly those in the data structure.
375 void MEDMeshMultiLev::retrieveNumberIdsOnNodes(DataArrayInt *& numIds, bool& isWithoutCopy) const
377 const DataArrayInt *fids(_node_num_ids);
379 { numIds=0; isWithoutCopy=true; return ; }
380 const DataArrayInt *nr(_node_reduction);
384 numIds=fids->selectByTupleIdSafe(nr->begin(),nr->end());
388 numIds=const_cast<DataArrayInt *>(fids); numIds->incrRef();
389 isWithoutCopy=_mesh->isObjectInTheProgeny(numIds);
393 std::vector< INTERP_KERNEL::NormalizedCellType > MEDMeshMultiLev::getGeoTypes() const
398 void MEDMeshMultiLev::setFamilyIdsOnCells(DataArrayInt *famIds)
400 _cell_fam_ids=famIds;
405 void MEDMeshMultiLev::setNumberIdsOnCells(DataArrayInt *numIds)
407 _cell_num_ids=numIds;
412 void MEDMeshMultiLev::setFamilyIdsOnNodes(DataArrayInt *famIds)
414 _node_fam_ids=famIds;
419 void MEDMeshMultiLev::setNumberIdsOnNodes(DataArrayInt *numIds)
421 _node_num_ids=numIds;
426 std::string MEDMeshMultiLev::getPflNameOfId(int id) const
428 std::size_t sz(_pfls.size());
429 if(id<0 || id>=(int)sz)
430 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::getPflNameOfId : invalid input id !");
431 const DataArrayInt *pfl(_pfls[id]);
433 return std::string("");
434 return pfl->getName();
438 * Returns the number of cells having geometric type \a t.
439 * The profiles are **NOT** taken into account here.
441 int MEDMeshMultiLev::getNumberOfCells(INTERP_KERNEL::NormalizedCellType t) const
443 std::size_t sz(_nb_entities.size());
444 for(std::size_t i=0;i<sz;i++)
446 return _nb_entities[i];
447 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::getNumberOfCells : not existing geometric type in this !");
450 int MEDMeshMultiLev::getNumberOfNodes() const
455 DataArray *MEDMeshMultiLev::constructDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const
457 if(fst.getType()==ON_NODES)
459 if(fst.getNumberOfItems()!=1)
460 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes !");
461 const MEDFileField1TSStructItem2& p(fst[0]);
462 std::string pflName(p.getPflName());
463 const DataArrayInt *nr(_node_reduction);
464 if(pflName.empty() && !nr)
465 return vals->deepCpy();
466 if(pflName.empty() && nr)
467 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 2 !");
468 if(!pflName.empty() && nr)
470 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(globs->getProfile(pflName.c_str())->deepCpy());
471 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p2(nr->deepCpy());
472 p1->sort(true); p2->sort(true);
473 if(!p1->isEqualWithoutConsideringStr(*p2))
474 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : it appears that a profile on nodes does not cover the cells correctly !");
475 p1=DataArrayInt::FindPermutationFromFirstToSecond(globs->getProfile(pflName.c_str()),nr);
476 MEDCouplingAutoRefCountObjectPtr<DataArray> ret(vals->deepCpy());
477 ret->renumberInPlace(p1->begin());
480 if(!pflName.empty() && !nr)
482 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(globs->getProfile(pflName.c_str())->deepCpy());
484 if(!p1->isIdentity() || p1->getNumberOfTuples()!=getNumberOfNodes())
485 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 4 !");
486 MEDCouplingAutoRefCountObjectPtr<DataArray> ret(vals->deepCpy());
487 ret->renumberInPlace(globs->getProfile(pflName.c_str())->begin());
490 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 5 !");
494 std::size_t sz(fst.getNumberOfItems());
495 std::set<INTERP_KERNEL::NormalizedCellType> s(_geo_types.begin(),_geo_types.end());
496 if(s.size()!=_geo_types.size())
497 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 2 !");
498 std::vector< const DataArray *> arr(s.size());
499 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArray> > arrSafe(s.size());
501 int nc(vals->getNumberOfComponents());
502 std::vector<std::string> compInfo(vals->getInfoOnComponents());
503 for(std::vector< INTERP_KERNEL::NormalizedCellType >::const_iterator it=_geo_types.begin();it!=_geo_types.end();it++,iii++)
505 const DataArrayInt *thisP(_pfls[iii]);
506 std::vector<const MEDFileField1TSStructItem2 *> ps;
507 for(std::size_t i=0;i<sz;i++)
509 const MEDFileField1TSStructItem2& p(fst[i]);
514 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 1 !");
517 int nbi(ps[0]->getNbOfIntegrationPts(globs));
518 const DataArrayInt *otherP(ps[0]->getPfl(globs));
519 const std::pair<int,int>& strtStop(ps[0]->getStartStop());
520 MEDCouplingAutoRefCountObjectPtr<DataArray> ret(vals->selectByTupleId2(strtStop.first,strtStop.second,1));
521 if(!thisP && !otherP)
523 arrSafe[iii]=ret; arr[iii]=ret;
528 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(otherP->invertArrayN2O2O2N(getNumberOfCells(ps[0]->getGeo())));
529 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p2(thisP->deepCpy());
530 p2->transformWithIndArr(p1->begin(),p1->end());
531 //p1=p2->getIdsNotEqual(-1);
532 //p1=p2->selectByTupleIdSafe(p1->begin(),p1->end());
533 ret->rearrange(nbi*nc); ret=ret->selectByTupleIdSafe(p2->begin(),p2->end()); ret->rearrange(nc); ret->setInfoOnComponents(compInfo);
534 arrSafe[iii]=ret; arr[iii]=ret;
539 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(otherP->deepCpy());
541 p1->checkAllIdsInRange(0,getNumberOfCells(ps[0]->getGeo()));
542 p1=DataArrayInt::FindPermutationFromFirstToSecond(otherP,p1);
543 ret->rearrange(nbi*nc); ret->renumberInPlace(p1->begin()); ret->rearrange(nc); ret->setInfoOnComponents(compInfo);
544 arrSafe[iii]=ret; arr[iii]=ret;
547 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 3 !");
551 std::vector< const DataArrayInt * >otherPS(ps.size());
552 std::vector< const DataArray * > arr2(ps.size());
553 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArray> > arr2Safe(ps.size());
554 std::vector< const DataArrayInt * > nbis(ps.size());
555 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > nbisSafe(ps.size());
557 for(std::vector<const MEDFileField1TSStructItem2 *>::const_iterator it2=ps.begin();it2!=ps.end();it2++,jj++)
559 int nbi((*it2)->getNbOfIntegrationPts(globs));
560 const DataArrayInt *otherPfl((*it2)->getPfl(globs));
561 const std::pair<int,int>& strtStop((*it2)->getStartStop());
562 MEDCouplingAutoRefCountObjectPtr<DataArray> ret2(vals->selectByTupleId2(strtStop.first,strtStop.second,1));
564 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 4 !");
565 arr2[jj]=ret2; arr2Safe[jj]=ret2; otherPS[jj]=otherPfl;
566 nbisSafe[jj]=DataArrayInt::New(); nbisSafe[jj]->alloc(otherPfl->getNumberOfTuples(),1); nbisSafe[jj]->fillWithValue(nbi);
567 nbis[jj]=nbisSafe[jj];
569 MEDCouplingAutoRefCountObjectPtr<DataArray> arr3(DataArray::Aggregate(arr2));
570 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> otherP(DataArrayInt::Aggregate(otherPS));
571 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> zenbis(DataArrayInt::Aggregate(nbis));
572 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> otherPN(otherP->invertArrayN2O2O2N(getNumberOfCells(*it)));
573 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1;
575 p1=DataArrayInt::FindPermutationFromFirstToSecond(otherP,thisP);
577 p1=otherP->deepCpy();
578 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> zenbisN(zenbis->renumber(p1->begin()));
579 zenbisN->computeOffsets2();
581 for(std::vector<const MEDFileField1TSStructItem2 *>::const_iterator it2=ps.begin();it2!=ps.end();it2++,jj++)
583 //int nbi((*it2)->getNbOfIntegrationPts(globs));
584 const DataArrayInt *otherPfl((*it2)->getPfl(globs));
585 const std::pair<int,int>& strtStop((*it2)->getStartStop());
586 MEDCouplingAutoRefCountObjectPtr<DataArray> ret2(vals->selectByTupleId2(strtStop.first,strtStop.second,1));
588 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p2(otherPfl->deepCpy());
589 p2->transformWithIndArr(otherPN->begin(),otherPN->end());
590 p2->transformWithIndArr(p1->begin(),p1->end());
591 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsN(p2->buildExplicitArrByRanges(zenbisN));
592 arr3->setPartOfValuesBase3(ret2,idsN->begin(),idsN->end(),0,nc,1);
594 arrSafe[iii]=arr3; arr[iii]=arr3;
598 return DataArray::Aggregate(arr);
603 * This method is called to add NORM_POINT1 cells in \a this so that orphan nodes in \a verticesToAdd will be fetched.
605 void MEDMeshMultiLev::appendVertices(const DataArrayInt *verticesToAdd, DataArrayInt *nr)
607 int nbOfVertices(verticesToAdd->getNumberOfTuples());
608 std::size_t sz(_pfls.size());
610 _geo_types.resize(sz+1,INTERP_KERNEL::NORM_POINT1);
611 _nb_entities.resize(sz+1,nbOfVertices);
612 _node_reduction=nr; nr->incrRef();
613 _nb_nodes+=nbOfVertices;
614 const DataArrayInt *cf(_cell_fam_ids),*cn(_cell_num_ids),*nf(_node_fam_ids),*nn(_node_num_ids);
617 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp;
618 std::vector<const DataArrayInt *> a(2);
621 tmp=nf->selectByTupleIdSafe(verticesToAdd->begin(),verticesToAdd->end());
624 tmp=DataArrayInt::New(); tmp->alloc(nbOfVertices,1); tmp->fillWithZero();
627 _cell_fam_ids=DataArrayInt::Aggregate(a);
631 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp;
632 std::vector<const DataArrayInt *> a(2);
635 tmp=nn->selectByTupleIdSafe(verticesToAdd->begin(),verticesToAdd->end());
638 tmp=DataArrayInt::New(); tmp->alloc(nbOfVertices,1); tmp->fillWithZero();
641 _cell_num_ids=DataArrayInt::Aggregate(a);
645 MEDMeshMultiLev::MEDMeshMultiLev(const MEDFileMesh *mesh):_mesh(mesh),_nb_nodes(0)
649 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)
651 std::size_t sz(_geo_types.size());
652 if(sz!=pfls.size() || sz!=nbEntities.size())
653 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::MEDMeshMultiLev : input vector must have the same size !");
655 for(std::size_t i=0;i<sz;i++)
659 _pfls[i]=const_cast<DataArrayInt *>(pfls[i]);
663 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)
669 MEDUMeshMultiLev *MEDUMeshMultiLev::New(const MEDFileUMesh *m, const std::vector<int>& levs)
671 return new MEDUMeshMultiLev(m,levs);
674 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<int>& levs):MEDMeshMultiLev(m)
677 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev constructor : null input pointer !");
678 std::vector<MEDCoupling1GTUMesh *> v;
679 for(std::vector<int>::const_iterator it=levs.begin();it!=levs.end();it++)
681 std::vector<MEDCoupling1GTUMesh *> vTmp(m->getDirectUndergroundSingleGeoTypeMeshes(*it));
682 v.insert(v.end(),vTmp.begin(),vTmp.end());
684 std::size_t sz(v.size());
687 _coords=m->getCoords(); _coords->incrRef();
691 _geo_types.resize(sz);
692 _nb_entities.resize(sz);
693 for(std::size_t i=0;i<sz;i++)
695 MEDCoupling1GTUMesh *obj(v[i]);
699 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev constructor : presence of a null pointer !");
701 _geo_types[i]=obj->getCellModelEnum();
702 _nb_entities[i]=obj->getNumberOfCells();
704 // ids fields management
705 bool cellFamIdsNoCpy(levs.size()==1);
708 const DataArrayInt *tmp(m->getFamilyFieldAtLevel(levs[0]));
712 _cell_fam_ids=(const_cast<DataArrayInt *>(tmp));
717 std::vector<const DataArrayInt *> tmps(levs.size());
719 for(std::size_t i=0;i<levs.size();i++)
721 tmps[i]=m->getFamilyFieldAtLevel(levs[i]);
725 if(f && !tmps.empty())
726 _cell_fam_ids=DataArrayInt::Aggregate(tmps);
728 bool cellNumIdsNoCpy(levs.size()==1);
731 const DataArrayInt *tmp(m->getNumberFieldAtLevel(levs[0]));
735 _cell_num_ids=(const_cast<DataArrayInt *>(tmp));
740 std::vector<const DataArrayInt *> tmps(levs.size());
742 for(std::size_t i=0;i<levs.size();i++)
744 tmps[i]=m->getNumberFieldAtLevel(levs[i]);
748 if(n && !tmps.empty())
749 _cell_num_ids=DataArrayInt::Aggregate(tmps);
753 const DataArrayInt *tmp(m->getFamilyFieldAtLevel(1));
757 _node_fam_ids=(const_cast<DataArrayInt *>(tmp));
761 const DataArrayInt *tmp(m->getNumberFieldAtLevel(1));
765 _node_num_ids=(const_cast<DataArrayInt *>(tmp));
770 MEDUMeshMultiLev *MEDUMeshMultiLev::New(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities)
772 return new MEDUMeshMultiLev(m,gts,pfls,nbEntities);
775 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)
777 std::size_t sz(gts.size());
779 throw INTERP_KERNEL::Exception("constructor of MEDUMeshMultiLev : number of different geo type must be >= 1 !");
780 unsigned dim(INTERP_KERNEL::CellModel::GetCellModel(gts[0]).getDimension());
782 bool isSameDim(true),isNoPfl(true);
783 for(std::size_t i=0;i<sz;i++)
785 MEDCoupling1GTUMesh *elt(m->getDirectUndergroundSingleGeoTypeMesh(gts[i]));
786 if(INTERP_KERNEL::CellModel::GetCellModel(gts[i]).getDimension()!=dim)
794 // ids fields management
795 int lev((int)dim-m->getMeshDimension());
796 if(isSameDim && isNoPfl && m->getGeoTypesAtLevel(lev)==gts)//optimized part
798 const DataArrayInt *famIds(m->getFamilyFieldAtLevel(lev));
800 { _cell_fam_ids=const_cast<DataArrayInt*>(famIds); famIds->incrRef(); }
801 const DataArrayInt *numIds(m->getNumberFieldAtLevel(lev));
803 { _cell_num_ids=const_cast<DataArrayInt*>(numIds); numIds->incrRef(); }
804 famIds=m->getFamilyFieldAtLevel(1);
806 { _node_fam_ids=const_cast<DataArrayInt*>(famIds); famIds->incrRef(); }
807 numIds=m->getNumberFieldAtLevel(1);
809 { _node_num_ids=const_cast<DataArrayInt*>(numIds); numIds->incrRef(); }
813 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > famIdsSafe(sz);
814 std::vector<const DataArrayInt *> famIds(sz);
816 for(std::size_t i=0;i<sz;i++)
818 famIdsSafe[i]=m->extractFamilyFieldOnGeoType(gts[i]);
819 famIds[i]=famIdsSafe[i];
824 _cell_fam_ids=DataArrayInt::Aggregate(famIds);
825 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > numIdsSafe(sz);
826 std::vector<const DataArrayInt *> numIds(sz);
828 for(std::size_t i=0;i<sz;i++)
830 numIdsSafe[i]=m->extractNumberFieldOnGeoType(gts[i]);
831 numIds[i]=numIdsSafe[i];
836 _cell_num_ids=DataArrayInt::Aggregate(numIds);
837 // node ids management
838 const DataArrayInt *nodeFamIds(m->getFamilyFieldAtLevel(1));
840 { _node_fam_ids=const_cast<DataArrayInt*>(nodeFamIds); nodeFamIds->incrRef(); }
841 const DataArrayInt *nodeNumIds(m->getNumberFieldAtLevel(1));
843 { _node_num_ids=const_cast<DataArrayInt*>(nodeNumIds); nodeNumIds->incrRef(); }
846 void MEDUMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes)
848 if(!pflNodes || !pflNodes->isAllocated())
850 std::size_t sz(_parts.size());
851 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > a(sz);
852 std::vector< const DataArrayInt *> aa(sz);
853 for(std::size_t i=0;i<sz;i++)
855 const DataArrayInt *pfl(_pfls[i]);
856 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> m(_parts[i]);
858 m=dynamic_cast<MEDCoupling1GTUMesh *>(_parts[i]->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
859 DataArrayInt *cellIds=0;
860 m->fillCellIdsToKeepFromNodeIds(pflNodes->begin(),pflNodes->end(),true,cellIds);
861 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIdsSafe(cellIds);
862 MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> m2(m->buildPartOfMySelfKeepCoords(cellIds->begin(),cellIds->end()));
864 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n(m2->getNodeIdsInUse(tmp));
865 a[i]=o2n->invertArrayO2N2N2O(tmp); aa[i]=a[i];
867 _pfls[i]=pfl->selectByTupleIdSafe(cellIds->begin(),cellIds->end());
869 _pfls[i]=cellIdsSafe;
872 _node_reduction=DataArrayInt::Aggregate(aa);//general case
874 _node_reduction=pflNodes->deepCpy();//case where no cells in read mesh.
875 _node_reduction->sort(true);
876 _node_reduction=_node_reduction->buildUnique();
877 if(_node_reduction->getNumberOfTuples()==pflNodes->getNumberOfTuples())
878 return ;//This is the classical case where the input node profile corresponds perfectly to a subset of cells in _parts
879 if(_node_reduction->getNumberOfTuples()>pflNodes->getNumberOfTuples())
880 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::selectPartOfNodes : internal error in MEDCoupling during cell select from a list of nodes !");
881 // Here the cells available in _parts is not enough to cover all the nodes in pflNodes. So adding vertices cells in _parts...
882 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pflNodes2(pflNodes->deepCpy());
883 pflNodes2->sort(true);
884 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diff(pflNodes2->buildSubstractionOptimized(_node_reduction));
885 appendVertices(diff,pflNodes2);
888 MEDMeshMultiLev *MEDUMeshMultiLev::prepare() const
890 return new MEDUMeshMultiLev(*this);
893 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDUMeshMultiLev& other):MEDMeshMultiLev(other),_parts(other._parts),_coords(other._coords)
897 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDStructuredMeshMultiLev& other, const MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh>& part):MEDMeshMultiLev(other)
901 _geo_types.resize(1); _geo_types[0]=part->getCellModelEnum();
902 _nb_entities.resize(1); _nb_entities[0]=part->getNumberOfCells();
903 _pfls.resize(1); _pfls[0]=0;
907 * To be called only once ! Because due to some optimizations (sometimes aggressive) the internal state can be changed...
908 * 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.
909 * 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.
911 bool MEDUMeshMultiLev::buildVTUArrays(DataArrayDouble *& coords, DataArrayByte *&types, DataArrayInt *&cellLocations, DataArrayInt *& cells, DataArrayInt *&faceLocations, DataArrayInt *&faces) const
913 const DataArrayDouble *tmp(0);
917 tmp=_parts[0]->getCoords();
919 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : the coordinates are null !");
920 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> a(const_cast<DataArrayDouble *>(tmp)); tmp->incrRef();
921 int szBCE(0),szD(0),szF(0);
924 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_parts.begin();it!=_parts.end();it++,iii++)
926 const MEDCoupling1GTUMesh *cur(*it);
928 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : a part is null !");
930 const DataArrayInt *pfl(_pfls[iii]);
931 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> cur2;
933 { cur2=const_cast<MEDCoupling1GTUMesh *>(cur); cur2->incrRef(); }
935 { cur2=dynamic_cast<MEDCoupling1GTUMesh *>(cur->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end())); cur=cur2; }
937 int curNbCells(cur->getNumberOfCells());
939 if((*it)->getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED)
940 szD+=cur->getNodalConnectivity()->getNumberOfTuples()+curNbCells;
944 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp2(cur->computeEffectiveNbOfNodesPerCell());
945 szD+=tmp2->accumulate(0)+curNbCells;
946 szF+=2*curNbCells+cur->getNodalConnectivity()->getNumberOfTuples();
949 MEDCouplingAutoRefCountObjectPtr<DataArrayByte> b(DataArrayByte::New()); b->alloc(szBCE,1); char *bPtr(b->getPointer());
950 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c(DataArrayInt::New()); c->alloc(szBCE,1); int *cPtr(c->getPointer());
951 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d(DataArrayInt::New()); d->alloc(szD,1); int *dPtr(d->getPointer());
952 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> e(DataArrayInt::New()),f(DataArrayInt::New()); int *ePtr(0),*fPtr(0);
954 { e->alloc(szBCE,1); ePtr=e->getPointer(); f->alloc(szF,1); fPtr=f->getPointer(); }
957 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_parts.begin();it!=_parts.end();it++,iii++)
959 const MEDCoupling1GTUMesh *cur(*it);
961 const DataArrayInt *pfl(_pfls[iii]);
962 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> cur2;
964 { cur2=const_cast<MEDCoupling1GTUMesh *>(cur); cur2->incrRef(); }
966 { cur2=dynamic_cast<MEDCoupling1GTUMesh *>(cur->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end())); cur=cur2; }
968 int curNbCells(cur->getNumberOfCells());
969 int gt((int)cur->getCellModelEnum());
970 if(gt<0 || gt>=PARAMEDMEM_2_VTKTYPE_LGTH)
971 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : invalid geometric type !");
972 unsigned char gtvtk(PARAMEDMEM_2_VTKTYPE[gt]);
974 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : no VTK type for the requested INTERP_KERNEL geometric type !");
975 std::fill(bPtr,bPtr+curNbCells,gtvtk); bPtr+=curNbCells;
976 const MEDCoupling1SGTUMesh *scur(dynamic_cast<const MEDCoupling1SGTUMesh *>(cur));
977 const MEDCoupling1DGTUMesh *dcur(dynamic_cast<const MEDCoupling1DGTUMesh *>(cur));
978 const int *connPtr(cur->getNodalConnectivity()->begin());
980 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : internal error !");
983 if(cur->getCellModelEnum()!=INTERP_KERNEL::NORM_HEXA27)
985 int nnpc(scur->getNumberOfNodesPerCell());
986 for(int i=0;i<curNbCells;i++,connPtr+=nnpc)
989 dPtr=std::copy(connPtr,connPtr+nnpc,dPtr);
990 *cPtr++=k; k+=nnpc+1;
995 for(int i=0;i<curNbCells;i++,connPtr+=27)
998 for(int j=0;j<27;j++,dPtr++)
999 *dPtr=connPtr[HEXA27_PERM_ARRAY[j]];
1004 { std::fill(ePtr,ePtr+curNbCells,-1); ePtr+=curNbCells; }
1008 const int *connIPtr(dcur->getNodalConnectivityIndex()->begin());
1009 if(cur->getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED)
1011 for(int i=0;i<curNbCells;i++,connIPtr++)
1013 *dPtr++=connIPtr[1]-connIPtr[0];
1014 dPtr=std::copy(connPtr+connIPtr[0],connPtr+connIPtr[1],dPtr);
1015 *cPtr++=k; k+=connIPtr[1]-connIPtr[0]+1;
1020 for(int i=0;i<curNbCells;i++,connIPtr++)
1022 std::set<int> s(connPtr+connIPtr[0],connPtr+connIPtr[1]); s.erase(-1);
1023 *dPtr++=(int)s.size();
1024 dPtr=std::copy(s.begin(),s.end(),dPtr);
1025 *cPtr++=k; k+=(int)s.size()+1;
1030 connIPtr=dcur->getNodalConnectivityIndex()->begin();
1031 if(cur->getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED)
1032 { std::fill(ePtr,ePtr+curNbCells,-1); ePtr+=curNbCells; }
1036 for(int i=0;i<curNbCells;i++,connIPtr++)
1038 int nbFace(std::count(connPtr+connIPtr[0],connPtr+connIPtr[1],-1)+1);
1040 const int *work(connPtr+connIPtr[0]);
1041 for(int j=0;j<nbFace;j++)
1043 const int *work2=std::find(work,connPtr+connIPtr[1],-1);
1044 *fPtr++=std::distance(work,work2);
1045 fPtr=std::copy(work,work2,fPtr);
1048 *ePtr++=kk; kk+=connIPtr[1]-connIPtr[0]+2;
1055 reorderNodesIfNecessary(a,d,0);
1057 reorderNodesIfNecessary(a,d,f);
1058 if(a->getNumberOfComponents()!=3)
1059 a=a->changeNbOfComponents(3,0.);
1060 coords=a.retn(); types=b.retn(); cellLocations=c.retn(); cells=d.retn();
1062 { faceLocations=0; faces=0; }
1064 { faceLocations=e.retn(); faces=f.retn(); }
1065 return _mesh->isObjectInTheProgeny(coords);
1068 void MEDUMeshMultiLev::reorderNodesIfNecessary(MEDCouplingAutoRefCountObjectPtr<DataArrayDouble>& coords, DataArrayInt *nodalConnVTK, DataArrayInt *polyhedNodalConnVTK) const
1070 const DataArrayInt *nr(_node_reduction);
1073 if(nodalConnVTK->empty() && !polyhedNodalConnVTK)
1075 coords=(coords->selectByTupleIdSafe(nr->begin(),nr->end()));
1078 int sz(coords->getNumberOfTuples());
1079 std::vector<bool> b(sz,false);
1080 const int *work(nodalConnVTK->begin()),*endW(nodalConnVTK->end());
1084 for(int i=0;i<nb && work!=endW;i++,work++)
1086 if(*work>=0 && *work<sz)
1089 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::reorderNodesIfNecessary : internal error !");
1092 if(polyhedNodalConnVTK)
1094 work=polyhedNodalConnVTK->begin(); endW=polyhedNodalConnVTK->end();
1098 for(int i=0;i<nb && work!=endW;i++)
1101 for(int j=0;j<nb2 && work!=endW;j++,work++)
1103 if(*work>=0 && *work<sz)
1106 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::reorderNodesIfNecessary : internal error #2 !");
1111 int szExp(std::count(b.begin(),b.end(),true));
1112 if(szExp!=nr->getNumberOfTuples())
1113 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::reorderNodesIfNecessary : internal error #3 !");
1115 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n(DataArrayInt::New()); o2n->alloc(sz,1);
1116 int *o2nPtr(o2n->getPointer());
1118 for(int i=0;i<sz;i++,o2nPtr++)
1119 if(b[i]) *o2nPtr=newId++; else *o2nPtr=-1;
1120 const int *o2nPtrc(o2n->begin());
1121 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> n2o(o2n->invertArrayO2N2N2O(nr->getNumberOfTuples()));
1122 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> perm(DataArrayInt::FindPermutationFromFirstToSecond(n2o,nr));
1123 const int *permPtr(perm->begin());
1124 int *work2(nodalConnVTK->getPointer()),*endW2(nodalConnVTK->getPointer()+nodalConnVTK->getNumberOfTuples());
1128 for(int i=0;i<nb && work2!=endW2;i++,work2++)
1129 *work2=permPtr[o2nPtrc[*work2]];
1131 if(polyhedNodalConnVTK)
1133 work2=polyhedNodalConnVTK->getPointer(); endW2=polyhedNodalConnVTK->getPointer()+polyhedNodalConnVTK->getNumberOfTuples();
1137 for(int i=0;i<nb && work2!=endW2;i++)
1140 for(int j=0;j<nb2 && work2!=endW2;j++,work2++)
1141 *work2=permPtr[o2nPtrc[*work2]];
1145 coords=(coords->selectByTupleIdSafe(nr->begin(),nr->end()));
1149 void MEDUMeshMultiLev::appendVertices(const DataArrayInt *verticesToAdd, DataArrayInt *nr)
1151 int nbOfCells(verticesToAdd->getNumberOfTuples());//it is not a bug cells are NORM_POINT1
1152 MEDMeshMultiLev::appendVertices(verticesToAdd,nr);
1153 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> elt(MEDCoupling1SGTUMesh::New("",INTERP_KERNEL::NORM_POINT1));
1154 elt->allocateCells(nbOfCells);
1155 for(int i=0;i<nbOfCells;i++)
1157 int pt(verticesToAdd->getIJ(i,0));
1158 elt->insertNextCell(&pt,&pt+1);
1161 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::appendVertices : parts are empty !");
1162 elt->setCoords(_parts[0]->getCoords());
1163 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> elt2((MEDCoupling1SGTUMesh *)elt); elt2->incrRef();
1164 _parts.push_back(elt2);
1169 MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector<int>& lev):MEDMeshMultiLev(m),_is_internal(true)
1171 initStdFieldOfIntegers(m);
1174 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)
1176 initStdFieldOfIntegers(m);
1179 MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other):MEDMeshMultiLev(other),_is_internal(true),_face_fam_ids(other._face_fam_ids),_face_num_ids(other._face_num_ids)
1183 void MEDStructuredMeshMultiLev::initStdFieldOfIntegers(const MEDFileStructuredMesh *m)
1185 // ids fields management
1186 const DataArrayInt *tmp(0);
1187 tmp=m->getFamilyFieldAtLevel(0);
1191 _cell_fam_ids=const_cast<DataArrayInt *>(tmp);
1193 tmp=m->getNumberFieldAtLevel(0);
1197 _cell_num_ids=const_cast<DataArrayInt *>(tmp);
1201 tmp=m->getFamilyFieldAtLevel(1);
1205 _node_fam_ids=const_cast<DataArrayInt *>(tmp);
1207 tmp=m->getNumberFieldAtLevel(1);
1211 _node_num_ids=const_cast<DataArrayInt *>(tmp);
1214 tmp=m->getFamilyFieldAtLevel(-1);
1218 _face_fam_ids=const_cast<DataArrayInt *>(tmp);
1220 tmp=m->getNumberFieldAtLevel(-1);
1224 _face_num_ids=const_cast<DataArrayInt *>(tmp);
1228 void MEDStructuredMeshMultiLev::moveFaceToCell() const
1230 const_cast<MEDStructuredMeshMultiLev *>(this)->_cell_fam_ids=_face_fam_ids; const_cast<MEDStructuredMeshMultiLev *>(this)->_face_fam_ids=0;
1231 const_cast<MEDStructuredMeshMultiLev *>(this)->_cell_num_ids=_face_num_ids; const_cast<MEDStructuredMeshMultiLev *>(this)->_face_num_ids=0;
1234 bool MEDStructuredMeshMultiLev::prepareForImplicitUnstructuredMeshCase(MEDMeshMultiLev *&ret) const
1237 if(_geo_types.empty())
1239 if(_geo_types.size()!=1)
1240 throw INTERP_KERNEL::Exception("MEDStructuredMeshMultiLev::prepareForImplicitUnstructuredMeshCase only one geo types supported at most supported for the moment !");
1241 INTERP_KERNEL::NormalizedCellType gt(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(_mesh->getMeshDimension()));
1242 if(_geo_types[0]==gt)
1244 MEDCoupling1GTUMesh *facesIfPresent((static_cast<const MEDFileStructuredMesh *>(_mesh))->getImplicitFaceMesh());
1247 const DataArrayInt *pfl(0),*nr(_node_reduction);
1250 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> facesIfPresent2(facesIfPresent); facesIfPresent->incrRef();
1252 MEDCouplingAutoRefCountObjectPtr<MEDUMeshMultiLev> ret2(new MEDUMeshMultiLev(*this,facesIfPresent2));
1254 ret2->setCellReduction(pfl);
1256 throw INTERP_KERNEL::Exception("MEDStructuredMeshMultiLev::prepareForImplicitUnstructuredMeshCase : case is not treated yet for node reduction on implicit unstructured mesh.");
1261 void MEDStructuredMeshMultiLev::dealWithImplicitUnstructuredMesh(const MEDFileMesh *m)
1263 const DataArrayInt *tmp(0);
1264 tmp=m->getFamilyFieldAtLevel(-1);
1268 _cell_fam_ids=const_cast<DataArrayInt *>(tmp);
1270 tmp=m->getNumberFieldAtLevel(-1);
1274 _cell_num_ids=const_cast<DataArrayInt *>(tmp);
1278 void MEDStructuredMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes)
1280 if(!pflNodes || !pflNodes->isAllocated())
1282 std::vector<int> ngs(getNodeGridStructure());
1283 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(MEDCouplingStructuredMesh::Build1GTNodalConnectivity(&ngs[0],&ngs[0]+ngs.size()));
1284 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> m(MEDCoupling1SGTUMesh::New("",MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(ngs.size())));
1285 m->setNodalConnectivity(conn);
1286 const DataArrayInt *pfl(_pfls[0]);
1289 m=dynamic_cast<MEDCoupling1SGTUMesh *>(m->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
1291 DataArrayInt *cellIds=0;
1292 m->fillCellIdsToKeepFromNodeIds(pflNodes->begin(),pflNodes->end(),true,cellIds);
1293 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIdsSafe(cellIds);
1294 MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> m2(m->buildPartOfMySelfKeepCoords(cellIds->begin(),cellIds->end()));
1296 _node_reduction=m2->getNodeIdsInUse(tmp);
1298 _pfls[0]=pfl->selectByTupleIdSafe(cellIds->begin(),cellIds->end());
1300 _pfls[0]=cellIdsSafe;
1305 MEDCMeshMultiLev *MEDCMeshMultiLev::New(const MEDFileCMesh *m, const std::vector<int>& levs)
1307 return new MEDCMeshMultiLev(m,levs);
1310 MEDCMeshMultiLev *MEDCMeshMultiLev::New(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities)
1312 return new MEDCMeshMultiLev(m,gts,pfls,nbEntities);
1315 MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<int>& levs):MEDStructuredMeshMultiLev(m,levs)
1318 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor : null input pointer !");
1319 if(levs.size()!=1 || levs[0]!=0)
1320 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor : levels supported is 0 only !");
1321 int sdim(m->getSpaceDimension());
1322 _coords.resize(sdim);
1323 for(int i=0;i<sdim;i++)
1325 DataArrayDouble *elt(const_cast<DataArrayDouble *>(m->getMesh()->getCoordsAt(i)));
1327 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : presence of null pointer for an vector of double along an axis !");
1333 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)
1336 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : null input pointer !");
1337 if(gts.size()!=1 || pfls.size()!=1)
1338 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : lengthes of gts and pfls must be equal to one !");
1339 int mdim(m->getMeshDimension());
1340 INTERP_KERNEL::NormalizedCellType gt(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(mdim));
1343 _coords.resize(mdim);
1344 for(int i=0;i<mdim;i++)
1346 DataArrayDouble *elt(const_cast<DataArrayDouble *>(m->getMesh()->getCoordsAt(i)));
1348 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : presence of null pointer for an vector of double along an axis !");
1349 _coords[i]=elt; _coords[i]->incrRef();
1353 dealWithImplicitUnstructuredMesh(m);
1356 MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDCMeshMultiLev& other):MEDStructuredMeshMultiLev(other),_coords(other._coords)
1360 std::vector<int> MEDCMeshMultiLev::getNodeGridStructure() const
1362 std::vector<int> ret(_coords.size());
1363 for(std::size_t i=0;i<_coords.size();i++)
1364 ret[i]=_coords[i]->getNumberOfTuples();
1368 MEDMeshMultiLev *MEDCMeshMultiLev::prepare() const
1370 MEDMeshMultiLev *retSpecific(0);
1371 if(prepareForImplicitUnstructuredMeshCase(retSpecific))
1373 const DataArrayInt *pfl(0),*nr(_node_reduction);
1376 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nnr;
1377 std::vector<int> cgs,ngs(getNodeGridStructure());
1378 cgs.resize(ngs.size());
1379 std::transform(ngs.begin(),ngs.end(),cgs.begin(),std::bind2nd(std::plus<int>(),-1));
1382 std::vector< std::pair<int,int> > cellParts;
1383 MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> ret2;
1384 if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts))
1386 MEDCouplingAutoRefCountObjectPtr<MEDCMeshMultiLev> ret(new MEDCMeshMultiLev(*this));
1387 ret->_is_internal=false;
1389 { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1390 ret->_nb_entities[0]=pfl->getNumberOfTuples();
1392 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > coords(_coords.size());
1393 for(std::size_t i=0;i<_coords.size();i++)
1394 coords[i]=_coords[i]->selectByTupleId2(cellParts[i].first,cellParts[i].second+1,1);
1395 ret->_coords=coords;
1396 ret2=(MEDCMeshMultiLev *)ret; ret2->incrRef();
1400 MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> m(MEDCouplingCMesh::New());
1401 for(std::size_t i=0;i<ngs.size();i++)
1402 m->setCoordsAt(i,_coords[i]);
1403 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> m2(m->build1SGTUnstructured());
1404 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> m3=dynamic_cast<MEDCoupling1GTUMesh *>(m2->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
1405 MEDCouplingAutoRefCountObjectPtr<MEDUMeshMultiLev> ret(new MEDUMeshMultiLev(*this,m3));
1407 { m3->zipCoords(); nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1408 ret2=(MEDUMeshMultiLev *)ret; ret2->incrRef();
1410 const DataArrayInt *famIds(_cell_fam_ids),*numIds(_cell_num_ids);
1413 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(famIds->selectByTupleIdSafe(pfl->begin(),pfl->end()));
1414 ret2->setFamilyIdsOnCells(tmp);
1418 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(numIds->selectByTupleIdSafe(pfl->begin(),pfl->end()));
1419 ret2->setNumberIdsOnCells(tmp);
1426 MEDCouplingAutoRefCountObjectPtr<MEDCMeshMultiLev> ret(new MEDCMeshMultiLev(*this));
1428 { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1434 * \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.
1436 std::vector< DataArrayDouble * > MEDCMeshMultiLev::buildVTUArrays(bool& isInternal) const
1438 isInternal=_is_internal;
1439 std::size_t sz(_coords.size());
1440 std::vector< DataArrayDouble * > ret(sz);
1441 for(std::size_t i=0;i<sz;i++)
1443 ret[i]=const_cast<DataArrayDouble *>((const DataArrayDouble *)_coords[i]);
1451 MEDCurveLinearMeshMultiLev *MEDCurveLinearMeshMultiLev::New(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs)
1453 return new MEDCurveLinearMeshMultiLev(m,levs);
1456 MEDCurveLinearMeshMultiLev *MEDCurveLinearMeshMultiLev::New(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities)
1458 return new MEDCurveLinearMeshMultiLev(m,gts,pfls,nbEntities);
1461 MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs):MEDStructuredMeshMultiLev(m,levs)
1464 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor : null input pointer !");
1465 if(levs.size()!=1 || levs[0]!=0)
1466 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor : levels supported is 0 only !");
1467 DataArrayDouble *coords(const_cast<DataArrayDouble *>(m->getMesh()->getCoords()));
1469 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : no coords set !");
1472 _structure=m->getMesh()->getNodeGridStructure();
1475 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)
1478 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : null input pointer !");
1479 if(gts.size()!=1 || pfls.size()!=1)
1480 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : lengthes of gts and pfls must be equal to one !");
1481 INTERP_KERNEL::NormalizedCellType gt(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(m->getMeshDimension()));
1484 DataArrayDouble *coords(const_cast<DataArrayDouble *>(m->getMesh()->getCoords()));
1486 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : no coords set !");
1489 _structure=m->getMesh()->getNodeGridStructure();
1492 dealWithImplicitUnstructuredMesh(m);
1495 MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDCurveLinearMeshMultiLev& other):MEDStructuredMeshMultiLev(other),_coords(other._coords),_structure(other._structure)
1499 std::vector<int> MEDCurveLinearMeshMultiLev::getNodeGridStructure() const
1504 MEDMeshMultiLev *MEDCurveLinearMeshMultiLev::prepare() const
1506 MEDMeshMultiLev *retSpecific(0);
1507 if(prepareForImplicitUnstructuredMeshCase(retSpecific))
1509 const DataArrayInt *pfl(0),*nr(_node_reduction);
1512 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nnr;
1513 std::vector<int> cgs,ngs(getNodeGridStructure());
1514 cgs.resize(ngs.size());
1515 std::transform(ngs.begin(),ngs.end(),cgs.begin(),std::bind2nd(std::plus<int>(),-1));
1518 std::vector< std::pair<int,int> > cellParts,nodeParts;
1519 MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> ret2;
1520 if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts))
1522 nodeParts=cellParts;
1523 std::vector<int> st(ngs.size());
1524 for(std::size_t i=0;i<ngs.size();i++)
1526 nodeParts[i].second++;
1527 st[i]=nodeParts[i].second-nodeParts[i].first;
1529 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p(MEDCouplingStructuredMesh::BuildExplicitIdsFrom(ngs,nodeParts));
1530 MEDCouplingAutoRefCountObjectPtr<MEDCurveLinearMeshMultiLev> ret(new MEDCurveLinearMeshMultiLev(*this));
1531 ret->_is_internal=false;
1533 { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1534 ret->_nb_entities[0]=pfl->getNumberOfTuples();
1536 ret->_coords=_coords->selectByTupleIdSafe(p->begin(),p->end());
1538 ret2=(MEDCurveLinearMeshMultiLev *)ret; ret2->incrRef();
1542 MEDCouplingAutoRefCountObjectPtr<MEDCouplingCurveLinearMesh> m(MEDCouplingCurveLinearMesh::New());
1543 m->setCoords(_coords); m->setNodeGridStructure(&_structure[0],&_structure[0]+_structure.size());
1544 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> m2(m->build1SGTUnstructured());
1545 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> m3=dynamic_cast<MEDCoupling1GTUMesh *>(m2->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
1546 MEDCouplingAutoRefCountObjectPtr<MEDUMeshMultiLev> ret(new MEDUMeshMultiLev(*this,m3));
1548 { m3->zipCoords(); nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1549 ret2=(MEDUMeshMultiLev *)ret; ret2->incrRef();
1551 const DataArrayInt *famIds(_cell_fam_ids),*numIds(_cell_num_ids);
1554 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(famIds->selectByTupleIdSafe(pfl->begin(),pfl->end()));
1555 ret2->setFamilyIdsOnCells(tmp);
1559 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(numIds->selectByTupleIdSafe(pfl->begin(),pfl->end()));
1560 ret2->setNumberIdsOnCells(tmp);
1566 MEDCouplingAutoRefCountObjectPtr<MEDCurveLinearMeshMultiLev> ret(new MEDCurveLinearMeshMultiLev(*this));
1568 { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1573 void MEDCurveLinearMeshMultiLev::buildVTUArrays(DataArrayDouble *&coords, std::vector<int>& nodeStrct, bool& isInternal) const
1575 isInternal=_is_internal;
1576 nodeStrct=_structure;
1577 const DataArrayDouble *coo(_coords);
1579 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev::buildVTUArrays : null pointer on coordinates !");
1580 coords=const_cast<DataArrayDouble *>(coo); coords->incrRef();
1585 MEDFileField1TSStructItem2::MEDFileField1TSStructItem2()
1589 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)
1591 _pfl->setName(c.c_str());
1594 void MEDFileField1TSStructItem2::checkWithMeshStructForCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
1596 if(!mst->doesManageGeoType(_geo_type))
1598 MEDFileMeshStruct *mstUnConstCasted(const_cast<MEDFileMeshStruct *>(mst));
1599 mstUnConstCasted->appendIfImplicitType(_geo_type);
1601 int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
1602 checkInRange(nbOfEnt,1,globs);
1605 void MEDFileField1TSStructItem2::checkWithMeshStructForGaussNE(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
1607 int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
1608 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1609 checkInRange(nbOfEnt,(int)cm.getNumberOfNodes(),globs);
1612 void MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
1615 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT : no globals specified !");
1617 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT : no localization specified !");
1618 const MEDFileFieldLoc& loc=globs->getLocalization(_loc.c_str());
1619 int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
1620 checkInRange(nbOfEnt,loc.getNumberOfGaussPoints(),globs);
1623 int MEDFileField1TSStructItem2::getNbOfIntegrationPts(const MEDFileFieldGlobsReal *globs) const
1627 if(getPflName().empty())
1628 return (_start_end.second-_start_end.first)/_nb_of_entity;
1630 return (_start_end.second-_start_end.first)/getPfl(globs)->getNumberOfTuples();
1634 const MEDFileFieldLoc& loc(globs->getLocalization(_loc.c_str()));
1635 return loc.getNumberOfGaussPoints();
1639 std::string MEDFileField1TSStructItem2::getPflName() const
1641 return _pfl->getName();
1644 const DataArrayInt *MEDFileField1TSStructItem2::getPfl(const MEDFileFieldGlobsReal *globs) const
1646 if(!_pfl->isAllocated())
1648 if(_pfl->getName().empty())
1651 return globs->getProfile(_pfl->getName().c_str());
1658 * \param [in] nbOfEntity - number of entity that can be either cells or nodes. Not other possiblity.
1659 * \param [in] nip - number of integration points. 1 for ON_CELLS and NO_NODES
1661 void MEDFileField1TSStructItem2::checkInRange(int nbOfEntity, int nip, const MEDFileFieldGlobsReal *globs)
1663 _nb_of_entity=nbOfEntity;
1664 if(_pfl->getName().empty())
1666 if(nbOfEntity!=(_start_end.second-_start_end.first)/nip)
1667 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Mismatch between number of entities and size of node field !");
1673 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Presence of a profile on field whereas no globals found in file !");
1674 const DataArrayInt *pfl=globs->getProfile(_pfl->getName().c_str());
1676 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Presence of a profile on field whereas no such profile found in file !");
1677 pfl->checkAllIdsInRange(0,nbOfEntity);
1681 bool MEDFileField1TSStructItem2::isFastlyEqual(int& startExp, INTERP_KERNEL::NormalizedCellType gt, const std::string& pflName) const
1683 if(startExp!=_start_end.first)
1687 if(getPflName()!=pflName)
1689 startExp=_start_end.second;
1693 bool MEDFileField1TSStructItem2::operator==(const MEDFileField1TSStructItem2& other) const
1695 //_nb_of_entity is not taken into account here. It is not a bug, because no mesh consideration needed here to perform fast compare.
1696 //idem for _loc. It is not an effective attribute for support comparison.
1697 return _geo_type==other._geo_type && _start_end==other._start_end && _pfl->getName()==other._pfl->getName();
1700 bool MEDFileField1TSStructItem2::isCellSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const
1702 if(_geo_type!=other._geo_type)
1704 if(_nb_of_entity!=other._nb_of_entity)
1706 if((_pfl->getName().empty() && !other._pfl->getName().empty()) || (!_pfl->getName().empty() && other._pfl->getName().empty()))
1708 if(_pfl->getName().empty() && other._pfl->getName().empty())
1710 const DataArrayInt *pfl1(getPfl(globs)),*pfl2(other.getPfl(globs));
1711 return pfl1->isEqualWithoutConsideringStr(*pfl2);
1714 bool MEDFileField1TSStructItem2::isNodeSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const
1716 return isCellSupportEqual(other,globs);
1720 * \a objs must be non empty. \a objs should contain items having same geometric type.
1722 MEDFileField1TSStructItem2 MEDFileField1TSStructItem2::BuildAggregationOf(const std::vector<const MEDFileField1TSStructItem2 *>& objs, const MEDFileFieldGlobsReal *globs)
1725 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : empty input !");
1727 return MEDFileField1TSStructItem2(*objs[0]);
1728 INTERP_KERNEL::NormalizedCellType gt(objs[0]->_geo_type);
1729 int nbEntityRef(objs[0]->_nb_of_entity);
1730 std::size_t sz(objs.size());
1731 std::vector<const DataArrayInt *> arrs(sz);
1732 for(std::size_t i=0;i<sz;i++)
1734 const MEDFileField1TSStructItem2 *obj(objs[i]);
1735 if(gt!=obj->_geo_type)
1736 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : invalid situation ! All input must have the same geo type !");
1737 if(nbEntityRef!=obj->_nb_of_entity)
1738 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : invalid situation ! All input must have the global nb of entity !");
1739 if(obj->_pfl->getName().empty())
1740 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : invalid situation ! Several same geo type chunk must all lie on profiles !");
1741 arrs[i]=globs->getProfile(obj->_pfl->getName().c_str());
1743 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr(DataArrayInt::Aggregate(arrs));
1745 int oldNbTuples(arr->getNumberOfTuples());
1746 arr=arr->buildUnique();
1747 if(oldNbTuples!=arr->getNumberOfTuples())
1748 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : some entities are present several times !");
1749 if(arr->isIdentity() && oldNbTuples==nbEntityRef)
1751 std::pair<int,int> p(0,nbEntityRef);
1753 MEDFileField1TSStructItem2 ret(gt,p,a,b);
1754 ret._nb_of_entity=nbEntityRef;
1759 arr->setName(arrs[0]->getName());
1760 std::pair<int,int> p(0,oldNbTuples);
1762 MEDFileField1TSStructItem2 ret(gt,p,a,b);
1763 ret._nb_of_entity=nbEntityRef;
1769 std::size_t MEDFileField1TSStructItem2::getHeapMemorySizeWithoutChildren() const
1771 std::size_t ret(_loc.capacity());
1775 std::vector<const BigMemoryObject *> MEDFileField1TSStructItem2::getDirectChildrenWithNull() const
1777 std::vector<const BigMemoryObject *> ret;
1778 ret.push_back((const DataArrayInt *)_pfl);
1784 MEDFileField1TSStructItem::MEDFileField1TSStructItem(TypeOfField a, const std::vector< MEDFileField1TSStructItem2 >& b):_computed(false),_type(a),_items(b)
1788 void MEDFileField1TSStructItem::checkWithMeshStruct(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
1794 int nbOfEnt=mst->getNumberOfNodes();
1795 if(_items.size()!=1)
1796 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::checkWithMeshStruct : for nodes field only one subdivision supported !");
1797 _items[0].checkInRange(nbOfEnt,1,globs);
1802 for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
1803 (*it).checkWithMeshStructForCells(mst,globs);
1808 for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
1809 (*it).checkWithMeshStructForGaussNE(mst,globs);
1814 for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
1815 (*it).checkWithMeshStructForGaussPT(mst,globs);
1819 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::checkWithMeshStruct : not managed field type !");
1823 bool MEDFileField1TSStructItem::operator==(const MEDFileField1TSStructItem& other) const
1825 if(_type!=other._type)
1827 if(_items.size()!=other._items.size())
1829 for(std::size_t i=0;i<_items.size();i++)
1830 if(!(_items[i]==other._items[i]))
1835 bool MEDFileField1TSStructItem::isCellSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const
1837 if(_type!=other._type)
1839 if(_items.size()!=other._items.size())
1841 for(std::size_t i=0;i<_items.size();i++)
1842 if(!(_items[i].isCellSupportEqual(other._items[i],globs)))
1847 bool MEDFileField1TSStructItem::isNodeSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const
1849 if(_type!=other._type)
1851 if(_items.size()!=other._items.size())
1853 for(std::size_t i=0;i<_items.size();i++)
1854 if(!(_items[i].isNodeSupportEqual(other._items[i],globs)))
1859 bool MEDFileField1TSStructItem::isEntityCell() const
1870 CmpGeo(INTERP_KERNEL::NormalizedCellType geoTyp):_geo_type(geoTyp) { }
1871 bool operator()(const std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > & v) const { return _geo_type==v.first; }
1873 INTERP_KERNEL::NormalizedCellType _geo_type;
1876 MEDFileField1TSStructItem MEDFileField1TSStructItem::simplifyMeOnCellEntity(const MEDFileFieldGlobsReal *globs) const
1879 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::simplifyMeOnCellEntity : must be on ON_CELLS, ON_GAUSS_NE or ON_GAUSS_PT !");
1880 std::vector< std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > > m;
1882 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++,i++)
1884 std::vector< std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > >::iterator it0(std::find_if(m.begin(),m.end(),CmpGeo((*it).getGeo())));
1886 m.push_back(std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> >((*it).getGeo(),std::vector<std::size_t>(1,i)));
1888 (*it0).second.push_back(i);
1890 if(m.size()==_items.size())
1892 MEDFileField1TSStructItem ret(*this);
1896 std::size_t sz(m.size());
1897 std::vector< MEDFileField1TSStructItem2 > items(sz);
1900 const std::vector<std::size_t>& ids=m[i].second;
1901 std::vector<const MEDFileField1TSStructItem2 *>objs(ids.size());
1902 for(std::size_t j=0;j<ids.size();j++)
1903 objs[j]=&_items[ids[j]];
1904 items[i]=MEDFileField1TSStructItem2::BuildAggregationOf(objs,globs);
1906 MEDFileField1TSStructItem ret(ON_CELLS,items);
1912 * \a this is expected to be ON_CELLS and simplified.
1914 bool MEDFileField1TSStructItem::isCompatibleWithNodesDiscr(const MEDFileField1TSStructItem& other, const MEDFileMeshStruct *meshSt, const MEDFileFieldGlobsReal *globs) const
1916 if(other._type!=ON_NODES)
1917 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isCompatibleWithNodesDiscr : other must be on nodes !");
1918 if(other._items.size()!=1)
1919 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isCompatibleWithNodesDiscr : other is on nodes but number of subparts !");
1920 int theFirstLevFull;
1921 bool ret0=isFullyOnOneLev(meshSt,theFirstLevFull);
1922 const MEDFileField1TSStructItem2& otherNodeIt(other._items[0]);
1923 if(otherNodeIt.getPflName().empty())
1927 return theFirstLevFull==0;
1931 const DataArrayInt *pfl=globs->getProfile(otherNodeIt.getPflName().c_str());
1932 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpyPfl(pfl->deepCpy());
1934 int nbOfNodes(meshSt->getNumberOfNodes());
1935 if(cpyPfl->isIdentity() && cpyPfl->getNumberOfTuples()==nbOfNodes)
1936 {//on all nodes also !
1939 return theFirstLevFull==0;
1941 std::vector<bool> nodesFetched(nbOfNodes,false);
1942 meshSt->getTheMesh()->whichAreNodesFetched(*this,globs,nodesFetched);
1943 return cpyPfl->isFittingWith(nodesFetched);
1947 bool MEDFileField1TSStructItem::isFullyOnOneLev(const MEDFileMeshStruct *meshSt, int& theFirstLevFull) const
1950 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : works only for ON_CELLS discretization !");
1952 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : items vector is empty !");
1953 int nbOfLevs(meshSt->getNumberOfLevs());
1955 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : no levels in input mesh structure !");
1956 std::vector<int> levs(nbOfLevs);
1958 std::set<INTERP_KERNEL::NormalizedCellType> gts;
1959 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++)
1961 if(!(*it).getPflName().empty())
1963 INTERP_KERNEL::NormalizedCellType gt((*it).getGeo());
1964 if(gts.find(gt)!=gts.end())
1965 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : internal error !");
1967 int pos(meshSt->getLevelOfGeoType((*it).getGeo()));
1970 for(int i=0;i<nbOfLevs;i++)
1971 if(meshSt->getNumberOfGeoTypesInLev(-i)==levs[i])
1972 { theFirstLevFull=-i; return true; }
1976 const MEDFileField1TSStructItem2& MEDFileField1TSStructItem::operator[](std::size_t i) const
1978 if(i>=_items.size())
1979 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::operator[] : input is not in valid range !");
1983 std::size_t MEDFileField1TSStructItem::getHeapMemorySizeWithoutChildren() const
1985 std::size_t ret(_items.size()*sizeof(MEDFileField1TSStructItem2));
1989 std::vector<const BigMemoryObject *> MEDFileField1TSStructItem::getDirectChildrenWithNull() const
1991 std::vector<const BigMemoryObject *> ret;
1992 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++)
1993 ret.push_back(&(*it));
1997 MEDMeshMultiLev *MEDFileField1TSStructItem::buildFromScratchDataSetSupportOnCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const
1999 std::size_t sz(_items.size());
2000 std::vector<INTERP_KERNEL::NormalizedCellType> a0(sz);
2001 std::vector<const DataArrayInt *> a1(sz);
2002 std::vector<int> a2(sz);
2004 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++,i++)
2006 a0[i]=(*it).getGeo();
2007 a1[i]=(*it).getPfl(globs);
2008 a2[i]=mst->getNumberOfElemsOfGeoType((*it).getGeo());
2010 return MEDMeshMultiLev::New(mst->getTheMesh(),a0,a1,a2);
2013 std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileField1TSStructItem::getGeoTypes(const MEDFileMesh *m) const
2015 std::vector<INTERP_KERNEL::NormalizedCellType> ret;
2018 if(!_items.empty() && _items[0].getPflName().empty())
2021 return m->getAllGeoTypes();
2028 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++)
2030 INTERP_KERNEL::NormalizedCellType elt((*it).getGeo());
2031 std::vector<INTERP_KERNEL::NormalizedCellType>::iterator it2(std::find(ret.begin(),ret.end(),elt));
2038 MEDFileField1TSStructItem MEDFileField1TSStructItem::BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt)
2040 std::vector< MEDFileField1TSStructItem2 > anItems;
2042 std::vector< std::vector<std::string> > pfls,locs;
2043 std::vector< std::vector<TypeOfField> > typesF;
2044 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2045 std::vector< std::vector<std::pair<int,int> > > strtEnds=ref->getFieldSplitedByType(std::string(),geoTypes,typesF,pfls,locs);
2046 std::size_t nbOfGeoTypes(geoTypes.size());
2048 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : not null by empty ref !");
2049 if(typesF[0].empty())
2050 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : internal error #1 bis !");
2051 TypeOfField atype(typesF[0][0]);
2052 for(std::size_t i=0;i<nbOfGeoTypes;i++)
2054 std::size_t sz=typesF[i].size();
2055 if(strtEnds[i].size()<1 || sz<1 || pfls[i].size()<1)
2056 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : internal error #1 !");
2058 for(std::size_t j=0;j<sz;j++)
2060 if(atype==typesF[i][j])
2061 anItems.push_back(MEDFileField1TSStructItem2(geoTypes[i],strtEnds[i][j],pfls[i][j],locs[i][j]));
2063 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : can be applied only on single spatial discretization fields ! Call SplitPerDiscretization method !");
2066 MEDFileField1TSStructItem ret(atype,anItems);
2067 ret.checkWithMeshStruct(meshSt,ref);
2073 MEDFileField1TSStruct *MEDFileField1TSStruct::New(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst)
2075 return new MEDFileField1TSStruct(ref,mst);
2078 MEDFileField1TSStruct::MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst)
2080 _already_checked.push_back(MEDFileField1TSStructItem::BuildItemFrom(ref,mst));
2083 void MEDFileField1TSStruct::checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
2085 if(_already_checked.empty())
2086 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::checkWithMeshStruct : not correctly initialized !");
2087 _already_checked.back().checkWithMeshStruct(mst,globs);
2090 bool MEDFileField1TSStruct::isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *mst) const
2092 MEDFileField1TSStructItem b(MEDFileField1TSStructItem::BuildItemFrom(other,mst));
2093 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++)
2102 * Not const because \a other structure will be added to the \c _already_checked attribute in case of success.
2104 bool MEDFileField1TSStruct::isSupportSameAs(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt)
2106 if(_already_checked.empty())
2107 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isSupportSameAs : no ref !");
2108 MEDFileField1TSStructItem b(MEDFileField1TSStructItem::BuildItemFrom(other,meshSt));
2109 if(!_already_checked[0].isEntityCell() || !b.isEntityCell())
2110 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isSupportSameAs : only available on cell entities !");
2111 MEDFileField1TSStructItem other1(b.simplifyMeOnCellEntity(other));
2113 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
2114 if((*it).isComputed())
2119 MEDFileField1TSStructItem this1(_already_checked[0].simplifyMeOnCellEntity(other));
2120 ret=this1.isCellSupportEqual(other1,other);
2122 _already_checked.push_back(this1);
2125 ret=_already_checked[found].isCellSupportEqual(other1,other);
2127 _already_checked.push_back(b);
2132 * \param [in] other - a field with only one spatial discretization : ON_NODES.
2134 bool MEDFileField1TSStruct::isCompatibleWithNodesDiscr(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt)
2136 if(_already_checked.empty())
2137 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isCompatibleWithNodesDiscr : no ref !");
2138 MEDFileField1TSStructItem other1(MEDFileField1TSStructItem::BuildItemFrom(other,meshSt));
2139 if(_already_checked[0].isEntityCell())
2142 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
2143 if((*it).isComputed())
2148 MEDFileField1TSStructItem this1(_already_checked[0].simplifyMeOnCellEntity(other));
2149 ret=this1.isCompatibleWithNodesDiscr(other1,meshSt,other);
2151 _already_checked.push_back(this1);
2154 ret=_already_checked[found].isCompatibleWithNodesDiscr(other1,meshSt,other);
2156 _already_checked.push_back(other1);
2160 return _already_checked[0].isNodeSupportEqual(other1,other);
2163 std::size_t MEDFileField1TSStruct::getHeapMemorySizeWithoutChildren() const
2165 std::size_t ret(_already_checked.capacity()*sizeof(MEDFileField1TSStructItem));
2169 std::vector<const BigMemoryObject *> MEDFileField1TSStruct::getDirectChildrenWithNull() const
2171 std::vector<const BigMemoryObject *> ret;
2172 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++)
2173 ret.push_back(&(*it));
2177 MEDMeshMultiLev *MEDFileField1TSStruct::buildFromScratchDataSetSupport(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const
2179 if(_already_checked.empty())
2180 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::buildFromScratchDataSetSupport : No outline structure in this !");
2181 int pos0(-1),pos1(-1);
2182 if(presenceOfCellDiscr(pos0))
2184 MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> ret(_already_checked[pos0].buildFromScratchDataSetSupportOnCells(mst,globs));
2185 if(presenceOfPartialNodeDiscr(pos1))
2186 ret->setNodeReduction(_already_checked[pos1][0].getPfl(globs));
2191 if(!presenceOfPartialNodeDiscr(pos1))
2192 {//we have only all nodes, no cell definition info -> all existing levels !;
2193 return MEDMeshMultiLev::New(mst->getTheMesh(),mst->getTheMesh()->getNonEmptyLevels());
2196 return MEDMeshMultiLev::NewOnlyOnNode(mst->getTheMesh(),_already_checked[pos1][0].getPfl(globs));
2200 bool MEDFileField1TSStruct::isDataSetSupportFastlyEqualTo(const MEDFileField1TSStruct& other, const MEDFileFieldGlobsReal *globs) const
2203 bool a0(presenceOfCellDiscr(b0)),a1(presenceOfPartialNodeDiscr(b1));
2205 bool c0(other.presenceOfCellDiscr(d0)),c1(other.presenceOfPartialNodeDiscr(d1));
2206 if(a0!=c0 || a1!=c1)
2209 if(!_already_checked[b0].isCellSupportEqual(other._already_checked[d0],globs))
2212 if(!_already_checked[b1].isNodeSupportEqual(other._already_checked[d1],globs))
2217 std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileField1TSStruct::getGeoTypes(const MEDFileMesh *m) const
2219 std::vector<INTERP_KERNEL::NormalizedCellType> ret;
2220 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++)
2222 std::vector<INTERP_KERNEL::NormalizedCellType> ret2((*it).getGeoTypes(m));
2223 for(std::vector<INTERP_KERNEL::NormalizedCellType>::const_iterator it2=ret2.begin();it2!=ret2.end();it2++)
2225 if(*it2==INTERP_KERNEL::NORM_ERROR)
2227 std::vector<INTERP_KERNEL::NormalizedCellType>::iterator it3(std::find(ret.begin(),ret.end(),*it2));
2229 ret.push_back(*it2);
2236 * Returns true if presence in \a this of discretization ON_CELLS, ON_GAUSS_PT, ON_GAUSS_NE.
2237 * 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.
2239 bool MEDFileField1TSStruct::presenceOfCellDiscr(int& pos) const
2241 std::size_t refSz(std::numeric_limits<std::size_t>::max());
2244 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
2246 if((*it).getType()!=ON_NODES)
2249 std::size_t sz((*it).getNumberOfItems());
2251 { pos=i; refSz=sz; }
2255 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::presenceOfCellDiscr : an element in this on entity CELL is empty !");
2260 * Returns true if presence in \a this of discretization ON_NODES.
2261 * If true is returned the pos of the first element containing the single subpart.
2263 bool MEDFileField1TSStruct::presenceOfPartialNodeDiscr(int& pos) const
2266 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
2268 if((*it).getType()==ON_NODES)
2270 std::size_t sz((*it).getNumberOfItems());
2273 if(!(*it)[0].getPflName().empty())
2274 { pos=i; return true; }
2277 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::presenceOfPartialNodeDiscr : an element in this on entity NODE is split into several parts !");
2285 MEDFileFastCellSupportComparator *MEDFileFastCellSupportComparator::New(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref)
2287 return new MEDFileFastCellSupportComparator(m,ref);
2290 MEDFileFastCellSupportComparator::MEDFileFastCellSupportComparator(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref)
2293 throw INTERP_KERNEL::Exception("MEDFileFastCellSupportComparator constructor : null input mesh struct !");
2294 _mesh_comp=const_cast<MEDFileMeshStruct *>(m); _mesh_comp->incrRef();
2295 int nbPts=ref->getNumberOfTS();
2296 _f1ts_cmps.resize(nbPts);
2297 for(int i=0;i<nbPts;i++)
2299 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt=ref->getTimeStepAtPos(i);
2300 _f1ts_cmps[i]=MEDFileField1TSStruct::New(elt,_mesh_comp);
2301 _f1ts_cmps[i]->checkWithMeshStruct(_mesh_comp,elt);
2305 std::size_t MEDFileFastCellSupportComparator::getHeapMemorySizeWithoutChildren() const
2307 std::size_t ret(_f1ts_cmps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct>));
2311 std::vector<const BigMemoryObject *> MEDFileFastCellSupportComparator::getDirectChildrenWithNull() const
2313 std::vector<const BigMemoryObject *> ret;
2314 const MEDFileMeshStruct *mst(_mesh_comp);
2317 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct> >::const_iterator it=_f1ts_cmps.begin();it!=_f1ts_cmps.end();it++)
2318 ret.push_back((const MEDFileField1TSStruct *)*it);
2322 bool MEDFileFastCellSupportComparator::isEqual(const MEDFileAnyTypeFieldMultiTS *other)
2324 int nbPts=other->getNumberOfTS();
2325 if(nbPts!=(int)_f1ts_cmps.size())
2327 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isEqual : unexpected nb of time steps in input ! Should be " << _f1ts_cmps.size() << " it is in reality " << nbPts << " !";
2328 throw INTERP_KERNEL::Exception(oss.str().c_str());
2330 for(int i=0;i<nbPts;i++)
2332 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt=other->getTimeStepAtPos(i);
2333 if(!_f1ts_cmps[i]->isEqualConsideringThePast(elt,_mesh_comp))
2334 if(!_f1ts_cmps[i]->isSupportSameAs(elt,_mesh_comp))
2340 bool MEDFileFastCellSupportComparator::isCompatibleWithNodesDiscr(const MEDFileAnyTypeFieldMultiTS *other)
2342 int nbPts=other->getNumberOfTS();
2343 if(nbPts!=(int)_f1ts_cmps.size())
2345 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isCompatibleWithNodesDiscr : unexpected nb of time steps in input ! Should be " << _f1ts_cmps.size() << " it is in reality " << nbPts << " !";
2346 throw INTERP_KERNEL::Exception(oss.str().c_str());
2348 for(int i=0;i<nbPts;i++)
2350 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt=other->getTimeStepAtPos(i);
2351 if(!_f1ts_cmps[i]->isCompatibleWithNodesDiscr(elt,_mesh_comp))
2357 MEDMeshMultiLev *MEDFileFastCellSupportComparator::buildFromScratchDataSetSupport(int timeStepId, const MEDFileFieldGlobsReal *globs) const
2359 if(timeStepId<0 || timeStepId>=(int)_f1ts_cmps.size())
2361 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::buildFromScratchDataSetSupport : requested time step id #" << timeStepId << " is not in [0," << _f1ts_cmps.size() << ") !";
2362 throw INTERP_KERNEL::Exception(oss.str().c_str());
2364 const MEDFileField1TSStruct *obj(_f1ts_cmps[timeStepId]);
2367 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::buildFromScratchDataSetSupport : at time step id #" << timeStepId << " no field structure overview defined !";
2368 throw INTERP_KERNEL::Exception(oss.str().c_str());
2370 return obj->buildFromScratchDataSetSupport(_mesh_comp,globs);
2373 bool MEDFileFastCellSupportComparator::isDataSetSupportEqualToThePreviousOne(int timeStepId, const MEDFileFieldGlobsReal *globs) const
2375 if(timeStepId<=0 || timeStepId>=(int)_f1ts_cmps.size())
2377 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isDataSetSupportEqualToThePreviousOne : requested time step id #" << timeStepId << " is not in [1," << _f1ts_cmps.size() << ") !";
2378 throw INTERP_KERNEL::Exception(oss.str().c_str());
2380 const MEDFileField1TSStruct *obj(_f1ts_cmps[timeStepId]);
2381 const MEDFileField1TSStruct *objRef(_f1ts_cmps[timeStepId-1]);
2382 return objRef->isDataSetSupportFastlyEqualTo(*obj,globs);
2385 int MEDFileFastCellSupportComparator::getNumberOfTS() const
2387 return _f1ts_cmps.size();
2390 std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileFastCellSupportComparator::getGeoTypesAt(int timeStepId, const MEDFileMesh *m) const
2392 if(timeStepId<0 || timeStepId>=(int)_f1ts_cmps.size())
2394 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::getGeoTypesAt : requested time step id #" << timeStepId << " is not in [0," << _f1ts_cmps.size() << ") !";
2395 throw INTERP_KERNEL::Exception(oss.str().c_str());
2397 const MEDFileField1TSStruct *elt(_f1ts_cmps[timeStepId]);
2400 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::getGeoTypesAt : requested time step id #" << timeStepId << " points to a NULL pointer !";
2401 throw INTERP_KERNEL::Exception(oss.str().c_str());
2403 return elt->getGeoTypes(m);