1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDFileFieldOverView.hxx"
22 #include "MEDFileField.hxx"
23 #include "MEDFileMesh.hxx"
25 #include "CellModel.hxx"
27 using namespace ParaMEDMEM;
29 const unsigned char MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE[MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE_LGTH]=
30 {1,3,21,5,9,7,22,34,23,28,-1,-1,-1,-1,10,14,13,-1,12,-1,24,-1,16,27,-1,26,-1,29,-1,-1,25,42,-1,4};
32 const char MEDFileField1TSStructItem2::NEWLY_CREATED_PFL_NAME[]="???";
34 MEDFileMeshStruct *MEDFileMeshStruct::New(const MEDFileMesh *mesh)
36 return new MEDFileMeshStruct(mesh);
39 std::size_t MEDFileMeshStruct::getHeapMemorySize() const
42 for(std::vector< std::vector<int> >::const_iterator it0=_geo_types_distrib.begin();it0!=_geo_types_distrib.end();it0++)
43 ret+=(*it0).capacity()*sizeof(int);
44 ret+=_geo_types_distrib.capacity()*sizeof(std::vector<int>);
48 MEDFileMeshStruct::MEDFileMeshStruct(const MEDFileMesh *mesh):_mesh(mesh)
50 std::vector<int> levs=mesh->getNonEmptyLevels();
51 _name=mesh->getName();
52 _nb_nodes=mesh->getNumberOfNodes();
53 _geo_types_distrib.resize(levs.size());
54 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
56 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mLev=mesh->getGenMeshAtLevel(*lev);
57 _geo_types_distrib[-(*lev)]=mLev->getDistributionOfTypes();
61 int MEDFileMeshStruct::getLevelOfGeoType(INTERP_KERNEL::NormalizedCellType t) const throw(INTERP_KERNEL::Exception)
64 for(std::vector< std::vector<int> >::const_iterator it1=_geo_types_distrib.begin();it1!=_geo_types_distrib.end();it1++,j--)
66 std::size_t sz=(*it1).size();
68 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getLevelOfGeoType : internal error in code !");
69 std::size_t nbGeo=sz/3;
70 for(std::size_t i=0;i<nbGeo;i++)
71 if((*it1)[3*i]==(int)t)
74 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getLevelOfGeoType : The specified geometric type is not present in the mesh structure !");
77 int MEDFileMeshStruct::getNumberOfElemsOfGeoType(INTERP_KERNEL::NormalizedCellType t) const throw(INTERP_KERNEL::Exception)
79 for(std::vector< std::vector<int> >::const_iterator it1=_geo_types_distrib.begin();it1!=_geo_types_distrib.end();it1++)
81 std::size_t sz=(*it1).size();
83 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfElemsOfGeoType : internal error in code !");
84 std::size_t nbGeo=sz/3;
85 for(std::size_t i=0;i<nbGeo;i++)
86 if((*it1)[3*i]==(int)t)
89 throw INTERP_KERNEL::Exception("The specified geometric type is not present in the mesh structure !");
92 int MEDFileMeshStruct::getNumberOfLevs() const
94 return (int)_geo_types_distrib.size();
97 int MEDFileMeshStruct::getNumberOfGeoTypesInLev(int relativeLev) const throw(INTERP_KERNEL::Exception)
99 int pos(-relativeLev);
100 if(pos<0 || pos>=_geo_types_distrib.size())
101 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfGeoTypesInLev : invalid level specified !");
102 std::size_t sz=_geo_types_distrib[pos].size();
104 throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfGeoTypesInLev : internal error in code !");
110 std::size_t MEDMeshMultiLev::getHeapMemorySize() const
115 MEDMeshMultiLev *MEDMeshMultiLev::New(const MEDFileMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception)
118 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New : null input pointer !");
119 const MEDFileUMesh *um(dynamic_cast<const MEDFileUMesh *>(m));
121 return MEDUMeshMultiLev::New(um,levs);
122 const MEDFileCMesh *cm(dynamic_cast<const MEDFileCMesh *>(m));
124 return MEDCMeshMultiLev::New(cm,levs);
125 const MEDFileCurveLinearMesh *clm(dynamic_cast<const MEDFileCurveLinearMesh *>(m));
127 return MEDCurveLinearMeshMultiLev::New(clm,levs);
128 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New : unrecognized type of mesh ! Must be in [MEDFileUMesh,MEDFileCMesh,MEDFileCurveLinearMesh] !");
131 MEDMeshMultiLev *MEDMeshMultiLev::New(const MEDFileMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities) throw(INTERP_KERNEL::Exception)
134 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New 2 : null input pointer !");
135 const MEDFileUMesh *um(dynamic_cast<const MEDFileUMesh *>(m));
137 return MEDUMeshMultiLev::New(um,gts,pfls,nbEntities);
138 const MEDFileCMesh *cm(dynamic_cast<const MEDFileCMesh *>(m));
140 return MEDCMeshMultiLev::New(cm,gts,pfls,nbEntities);
141 const MEDFileCurveLinearMesh *clm(dynamic_cast<const MEDFileCurveLinearMesh *>(m));
143 return MEDCurveLinearMeshMultiLev::New(clm,gts,pfls,nbEntities);
144 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New 2 : unrecognized type of mesh ! Must be in [MEDFileUMesh,MEDFileCMesh,MEDFileCurveLinearMesh] !");
147 MEDMeshMultiLev *MEDMeshMultiLev::NewOnlyOnNode(const MEDFileMesh *m, const DataArrayInt *pflOnNode) throw(INTERP_KERNEL::Exception)
149 std::vector<int> levs(1,0);
150 MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> ret(MEDMeshMultiLev::New(m,levs));
151 ret->selectPartOfNodes(pflOnNode);
155 void MEDMeshMultiLev::setNodeReduction(const DataArrayInt *nr)
159 _node_reduction=const_cast<DataArrayInt*>(nr);
162 bool MEDMeshMultiLev::isFastlyTheSameStruct(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
164 if(fst.getType()==ON_NODES)
166 if(fst.getNumberOfItems()!=1)
167 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::isFastlyTheSameStruct : unexpected situation for nodes !");
168 const MEDFileField1TSStructItem2& p(fst[0]);
169 std::string pflName(p.getPflName());
170 const DataArrayInt *nr(_node_reduction);
171 if(pflName.empty() && !nr)
173 if(pflName==nr->getName())
179 std::size_t sz(fst.getNumberOfItems());
180 if(sz!=_geo_types.size())
183 for(std::size_t i=0;i<sz;i++)
185 const MEDFileField1TSStructItem2& p(fst[i]);
186 if(!p.isFastlyEqual(strt,_geo_types[i],getPflNameOfId(i).c_str()))
193 DataArray *MEDMeshMultiLev::buildDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const throw(INTERP_KERNEL::Exception)
195 MEDCouplingAutoRefCountObjectPtr<DataArray> ret(const_cast<DataArray *>(vals)); ret->incrRef();
196 if(isFastlyTheSameStruct(fst,globs))
199 return constructDataArray(fst,globs,vals);
202 std::string MEDMeshMultiLev::getPflNameOfId(int id) const
204 std::size_t sz(_pfls.size());
206 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::getPflNameOfId : invalid input id !");
207 const DataArrayInt *pfl(_pfls[id]);
209 return std::string("");
210 return pfl->getName();
213 DataArray *MEDMeshMultiLev::constructDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const throw(INTERP_KERNEL::Exception)
215 if(fst.getType()==ON_NODES)
217 if(fst.getNumberOfItems()!=1)
218 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes !");
219 const MEDFileField1TSStructItem2& p(fst[0]);
220 std::string pflName(p.getPflName());
221 const DataArrayInt *nr(_node_reduction);
222 if(pflName.empty() && !nr)
223 return vals->deepCpy();
224 if(pflName.empty() && nr)
225 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 2 !");
226 if(!pflName.empty() && nr)
228 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(globs->getProfile(pflName.c_str())->deepCpy());
229 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p2(nr->deepCpy());
230 p1->sort(true); p2->sort(true);
231 if(!p1->isEqualWithoutConsideringStr(*p2))
232 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 3 !");
233 p1=DataArrayInt::FindPermutationFromFirstToSecond(globs->getProfile(pflName.c_str()),nr);
234 MEDCouplingAutoRefCountObjectPtr<DataArray> ret(vals->deepCpy());
235 ret->renumberInPlace(p1->begin());
238 if(!pflName.empty() && !nr)
240 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(globs->getProfile(pflName.c_str())->deepCpy());
242 if(!p1->isIdentity() || p1->getNumberOfTuples()!=p.getNbEntity())
243 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 4 !");
244 MEDCouplingAutoRefCountObjectPtr<DataArray> ret(vals->deepCpy());
245 ret->renumberInPlace(globs->getProfile(pflName.c_str())->begin());
248 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 5 !");
252 std::size_t sz(fst.getNumberOfItems());
253 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArray> > arrSafe(sz);
254 std::vector< const DataArray *> arr(sz);
255 for(std::size_t i=0;i<sz;i++)
257 const MEDFileField1TSStructItem2& p(fst[i]);
258 const std::pair<int,int>& strtStop(p.getStartStop());
259 std::vector< INTERP_KERNEL::NormalizedCellType >::const_iterator it(std::find(_geo_types.begin(),_geo_types.end(),p.getGeo()));
260 if(it==_geo_types.end())
261 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 1 !");
262 if(std::find(it+1,_geo_types.end(),p.getGeo())!=_geo_types.end())
263 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 2 !");
264 std::size_t pos(std::distance(_geo_types.begin(),it));
265 const DataArrayInt *thisP(_pfls[pos]),*otherP(p.getPfl(globs));
266 MEDCouplingAutoRefCountObjectPtr<DataArray> ret(vals->selectByTupleId2(strtStop.first,strtStop.second,1));
267 if(!thisP && !otherP)
269 arrSafe[i]=ret; arr[i]=ret;
272 int nbi(p.getNbOfIntegrationPts(globs)),nc(ret->getNumberOfComponents());
275 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(otherP->deepCpy());
277 if(!p1->isIdentity() || p1->getNumberOfTuples()!=p.getNbEntity())
278 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 3 !");
279 ret->rearrange(nbi*nc); ret->renumberInPlace(otherP->begin()); ret->rearrange(nc);
280 arrSafe[i]=ret; arr[i]=ret;
285 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(otherP->deepCpy());
286 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p2(thisP->deepCpy());
287 p1->sort(true); p2->sort(true);
288 if(!p1->isEqualWithoutConsideringStr(*p2))
289 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 4 !");
290 p1=DataArrayInt::FindPermutationFromFirstToSecond(otherP,thisP);
291 ret->rearrange(nbi*nc); ret->renumberInPlace(p1->begin()); ret->rearrange(nc);
296 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(thisP->deepCpy());
298 if(!p1->isIdentity() || p1->getNumberOfTuples()!=p.getNbEntity())
299 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 3 !");
300 ret->rearrange(nbi*nc); ret->renumberInPlaceR(otherP->begin()); ret->rearrange(nc);
301 arrSafe[i]=ret; arr[i]=ret;
304 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 6 !");
306 return DataArray::Aggregate(arr);
310 MEDMeshMultiLev::MEDMeshMultiLev()
314 MEDMeshMultiLev::MEDMeshMultiLev(const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):_geo_types(gts),_nb_entities(nbEntities)
316 std::size_t sz(_geo_types.size());
317 if(sz!=pfls.size() || sz!=nbEntities.size())
318 throw INTERP_KERNEL::Exception("MEDMeshMultiLev::MEDMeshMultiLev : input vector must have the same size !");
320 for(std::size_t i=0;i<sz;i++)
324 _pfls[i]=const_cast<DataArrayInt *>(pfls[i]);
328 MEDMeshMultiLev::MEDMeshMultiLev(const MEDMeshMultiLev& other):_pfls(other._pfls),_geo_types(other._geo_types),_nb_entities(other._nb_entities),_node_reduction(other._node_reduction)
334 MEDUMeshMultiLev *MEDUMeshMultiLev::New(const MEDFileUMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception)
336 return new MEDUMeshMultiLev(m,levs);
339 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<int>& levs)
342 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev constructor : null input pointer !");
343 std::vector<MEDCoupling1GTUMesh *> v;
344 for(std::vector<int>::const_iterator it=levs.begin();it!=levs.end();it++)
346 std::vector<MEDCoupling1GTUMesh *> vTmp(m->getDirectUndergroundSingleGeoTypeMeshes(*it));
347 v.insert(v.end(),vTmp.begin(),vTmp.end());
349 std::size_t sz(v.size());
352 _geo_types.resize(sz);
353 for(std::size_t i=0;i<sz;i++)
355 MEDCoupling1GTUMesh *obj(v[i]);
359 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev constructor : presence of a null pointer !");
361 _geo_types[i]=obj->getCellModelEnum();
365 MEDUMeshMultiLev *MEDUMeshMultiLev::New(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities) throw(INTERP_KERNEL::Exception)
367 return new MEDUMeshMultiLev(m,gts,pfls,nbEntities);
370 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDMeshMultiLev(gts,pfls,nbEntities)
372 std::size_t sz(gts.size());
374 for(std::size_t i=0;i<sz;i++)
376 MEDCoupling1GTUMesh *elt(m->getDirectUndergroundSingleGeoTypeMesh(gts[i]));
383 void MEDUMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes) throw(INTERP_KERNEL::Exception)
385 if(!pflNodes || !pflNodes->isAllocated())
387 std::size_t sz(_parts.size());
388 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > a(sz);
389 std::vector< const DataArrayInt *> aa(sz);
390 for(std::size_t i=0;i<sz;i++)
393 const DataArrayInt *pfl(_pfls[i]);
394 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> m(_parts[i]);
396 m=dynamic_cast<MEDCoupling1GTUMesh *>(_parts[i]->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
397 DataArrayInt *cellIds=0;
398 m->fillCellIdsToKeepFromNodeIds(pflNodes->begin(),pflNodes->end(),true,cellIds);
399 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIdsSafe(cellIds);
400 MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> m2(m->buildPartOfMySelfKeepCoords(cellIds->begin(),cellIds->end()));
402 a[i]=m2->getNodeIdsInUse(tmp); aa[i]=a[i];
404 _pfls[i]=pfl->selectByTupleIdSafe(cellIds->begin(),cellIds->end());
406 _pfls[i]=cellIdsSafe;
408 _node_reduction=DataArrayInt::Aggregate(aa);
409 _node_reduction->sort(true);
410 _node_reduction=_node_reduction->buildUnique();
413 MEDMeshMultiLev *MEDUMeshMultiLev::prepare() const throw(INTERP_KERNEL::Exception)
415 return new MEDUMeshMultiLev(*this);
418 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDUMeshMultiLev& other):MEDMeshMultiLev(other),_parts(other._parts)
422 MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDStructuredMeshMultiLev& other, const MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh>& part):MEDMeshMultiLev(other)
428 void MEDUMeshMultiLev::buildVTUArrays(DataArrayDouble *& coords, DataArrayByte *&types, DataArrayInt *&cellLocations, DataArrayInt *& cells, DataArrayInt *&faceLocations, DataArrayInt *&faces) const throw(INTERP_KERNEL::Exception)
431 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : empty array !");
432 if(!(const MEDCoupling1GTUMesh *)_parts[0])
433 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : first part is null !");
434 const DataArrayDouble *tmp(_parts[0]->getCoords());
436 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : the coordinates are null !");
437 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> a(const_cast<DataArrayDouble *>(tmp)); tmp->incrRef();
438 int szBCE(0),szD(0),szF(0);
440 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_parts.begin();it!=_parts.end();it++)
442 const MEDCoupling1GTUMesh *cur(*it);
444 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : a part is null !");
445 int curNbCells(cur->getNumberOfCells());
447 if((*it)->getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED)
448 szD=(*it)->getNodalConnectivity()->getNumberOfTuples()+curNbCells;
452 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp((*it)->computeEffectiveNbOfNodesPerCell());
453 szD+=tmp->accumulate(0)+curNbCells;
454 szF+=2*curNbCells+(*it)->getNodalConnectivity()->getNumberOfTuples();
457 MEDCouplingAutoRefCountObjectPtr<DataArrayByte> b(DataArrayByte::New()); b->alloc(szBCE,1); char *bPtr(b->getPointer());
458 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c(DataArrayInt::New()); c->alloc(szBCE,1); int *cPtr(c->getPointer());
459 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d(DataArrayInt::New()); d->alloc(szD,1); int *dPtr(d->getPointer());
460 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> e(DataArrayInt::New()),f(DataArrayInt::New()); int *ePtr(0),*fPtr(0);
462 { e->alloc(szBCE,1); ePtr=e->getPointer(); f->alloc(szF,1); fPtr=f->getPointer(); }
464 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_parts.begin();it!=_parts.end();it++)
466 const MEDCoupling1GTUMesh *cur(*it);
467 int curNbCells(cur->getNumberOfCells());
468 int gt((int)cur->getCellModelEnum());
469 if(gt<0 || gt>=PARAMEDMEM_2_VTKTYPE_LGTH)
470 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : invalid geometric type !");
471 unsigned char gtvtk(PARAMEDMEM_2_VTKTYPE[gt]);
473 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : no VTK type for the requested INTERP_KERNEL geometric type !");
474 std::fill(bPtr,bPtr+curNbCells,gtvtk); bPtr+=curNbCells;
475 const MEDCoupling1SGTUMesh *scur(dynamic_cast<const MEDCoupling1SGTUMesh *>(cur));
476 const MEDCoupling1DGTUMesh *dcur(dynamic_cast<const MEDCoupling1DGTUMesh *>(cur));
477 const int *connPtr(cur->getNodalConnectivity()->begin());
479 throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : internal error !");
482 int nnpc(scur->getNumberOfNodesPerCell());
483 for(int i=0;i<curNbCells;i++,connPtr+=nnpc)
486 dPtr=std::copy(connPtr,connPtr+nnpc,dPtr);
487 *cPtr=k+nnpc; k=*cPtr++;
490 { std::fill(ePtr,ePtr+curNbCells,-1); ePtr+=curNbCells; }
494 const int *connIPtr(dcur->getNodalConnectivityIndex()->begin());
495 if(cur->getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED)
497 for(int i=0;i<curNbCells;i++,connIPtr++)
499 *dPtr++=connIPtr[1]-connIPtr[0];
500 dPtr=std::copy(connPtr+connIPtr[0],connPtr+connIPtr[1],dPtr);
501 *cPtr=k+connIPtr[1]-connIPtr[0]; k=*cPtr++;
506 for(int i=0;i<curNbCells;i++,connIPtr++)
508 std::set<int> s(connPtr+connIPtr[0],connPtr+connIPtr[1]);
509 *dPtr++=(int)s.size();
510 dPtr=std::copy(s.begin(),s.end(),dPtr);
511 *cPtr=k+(int)s.size(); k=*cPtr++;
516 connIPtr=dcur->getNodalConnectivityIndex()->begin();
517 if(cur->getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED)
518 { std::fill(ePtr,ePtr+curNbCells,-1); ePtr+=curNbCells; }
522 for(int i=0;i<curNbCells;i++,connIPtr++)
524 int nbFace(std::count(connPtr+connIPtr[0],connPtr+connIPtr[1],-1)+1);
526 const int *work(connPtr+connIPtr[0]);
527 for(int j=0;j<nbFace;j++)
529 const int *work2=std::find(work,connPtr+connIPtr[1],-1);
530 *fPtr++=std::distance(work,work2);
531 fPtr=std::copy(work,work2,fPtr);
534 *ePtr=kk; kk+=connIPtr[1]-connIPtr[0]+2;
541 reorderNodesIfNecessary(a,d,0);
543 reorderNodesIfNecessary(a,d,f);
544 coords=a.retn(); types=b.retn(); cellLocations=c.retn(); cells=d.retn();
546 { faceLocations=0; faces=0; }
548 { faceLocations=e.retn(); faces=f.retn(); }
551 void MEDUMeshMultiLev::reorderNodesIfNecessary(DataArrayDouble *coords, DataArrayInt *nodalConnVTK, DataArrayInt *polyhedNodalConnVTK) const throw(INTERP_KERNEL::Exception)
553 const DataArrayInt *nr(_node_reduction);
556 int sz(coords->getNumberOfTuples());
557 std::vector<bool> b(sz,false);
558 const int *work(nodalConnVTK->begin()),*endW(nodalConnVTK->end());
562 for(int i=0;i<nb && work!=endW;i++,work++)
564 if(*work>=0 && *work<sz)
567 throw INTERP_KERNEL::Exception("MEDStructuredMeshMultiLev::reorderNodesIfNecessary : internal error !");
570 if(polyhedNodalConnVTK)
572 work=polyhedNodalConnVTK->begin(); endW=polyhedNodalConnVTK->end();
576 for(int i=0;i<nb && work!=endW;i++)
579 for(int j=0;j<nb2 && work!=endW;j++,work++)
581 if(*work>=0 && *work<sz)
584 throw INTERP_KERNEL::Exception("MEDStructuredMeshMultiLev::reorderNodesIfNecessary : internal error #2 !");
589 int szExp(std::count(b.begin(),b.end(),true));
590 if(szExp!=nr->getNumberOfTuples())
591 throw INTERP_KERNEL::Exception("MEDStructuredMeshMultiLev::reorderNodesIfNecessary : internal error #3 !");
593 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n(DataArrayInt::New()); o2n->alloc(sz,1);
594 int *o2nPtr(o2n->getPointer());
596 for(int i=0;i<sz;i++,o2nPtr++)
597 if(b[i]) *o2nPtr=newId++; else *o2nPtr=-1;
598 const int *o2nPtrc(o2n->begin());
599 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> n2o(o2n->invertArrayO2N2N2O(nr->getNumberOfTuples()));
600 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> perm(DataArrayInt::FindPermutationFromFirstToSecond(n2o,nr));
601 const int *permPtr(perm->begin());
602 int *work2(nodalConnVTK->getPointer()),*endW2(nodalConnVTK->getPointer()+nodalConnVTK->getNumberOfTuples());
606 for(int i=0;i<nb && work2!=endW2;i++,work2++)
607 *work2=permPtr[o2nPtrc[*work2]];
609 if(polyhedNodalConnVTK)
611 work2=polyhedNodalConnVTK->getPointer(); endW2=polyhedNodalConnVTK->getPointer()+polyhedNodalConnVTK->getNumberOfTuples();
615 for(int i=0;i<nb && work2!=endW2;i++)
618 for(int j=0;j<nb2 && work2!=endW2;j++,work2++)
619 *work2=permPtr[o2nPtrc[*work2]];
623 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coo(coords->selectByTupleIdSafe(nr->begin(),nr->end()));
624 coords->cpyFrom(*coo);
629 MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev()
633 MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDMeshMultiLev(gts,pfls,nbEntities)
637 void MEDStructuredMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes) throw(INTERP_KERNEL::Exception)
639 if(!pflNodes || !pflNodes->isAllocated())
641 std::vector<int> ngs(getNodeGridStructure());
642 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(MEDCouplingStructuredMesh::Build1GTNodalConnectivity(&ngs[0],&ngs[0]+ngs.size()));
643 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> m(MEDCoupling1SGTUMesh::New("",MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(ngs.size())));
644 m->setNodalConnectivity(conn);
645 const DataArrayInt *pfl(_pfls[0]);
648 m=dynamic_cast<MEDCoupling1SGTUMesh *>(m->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
650 DataArrayInt *cellIds=0;
651 m->fillCellIdsToKeepFromNodeIds(pflNodes->begin(),pflNodes->end(),true,cellIds);
652 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIdsSafe(cellIds);
653 MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> m2(m->buildPartOfMySelfKeepCoords(cellIds->begin(),cellIds->end()));
655 _node_reduction=m2->getNodeIdsInUse(tmp);
657 _pfls[0]=pfl->selectByTupleIdSafe(cellIds->begin(),cellIds->end());
659 _pfls[0]=cellIdsSafe;
662 MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other):MEDMeshMultiLev(other)
668 MEDCMeshMultiLev *MEDCMeshMultiLev::New(const MEDFileCMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception)
670 return new MEDCMeshMultiLev(m,levs);
673 MEDCMeshMultiLev *MEDCMeshMultiLev::New(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities) throw(INTERP_KERNEL::Exception)
675 return new MEDCMeshMultiLev(m,gts,pfls,nbEntities);
678 MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<int>& levs)
681 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor : null input pointer !");
682 if(levs.size()!=1 || levs[0]!=0)
683 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor : levels supported is 0 only !");
684 int mdim(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(m->getMeshDimension()));
685 _coords.resize(mdim);
686 for(int i=0;i<mdim;i++)
688 DataArrayDouble *elt(const_cast<DataArrayDouble *>(m->getMesh()->getCoordsAt(i)));
690 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : presence of null pointer for an vector of double along an axis !");
695 MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDStructuredMeshMultiLev(gts,pfls,nbEntities)
698 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : null input pointer !");
699 if(gts.size()!=1 || pfls.size()!=1)
700 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : lengthes of gts and pfls must be equal to one !");
701 int mdim(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(m->getMeshDimension()));
703 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : the unique geo type is invalid regarding meshdim !");
704 _coords.resize(mdim);
705 for(int i=0;i<mdim;i++)
707 DataArrayDouble *elt(const_cast<DataArrayDouble *>(m->getMesh()->getCoordsAt(i)));
709 throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : presence of null pointer for an vector of double along an axis !");
714 MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDCMeshMultiLev& other):MEDStructuredMeshMultiLev(other)
718 std::vector<int> MEDCMeshMultiLev::getNodeGridStructure() const throw(INTERP_KERNEL::Exception)
720 std::vector<int> ret(_coords.size());
721 for(std::size_t i=0;i<_coords.size();i++)
722 ret[i]=_coords[i]->getNumberOfTuples();
726 MEDMeshMultiLev *MEDCMeshMultiLev::prepare() const throw(INTERP_KERNEL::Exception)
728 const DataArrayInt *pfl(_pfls[0]),*nr(_node_reduction);
729 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nnr;
730 std::vector<int> cgs,ngs(getNodeGridStructure());
731 cgs.resize(ngs.size());
732 std::transform(ngs.begin(),ngs.end(),cgs.begin(),std::bind2nd(std::plus<int>(),-1));
735 std::vector< std::pair<int,int> > cellParts;
736 if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts))
738 MEDCouplingAutoRefCountObjectPtr<MEDCMeshMultiLev> ret(new MEDCMeshMultiLev(*this));
740 { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
741 ret->_nb_entities[0]=pfl->getNumberOfTuples();
743 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > coords(_coords.size());
744 for(std::size_t i=0;i<_coords.size();i++)
745 coords[i]=_coords[i]->selectByTupleId2(cellParts[i].first,cellParts[i].second+1,1);
751 MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> m(MEDCouplingCMesh::New());
752 for(std::size_t i=0;i<ngs.size();i++)
753 m->setCoordsAt(i,_coords[i]);
754 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> m2(m->build1SGTUnstructured());
755 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> m3=dynamic_cast<MEDCoupling1GTUMesh *>(m2->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
756 MEDCouplingAutoRefCountObjectPtr<MEDUMeshMultiLev> ret(new MEDUMeshMultiLev(*this,m3));
758 { m3->zipCoords(); nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
764 MEDCouplingAutoRefCountObjectPtr<MEDCMeshMultiLev> ret(new MEDCMeshMultiLev(*this));
766 { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
771 std::vector< DataArrayDouble * > MEDCMeshMultiLev::buildVTUArrays() const throw(INTERP_KERNEL::Exception)
773 std::size_t sz(_coords.size());
774 std::vector< DataArrayDouble * > ret(sz);
775 for(std::size_t i=0;i<sz;i++)
777 ret[i]=const_cast<DataArrayDouble *>((const DataArrayDouble *)_coords[i]);
785 MEDCurveLinearMeshMultiLev *MEDCurveLinearMeshMultiLev::New(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception)
787 return new MEDCurveLinearMeshMultiLev(m,levs);
790 MEDCurveLinearMeshMultiLev *MEDCurveLinearMeshMultiLev::New(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities) throw(INTERP_KERNEL::Exception)
792 return new MEDCurveLinearMeshMultiLev(m,gts,pfls,nbEntities);
795 MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs)
798 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor : null input pointer !");
799 if(levs.size()!=1 || levs[0]!=0)
800 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor : levels supported is 0 only !");
801 DataArrayDouble *coords(const_cast<DataArrayDouble *>(m->getMesh()->getCoords()));
803 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : no coords set !");
806 _structure=m->getMesh()->getNodeGridStructure();
809 MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDStructuredMeshMultiLev(gts,pfls,nbEntities)
812 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : null input pointer !");
813 if(gts.size()!=1 || pfls.size()!=1)
814 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : lengthes of gts and pfls must be equal to one !");
815 int mdim(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(m->getMeshDimension()));
817 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : the unique geo type is invalid regarding meshdim !");
818 DataArrayDouble *coords(const_cast<DataArrayDouble *>(m->getMesh()->getCoords()));
820 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : no coords set !");
823 _structure=m->getMesh()->getNodeGridStructure();
826 MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDCurveLinearMeshMultiLev& other):MEDStructuredMeshMultiLev(other),_coords(other._coords),_structure(other._structure)
830 std::vector<int> MEDCurveLinearMeshMultiLev::getNodeGridStructure() const throw(INTERP_KERNEL::Exception)
835 MEDMeshMultiLev *MEDCurveLinearMeshMultiLev::prepare() const throw(INTERP_KERNEL::Exception)
837 const DataArrayInt *pfl(_pfls[0]),*nr(_node_reduction);
838 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nnr;
839 std::vector<int> cgs,ngs(getNodeGridStructure());
840 cgs.resize(ngs.size());
841 std::transform(ngs.begin(),ngs.end(),cgs.begin(),std::bind2nd(std::plus<int>(),-1));
844 std::vector< std::pair<int,int> > cellParts,nodeParts;
845 if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts))
848 std::vector<int> st(ngs.size());
849 for(std::size_t i=0;i<ngs.size();i++)
851 nodeParts[i].second++;
852 st[i]=nodeParts[i].second-nodeParts[i].first;
854 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p(MEDCouplingStructuredMesh::BuildExplicitIdsFrom(ngs,nodeParts));
855 MEDCouplingAutoRefCountObjectPtr<MEDCurveLinearMeshMultiLev> ret(new MEDCurveLinearMeshMultiLev(*this));
857 { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
858 ret->_nb_entities[0]=pfl->getNumberOfTuples();
860 ret->_coords=_coords->selectByTupleIdSafe(p->begin(),p->end());
866 MEDCouplingAutoRefCountObjectPtr<MEDCouplingCurveLinearMesh> m(MEDCouplingCurveLinearMesh::New());
867 m->setCoords(_coords); m->setNodeGridStructure(&_structure[0],&_structure[0]+_structure.size());
868 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> m2(m->build1SGTUnstructured());
869 MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> m3=dynamic_cast<MEDCoupling1GTUMesh *>(m2->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
870 MEDCouplingAutoRefCountObjectPtr<MEDUMeshMultiLev> ret(new MEDUMeshMultiLev(*this,m3));
872 { m3->zipCoords(); nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
878 MEDCouplingAutoRefCountObjectPtr<MEDCurveLinearMeshMultiLev> ret(new MEDCurveLinearMeshMultiLev(*this));
880 { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
885 void MEDCurveLinearMeshMultiLev::buildVTUArrays(DataArrayDouble *&coords, std::vector<int>& nodeStrct) const throw(INTERP_KERNEL::Exception)
887 nodeStrct=_structure;
888 const DataArrayDouble *coo(_coords);
890 throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev::buildVTUArrays : null pointer on coordinates !");
891 coords=const_cast<DataArrayDouble *>(coo); coords->incrRef();
896 MEDFileField1TSStructItem2::MEDFileField1TSStructItem2()
900 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)
902 _pfl->setName(c.c_str());
905 void MEDFileField1TSStructItem2::checkWithMeshStructForCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception)
907 int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
908 checkInRange(nbOfEnt,1,globs);
911 void MEDFileField1TSStructItem2::checkWithMeshStructForGaussNE(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception)
913 int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
914 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
915 checkInRange(nbOfEnt,(int)cm.getNumberOfNodes(),globs);
918 void MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception)
921 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT : no globals specified !");
923 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT : no localization specified !");
924 const MEDFileFieldLoc& loc=globs->getLocalization(_loc.c_str());
925 int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
926 checkInRange(nbOfEnt,loc.getNumberOfGaussPoints(),globs);
929 int MEDFileField1TSStructItem2::getNbOfIntegrationPts(const MEDFileFieldGlobsReal *globs) const
933 if(getPflName().empty())
934 return (_start_end.second-_start_end.first)/_nb_of_entity;
936 return (_start_end.second-_start_end.first)/getPfl(globs)->getNumberOfTuples();
940 const MEDFileFieldLoc& loc(globs->getLocalization(_loc.c_str()));
941 return loc.getNumberOfGaussPoints();
945 std::string MEDFileField1TSStructItem2::getPflName() const
947 return _pfl->getName();
950 const DataArrayInt *MEDFileField1TSStructItem2::getPfl(const MEDFileFieldGlobsReal *globs) const
952 if(!_pfl->isAllocated())
954 if(_pfl->getName().empty())
957 return globs->getProfile(_pfl->getName().c_str());
964 * \param [in] nbOfEntity - number of entity that can be either cells or nodes. Not other possiblity.
965 * \param [in] nip - number of integration points. 1 for ON_CELLS and NO_NODES
967 void MEDFileField1TSStructItem2::checkInRange(int nbOfEntity, int nip, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception)
969 _nb_of_entity=nbOfEntity;
970 if(_pfl->getName().empty())
972 if(nbOfEntity!=(_start_end.second-_start_end.first)/nip)
973 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Mismatch between number of entities and size of node field !");
979 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Presence of a profile on field whereas no globals found in file !");
980 const DataArrayInt *pfl=globs->getProfile(_pfl->getName().c_str());
982 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Presence of a profile on field whereas no such profile found in file !");
983 pfl->checkAllIdsInRange(0,nbOfEntity);
987 bool MEDFileField1TSStructItem2::isFastlyEqual(int& startExp, INTERP_KERNEL::NormalizedCellType gt, const char *pflName) const
989 if(startExp!=_start_end.first)
993 if(getPflName()!=pflName)
995 startExp=_start_end.second;
999 bool MEDFileField1TSStructItem2::operator==(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception)
1001 //_nb_of_entity is not taken into account here. It is not a bug, because no mesh consideration needed here to perform fast compare.
1002 //idem for _loc. It is not an effective attribute for support comparison.
1003 return _geo_type==other._geo_type && _start_end==other._start_end && _pfl->getName()==other._pfl->getName();
1006 bool MEDFileField1TSStructItem2::isCellSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
1008 if(_geo_type!=other._geo_type)
1010 if(_nb_of_entity!=other._nb_of_entity)
1012 if((_pfl->getName().empty() && !other._pfl->getName().empty()) || (!_pfl->getName().empty() && other._pfl->getName().empty()))
1014 if(_pfl->getName().empty() && other._pfl->getName().empty())
1016 const DataArrayInt *pfl1(getPfl(globs)),*pfl2(other.getPfl(globs));
1017 return pfl1->isEqualWithoutConsideringStr(*pfl2);
1020 bool MEDFileField1TSStructItem2::isNodeSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
1022 return isCellSupportEqual(other,globs);
1026 * \a objs must be non empty. \a objs should contain items having same geometric type.
1028 MEDFileField1TSStructItem2 MEDFileField1TSStructItem2::BuildAggregationOf(const std::vector<const MEDFileField1TSStructItem2 *>& objs, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception)
1031 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : empty input !");
1033 return MEDFileField1TSStructItem2(*objs[0]);
1034 INTERP_KERNEL::NormalizedCellType gt(objs[0]->_geo_type);
1035 int nbEntityRef(objs[0]->_nb_of_entity);
1036 std::size_t sz(objs.size());
1037 std::vector<const DataArrayInt *> arrs(sz);
1038 for(std::size_t i=0;i<sz;i++)
1040 const MEDFileField1TSStructItem2 *obj(objs[i]);
1041 if(gt!=obj->_geo_type)
1042 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : invalid situation ! All input must have the same geo type !");
1043 if(nbEntityRef!=obj->_nb_of_entity)
1044 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : invalid situation ! All input must have the global nb of entity !");
1045 if(obj->_pfl->getName().empty())
1046 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : invalid situation ! Several same geo type chunk must all lie on profiles !");
1047 arrs[i]=globs->getProfile(obj->_pfl->getName().c_str());
1049 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr(DataArrayInt::Aggregate(arrs));
1051 int oldNbTuples(arr->getNumberOfTuples());
1052 arr=arr->buildUnique();
1053 if(oldNbTuples!=arr->getNumberOfTuples())
1054 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : some entities are present several times !");
1055 if(arr->isIdentity() && oldNbTuples==nbEntityRef)
1057 std::pair<int,int> p(0,nbEntityRef);
1059 MEDFileField1TSStructItem2 ret(gt,p,a,b);
1060 ret._nb_of_entity=nbEntityRef;
1065 arr->setName(NEWLY_CREATED_PFL_NAME);
1066 std::pair<int,int> p(0,oldNbTuples);
1068 MEDFileField1TSStructItem2 ret(gt,p,a,b);
1069 ret._nb_of_entity=nbEntityRef;
1075 std::size_t MEDFileField1TSStructItem2::getHeapMemorySize() const
1078 const DataArrayInt *pfl(_pfl);
1080 ret+=pfl->getHeapMemorySize();
1081 ret+=_loc.capacity();
1087 MEDFileField1TSStructItem::MEDFileField1TSStructItem(TypeOfField a, const std::vector< MEDFileField1TSStructItem2 >& b):_computed(false),_type(a),_items(b)
1091 void MEDFileField1TSStructItem::checkWithMeshStruct(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception)
1097 int nbOfEnt=mst->getNumberOfNodes();
1098 if(_items.size()!=1)
1099 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::checkWithMeshStruct : for nodes field only one subdivision supported !");
1100 _items[0].checkInRange(nbOfEnt,1,globs);
1105 for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
1106 (*it).checkWithMeshStructForCells(mst,globs);
1111 for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
1112 (*it).checkWithMeshStructForGaussNE(mst,globs);
1117 for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
1118 (*it).checkWithMeshStructForGaussPT(mst,globs);
1122 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::checkWithMeshStruct : not managed field type !");
1126 bool MEDFileField1TSStructItem::operator==(const MEDFileField1TSStructItem& other) const throw(INTERP_KERNEL::Exception)
1128 if(_type!=other._type)
1130 if(_items.size()!=other._items.size())
1132 for(std::size_t i=0;i<_items.size();i++)
1133 if(!(_items[i]==other._items[i]))
1138 bool MEDFileField1TSStructItem::isCellSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
1140 if(_type!=other._type)
1142 if(_items.size()!=other._items.size())
1144 for(std::size_t i=0;i<_items.size();i++)
1145 if(!(_items[i].isCellSupportEqual(other._items[i],globs)))
1150 bool MEDFileField1TSStructItem::isNodeSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
1152 if(_type!=other._type)
1154 if(_items.size()!=other._items.size())
1156 for(std::size_t i=0;i<_items.size();i++)
1157 if(!(_items[i].isNodeSupportEqual(other._items[i],globs)))
1162 bool MEDFileField1TSStructItem::isEntityCell() const
1173 CmpGeo(INTERP_KERNEL::NormalizedCellType geoTyp):_geo_type(geoTyp) { }
1174 bool operator()(const std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > & v) const { return _geo_type==v.first; }
1176 INTERP_KERNEL::NormalizedCellType _geo_type;
1179 MEDFileField1TSStructItem MEDFileField1TSStructItem::simplifyMeOnCellEntity(const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
1182 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::simplifyMeOnCellEntity : must be on ON_CELLS, ON_GAUSS_NE or ON_GAUSS_PT !");
1183 std::vector< std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > > m;
1185 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++,i++)
1187 std::vector< std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > >::iterator it0(std::find_if(m.begin(),m.end(),CmpGeo((*it).getGeo())));
1189 m.push_back(std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> >((*it).getGeo(),std::vector<std::size_t>(1,i)));
1191 (*it0).second.push_back(i);
1193 if(m.size()==_items.size())
1195 MEDFileField1TSStructItem ret(*this);
1199 std::size_t sz(m.size());
1200 std::vector< MEDFileField1TSStructItem2 > items(sz);
1203 const std::vector<std::size_t>& ids=m[i].second;
1204 std::vector<const MEDFileField1TSStructItem2 *>objs(ids.size());
1205 for(std::size_t j=0;j<ids.size();j++)
1206 objs[j]=&_items[ids[j]];
1207 items[i]=MEDFileField1TSStructItem2::BuildAggregationOf(objs,globs);
1209 MEDFileField1TSStructItem ret(ON_CELLS,items);
1215 * \a this is expected to be ON_CELLS and simplified.
1217 bool MEDFileField1TSStructItem::isCompatibleWithNodesDiscr(const MEDFileField1TSStructItem& other, const MEDFileMeshStruct *meshSt, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
1219 if(other._type!=ON_NODES)
1220 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isCompatibleWithNodesDiscr : other must be on nodes !");
1221 if(other._items.size()!=1)
1222 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isCompatibleWithNodesDiscr : other is on nodes but number of subparts !");
1223 int theFirstLevFull;
1224 bool ret0=isFullyOnOneLev(meshSt,theFirstLevFull);
1225 const MEDFileField1TSStructItem2& otherNodeIt(other._items[0]);
1226 if(otherNodeIt.getPflName().empty())
1230 return theFirstLevFull==0;
1234 const DataArrayInt *pfl=globs->getProfile(otherNodeIt.getPflName().c_str());
1235 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpyPfl(pfl->deepCpy());
1237 int nbOfNodes(meshSt->getNumberOfNodes());
1238 if(cpyPfl->isIdentity() && cpyPfl->getNumberOfTuples()==nbOfNodes)
1239 {//on all nodes also !
1242 return theFirstLevFull==0;
1244 std::vector<bool> nodesFetched(nbOfNodes,false);
1245 meshSt->getTheMesh()->whichAreNodesFetched(*this,globs,nodesFetched);
1246 return cpyPfl->isFittingWith(nodesFetched);
1250 bool MEDFileField1TSStructItem::isFullyOnOneLev(const MEDFileMeshStruct *meshSt, int& theFirstLevFull) const throw(INTERP_KERNEL::Exception)
1253 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : works only for ON_CELLS discretization !");
1255 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : items vector is empty !");
1256 int nbOfLevs(meshSt->getNumberOfLevs());
1258 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : no levels in input mesh structure !");
1259 std::vector<int> levs(nbOfLevs);
1262 std::set<INTERP_KERNEL::NormalizedCellType> gts;
1263 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++)
1265 if(!(*it).getPflName().empty())
1267 INTERP_KERNEL::NormalizedCellType gt((*it).getGeo());
1268 if(gts.find(gt)!=gts.end())
1269 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : internal error !");
1271 int pos(meshSt->getLevelOfGeoType((*it).getGeo()));
1274 for(int i=0;i<nbOfLevs;i++)
1275 if(meshSt->getNumberOfGeoTypesInLev(-i)==levs[i])
1276 { theFirstLevFull=-i; return true; }
1280 const MEDFileField1TSStructItem2& MEDFileField1TSStructItem::operator[](std::size_t i) const throw(INTERP_KERNEL::Exception)
1282 if(i<0 || i>=_items.size())
1283 throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::operator[] : input is not in valid range !");
1287 std::size_t MEDFileField1TSStructItem::getHeapMemorySize() const
1290 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++)
1291 ret+=(*it).getHeapMemorySize();
1292 ret+=_items.size()*sizeof(MEDFileField1TSStructItem2);
1296 MEDMeshMultiLev *MEDFileField1TSStructItem::buildFromScratchDataSetSupportOnCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
1298 std::vector<INTERP_KERNEL::NormalizedCellType> a0;
1299 std::vector<const DataArrayInt *> a1;
1300 std::vector<int> a2;
1302 for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++,i++)
1304 a0[i]=(*it).getGeo();
1305 a1[i]=(*it).getPfl(globs);
1306 a2[i]=mst->getNumberOfElemsOfGeoType((*it).getGeo());
1308 return MEDMeshMultiLev::New(mst->getTheMesh(),a0,a1,a2);
1311 MEDFileField1TSStructItem MEDFileField1TSStructItem::BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt)
1314 std::vector< MEDFileField1TSStructItem2 > anItems;
1316 std::vector< std::vector<std::string> > pfls,locs;
1317 std::vector< std::vector<TypeOfField> > typesF;
1318 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
1319 std::vector< std::vector<std::pair<int,int> > > strtEnds=ref->getFieldSplitedByType(0,geoTypes,typesF,pfls,locs);
1320 std::size_t nbOfGeoTypes(geoTypes.size());
1322 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : not null by empty ref !");
1324 for(std::size_t i=0;i<nbOfGeoTypes;i++)
1326 std::size_t sz=typesF[i].size();
1327 if(strtEnds[i].size()<1 || sz<1 || pfls[i].size()<1)
1328 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : internal error #1 !");
1334 for(std::size_t j=0;j<sz;j++)
1336 if(atype==typesF[i][j])
1337 anItems.push_back(MEDFileField1TSStructItem2(geoTypes[i],strtEnds[i][j],pfls[i][j],locs[i][j]));
1339 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : can be applied only on single spatial discretization fields ! Call SplitPerDiscretization method !");
1342 MEDFileField1TSStructItem ret(atype,anItems);
1343 ret.checkWithMeshStruct(meshSt,ref);
1349 MEDFileField1TSStruct *MEDFileField1TSStruct::New(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst) throw(INTERP_KERNEL::Exception)
1351 return new MEDFileField1TSStruct(ref,mst);
1354 MEDFileField1TSStruct::MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst)
1356 _already_checked.push_back(MEDFileField1TSStructItem::BuildItemFrom(ref,mst));
1359 void MEDFileField1TSStruct::checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception)
1361 if(_already_checked.empty())
1362 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::checkWithMeshStruct : not correctly initialized !");
1363 _already_checked.back().checkWithMeshStruct(mst,globs);
1366 bool MEDFileField1TSStruct::isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *mst) const throw(INTERP_KERNEL::Exception)
1368 MEDFileField1TSStructItem b(MEDFileField1TSStructItem::BuildItemFrom(other,mst));
1369 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++)
1378 * Not const because \a other structure will be added to the \c _already_checked attribute in case of success.
1380 bool MEDFileField1TSStruct::isSupportSameAs(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception)
1382 if(_already_checked.empty())
1383 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isSupportSameAs : no ref !");
1384 MEDFileField1TSStructItem b(MEDFileField1TSStructItem::BuildItemFrom(other,meshSt));
1385 if(!_already_checked[0].isEntityCell() || !b.isEntityCell())
1386 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isSupportSameAs : only available on cell entities !");
1387 MEDFileField1TSStructItem other1(b.simplifyMeOnCellEntity(other));
1389 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
1390 if((*it).isComputed())
1395 MEDFileField1TSStructItem this1(_already_checked[0].simplifyMeOnCellEntity(other));
1396 ret=this1.isCellSupportEqual(other1,other);
1398 _already_checked.push_back(this1);
1401 ret=_already_checked[found].isCellSupportEqual(other1,other);
1403 _already_checked.push_back(b);
1407 bool MEDFileField1TSStruct::isCompatibleWithNodesDiscr(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception)
1409 if(_already_checked.empty())
1410 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isCompatibleWithNodesDiscr : no ref !");
1411 if(!_already_checked[0].isEntityCell())
1412 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isCompatibleWithNodesDiscr : only available on cell entities !");
1413 MEDFileField1TSStructItem other1(MEDFileField1TSStructItem::BuildItemFrom(other,meshSt));
1416 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
1417 if((*it).isComputed())
1422 MEDFileField1TSStructItem this1(_already_checked[0].simplifyMeOnCellEntity(other));
1423 ret=this1.isCompatibleWithNodesDiscr(other1,meshSt,other);
1425 _already_checked.push_back(this1);
1428 ret=_already_checked[found].isCompatibleWithNodesDiscr(other1,meshSt,other);
1430 _already_checked.push_back(other1);
1434 std::size_t MEDFileField1TSStruct::getHeapMemorySize() const
1437 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++)
1438 ret+=(*it).getHeapMemorySize();
1439 ret+=_already_checked.capacity()*sizeof(MEDFileField1TSStructItem);
1443 MEDMeshMultiLev *MEDFileField1TSStruct::buildFromScratchDataSetSupport(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
1445 if(_already_checked.empty())
1446 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::buildFromScratchDataSetSupport : No outline structure in this !");
1447 int pos0(-1),pos1(-1);
1448 if(presenceOfCellDiscr(pos0))
1450 MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> ret(_already_checked[pos0].buildFromScratchDataSetSupportOnCells(mst,globs));
1451 if(presenceOfPartialNodeDiscr(pos1))
1452 ret->setNodeReduction(_already_checked[pos1][0].getPfl(globs));
1457 if(!presenceOfPartialNodeDiscr(pos1))
1458 {//we have only all nodes, no cell definition info -> level 0;
1459 std::vector<int> levs(1,0);
1460 return MEDMeshMultiLev::New(mst->getTheMesh(),levs);
1463 return MEDMeshMultiLev::NewOnlyOnNode(mst->getTheMesh(),_already_checked[pos1][0].getPfl(globs));
1467 bool MEDFileField1TSStruct::isDataSetSupportFastlyEqualTo(const MEDFileField1TSStruct& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
1470 bool a0(presenceOfCellDiscr(b0)),a1(presenceOfPartialNodeDiscr(b1));
1472 bool c0(other.presenceOfCellDiscr(d0)),c1(other.presenceOfPartialNodeDiscr(d1));
1473 if(a0!=c0 || a1!=c1)
1476 if(!_already_checked[b0].isCellSupportEqual(other._already_checked[d0],globs))
1479 if(!_already_checked[b1].isNodeSupportEqual(other._already_checked[d1],globs))
1485 * Returns true if presence in \a this of discretization ON_CELLS, ON_GAUSS_PT, ON_GAUSS_NE.
1486 * 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.
1488 bool MEDFileField1TSStruct::presenceOfCellDiscr(int& pos) const throw(INTERP_KERNEL::Exception)
1490 std::size_t refSz(std::numeric_limits<std::size_t>::max());
1493 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
1495 if((*it).getType()!=ON_NODES)
1498 std::size_t sz((*it).getNumberOfItems());
1500 { pos=i; refSz=sz; }
1504 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::presenceOfCellDiscr : an element in this on entity CELL is empty !");
1509 * Returns true if presence in \a this of discretization ON_NODES.
1510 * If true is returned the pos of the first element containing the single subpart.
1512 bool MEDFileField1TSStruct::presenceOfPartialNodeDiscr(int& pos) const throw(INTERP_KERNEL::Exception)
1515 for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++)
1517 if((*it).getType()==ON_NODES)
1519 std::size_t sz((*it).getNumberOfItems());
1522 if(!(*it)[0].getPflName().empty())
1523 { pos=i; return true; }
1526 throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::presenceOfPartialNodeDiscr : an element in this on entity NODE is split into several parts !");
1534 MEDFileFastCellSupportComparator *MEDFileFastCellSupportComparator::New(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref) throw(INTERP_KERNEL::Exception)
1536 return new MEDFileFastCellSupportComparator(m,ref);
1539 MEDFileFastCellSupportComparator::MEDFileFastCellSupportComparator(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref)
1542 throw INTERP_KERNEL::Exception("MEDFileFastCellSupportComparator constructor : null input mesh struct !");
1543 _mesh_comp=const_cast<MEDFileMeshStruct *>(m); _mesh_comp->incrRef();
1544 int nbPts=ref->getNumberOfTS();
1545 _f1ts_cmps.resize(nbPts);
1546 for(int i=0;i<nbPts;i++)
1548 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt=ref->getTimeStepAtPos(i);
1549 _f1ts_cmps[i]=MEDFileField1TSStruct::New(elt,_mesh_comp);
1550 _f1ts_cmps[i]->checkWithMeshStruct(_mesh_comp,elt);
1554 std::size_t MEDFileFastCellSupportComparator::getHeapMemorySize() const
1557 const MEDFileMeshStruct *mst(_mesh_comp);
1559 ret+=mst->getHeapMemorySize();
1560 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct> >::const_iterator it=_f1ts_cmps.begin();it!=_f1ts_cmps.end();it++)
1562 const MEDFileField1TSStruct *cur(*it);
1564 ret+=cur->getHeapMemorySize()+sizeof(MEDFileField1TSStruct);
1566 ret+=_f1ts_cmps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct>);
1570 bool MEDFileFastCellSupportComparator::isEqual(const MEDFileAnyTypeFieldMultiTS *other) throw(INTERP_KERNEL::Exception)
1572 int nbPts=other->getNumberOfTS();
1573 if(nbPts!=(int)_f1ts_cmps.size())
1575 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isEqual : unexpected nb of time steps in input ! Should be " << _f1ts_cmps.size() << " it is in reality " << nbPts << " !";
1576 throw INTERP_KERNEL::Exception(oss.str().c_str());
1578 for(int i=0;i<nbPts;i++)
1580 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt=other->getTimeStepAtPos(i);
1581 if(!_f1ts_cmps[i]->isEqualConsideringThePast(elt,_mesh_comp))
1582 if(!_f1ts_cmps[i]->isSupportSameAs(elt,_mesh_comp))
1588 bool MEDFileFastCellSupportComparator::isCompatibleWithNodesDiscr(const MEDFileAnyTypeFieldMultiTS *other) throw(INTERP_KERNEL::Exception)
1590 int nbPts=other->getNumberOfTS();
1591 if(nbPts!=(int)_f1ts_cmps.size())
1593 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isCompatibleWithNodesDiscr : unexpected nb of time steps in input ! Should be " << _f1ts_cmps.size() << " it is in reality " << nbPts << " !";
1594 throw INTERP_KERNEL::Exception(oss.str().c_str());
1596 for(int i=0;i<nbPts;i++)
1598 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt=other->getTimeStepAtPos(i);
1599 if(!_f1ts_cmps[i]->isCompatibleWithNodesDiscr(elt,_mesh_comp))
1605 MEDMeshMultiLev *MEDFileFastCellSupportComparator::buildFromScratchDataSetSupport(int timeStepId, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
1607 if(timeStepId<0 || timeStepId>=(int)_f1ts_cmps.size())
1609 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::buildFromScratchDataSetSupport : requested time step id #" << timeStepId << " is not in [0," << _f1ts_cmps.size() << ") !";
1610 throw INTERP_KERNEL::Exception(oss.str().c_str());
1612 const MEDFileField1TSStruct *obj(_f1ts_cmps[timeStepId]);
1615 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::buildFromScratchDataSetSupport : at time step id #" << timeStepId << " no field structure overview defined !";
1616 throw INTERP_KERNEL::Exception(oss.str().c_str());
1618 return obj->buildFromScratchDataSetSupport(_mesh_comp,globs);
1621 bool MEDFileFastCellSupportComparator::isDataSetSupportEqualToThePreviousOne(int timeStepId, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception)
1623 if(timeStepId<=0 || timeStepId>=(int)_f1ts_cmps.size())
1625 std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isDataSetSupportEqualToThePreviousOne : requested time step id #" << timeStepId << " is not in [1," << _f1ts_cmps.size() << ") !";
1626 throw INTERP_KERNEL::Exception(oss.str().c_str());
1628 const MEDFileField1TSStruct *obj(_f1ts_cmps[timeStepId]);
1629 const MEDFileField1TSStruct *objRef(_f1ts_cmps[timeStepId-1]);
1630 return objRef->isDataSetSupportFastlyEqualTo(*obj,globs);