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::getDirectChildren() 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 !");
84 int MEDFileMeshStruct::getNumberOfElemsOfGeoType(INTERP_KERNEL::NormalizedCellType t) const
86 for(std::vector< std::vector<int> >::const_iterator it1=_geo_types_distrib.begin();it1!=_geo_types_distrib.end();it1++)
88 std::size_t sz=(*it1).size();
90 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfElemsOfGeoType : internal error in code !");
91 std::size_t nbGeo=sz/3;
92 for(std::size_t i=0;i<nbGeo;i++)
93 if((*it1)[3*i]==(int)t)
96 throw INTERP_KERNEL::Exception("The specified geometric type is not present in the mesh structure !");
99 int MEDFileMeshStruct::getNumberOfLevs() const
101 return (int)_geo_types_distrib.size();
104 int MEDFileMeshStruct::getNumberOfGeoTypesInLev(int relativeLev) const
106 int pos(-relativeLev);
107 if(pos<0 || pos>=(int)_geo_types_distrib.size())
108 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfGeoTypesInLev : invalid level specified !");
109 std::size_t sz=_geo_types_distrib[pos].size();
111 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfGeoTypesInLev : internal error in code !");
117 std::size_t MEDMeshMultiLev::getHeapMemorySizeWithoutChildren() const
122 std::vector<const BigMemoryObject *> MEDMeshMultiLev::getDirectChildren() const
124 return std::vector<const BigMemoryObject *>();
127 MEDMeshMultiLev *MEDMeshMultiLev::New(const MEDFileMesh *m, const std::vector<int>& levs)
130 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New : null input pointer !");
131 const MEDFileUMesh *um(dynamic_cast<const MEDFileUMesh *>(m));
133 return MEDUMeshMultiLev::New(um,levs);
134 const MEDFileCMesh *cm(dynamic_cast<const MEDFileCMesh *>(m));
136 return MEDCMeshMultiLev::New(cm,levs);
137 const MEDFileCurveLinearMesh *clm(dynamic_cast<const MEDFileCurveLinearMesh *>(m));
139 return MEDCurveLinearMeshMultiLev::New(clm,levs);
140 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New : unrecognized type of mesh ! Must be in [MEDFileUMesh,MEDFileCMesh,MEDFileCurveLinearMesh] !");
143 MEDMeshMultiLev *MEDMeshMultiLev::New(const MEDFileMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities)
146 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New 2 : null input pointer !");
147 const MEDFileUMesh *um(dynamic_cast<const MEDFileUMesh *>(m));
149 return MEDUMeshMultiLev::New(um,gts,pfls,nbEntities);
150 const MEDFileCMesh *cm(dynamic_cast<const MEDFileCMesh *>(m));
152 return MEDCMeshMultiLev::New(cm,gts,pfls,nbEntities);
153 const MEDFileCurveLinearMesh *clm(dynamic_cast<const MEDFileCurveLinearMesh *>(m));
155 return MEDCurveLinearMeshMultiLev::New(clm,gts,pfls,nbEntities);
156 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New 2 : unrecognized type of mesh ! Must be in [MEDFileUMesh,MEDFileCMesh,MEDFileCurveLinearMesh] !");
159 MEDMeshMultiLev *MEDMeshMultiLev::NewOnlyOnNode(const MEDFileMesh *m, const DataArrayInt *pflOnNode)
161 MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> ret(MEDMeshMultiLev::New(m,m->getNonEmptyLevels()));
162 ret->selectPartOfNodes(pflOnNode);
166 void MEDMeshMultiLev::setNodeReduction(const DataArrayInt *nr)
170 _node_reduction=const_cast<DataArrayInt*>(nr);
173 bool MEDMeshMultiLev::isFastlyTheSameStruct(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs) const
175 if(fst.getType()==ON_NODES)
177 if(fst.getNumberOfItems()!=1)
178 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::isFastlyTheSameStruct : unexpected situation for nodes !");
179 const MEDFileField1TSStructItem2& p(fst[0]);
180 std::string pflName(p.getPflName());
181 const DataArrayInt *nr(_node_reduction);
182 if(pflName.empty() && !nr)
184 if(!pflName.empty() && !nr)
186 if(pflName==nr->getName())
192 std::size_t sz(fst.getNumberOfItems());
193 if(sz!=_geo_types.size())
196 for(std::size_t i=0;i<sz;i++)
198 const MEDFileField1TSStructItem2& p(fst[i]);
199 if(!p.isFastlyEqual(strt,_geo_types[i],getPflNameOfId(i).c_str()))
206 DataArray *MEDMeshMultiLev::buildDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const
208 MEDCouplingAutoRefCountObjectPtr<DataArray> ret(const_cast<DataArray *>(vals)); ret->incrRef();
209 if(isFastlyTheSameStruct(fst,globs))
212 return constructDataArray(fst,globs,vals);
216 * \param [out] famIds - Can be null. If not null the instance has to be dealt by the caller (decrRef).
217 * \param [out] isWithoutCopy - When true the returned instance \a famIds if not null is directly those in the data structure.
219 void MEDMeshMultiLev::retrieveFamilyIdsOnCells(DataArrayInt *& famIds, bool& isWithoutCopy) const
221 const DataArrayInt *fids(_cell_fam_ids);
223 { famIds=0; isWithoutCopy=true; return ; }
224 std::size_t sz(_geo_types.size());
225 bool presenceOfPfls(false);
226 for(std::size_t i=0;i<sz && !presenceOfPfls;i++)
228 const DataArrayInt *pfl(_pfls[i]);
233 { famIds=const_cast<DataArrayInt *>(fids); famIds->incrRef(); isWithoutCopy=_cell_fam_ids_nocpy; return ; }
234 //bad luck the slowest part
236 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > retSafe(sz);
237 std::vector< const DataArrayInt *> ret(sz);
239 for(std::size_t i=0;i<sz;i++)
241 const DataArrayInt *pfl(_pfls[i]);
242 int lgth(_nb_entities[i]);
245 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(fids->selectByTupleId2(start,start+lgth,1));
246 retSafe[i]=tmp->selectByTupleIdSafe(pfl->begin(),pfl->end());
250 retSafe[i]=fids->selectByTupleId2(start,start+lgth,1);
255 famIds=DataArrayInt::Aggregate(ret);
259 * \param [out] numIds - Can be null. If not null the instance has to be dealt by the caller (decrRef).
260 * \param [out] isWithoutCopy - When true the returned instance \a numIds if not null is directly those in the data structure.
262 void MEDMeshMultiLev::retrieveNumberIdsOnCells(DataArrayInt *& numIds, bool& isWithoutCopy) const
264 const DataArrayInt *nids(_cell_num_ids);
266 { numIds=0; isWithoutCopy=true; return ; }
267 std::size_t sz(_geo_types.size());
268 bool presenceOfPfls(false);
269 for(std::size_t i=0;i<sz && !presenceOfPfls;i++)
271 const DataArrayInt *pfl(_pfls[i]);
276 { numIds=const_cast<DataArrayInt *>(nids); numIds->incrRef(); isWithoutCopy=_cell_num_ids_nocpy; return ; }
277 //bad luck the slowest part
279 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > retSafe(sz);
280 std::vector< const DataArrayInt *> ret(sz);
282 for(std::size_t i=0;i<sz;i++)
284 const DataArrayInt *pfl(_pfls[i]);
285 int lgth(_nb_entities[i]);
288 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(nids->selectByTupleId2(start,start+lgth,1));
289 retSafe[i]=tmp->selectByTupleIdSafe(pfl->begin(),pfl->end());
293 retSafe[i]=nids->selectByTupleId2(start,start+lgth,1);
298 numIds=DataArrayInt::Aggregate(ret);
302 * \param [out] famIds - Can be null. If not null the instance has to be dealt by the caller (decrRef).
303 * \param [out] isWithoutCopy - When true the returned instance \a famIds if not null is directly those in the data structure.
305 void MEDMeshMultiLev::retrieveFamilyIdsOnNodes(DataArrayInt *& famIds, bool& isWithoutCopy) const
307 const DataArrayInt *fids(_node_fam_ids);
309 { famIds=0; isWithoutCopy=true; return ; }
310 const DataArrayInt *nr(_node_reduction);
314 famIds=fids->selectByTupleIdSafe(nr->begin(),nr->end());
318 isWithoutCopy=_node_fam_ids_nocpy;
319 famIds=const_cast<DataArrayInt *>(fids); famIds->incrRef();
324 * \param [out] numIds - Can be null. If not null the instance has to be dealt by the caller (decrRef).
325 * \param [out] isWithoutCopy - When true the returned instance \a numIds if not null is directly those in the data structure.
327 void MEDMeshMultiLev::retrieveNumberIdsOnNodes(DataArrayInt *& numIds, bool& isWithoutCopy) const
329 const DataArrayInt *fids(_node_num_ids);
331 { numIds=0; isWithoutCopy=true; return ; }
332 const DataArrayInt *nr(_node_reduction);
336 numIds=fids->selectByTupleIdSafe(nr->begin(),nr->end());
340 isWithoutCopy=_node_num_ids_nocpy;
341 numIds=const_cast<DataArrayInt *>(fids); numIds->incrRef();
345 std::vector< INTERP_KERNEL::NormalizedCellType > MEDMeshMultiLev::getGeoTypes() const
350 void MEDMeshMultiLev::setFamilyIdsOnCells(DataArrayInt *famIds, bool isNoCopy)
352 _cell_fam_ids=famIds;
355 _cell_fam_ids_nocpy=isNoCopy;
358 void MEDMeshMultiLev::setNumberIdsOnCells(DataArrayInt *numIds, bool isNoCopy)
360 _cell_num_ids=numIds;
363 _cell_num_ids_nocpy=isNoCopy;
366 void MEDMeshMultiLev::setFamilyIdsOnNodes(DataArrayInt *famIds, bool isNoCopy)
368 _node_fam_ids=famIds;
371 _node_fam_ids_nocpy=isNoCopy;
374 void MEDMeshMultiLev::setNumberIdsOnNodes(DataArrayInt *numIds, bool isNoCopy)
376 _node_num_ids=numIds;
379 _node_num_ids_nocpy=isNoCopy;
382 std::string MEDMeshMultiLev::getPflNameOfId(int id) const
384 std::size_t sz(_pfls.size());
385 if(id<0 || id>=(int)sz)
386 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::getPflNameOfId : invalid input id !");
387 const DataArrayInt *pfl(_pfls[id]);
389 return std::string("");
390 return pfl->getName();
394 * Returns the number of cells having geometric type \a t.
395 * The profiles are **NOT** taken into account here.
397 int MEDMeshMultiLev::getNumberOfCells(INTERP_KERNEL::NormalizedCellType t) const
399 std::size_t sz(_nb_entities.size());
400 for(std::size_t i=0;i<sz;i++)
402 return _nb_entities[i];
403 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::getNumberOfCells : not existing geometric type in this !");
406 int MEDMeshMultiLev::getNumberOfNodes() const
411 DataArray *MEDMeshMultiLev::constructDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const
413 if(fst.getType()==ON_NODES)
415 if(fst.getNumberOfItems()!=1)
416 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes !");
417 const MEDFileField1TSStructItem2& p(fst[0]);
418 std::string pflName(p.getPflName());
419 const DataArrayInt *nr(_node_reduction);
420 if(pflName.empty() && !nr)
421 return vals->deepCpy();
422 if(pflName.empty() && nr)
423 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 2 !");
424 if(!pflName.empty() && nr)
426 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(globs->getProfile(pflName.c_str())->deepCpy());
427 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p2(nr->deepCpy());
428 p1->sort(true); p2->sort(true);
429 if(!p1->isEqualWithoutConsideringStr(*p2))
430 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : it appears that a profile on nodes does not cover the cells correctly !");
431 p1=DataArrayInt::FindPermutationFromFirstToSecond(globs->getProfile(pflName.c_str()),nr);
432 MEDCouplingAutoRefCountObjectPtr<DataArray> ret(vals->deepCpy());
433 ret->renumberInPlace(p1->begin());
436 if(!pflName.empty() && !nr)
438 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(globs->getProfile(pflName.c_str())->deepCpy());
440 if(!p1->isIdentity() || p1->getNumberOfTuples()!=getNumberOfNodes())
441 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 4 !");
442 MEDCouplingAutoRefCountObjectPtr<DataArray> ret(vals->deepCpy());
443 ret->renumberInPlace(globs->getProfile(pflName.c_str())->begin());
446 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 5 !");
450 std::size_t sz(fst.getNumberOfItems());
451 std::set<INTERP_KERNEL::NormalizedCellType> s(_geo_types.begin(),_geo_types.end());
452 if(s.size()!=_geo_types.size())
453 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 2 !");
454 std::vector< const DataArray *> arr(s.size());
455 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArray> > arrSafe(s.size());
457 int nc(vals->getNumberOfComponents());
458 std::vector<std::string> compInfo(vals->getInfoOnComponents());
459 for(std::vector< INTERP_KERNEL::NormalizedCellType >::const_iterator it=_geo_types.begin();it!=_geo_types.end();it++,iii++)
461 const DataArrayInt *thisP(_pfls[iii]);
462 std::vector<const MEDFileField1TSStructItem2 *> ps;
463 for(std::size_t i=0;i<sz;i++)
465 const MEDFileField1TSStructItem2& p(fst[i]);
470 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 1 !");
473 int nbi(ps[0]->getNbOfIntegrationPts(globs));
474 const DataArrayInt *otherP(ps[0]->getPfl(globs));
475 const std::pair<int,int>& strtStop(ps[0]->getStartStop());
476 MEDCouplingAutoRefCountObjectPtr<DataArray> ret(vals->selectByTupleId2(strtStop.first,strtStop.second,1));
477 if(!thisP && !otherP)
479 arrSafe[iii]=ret; arr[iii]=ret;
484 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(otherP->invertArrayN2O2O2N(getNumberOfCells(ps[0]->getGeo())));
485 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p2(thisP->deepCpy());
486 p2->transformWithIndArr(p1->begin(),p1->end());
487 //p1=p2->getIdsNotEqual(-1);
488 //p1=p2->selectByTupleIdSafe(p1->begin(),p1->end());
489 ret->rearrange(nbi*nc); ret=ret->selectByTupleIdSafe(p2->begin(),p2->end()); ret->rearrange(nc); ret->setInfoOnComponents(compInfo);
490 arrSafe[iii]=ret; arr[iii]=ret;
495 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(otherP->deepCpy());
497 p1->checkAllIdsInRange(0,getNumberOfCells(ps[0]->getGeo()));
498 p1=DataArrayInt::FindPermutationFromFirstToSecond(otherP,p1);
499 ret->rearrange(nbi*nc); ret->renumberInPlace(p1->begin()); ret->rearrange(nc); ret->setInfoOnComponents(compInfo);
500 arrSafe[iii]=ret; arr[iii]=ret;
503 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 3 !");
507 std::vector< const DataArrayInt * >otherPS(ps.size());
508 std::vector< const DataArray * > arr2(ps.size());
509 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArray> > arr2Safe(ps.size());
510 std::vector< const DataArrayInt * > nbis(ps.size());
511 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > nbisSafe(ps.size());
513 for(std::vector<const MEDFileField1TSStructItem2 *>::const_iterator it2=ps.begin();it2!=ps.end();it2++,jj++)
515 int nbi((*it2)->getNbOfIntegrationPts(globs));
516 const DataArrayInt *otherPfl((*it2)->getPfl(globs));
517 const std::pair<int,int>& strtStop((*it2)->getStartStop());
518 MEDCouplingAutoRefCountObjectPtr<DataArray> ret2(vals->selectByTupleId2(strtStop.first,strtStop.second,1));
520 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 4 !");
521 arr2[jj]=ret2; arr2Safe[jj]=ret2; otherPS[jj]=otherPfl;
522 nbisSafe[jj]=DataArrayInt::New(); nbisSafe[jj]->alloc(otherPfl->getNumberOfTuples(),1); nbisSafe[jj]->fillWithValue(nbi);
523 nbis[jj]=nbisSafe[jj];
525 MEDCouplingAutoRefCountObjectPtr<DataArray> arr3(DataArray::Aggregate(arr2));
526 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> otherP(DataArrayInt::Aggregate(otherPS));
527 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> zenbis(DataArrayInt::Aggregate(nbis));
528 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> otherPN(otherP->invertArrayN2O2O2N(getNumberOfCells(*it)));
529 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1;
531 p1=DataArrayInt::FindPermutationFromFirstToSecond(otherP,thisP);
533 p1=otherP->deepCpy();
534 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> zenbisN(zenbis->renumber(p1->begin()));
535 zenbisN->computeOffsets2();
537 for(std::vector<const MEDFileField1TSStructItem2 *>::const_iterator it2=ps.begin();it2!=ps.end();it2++,jj++)
539 //int nbi((*it2)->getNbOfIntegrationPts(globs));
540 const DataArrayInt *otherPfl((*it2)->getPfl(globs));
541 const std::pair<int,int>& strtStop((*it2)->getStartStop());
542 MEDCouplingAutoRefCountObjectPtr<DataArray> ret2(vals->selectByTupleId2(strtStop.first,strtStop.second,1));
544 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p2(otherPfl->deepCpy());
545 p2->transformWithIndArr(otherPN->begin(),otherPN->end());
546 p2->transformWithIndArr(p1->begin(),p1->end());
547 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsN(p2->buildExplicitArrByRanges(zenbisN));
548 arr3->setPartOfValuesBase3(ret2,idsN->begin(),idsN->end(),0,nc,1);
550 arrSafe[iii]=arr3; arr[iii]=arr3;
554 return DataArray::Aggregate(arr);
559 * This method is called to add NORM_POINT1 cells in \a this so that orphan nodes in \a verticesToAdd will be fetched.
561 void MEDMeshMultiLev::appendVertices(const DataArrayInt *verticesToAdd, DataArrayInt *nr)
563 int nbOfVertices(verticesToAdd->getNumberOfTuples());
564 std::size_t sz(_pfls.size());
566 _geo_types.resize(sz+1,INTERP_KERNEL::NORM_POINT1);
567 _nb_entities.resize(sz+1,nbOfVertices);
568 _node_reduction=nr; nr->incrRef();
569 _nb_nodes+=nbOfVertices;
570 const DataArrayInt *cf(_cell_fam_ids),*cn(_cell_num_ids),*nf(_node_fam_ids),*nn(_node_num_ids);
573 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp;
574 std::vector<const DataArrayInt *> a(2);
577 tmp=nf->selectByTupleIdSafe(verticesToAdd->begin(),verticesToAdd->end());
580 tmp=DataArrayInt::New(); tmp->alloc(nbOfVertices,1); tmp->fillWithZero();
583 _cell_fam_ids=DataArrayInt::Aggregate(a);
584 _cell_fam_ids_nocpy=false;
588 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp;
589 std::vector<const DataArrayInt *> a(2);
592 tmp=nn->selectByTupleIdSafe(verticesToAdd->begin(),verticesToAdd->end());
595 tmp=DataArrayInt::New(); tmp->alloc(nbOfVertices,1); tmp->fillWithZero();
598 _cell_num_ids=DataArrayInt::Aggregate(a);
599 _cell_num_ids_nocpy=false;
603 MEDMeshMultiLev::MEDMeshMultiLev():_nb_nodes(0),_cell_fam_ids_nocpy(false)
607 MEDMeshMultiLev::MEDMeshMultiLev(int nbNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):_geo_types(gts),_nb_entities(nbEntities),_nb_nodes(nbNodes),_cell_fam_ids_nocpy(false),_cell_num_ids_nocpy(false),_node_fam_ids_nocpy(false),_node_num_ids_nocpy(false)
609 std::size_t sz(_geo_types.size());
610 if(sz!=pfls.size() || sz!=nbEntities.size())
611 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::MEDMeshMultiLev : input vector must have the same size !");
613 for(std::size_t i=0;i<sz;i++)
617 _pfls[i]=const_cast<DataArrayInt *>(pfls[i]);
621 MEDMeshMultiLev::MEDMeshMultiLev(const MEDMeshMultiLev& other):RefCountObject(other),_pfls(other._pfls),_geo_types(other._geo_types),_nb_entities(other._nb_entities),_node_reduction(other._node_reduction),_nb_nodes(other._nb_nodes),_cell_fam_ids(other._cell_fam_ids),_cell_fam_ids_nocpy(other._cell_fam_ids_nocpy),_cell_num_ids(other._cell_num_ids),_cell_num_ids_nocpy(other._cell_num_ids_nocpy),_node_fam_ids(other._node_fam_ids),_node_fam_ids_nocpy(other._node_fam_ids_nocpy),_node_num_ids(other._node_num_ids),_node_num_ids_nocpy(other._node_num_ids_nocpy)
627 MEDUMeshMultiLev *MEDUMeshMultiLev::New(const MEDFileUMesh *m, const std::vector<int>& levs)
629 return new MEDUMeshMultiLev(m,levs);
632 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<int>& levs)
635 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev constructor : null input pointer !");
636 std::vector<MEDCoupling1GTUMesh *> v;
637 for(std::vector<int>::const_iterator it=levs.begin();it!=levs.end();it++)
639 std::vector<MEDCoupling1GTUMesh *> vTmp(m->getDirectUndergroundSingleGeoTypeMeshes(*it));
640 v.insert(v.end(),vTmp.begin(),vTmp.end());
642 std::size_t sz(v.size());
645 _coords=m->getCoords(); _coords->incrRef();
649 _geo_types.resize(sz);
650 _nb_entities.resize(sz);
651 for(std::size_t i=0;i<sz;i++)
653 MEDCoupling1GTUMesh *obj(v[i]);
657 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev constructor : presence of a null pointer !");
659 _geo_types[i]=obj->getCellModelEnum();
660 _nb_entities[i]=obj->getNumberOfCells();
662 // ids fields management
663 _cell_fam_ids_nocpy=(levs.size()==1);
664 if(_cell_fam_ids_nocpy)
666 const DataArrayInt *tmp(m->getFamilyFieldAtLevel(levs[0]));
670 _cell_fam_ids=(const_cast<DataArrayInt *>(tmp));
675 std::vector<const DataArrayInt *> tmps(levs.size());
677 for(std::size_t i=0;i<levs.size();i++)
679 tmps[i]=m->getFamilyFieldAtLevel(levs[i]);
683 if(f && !tmps.empty())
684 _cell_fam_ids=DataArrayInt::Aggregate(tmps);
686 _cell_num_ids_nocpy=(levs.size()==1);
687 if(_cell_num_ids_nocpy)
689 const DataArrayInt *tmp(m->getNumberFieldAtLevel(levs[0]));
693 _cell_num_ids=(const_cast<DataArrayInt *>(tmp));
698 std::vector<const DataArrayInt *> tmps(levs.size());
700 for(std::size_t i=0;i<levs.size();i++)
702 tmps[i]=m->getNumberFieldAtLevel(levs[i]);
706 if(n && !tmps.empty())
707 _cell_num_ids=DataArrayInt::Aggregate(tmps);
710 _node_fam_ids_nocpy=true;
712 const DataArrayInt *tmp(m->getFamilyFieldAtLevel(1));
716 _node_fam_ids=(const_cast<DataArrayInt *>(tmp));
719 _node_num_ids_nocpy=true;
721 const DataArrayInt *tmp(m->getNumberFieldAtLevel(1));
725 _node_num_ids=(const_cast<DataArrayInt *>(tmp));
730 MEDUMeshMultiLev *MEDUMeshMultiLev::New(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities)
732 return new MEDUMeshMultiLev(m,gts,pfls,nbEntities);
735 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDMeshMultiLev(m->getNumberOfNodes(),gts,pfls,nbEntities)
737 std::size_t sz(gts.size());
739 throw INTERP_KERNEL::Exception("constructor of MEDUMeshMultiLev : number of different geo type must be >= 1 !");
740 unsigned dim(INTERP_KERNEL::CellModel::GetCellModel(gts[0]).getDimension());
742 bool isSameDim(true),isNoPfl(true);
743 for(std::size_t i=0;i<sz;i++)
745 MEDCoupling1GTUMesh *elt(m->getDirectUndergroundSingleGeoTypeMesh(gts[i]));
746 if(INTERP_KERNEL::CellModel::GetCellModel(gts[i]).getDimension()!=dim)
754 // ids fields management
755 int lev((int)dim-m->getMeshDimension());
756 if(isSameDim && isNoPfl && m->getGeoTypesAtLevel(lev)==gts)//optimized part
758 _cell_fam_ids_nocpy=true;
759 const DataArrayInt *famIds(m->getFamilyFieldAtLevel(lev));
761 { _cell_fam_ids=const_cast<DataArrayInt*>(famIds); famIds->incrRef(); }
762 _cell_num_ids_nocpy=true;
763 const DataArrayInt *numIds(m->getNumberFieldAtLevel(lev));
765 { _cell_num_ids=const_cast<DataArrayInt*>(numIds); numIds->incrRef(); }
766 _node_fam_ids_nocpy=true;
767 famIds=m->getFamilyFieldAtLevel(1);
769 { _node_fam_ids=const_cast<DataArrayInt*>(famIds); famIds->incrRef(); }
770 _node_num_ids_nocpy=true;
771 numIds=m->getNumberFieldAtLevel(1);
773 { _node_num_ids=const_cast<DataArrayInt*>(numIds); numIds->incrRef(); }
777 _cell_fam_ids_nocpy=false;
778 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > famIdsSafe(sz);
779 std::vector<const DataArrayInt *> famIds(sz);
781 for(std::size_t i=0;i<sz;i++)
783 famIdsSafe[i]=m->extractFamilyFieldOnGeoType(gts[i]);
784 famIds[i]=famIdsSafe[i];
789 _cell_fam_ids=DataArrayInt::Aggregate(famIds);
790 _cell_num_ids_nocpy=false;
791 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > numIdsSafe(sz);
792 std::vector<const DataArrayInt *> numIds(sz);
794 for(std::size_t i=0;i<sz;i++)
796 numIdsSafe[i]=m->extractNumberFieldOnGeoType(gts[i]);
797 numIds[i]=numIdsSafe[i];
802 _cell_num_ids=DataArrayInt::Aggregate(numIds);
803 // node ids management
804 _node_fam_ids_nocpy=true;
805 const DataArrayInt *nodeFamIds(m->getFamilyFieldAtLevel(1));
807 { _node_fam_ids=const_cast<DataArrayInt*>(nodeFamIds); nodeFamIds->incrRef(); }
808 _node_num_ids_nocpy=true;
809 const DataArrayInt *nodeNumIds(m->getNumberFieldAtLevel(1));
811 { _node_num_ids=const_cast<DataArrayInt*>(nodeNumIds); nodeNumIds->incrRef(); }
814 void MEDUMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes)
816 if(!pflNodes || !pflNodes->isAllocated())
818 std::size_t sz(_parts.size());
819 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > a(sz);
820 std::vector< const DataArrayInt *> aa(sz);
821 for(std::size_t i=0;i<sz;i++)
823 const DataArrayInt *pfl(_pfls[i]);
824 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> m(_parts[i]);
826 m=dynamic_cast<MEDCoupling1GTUMesh *>(_parts[i]->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
827 DataArrayInt *cellIds=0;
828 m->fillCellIdsToKeepFromNodeIds(pflNodes->begin(),pflNodes->end(),true,cellIds);
829 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIdsSafe(cellIds);
830 MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> m2(m->buildPartOfMySelfKeepCoords(cellIds->begin(),cellIds->end()));
832 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n(m2->getNodeIdsInUse(tmp));
833 a[i]=o2n->invertArrayO2N2N2O(tmp); aa[i]=a[i];
835 _pfls[i]=pfl->selectByTupleIdSafe(cellIds->begin(),cellIds->end());
837 _pfls[i]=cellIdsSafe;
840 _node_reduction=DataArrayInt::Aggregate(aa);//general case
842 _node_reduction=pflNodes->deepCpy();//case where no cells in read mesh.
843 _node_reduction->sort(true);
844 _node_reduction=_node_reduction->buildUnique();
845 if(_node_reduction->getNumberOfTuples()==pflNodes->getNumberOfTuples())
846 return ;//This is the classical case where the input node profile corresponds perfectly to a subset of cells in _parts
847 if(_node_reduction->getNumberOfTuples()>pflNodes->getNumberOfTuples())
848 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::selectPartOfNodes : internal error in MEDCoupling during cell select from a list of nodes !");
849 // Here the cells available in _parts is not enough to cover all the nodes in pflNodes. So adding vertices cells in _parts...
850 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pflNodes2(pflNodes->deepCpy());
851 pflNodes2->sort(true);
852 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diff(pflNodes2->buildSubstractionOptimized(_node_reduction));
853 appendVertices(diff,pflNodes2);
856 MEDMeshMultiLev *MEDUMeshMultiLev::prepare() const
858 return new MEDUMeshMultiLev(*this);
861 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDUMeshMultiLev& other):MEDMeshMultiLev(other),_parts(other._parts),_coords(other._coords)
865 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDStructuredMeshMultiLev& other, const MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh>& part):MEDMeshMultiLev(other)
869 _geo_types.resize(1); _geo_types[0]=part->getCellModelEnum();
870 _nb_entities.resize(1); _nb_entities[0]=part->getNumberOfCells();
871 _pfls.resize(1); _pfls[0]=0;
875 * 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.
876 * 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.
878 bool MEDUMeshMultiLev::buildVTUArrays(DataArrayDouble *& coords, DataArrayByte *&types, DataArrayInt *&cellLocations, DataArrayInt *& cells, DataArrayInt *&faceLocations, DataArrayInt *&faces) const
880 const DataArrayDouble *tmp(0);
884 tmp=_parts[0]->getCoords();
886 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : the coordinates are null !");
887 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> a(const_cast<DataArrayDouble *>(tmp)); tmp->incrRef();
888 int szBCE(0),szD(0),szF(0);
891 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_parts.begin();it!=_parts.end();it++,iii++)
893 const MEDCoupling1GTUMesh *cur(*it);
895 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : a part is null !");
897 const DataArrayInt *pfl(_pfls[iii]);
898 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> cur2;
900 { cur2=const_cast<MEDCoupling1GTUMesh *>(cur); cur2->incrRef(); }
902 { cur2=dynamic_cast<MEDCoupling1GTUMesh *>(cur->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end())); cur=cur2; }
904 int curNbCells(cur->getNumberOfCells());
906 if((*it)->getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED)
907 szD+=cur->getNodalConnectivity()->getNumberOfTuples()+curNbCells;
911 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp2(cur->computeEffectiveNbOfNodesPerCell());
912 szD+=tmp2->accumulate(0)+curNbCells;
913 szF+=2*curNbCells+cur->getNodalConnectivity()->getNumberOfTuples();
916 MEDCouplingAutoRefCountObjectPtr<DataArrayByte> b(DataArrayByte::New()); b->alloc(szBCE,1); char *bPtr(b->getPointer());
917 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c(DataArrayInt::New()); c->alloc(szBCE,1); int *cPtr(c->getPointer());
918 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d(DataArrayInt::New()); d->alloc(szD,1); int *dPtr(d->getPointer());
919 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> e(DataArrayInt::New()),f(DataArrayInt::New()); int *ePtr(0),*fPtr(0);
921 { e->alloc(szBCE,1); ePtr=e->getPointer(); f->alloc(szF,1); fPtr=f->getPointer(); }
924 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_parts.begin();it!=_parts.end();it++,iii++)
926 const MEDCoupling1GTUMesh *cur(*it);
928 const DataArrayInt *pfl(_pfls[iii]);
929 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> cur2;
931 { cur2=const_cast<MEDCoupling1GTUMesh *>(cur); cur2->incrRef(); }
933 { cur2=dynamic_cast<MEDCoupling1GTUMesh *>(cur->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end())); cur=cur2; }
935 int curNbCells(cur->getNumberOfCells());
936 int gt((int)cur->getCellModelEnum());
937 if(gt<0 || gt>=PARAMEDMEM_2_VTKTYPE_LGTH)
938 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : invalid geometric type !");
939 unsigned char gtvtk(PARAMEDMEM_2_VTKTYPE[gt]);
941 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : no VTK type for the requested INTERP_KERNEL geometric type !");
942 std::fill(bPtr,bPtr+curNbCells,gtvtk); bPtr+=curNbCells;
943 const MEDCoupling1SGTUMesh *scur(dynamic_cast<const MEDCoupling1SGTUMesh *>(cur));
944 const MEDCoupling1DGTUMesh *dcur(dynamic_cast<const MEDCoupling1DGTUMesh *>(cur));
945 const int *connPtr(cur->getNodalConnectivity()->begin());
947 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : internal error !");
950 if(cur->getCellModelEnum()!=INTERP_KERNEL::NORM_HEXA27)
952 int nnpc(scur->getNumberOfNodesPerCell());
953 for(int i=0;i<curNbCells;i++,connPtr+=nnpc)
956 dPtr=std::copy(connPtr,connPtr+nnpc,dPtr);
957 *cPtr++=k; k+=nnpc+1;
962 for(int i=0;i<curNbCells;i++,connPtr+=27)
965 for(int j=0;j<27;j++,dPtr++)
966 *dPtr=connPtr[HEXA27_PERM_ARRAY[j]];
971 { std::fill(ePtr,ePtr+curNbCells,-1); ePtr+=curNbCells; }
975 const int *connIPtr(dcur->getNodalConnectivityIndex()->begin());
976 if(cur->getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED)
978 for(int i=0;i<curNbCells;i++,connIPtr++)
980 *dPtr++=connIPtr[1]-connIPtr[0];
981 dPtr=std::copy(connPtr+connIPtr[0],connPtr+connIPtr[1],dPtr);
982 *cPtr++=k; k+=connIPtr[1]-connIPtr[0];
987 for(int i=0;i<curNbCells;i++,connIPtr++)
989 std::set<int> s(connPtr+connIPtr[0],connPtr+connIPtr[1]); s.erase(-1);
990 *dPtr++=(int)s.size();
991 dPtr=std::copy(s.begin(),s.end(),dPtr);
992 *cPtr++=k; k+=(int)s.size()+1;
997 connIPtr=dcur->getNodalConnectivityIndex()->begin();
998 if(cur->getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED)
999 { std::fill(ePtr,ePtr+curNbCells,-1); ePtr+=curNbCells; }
1003 for(int i=0;i<curNbCells;i++,connIPtr++)
1005 int nbFace(std::count(connPtr+connIPtr[0],connPtr+connIPtr[1],-1)+1);
1007 const int *work(connPtr+connIPtr[0]);
1008 for(int j=0;j<nbFace;j++)
1010 const int *work2=std::find(work,connPtr+connIPtr[1],-1);
1011 *fPtr++=std::distance(work,work2);
1012 fPtr=std::copy(work,work2,fPtr);
1015 *ePtr++=kk; kk+=connIPtr[1]-connIPtr[0]+2;
1022 reorderNodesIfNecessary(a,d,0);
1024 reorderNodesIfNecessary(a,d,f);
1025 if(a->getNumberOfComponents()!=3)
1026 a=a->changeNbOfComponents(3,0.);
1027 coords=a.retn(); types=b.retn(); cellLocations=c.retn(); cells=d.retn();
1029 { faceLocations=0; faces=0; }
1031 { faceLocations=e.retn(); faces=f.retn(); }
1032 return tmp==((DataArrayDouble *)a);
1035 void MEDUMeshMultiLev::reorderNodesIfNecessary(MEDCouplingAutoRefCountObjectPtr<DataArrayDouble>& coords, DataArrayInt *nodalConnVTK, DataArrayInt *polyhedNodalConnVTK) const
1037 const DataArrayInt *nr(_node_reduction);
1040 if(nodalConnVTK->empty() && !polyhedNodalConnVTK)
1042 coords=(coords->selectByTupleIdSafe(nr->begin(),nr->end()));
1045 int sz(coords->getNumberOfTuples());
1046 std::vector<bool> b(sz,false);
1047 const int *work(nodalConnVTK->begin()),*endW(nodalConnVTK->end());
1051 for(int i=0;i<nb && work!=endW;i++,work++)
1053 if(*work>=0 && *work<sz)
1056 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::reorderNodesIfNecessary : internal error !");
1059 if(polyhedNodalConnVTK)
1061 work=polyhedNodalConnVTK->begin(); endW=polyhedNodalConnVTK->end();
1065 for(int i=0;i<nb && work!=endW;i++)
1068 for(int j=0;j<nb2 && work!=endW;j++,work++)
1070 if(*work>=0 && *work<sz)
1073 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::reorderNodesIfNecessary : internal error #2 !");
1078 int szExp(std::count(b.begin(),b.end(),true));
1079 if(szExp!=nr->getNumberOfTuples())
1080 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::reorderNodesIfNecessary : internal error #3 !");
1082 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n(DataArrayInt::New()); o2n->alloc(sz,1);
1083 int *o2nPtr(o2n->getPointer());
1085 for(int i=0;i<sz;i++,o2nPtr++)
1086 if(b[i]) *o2nPtr=newId++; else *o2nPtr=-1;
1087 const int *o2nPtrc(o2n->begin());
1088 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> n2o(o2n->invertArrayO2N2N2O(nr->getNumberOfTuples()));
1089 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> perm(DataArrayInt::FindPermutationFromFirstToSecond(n2o,nr));
1090 const int *permPtr(perm->begin());
1091 int *work2(nodalConnVTK->getPointer()),*endW2(nodalConnVTK->getPointer()+nodalConnVTK->getNumberOfTuples());
1095 for(int i=0;i<nb && work2!=endW2;i++,work2++)
1096 *work2=permPtr[o2nPtrc[*work2]];
1098 if(polyhedNodalConnVTK)
1100 work2=polyhedNodalConnVTK->getPointer(); endW2=polyhedNodalConnVTK->getPointer()+polyhedNodalConnVTK->getNumberOfTuples();
1104 for(int i=0;i<nb && work2!=endW2;i++)
1107 for(int j=0;j<nb2 && work2!=endW2;j++,work2++)
1108 *work2=permPtr[o2nPtrc[*work2]];
1112 coords=(coords->selectByTupleIdSafe(nr->begin(),nr->end()));
1116 void MEDUMeshMultiLev::appendVertices(const DataArrayInt *verticesToAdd, DataArrayInt *nr)
1118 int nbOfCells(verticesToAdd->getNumberOfTuples());//it is not a bug cells are NORM_POINT1
1119 MEDMeshMultiLev::appendVertices(verticesToAdd,nr);
1120 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> elt(MEDCoupling1SGTUMesh::New("",INTERP_KERNEL::NORM_POINT1));
1121 elt->allocateCells(nbOfCells);
1122 for(int i=0;i<nbOfCells;i++)
1124 int pt(verticesToAdd->getIJ(i,0));
1125 elt->insertNextCell(&pt,&pt+1);
1128 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::appendVertices : parts are empty !");
1129 elt->setCoords(_parts[0]->getCoords());
1130 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> elt2((MEDCoupling1SGTUMesh *)elt); elt2->incrRef();
1131 _parts.push_back(elt2);
1136 MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev():_is_internal(true)
1140 MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector<int>& lev):_is_internal(true)
1142 // ids fields management
1143 _cell_fam_ids_nocpy=true; _cell_num_ids_nocpy=true;
1144 const DataArrayInt *tmp(0);
1145 tmp=m->getFamilyFieldAtLevel(0);
1149 _cell_fam_ids=const_cast<DataArrayInt *>(tmp);
1151 tmp=m->getNumberFieldAtLevel(0);
1155 _cell_num_ids=const_cast<DataArrayInt *>(tmp);
1158 _node_fam_ids_nocpy=true; _node_num_ids_nocpy=true;
1160 tmp=m->getFamilyFieldAtLevel(1);
1164 _node_fam_ids=const_cast<DataArrayInt *>(tmp);
1166 tmp=m->getNumberFieldAtLevel(1);
1170 _node_num_ids=const_cast<DataArrayInt *>(tmp);
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(nbOfNodes,gts,pfls,nbEntities),_is_internal(true)
1176 // ids fields management
1177 _cell_fam_ids_nocpy=true; _cell_num_ids_nocpy=true;
1178 const DataArrayInt *tmp(0);
1179 tmp=m->getFamilyFieldAtLevel(0);
1183 _cell_fam_ids=const_cast<DataArrayInt *>(tmp);
1185 tmp=m->getNumberFieldAtLevel(0);
1189 _cell_num_ids=const_cast<DataArrayInt *>(tmp);
1192 _node_fam_ids_nocpy=true; _node_num_ids_nocpy=true;
1194 tmp=m->getFamilyFieldAtLevel(1);
1198 _node_fam_ids=const_cast<DataArrayInt *>(tmp);
1200 tmp=m->getNumberFieldAtLevel(1);
1204 _node_num_ids=const_cast<DataArrayInt *>(tmp);
1208 MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other):MEDMeshMultiLev(other),_is_internal(true)
1212 void MEDStructuredMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes)
1214 if(!pflNodes || !pflNodes->isAllocated())
1216 std::vector<int> ngs(getNodeGridStructure());
1217 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(MEDCouplingStructuredMesh::Build1GTNodalConnectivity(&ngs[0],&ngs[0]+ngs.size()));
1218 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> m(MEDCoupling1SGTUMesh::New("",MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(ngs.size())));
1219 m->setNodalConnectivity(conn);
1220 const DataArrayInt *pfl(_pfls[0]);
1223 m=dynamic_cast<MEDCoupling1SGTUMesh *>(m->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
1225 DataArrayInt *cellIds=0;
1226 m->fillCellIdsToKeepFromNodeIds(pflNodes->begin(),pflNodes->end(),true,cellIds);
1227 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIdsSafe(cellIds);
1228 MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> m2(m->buildPartOfMySelfKeepCoords(cellIds->begin(),cellIds->end()));
1230 _node_reduction=m2->getNodeIdsInUse(tmp);
1232 _pfls[0]=pfl->selectByTupleIdSafe(cellIds->begin(),cellIds->end());
1234 _pfls[0]=cellIdsSafe;
1239 MEDCMeshMultiLev *MEDCMeshMultiLev::New(const MEDFileCMesh *m, const std::vector<int>& levs)
1241 return new MEDCMeshMultiLev(m,levs);
1244 MEDCMeshMultiLev *MEDCMeshMultiLev::New(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities)
1246 return new MEDCMeshMultiLev(m,gts,pfls,nbEntities);
1249 MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<int>& levs):MEDStructuredMeshMultiLev(m,levs)
1252 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor : null input pointer !");
1253 if(levs.size()!=1 || levs[0]!=0)
1254 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor : levels supported is 0 only !");
1255 int sdim(m->getSpaceDimension());
1256 _coords.resize(sdim);
1257 for(int i=0;i<sdim;i++)
1259 DataArrayDouble *elt(const_cast<DataArrayDouble *>(m->getMesh()->getCoordsAt(i)));
1261 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : presence of null pointer for an vector of double along an axis !");
1267 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)
1270 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : null input pointer !");
1271 if(gts.size()!=1 || pfls.size()!=1)
1272 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : lengthes of gts and pfls must be equal to one !");
1273 int mdim(m->getMeshDimension());
1274 INTERP_KERNEL::NormalizedCellType gt(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(mdim));
1276 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : the unique geo type is invalid regarding meshdim !");
1277 _coords.resize(mdim);
1278 for(int i=0;i<mdim;i++)
1280 DataArrayDouble *elt(const_cast<DataArrayDouble *>(m->getMesh()->getCoordsAt(i)));
1282 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : presence of null pointer for an vector of double along an axis !");
1283 _coords[i]=elt; _coords[i]->incrRef();
1287 MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDCMeshMultiLev& other):MEDStructuredMeshMultiLev(other),_coords(other._coords)
1291 std::vector<int> MEDCMeshMultiLev::getNodeGridStructure() const
1293 std::vector<int> ret(_coords.size());
1294 for(std::size_t i=0;i<_coords.size();i++)
1295 ret[i]=_coords[i]->getNumberOfTuples();
1299 MEDMeshMultiLev *MEDCMeshMultiLev::prepare() const
1301 const DataArrayInt *pfl(0),*nr(_node_reduction);
1304 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nnr;
1305 std::vector<int> cgs,ngs(getNodeGridStructure());
1306 cgs.resize(ngs.size());
1307 std::transform(ngs.begin(),ngs.end(),cgs.begin(),std::bind2nd(std::plus<int>(),-1));
1310 std::vector< std::pair<int,int> > cellParts;
1311 MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> ret2;
1312 if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts))
1314 MEDCouplingAutoRefCountObjectPtr<MEDCMeshMultiLev> ret(new MEDCMeshMultiLev(*this));
1315 ret->_is_internal=false;
1317 { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1318 ret->_nb_entities[0]=pfl->getNumberOfTuples();
1320 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > coords(_coords.size());
1321 for(std::size_t i=0;i<_coords.size();i++)
1322 coords[i]=_coords[i]->selectByTupleId2(cellParts[i].first,cellParts[i].second+1,1);
1323 ret->_coords=coords;
1324 ret2=(MEDCMeshMultiLev *)ret; ret2->incrRef();
1328 MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> m(MEDCouplingCMesh::New());
1329 for(std::size_t i=0;i<ngs.size();i++)
1330 m->setCoordsAt(i,_coords[i]);
1331 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> m2(m->build1SGTUnstructured());
1332 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> m3=dynamic_cast<MEDCoupling1GTUMesh *>(m2->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
1333 MEDCouplingAutoRefCountObjectPtr<MEDUMeshMultiLev> ret(new MEDUMeshMultiLev(*this,m3));
1335 { m3->zipCoords(); nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1336 ret2=(MEDUMeshMultiLev *)ret; ret2->incrRef();
1338 const DataArrayInt *famIds(_cell_fam_ids),*numIds(_cell_num_ids);
1341 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(famIds->selectByTupleIdSafe(pfl->begin(),pfl->end()));
1342 ret2->setFamilyIdsOnCells(tmp,false);
1346 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(numIds->selectByTupleIdSafe(pfl->begin(),pfl->end()));
1347 ret2->setNumberIdsOnCells(tmp,false);
1354 MEDCouplingAutoRefCountObjectPtr<MEDCMeshMultiLev> ret(new MEDCMeshMultiLev(*this));
1356 { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1362 * \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.
1364 std::vector< DataArrayDouble * > MEDCMeshMultiLev::buildVTUArrays(bool& isInternal) const
1366 isInternal=_is_internal;
1367 std::size_t sz(_coords.size());
1368 std::vector< DataArrayDouble * > ret(sz);
1369 for(std::size_t i=0;i<sz;i++)
1371 ret[i]=const_cast<DataArrayDouble *>((const DataArrayDouble *)_coords[i]);
1379 MEDCurveLinearMeshMultiLev *MEDCurveLinearMeshMultiLev::New(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs)
1381 return new MEDCurveLinearMeshMultiLev(m,levs);
1384 MEDCurveLinearMeshMultiLev *MEDCurveLinearMeshMultiLev::New(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities)
1386 return new MEDCurveLinearMeshMultiLev(m,gts,pfls,nbEntities);
1389 MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs):MEDStructuredMeshMultiLev(m,levs)
1392 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor : null input pointer !");
1393 if(levs.size()!=1 || levs[0]!=0)
1394 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor : levels supported is 0 only !");
1395 DataArrayDouble *coords(const_cast<DataArrayDouble *>(m->getMesh()->getCoords()));
1397 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : no coords set !");
1400 _structure=m->getMesh()->getNodeGridStructure();
1403 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)
1406 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : null input pointer !");
1407 if(gts.size()!=1 || pfls.size()!=1)
1408 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : lengthes of gts and pfls must be equal to one !");
1409 int mdim(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(m->getMeshDimension()));
1411 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : the unique geo type is invalid regarding meshdim !");
1412 DataArrayDouble *coords(const_cast<DataArrayDouble *>(m->getMesh()->getCoords()));
1414 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : no coords set !");
1417 _structure=m->getMesh()->getNodeGridStructure();
1420 MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDCurveLinearMeshMultiLev& other):MEDStructuredMeshMultiLev(other),_coords(other._coords),_structure(other._structure)
1424 std::vector<int> MEDCurveLinearMeshMultiLev::getNodeGridStructure() const
1429 MEDMeshMultiLev *MEDCurveLinearMeshMultiLev::prepare() const
1431 const DataArrayInt *pfl(0),*nr(_node_reduction);
1434 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nnr;
1435 std::vector<int> cgs,ngs(getNodeGridStructure());
1436 cgs.resize(ngs.size());
1437 std::transform(ngs.begin(),ngs.end(),cgs.begin(),std::bind2nd(std::plus<int>(),-1));
1440 std::vector< std::pair<int,int> > cellParts,nodeParts;
1441 MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> ret2;
1442 if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts))
1444 nodeParts=cellParts;
1445 std::vector<int> st(ngs.size());
1446 for(std::size_t i=0;i<ngs.size();i++)
1448 nodeParts[i].second++;
1449 st[i]=nodeParts[i].second-nodeParts[i].first;
1451 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p(MEDCouplingStructuredMesh::BuildExplicitIdsFrom(ngs,nodeParts));
1452 MEDCouplingAutoRefCountObjectPtr<MEDCurveLinearMeshMultiLev> ret(new MEDCurveLinearMeshMultiLev(*this));
1453 ret->_is_internal=false;
1455 { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1456 ret->_nb_entities[0]=pfl->getNumberOfTuples();
1458 ret->_coords=_coords->selectByTupleIdSafe(p->begin(),p->end());
1460 ret2=(MEDCurveLinearMeshMultiLev *)ret; ret2->incrRef();
1464 MEDCouplingAutoRefCountObjectPtr<MEDCouplingCurveLinearMesh> m(MEDCouplingCurveLinearMesh::New());
1465 m->setCoords(_coords); m->setNodeGridStructure(&_structure[0],&_structure[0]+_structure.size());
1466 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> m2(m->build1SGTUnstructured());
1467 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> m3=dynamic_cast<MEDCoupling1GTUMesh *>(m2->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
1468 MEDCouplingAutoRefCountObjectPtr<MEDUMeshMultiLev> ret(new MEDUMeshMultiLev(*this,m3));
1470 { m3->zipCoords(); nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1471 ret2=(MEDUMeshMultiLev *)ret; ret2->incrRef();
1473 const DataArrayInt *famIds(_cell_fam_ids),*numIds(_cell_num_ids);
1476 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(famIds->selectByTupleIdSafe(pfl->begin(),pfl->end()));
1477 ret2->setFamilyIdsOnCells(tmp,false);
1481 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(numIds->selectByTupleIdSafe(pfl->begin(),pfl->end()));
1482 ret2->setNumberIdsOnCells(tmp,false);
1488 MEDCouplingAutoRefCountObjectPtr<MEDCurveLinearMeshMultiLev> ret(new MEDCurveLinearMeshMultiLev(*this));
1490 { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
1495 void MEDCurveLinearMeshMultiLev::buildVTUArrays(DataArrayDouble *&coords, std::vector<int>& nodeStrct, bool& isInternal) const
1497 isInternal=_is_internal;
1498 nodeStrct=_structure;
1499 const DataArrayDouble *coo(_coords);
1501 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev::buildVTUArrays : null pointer on coordinates !");
1502 coords=const_cast<DataArrayDouble *>(coo); coords->incrRef();
1507 MEDFileField1TSStructItem2::MEDFileField1TSStructItem2()
1511 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)
1513 _pfl->setName(c.c_str());
1516 void MEDFileField1TSStructItem2::checkWithMeshStructForCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
1518 int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
1519 checkInRange(nbOfEnt,1,globs);
1522 void MEDFileField1TSStructItem2::checkWithMeshStructForGaussNE(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
1524 int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
1525 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1526 checkInRange(nbOfEnt,(int)cm.getNumberOfNodes(),globs);
1529 void MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
1532 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT : no globals specified !");
1534 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT : no localization specified !");
1535 const MEDFileFieldLoc& loc=globs->getLocalization(_loc.c_str());
1536 int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
1537 checkInRange(nbOfEnt,loc.getNumberOfGaussPoints(),globs);
1540 int MEDFileField1TSStructItem2::getNbOfIntegrationPts(const MEDFileFieldGlobsReal *globs) const
1544 if(getPflName().empty())
1545 return (_start_end.second-_start_end.first)/_nb_of_entity;
1547 return (_start_end.second-_start_end.first)/getPfl(globs)->getNumberOfTuples();
1551 const MEDFileFieldLoc& loc(globs->getLocalization(_loc.c_str()));
1552 return loc.getNumberOfGaussPoints();
1556 std::string MEDFileField1TSStructItem2::getPflName() const
1558 return _pfl->getName();
1561 const DataArrayInt *MEDFileField1TSStructItem2::getPfl(const MEDFileFieldGlobsReal *globs) const
1563 if(!_pfl->isAllocated())
1565 if(_pfl->getName().empty())
1568 return globs->getProfile(_pfl->getName().c_str());
1575 * \param [in] nbOfEntity - number of entity that can be either cells or nodes. Not other possiblity.
1576 * \param [in] nip - number of integration points. 1 for ON_CELLS and NO_NODES
1578 void MEDFileField1TSStructItem2::checkInRange(int nbOfEntity, int nip, const MEDFileFieldGlobsReal *globs)
1580 _nb_of_entity=nbOfEntity;
1581 if(_pfl->getName().empty())
1583 if(nbOfEntity!=(_start_end.second-_start_end.first)/nip)
1584 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Mismatch between number of entities and size of node field !");
1590 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Presence of a profile on field whereas no globals found in file !");
1591 const DataArrayInt *pfl=globs->getProfile(_pfl->getName().c_str());
1593 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Presence of a profile on field whereas no such profile found in file !");
1594 pfl->checkAllIdsInRange(0,nbOfEntity);
1598 bool MEDFileField1TSStructItem2::isFastlyEqual(int& startExp, INTERP_KERNEL::NormalizedCellType gt, const std::string& pflName) const
1600 if(startExp!=_start_end.first)
1604 if(getPflName()!=pflName)
1606 startExp=_start_end.second;
1610 bool MEDFileField1TSStructItem2::operator==(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception)
1612 //_nb_of_entity is not taken into account here. It is not a bug, because no mesh consideration needed here to perform fast compare.
1613 //idem for _loc. It is not an effective attribute for support comparison.
1614 return _geo_type==other._geo_type && _start_end==other._start_end && _pfl->getName()==other._pfl->getName();
1617 bool MEDFileField1TSStructItem2::isCellSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const
1619 if(_geo_type!=other._geo_type)
1621 if(_nb_of_entity!=other._nb_of_entity)
1623 if((_pfl->getName().empty() && !other._pfl->getName().empty()) || (!_pfl->getName().empty() && other._pfl->getName().empty()))
1625 if(_pfl->getName().empty() && other._pfl->getName().empty())
1627 const DataArrayInt *pfl1(getPfl(globs)),*pfl2(other.getPfl(globs));
1628 return pfl1->isEqualWithoutConsideringStr(*pfl2);
1631 bool MEDFileField1TSStructItem2::isNodeSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const
1633 return isCellSupportEqual(other,globs);
1637 * \a objs must be non empty. \a objs should contain items having same geometric type.
1639 MEDFileField1TSStructItem2 MEDFileField1TSStructItem2::BuildAggregationOf(const std::vector<const MEDFileField1TSStructItem2 *>& objs, const MEDFileFieldGlobsReal *globs)
1642 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : empty input !");
1644 return MEDFileField1TSStructItem2(*objs[0]);
1645 INTERP_KERNEL::NormalizedCellType gt(objs[0]->_geo_type);
1646 int nbEntityRef(objs[0]->_nb_of_entity);
1647 std::size_t sz(objs.size());
1648 std::vector<const DataArrayInt *> arrs(sz);
1649 for(std::size_t i=0;i<sz;i++)
1651 const MEDFileField1TSStructItem2 *obj(objs[i]);
1652 if(gt!=obj->_geo_type)
1653 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : invalid situation ! All input must have the same geo type !");
1654 if(nbEntityRef!=obj->_nb_of_entity)
1655 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : invalid situation ! All input must have the global nb of entity !");
1656 if(obj->_pfl->getName().empty())
1657 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : invalid situation ! Several same geo type chunk must all lie on profiles !");
1658 arrs[i]=globs->getProfile(obj->_pfl->getName().c_str());
1660 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr(DataArrayInt::Aggregate(arrs));
1662 int oldNbTuples(arr->getNumberOfTuples());
1663 arr=arr->buildUnique();
1664 if(oldNbTuples!=arr->getNumberOfTuples())
1665 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : some entities are present several times !");
1666 if(arr->isIdentity() && oldNbTuples==nbEntityRef)
1668 std::pair<int,int> p(0,nbEntityRef);
1670 MEDFileField1TSStructItem2 ret(gt,p,a,b);
1671 ret._nb_of_entity=nbEntityRef;
1676 arr->setName(NEWLY_CREATED_PFL_NAME);
1677 std::pair<int,int> p(0,oldNbTuples);
1679 MEDFileField1TSStructItem2 ret(gt,p,a,b);
1680 ret._nb_of_entity=nbEntityRef;
1686 std::size_t MEDFileField1TSStructItem2::getHeapMemorySizeWithoutChildren() const
1688 std::size_t ret(_loc.capacity());
1692 std::vector<const BigMemoryObject *> MEDFileField1TSStructItem2::getDirectChildren() const
1694 std::vector<const BigMemoryObject *> ret;
1695 const DataArrayInt *pfl(_pfl);
1703 MEDFileField1TSStructItem::MEDFileField1TSStructItem(TypeOfField a, const std::vector< MEDFileField1TSStructItem2 >& b):_computed(false),_type(a),_items(b)
1707 void MEDFileField1TSStructItem::checkWithMeshStruct(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
1713 int nbOfEnt=mst->getNumberOfNodes();
1714 if(_items.size()!=1)
1715 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::checkWithMeshStruct : for nodes field only one subdivision supported !");
1716 _items[0].checkInRange(nbOfEnt,1,globs);
1721 for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
1722 (*it).checkWithMeshStructForCells(mst,globs);
1727 for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
1728 (*it).checkWithMeshStructForGaussNE(mst,globs);
1733 for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
1734 (*it).checkWithMeshStructForGaussPT(mst,globs);
1738 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::checkWithMeshStruct : not managed field type !");
1742 bool MEDFileField1TSStructItem::operator==(const MEDFileField1TSStructItem& other) const throw(INTERP_KERNEL::Exception)
1744 if(_type!=other._type)
1746 if(_items.size()!=other._items.size())
1748 for(std::size_t i=0;i<_items.size();i++)
1749 if(!(_items[i]==other._items[i]))
1754 bool MEDFileField1TSStructItem::isCellSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const
1756 if(_type!=other._type)
1758 if(_items.size()!=other._items.size())
1760 for(std::size_t i=0;i<_items.size();i++)
1761 if(!(_items[i].isCellSupportEqual(other._items[i],globs)))
1766 bool MEDFileField1TSStructItem::isNodeSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const
1768 if(_type!=other._type)
1770 if(_items.size()!=other._items.size())
1772 for(std::size_t i=0;i<_items.size();i++)
1773 if(!(_items[i].isNodeSupportEqual(other._items[i],globs)))
1778 bool MEDFileField1TSStructItem::isEntityCell() const
1789 CmpGeo(INTERP_KERNEL::NormalizedCellType geoTyp):_geo_type(geoTyp) { }
1790 bool operator()(const std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > & v) const { return _geo_type==v.first; }
1792 INTERP_KERNEL::NormalizedCellType _geo_type;
1795 MEDFileField1TSStructItem MEDFileField1TSStructItem::simplifyMeOnCellEntity(const MEDFileFieldGlobsReal *globs) const
1798 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::simplifyMeOnCellEntity : must be on ON_CELLS, ON_GAUSS_NE or ON_GAUSS_PT !");
1799 std::vector< std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > > m;
1801 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++,i++)
1803 std::vector< std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > >::iterator it0(std::find_if(m.begin(),m.end(),CmpGeo((*it).getGeo())));
1805 m.push_back(std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> >((*it).getGeo(),std::vector<std::size_t>(1,i)));
1807 (*it0).second.push_back(i);
1809 if(m.size()==_items.size())
1811 MEDFileField1TSStructItem ret(*this);
1815 std::size_t sz(m.size());
1816 std::vector< MEDFileField1TSStructItem2 > items(sz);
1819 const std::vector<std::size_t>& ids=m[i].second;
1820 std::vector<const MEDFileField1TSStructItem2 *>objs(ids.size());
1821 for(std::size_t j=0;j<ids.size();j++)
1822 objs[j]=&_items[ids[j]];
1823 items[i]=MEDFileField1TSStructItem2::BuildAggregationOf(objs,globs);
1825 MEDFileField1TSStructItem ret(ON_CELLS,items);
1831 * \a this is expected to be ON_CELLS and simplified.
1833 bool MEDFileField1TSStructItem::isCompatibleWithNodesDiscr(const MEDFileField1TSStructItem& other, const MEDFileMeshStruct *meshSt, const MEDFileFieldGlobsReal *globs) const
1835 if(other._type!=ON_NODES)
1836 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isCompatibleWithNodesDiscr : other must be on nodes !");
1837 if(other._items.size()!=1)
1838 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isCompatibleWithNodesDiscr : other is on nodes but number of subparts !");
1839 int theFirstLevFull;
1840 bool ret0=isFullyOnOneLev(meshSt,theFirstLevFull);
1841 const MEDFileField1TSStructItem2& otherNodeIt(other._items[0]);
1842 if(otherNodeIt.getPflName().empty())
1846 return theFirstLevFull==0;
1850 const DataArrayInt *pfl=globs->getProfile(otherNodeIt.getPflName().c_str());
1851 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpyPfl(pfl->deepCpy());
1853 int nbOfNodes(meshSt->getNumberOfNodes());
1854 if(cpyPfl->isIdentity() && cpyPfl->getNumberOfTuples()==nbOfNodes)
1855 {//on all nodes also !
1858 return theFirstLevFull==0;
1860 std::vector<bool> nodesFetched(nbOfNodes,false);
1861 meshSt->getTheMesh()->whichAreNodesFetched(*this,globs,nodesFetched);
1862 return cpyPfl->isFittingWith(nodesFetched);
1866 bool MEDFileField1TSStructItem::isFullyOnOneLev(const MEDFileMeshStruct *meshSt, int& theFirstLevFull) const
1869 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : works only for ON_CELLS discretization !");
1871 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : items vector is empty !");
1872 int nbOfLevs(meshSt->getNumberOfLevs());
1874 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : no levels in input mesh structure !");
1875 std::vector<int> levs(nbOfLevs);
1877 std::set<INTERP_KERNEL::NormalizedCellType> gts;
1878 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++)
1880 if(!(*it).getPflName().empty())
1882 INTERP_KERNEL::NormalizedCellType gt((*it).getGeo());
1883 if(gts.find(gt)!=gts.end())
1884 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : internal error !");
1886 int pos(meshSt->getLevelOfGeoType((*it).getGeo()));
1889 for(int i=0;i<nbOfLevs;i++)
1890 if(meshSt->getNumberOfGeoTypesInLev(-i)==levs[i])
1891 { theFirstLevFull=-i; return true; }
1895 const MEDFileField1TSStructItem2& MEDFileField1TSStructItem::operator[](std::size_t i) const throw(INTERP_KERNEL::Exception)
1897 if(i>=_items.size())
1898 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::operator[] : input is not in valid range !");
1902 std::size_t MEDFileField1TSStructItem::getHeapMemorySizeWithoutChildren() const
1904 std::size_t ret(_items.size()*sizeof(MEDFileField1TSStructItem2));
1908 std::vector<const BigMemoryObject *> MEDFileField1TSStructItem::getDirectChildren() const
1910 std::vector<const BigMemoryObject *> ret;
1911 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++)
1912 ret.push_back(&(*it));
1916 MEDMeshMultiLev *MEDFileField1TSStructItem::buildFromScratchDataSetSupportOnCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const
1918 std::size_t sz(_items.size());
1919 std::vector<INTERP_KERNEL::NormalizedCellType> a0(sz);
1920 std::vector<const DataArrayInt *> a1(sz);
1921 std::vector<int> a2(sz);
1923 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++,i++)
1925 a0[i]=(*it).getGeo();
1926 a1[i]=(*it).getPfl(globs);
1927 a2[i]=mst->getNumberOfElemsOfGeoType((*it).getGeo());
1929 return MEDMeshMultiLev::New(mst->getTheMesh(),a0,a1,a2);
1932 std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileField1TSStructItem::getGeoTypes(const MEDFileMesh *m) const
1934 std::vector<INTERP_KERNEL::NormalizedCellType> ret;
1937 if(!_items.empty() && _items[0].getPflName().empty())
1940 return m->getAllGeoTypes();
1947 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++)
1949 INTERP_KERNEL::NormalizedCellType elt((*it).getGeo());
1950 std::vector<INTERP_KERNEL::NormalizedCellType>::iterator it2(std::find(ret.begin(),ret.end(),elt));
1957 MEDFileField1TSStructItem MEDFileField1TSStructItem::BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt)
1960 std::vector< MEDFileField1TSStructItem2 > anItems;
1962 std::vector< std::vector<std::string> > pfls,locs;
1963 std::vector< std::vector<TypeOfField> > typesF;
1964 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
1965 std::vector< std::vector<std::pair<int,int> > > strtEnds=ref->getFieldSplitedByType(std::string(),geoTypes,typesF,pfls,locs);
1966 std::size_t nbOfGeoTypes(geoTypes.size());
1968 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : not null by empty ref !");
1970 for(std::size_t i=0;i<nbOfGeoTypes;i++)
1972 std::size_t sz=typesF[i].size();
1973 if(strtEnds[i].size()<1 || sz<1 || pfls[i].size()<1)
1974 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : internal error #1 !");
1980 for(std::size_t j=0;j<sz;j++)
1982 if(atype==typesF[i][j])
1983 anItems.push_back(MEDFileField1TSStructItem2(geoTypes[i],strtEnds[i][j],pfls[i][j],locs[i][j]));
1985 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : can be applied only on single spatial discretization fields ! Call SplitPerDiscretization method !");
1988 MEDFileField1TSStructItem ret(atype,anItems);
1989 ret.checkWithMeshStruct(meshSt,ref);
1995 MEDFileField1TSStruct *MEDFileField1TSStruct::New(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst)
1997 return new MEDFileField1TSStruct(ref,mst);
2000 MEDFileField1TSStruct::MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst)
2002 _already_checked.push_back(MEDFileField1TSStructItem::BuildItemFrom(ref,mst));
2005 void MEDFileField1TSStruct::checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
2007 if(_already_checked.empty())
2008 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::checkWithMeshStruct : not correctly initialized !");
2009 _already_checked.back().checkWithMeshStruct(mst,globs);
2012 bool MEDFileField1TSStruct::isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *mst) const
2014 MEDFileField1TSStructItem b(MEDFileField1TSStructItem::BuildItemFrom(other,mst));
2015 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++)
2024 * Not const because \a other structure will be added to the \c _already_checked attribute in case of success.
2026 bool MEDFileField1TSStruct::isSupportSameAs(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt)
2028 if(_already_checked.empty())
2029 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isSupportSameAs : no ref !");
2030 MEDFileField1TSStructItem b(MEDFileField1TSStructItem::BuildItemFrom(other,meshSt));
2031 if(!_already_checked[0].isEntityCell() || !b.isEntityCell())
2032 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isSupportSameAs : only available on cell entities !");
2033 MEDFileField1TSStructItem other1(b.simplifyMeOnCellEntity(other));
2035 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
2036 if((*it).isComputed())
2041 MEDFileField1TSStructItem this1(_already_checked[0].simplifyMeOnCellEntity(other));
2042 ret=this1.isCellSupportEqual(other1,other);
2044 _already_checked.push_back(this1);
2047 ret=_already_checked[found].isCellSupportEqual(other1,other);
2049 _already_checked.push_back(b);
2054 * \param [in] other - a field with only one spatial discretization : ON_NODES.
2056 bool MEDFileField1TSStruct::isCompatibleWithNodesDiscr(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt)
2058 if(_already_checked.empty())
2059 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isCompatibleWithNodesDiscr : no ref !");
2060 MEDFileField1TSStructItem other1(MEDFileField1TSStructItem::BuildItemFrom(other,meshSt));
2061 if(_already_checked[0].isEntityCell())
2064 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
2065 if((*it).isComputed())
2070 MEDFileField1TSStructItem this1(_already_checked[0].simplifyMeOnCellEntity(other));
2071 ret=this1.isCompatibleWithNodesDiscr(other1,meshSt,other);
2073 _already_checked.push_back(this1);
2076 ret=_already_checked[found].isCompatibleWithNodesDiscr(other1,meshSt,other);
2078 _already_checked.push_back(other1);
2082 return _already_checked[0].isNodeSupportEqual(other1,other);
2085 std::size_t MEDFileField1TSStruct::getHeapMemorySizeWithoutChildren() const
2087 std::size_t ret(_already_checked.capacity()*sizeof(MEDFileField1TSStructItem));
2091 std::vector<const BigMemoryObject *> MEDFileField1TSStruct::getDirectChildren() const
2093 std::vector<const BigMemoryObject *> ret;
2094 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++)
2095 ret.push_back(&(*it));
2099 MEDMeshMultiLev *MEDFileField1TSStruct::buildFromScratchDataSetSupport(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const
2101 if(_already_checked.empty())
2102 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::buildFromScratchDataSetSupport : No outline structure in this !");
2103 int pos0(-1),pos1(-1);
2104 if(presenceOfCellDiscr(pos0))
2106 MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> ret(_already_checked[pos0].buildFromScratchDataSetSupportOnCells(mst,globs));
2107 if(presenceOfPartialNodeDiscr(pos1))
2108 ret->setNodeReduction(_already_checked[pos1][0].getPfl(globs));
2113 if(!presenceOfPartialNodeDiscr(pos1))
2114 {//we have only all nodes, no cell definition info -> all existing levels !;
2115 return MEDMeshMultiLev::New(mst->getTheMesh(),mst->getTheMesh()->getNonEmptyLevels());
2118 return MEDMeshMultiLev::NewOnlyOnNode(mst->getTheMesh(),_already_checked[pos1][0].getPfl(globs));
2122 bool MEDFileField1TSStruct::isDataSetSupportFastlyEqualTo(const MEDFileField1TSStruct& other, const MEDFileFieldGlobsReal *globs) const
2125 bool a0(presenceOfCellDiscr(b0)),a1(presenceOfPartialNodeDiscr(b1));
2127 bool c0(other.presenceOfCellDiscr(d0)),c1(other.presenceOfPartialNodeDiscr(d1));
2128 if(a0!=c0 || a1!=c1)
2131 if(!_already_checked[b0].isCellSupportEqual(other._already_checked[d0],globs))
2134 if(!_already_checked[b1].isNodeSupportEqual(other._already_checked[d1],globs))
2139 std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileField1TSStruct::getGeoTypes(const MEDFileMesh *m) const
2141 std::vector<INTERP_KERNEL::NormalizedCellType> ret;
2142 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++)
2144 std::vector<INTERP_KERNEL::NormalizedCellType> ret2((*it).getGeoTypes(m));
2145 for(std::vector<INTERP_KERNEL::NormalizedCellType>::const_iterator it2=ret2.begin();it2!=ret2.end();it2++)
2147 if(*it2==INTERP_KERNEL::NORM_ERROR)
2149 std::vector<INTERP_KERNEL::NormalizedCellType>::iterator it3(std::find(ret.begin(),ret.end(),*it2));
2151 ret.push_back(*it2);
2158 * Returns true if presence in \a this of discretization ON_CELLS, ON_GAUSS_PT, ON_GAUSS_NE.
2159 * 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.
2161 bool MEDFileField1TSStruct::presenceOfCellDiscr(int& pos) const
2163 std::size_t refSz(std::numeric_limits<std::size_t>::max());
2166 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
2168 if((*it).getType()!=ON_NODES)
2171 std::size_t sz((*it).getNumberOfItems());
2173 { pos=i; refSz=sz; }
2177 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::presenceOfCellDiscr : an element in this on entity CELL is empty !");
2182 * Returns true if presence in \a this of discretization ON_NODES.
2183 * If true is returned the pos of the first element containing the single subpart.
2185 bool MEDFileField1TSStruct::presenceOfPartialNodeDiscr(int& pos) const
2188 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
2190 if((*it).getType()==ON_NODES)
2192 std::size_t sz((*it).getNumberOfItems());
2195 if(!(*it)[0].getPflName().empty())
2196 { pos=i; return true; }
2199 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::presenceOfPartialNodeDiscr : an element in this on entity NODE is split into several parts !");
2207 MEDFileFastCellSupportComparator *MEDFileFastCellSupportComparator::New(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref)
2209 return new MEDFileFastCellSupportComparator(m,ref);
2212 MEDFileFastCellSupportComparator::MEDFileFastCellSupportComparator(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref)
2215 throw INTERP_KERNEL::Exception("MEDFileFastCellSupportComparator constructor : null input mesh struct !");
2216 _mesh_comp=const_cast<MEDFileMeshStruct *>(m); _mesh_comp->incrRef();
2217 int nbPts=ref->getNumberOfTS();
2218 _f1ts_cmps.resize(nbPts);
2219 for(int i=0;i<nbPts;i++)
2221 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt=ref->getTimeStepAtPos(i);
2222 _f1ts_cmps[i]=MEDFileField1TSStruct::New(elt,_mesh_comp);
2223 _f1ts_cmps[i]->checkWithMeshStruct(_mesh_comp,elt);
2227 std::size_t MEDFileFastCellSupportComparator::getHeapMemorySizeWithoutChildren() const
2229 std::size_t ret(_f1ts_cmps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct>));
2233 std::vector<const BigMemoryObject *> MEDFileFastCellSupportComparator::getDirectChildren() const
2235 std::vector<const BigMemoryObject *> ret;
2236 const MEDFileMeshStruct *mst(_mesh_comp);
2239 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct> >::const_iterator it=_f1ts_cmps.begin();it!=_f1ts_cmps.end();it++)
2241 const MEDFileField1TSStruct *cur(*it);
2248 bool MEDFileFastCellSupportComparator::isEqual(const MEDFileAnyTypeFieldMultiTS *other)
2250 int nbPts=other->getNumberOfTS();
2251 if(nbPts!=(int)_f1ts_cmps.size())
2253 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isEqual : unexpected nb of time steps in input ! Should be " << _f1ts_cmps.size() << " it is in reality " << nbPts << " !";
2254 throw INTERP_KERNEL::Exception(oss.str().c_str());
2256 for(int i=0;i<nbPts;i++)
2258 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt=other->getTimeStepAtPos(i);
2259 if(!_f1ts_cmps[i]->isEqualConsideringThePast(elt,_mesh_comp))
2260 if(!_f1ts_cmps[i]->isSupportSameAs(elt,_mesh_comp))
2266 bool MEDFileFastCellSupportComparator::isCompatibleWithNodesDiscr(const MEDFileAnyTypeFieldMultiTS *other)
2268 int nbPts=other->getNumberOfTS();
2269 if(nbPts!=(int)_f1ts_cmps.size())
2271 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isCompatibleWithNodesDiscr : unexpected nb of time steps in input ! Should be " << _f1ts_cmps.size() << " it is in reality " << nbPts << " !";
2272 throw INTERP_KERNEL::Exception(oss.str().c_str());
2274 for(int i=0;i<nbPts;i++)
2276 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt=other->getTimeStepAtPos(i);
2277 if(!_f1ts_cmps[i]->isCompatibleWithNodesDiscr(elt,_mesh_comp))
2283 MEDMeshMultiLev *MEDFileFastCellSupportComparator::buildFromScratchDataSetSupport(int timeStepId, const MEDFileFieldGlobsReal *globs) const
2285 if(timeStepId<0 || timeStepId>=(int)_f1ts_cmps.size())
2287 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::buildFromScratchDataSetSupport : requested time step id #" << timeStepId << " is not in [0," << _f1ts_cmps.size() << ") !";
2288 throw INTERP_KERNEL::Exception(oss.str().c_str());
2290 const MEDFileField1TSStruct *obj(_f1ts_cmps[timeStepId]);
2293 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::buildFromScratchDataSetSupport : at time step id #" << timeStepId << " no field structure overview defined !";
2294 throw INTERP_KERNEL::Exception(oss.str().c_str());
2296 return obj->buildFromScratchDataSetSupport(_mesh_comp,globs);
2299 bool MEDFileFastCellSupportComparator::isDataSetSupportEqualToThePreviousOne(int timeStepId, const MEDFileFieldGlobsReal *globs) const
2301 if(timeStepId<=0 || timeStepId>=(int)_f1ts_cmps.size())
2303 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isDataSetSupportEqualToThePreviousOne : requested time step id #" << timeStepId << " is not in [1," << _f1ts_cmps.size() << ") !";
2304 throw INTERP_KERNEL::Exception(oss.str().c_str());
2306 const MEDFileField1TSStruct *obj(_f1ts_cmps[timeStepId]);
2307 const MEDFileField1TSStruct *objRef(_f1ts_cmps[timeStepId-1]);
2308 return objRef->isDataSetSupportFastlyEqualTo(*obj,globs);
2311 int MEDFileFastCellSupportComparator::getNumberOfTS() const
2313 return _f1ts_cmps.size();
2316 std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileFastCellSupportComparator::getGeoTypesAt(int timeStepId, const MEDFileMesh *m) const
2318 if(timeStepId<0 || timeStepId>=(int)_f1ts_cmps.size())
2320 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::getGeoTypesAt : requested time step id #" << timeStepId << " is not in [0," << _f1ts_cmps.size() << ") !";
2321 throw INTERP_KERNEL::Exception(oss.str().c_str());
2323 const MEDFileField1TSStruct *elt(_f1ts_cmps[timeStepId]);
2326 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::getGeoTypesAt : requested time step id #" << timeStepId << " points to a NULL pointer !";
2327 throw INTERP_KERNEL::Exception(oss.str().c_str());
2329 return elt->getGeoTypes(m);