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 "MEDFileMeshLL.hxx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDFileMeshReadSelector.hxx"
26 #include "MEDCouplingUMesh.hxx"
28 #include "InterpKernelAutoPtr.hxx"
29 #include "CellModel.hxx"
33 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
34 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
35 extern med_geometry_type typmainoeud[1];
37 using namespace ParaMEDMEM;
39 MEDFileMeshL2::MEDFileMeshL2():_name(MED_NAME_SIZE),_description(MED_COMMENT_SIZE),_univ_name(MED_LNAME_SIZE),_dt_unit(MED_LNAME_SIZE)
43 std::size_t MEDFileMeshL2::getHeapMemorySizeWithoutChildren() const
48 std::vector<const BigMemoryObject *> MEDFileMeshL2::getDirectChildren() const
50 return std::vector<const BigMemoryObject *>();
53 int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const std::string& mname, ParaMEDMEM::MEDCouplingMeshType& meshType, int& dt, int& it, std::string& dtunit1)
55 med_mesh_type type_maillage;
56 char maillage_description[MED_COMMENT_SIZE+1];
57 char dtunit[MED_LNAME_SIZE+1];
59 char nommaa[MED_NAME_SIZE+1];
60 med_int n=MEDnMesh(fid);
63 med_sorting_type stype;
64 std::vector<std::string> ms;
66 med_axis_type axistype;
67 for(int i=0;i<n && !found;i++)
69 int naxis=MEDmeshnAxis(fid,i+1);
70 INTERP_KERNEL::AutoPtr<char> axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
71 INTERP_KERNEL::AutoPtr<char> axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
72 MEDmeshInfo(fid,i+1,nommaa,&spaceDim,&dim,&type_maillage,maillage_description,dtunit,&stype,&nstep,&axistype,axisname,axisunit);
73 dtunit1=MEDLoaderBase::buildStringFromFortran(dtunit,sizeof(dtunit));
74 std::string cur=MEDLoaderBase::buildStringFromFortran(nommaa,sizeof(nommaa));
84 std::ostringstream oss;
85 oss << "No such meshname (" << mname << ") in file ! Must be in : ";
86 std::copy(ms.begin(),ms.end(),std::ostream_iterator<std::string>(oss,", "));
87 throw INTERP_KERNEL::Exception(oss.str().c_str());
91 case MED_UNSTRUCTURED_MESH:
92 meshType=UNSTRUCTURED;
94 case MED_STRUCTURED_MESH:
97 MEDmeshGridTypeRd(fid,mname.c_str(),>);
100 case MED_CARTESIAN_GRID:
103 case MED_CURVILINEAR_GRID:
104 meshType=CURVE_LINEAR;
107 throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getMeshIdFromName : unrecognized structured mesh type ! Supported are :\n - cartesian\n - curve linear\n");
112 throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getMeshIdFromName : unrecognized mesh type !");
116 MEDmeshComputationStepInfo(fid,mname.c_str(),1,&numdt,&numit,&dtt);
121 double MEDFileMeshL2::CheckMeshTimeStep(med_idt fid, const std::string& mName, int nstep, int dt, int it)
126 std::vector< std::pair<int,int> > p(nstep);
127 for(int i=0;i<nstep;i++)
129 MEDmeshComputationStepInfo(fid,mName.c_str(),i+1,&numdt,&numit,&dtt);
130 p[i]=std::make_pair<int,int>(numdt,numit);
131 found=(numdt==dt) && (numit==numit);
135 std::ostringstream oss; oss << "No such iteration=" << dt << ",order=" << it << " numbers found for mesh '" << mName << "' ! ";
136 oss << "Possibilities are : ";
137 for(int i=0;i<nstep;i++)
138 oss << "(" << p[i].first << "," << p[i].second << "), ";
139 throw INTERP_KERNEL::Exception(oss.str().c_str());
144 std::vector<std::string> MEDFileMeshL2::getAxisInfoOnMesh(med_idt fid, int mId, const std::string& mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& nstep, int& Mdim)
146 med_mesh_type type_maillage;
148 med_sorting_type stype;
149 med_axis_type axistype;
150 int naxis=MEDmeshnAxis(fid,mId);
151 INTERP_KERNEL::AutoPtr<char> nameTmp=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
152 INTERP_KERNEL::AutoPtr<char> axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
153 INTERP_KERNEL::AutoPtr<char> axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
154 INTERP_KERNEL::AutoPtr<char> univTmp=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
155 if(MEDmeshInfo(fid,mId,nameTmp,&spaceDim,&Mdim,&type_maillage,_description.getPointer(),_dt_unit.getPointer(),
156 &stype,&nstep,&axistype,axisname,axisunit)!=0)
157 throw INTERP_KERNEL::Exception("A problem has been detected when trying to get info on mesh !");
158 MEDmeshUniversalNameRd(fid,nameTmp,_univ_name.getPointer());
159 switch(type_maillage)
161 case MED_UNSTRUCTURED_MESH:
162 meshType=UNSTRUCTURED;
164 case MED_STRUCTURED_MESH:
167 MEDmeshGridTypeRd(fid,mName.c_str(),>);
170 case MED_CARTESIAN_GRID:
173 case MED_CURVILINEAR_GRID:
174 meshType=CURVE_LINEAR;
177 throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getAxisInfoOnMesh : unrecognized structured mesh type ! Supported are :\n - cartesian\n - curve linear\n");
182 throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getMeshIdFromName : unrecognized mesh type !");
185 std::vector<std::string> infosOnComp(naxis);
186 for(int i=0;i<naxis;i++)
188 std::string info=MEDLoaderBase::buildUnionUnit(((char *)axisname)+i*MED_SNAME_SIZE,MED_SNAME_SIZE,((char *)axisunit)+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
194 void MEDFileMeshL2::ReadFamiliesAndGrps(med_idt fid, const std::string& meshName, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps, MEDFileMeshReadSelector *mrs)
196 if(mrs && !(mrs->isCellFamilyFieldReading() || mrs->isNodeFamilyFieldReading()))
198 char nomfam[MED_NAME_SIZE+1];
200 int nfam=MEDnFamily(fid,meshName.c_str());
201 for(int i=0;i<nfam;i++)
203 int ngro=MEDnFamilyGroup(fid,meshName.c_str(),i+1);
204 med_int natt=MEDnFamily23Attribute(fid,meshName.c_str(),i+1);
205 INTERP_KERNEL::AutoPtr<med_int> attide=new med_int[natt];
206 INTERP_KERNEL::AutoPtr<med_int> attval=new med_int[natt];
207 INTERP_KERNEL::AutoPtr<char> attdes=new char[MED_COMMENT_SIZE*natt+1];
208 INTERP_KERNEL::AutoPtr<char> gro=new char[MED_LNAME_SIZE*ngro+1];
209 MEDfamily23Info(fid,meshName.c_str(),i+1,nomfam,attide,attval,attdes,&numfam,gro);
210 std::string famName=MEDLoaderBase::buildStringFromFortran(nomfam,MED_NAME_SIZE);
211 fams[famName]=numfam;
212 for(int j=0;j<ngro;j++)
214 std::string groupname=MEDLoaderBase::buildStringFromFortran(gro+j*MED_LNAME_SIZE,MED_LNAME_SIZE);
215 grps[groupname].push_back(famName);
220 void MEDFileMeshL2::WriteFamiliesAndGrps(med_idt fid, const std::string& mname, const std::map<std::string,int>& fams, const std::map<std::string, std::vector<std::string> >& grps, int tooLongStrPol)
222 for(std::map<std::string,int>::const_iterator it=fams.begin();it!=fams.end();it++)
224 std::vector<std::string> grpsOfFam;
225 for(std::map<std::string, std::vector<std::string> >::const_iterator it1=grps.begin();it1!=grps.end();it1++)
227 if(std::find((*it1).second.begin(),(*it1).second.end(),(*it).first)!=(*it1).second.end())
228 grpsOfFam.push_back((*it1).first);
230 int ngro=grpsOfFam.size();
231 INTERP_KERNEL::AutoPtr<char> groName=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE*ngro);
233 for(std::vector<std::string>::const_iterator it2=grpsOfFam.begin();it2!=grpsOfFam.end();it2++,i++)
234 MEDLoaderBase::safeStrCpy2((*it2).c_str(),MED_LNAME_SIZE-1,groName+i*MED_LNAME_SIZE,tooLongStrPol);
235 INTERP_KERNEL::AutoPtr<char> famName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
236 MEDLoaderBase::safeStrCpy((*it).first.c_str(),MED_NAME_SIZE,famName,tooLongStrPol);
237 int ret=MEDfamilyCr(fid,mname.c_str(),famName,(*it).second,ngro,groName);
242 MEDFileUMeshL2::MEDFileUMeshL2()
246 void MEDFileUMeshL2::loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
248 _name.set(mName.c_str());
251 ParaMEDMEM::MEDCouplingMeshType meshType;
252 std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName.c_str(),meshType,nstep,Mdim);
255 if(meshType!=UNSTRUCTURED)
256 throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected an unstructured one whereas in file it is not an unstructured !");
257 _time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
260 loadConnectivity(fid,Mdim,mName,dt,it,mrs);//to improve check (dt,it) coherency
261 loadCoords(fid,mId,infosOnComp,mName,dt,it);
264 void MEDFileUMeshL2::loadConnectivity(med_idt fid, int mdim, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
266 _per_type_mesh.resize(1);
267 _per_type_mesh[0].clear();
268 for(int j=0;j<MED_N_CELL_FIXED_GEO;j++)
270 MEDFileUMeshPerType *tmp=MEDFileUMeshPerType::New(fid,mName.c_str(),dt,it,mdim,typmai[j],typmai2[j],mrs);
272 _per_type_mesh[0].push_back(tmp);
277 void MEDFileUMeshL2::loadCoords(med_idt fid, int mId, const std::vector<std::string>& infosOnComp, const std::string& mName, int dt, int it)
279 int spaceDim=infosOnComp.size();
280 med_bool changement,transformation;
281 int nCoords=MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation);
282 _coords=DataArrayDouble::New();
283 _coords->alloc(nCoords,spaceDim);
284 double *coordsPtr=_coords->getPointer();
285 MEDmeshNodeCoordinateRd(fid,mName.c_str(),dt,it,MED_FULL_INTERLACE,coordsPtr);
286 if(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0)
288 _fam_coords=DataArrayInt::New();
289 _fam_coords->alloc(nCoords,1);
290 MEDmeshEntityFamilyNumberRd(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,_fam_coords->getPointer());
294 if(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,MED_NUMBER,MED_NODAL,&changement,&transformation)>0)
296 _num_coords=DataArrayInt::New();
297 _num_coords->alloc(nCoords,1);
298 MEDmeshEntityNumberRd(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,_num_coords->getPointer());
302 if(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,MED_NAME,MED_NODAL,&changement,&transformation)>0)
304 _name_coords=DataArrayAsciiChar::New();
305 _name_coords->alloc(nCoords+1,MED_SNAME_SIZE);//not a bug to avoid the memory corruption due to last \0 at the end
306 MEDmeshEntityNameRd(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,_name_coords->getPointer());
307 _name_coords->reAlloc(nCoords);//not a bug to avoid the memory corruption due to last \0 at the end
311 for(int i=0;i<spaceDim;i++)
312 _coords->setInfoOnComponent(i,infosOnComp[i]);
315 void MEDFileUMeshL2::sortTypes()
318 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> > tmp(_per_type_mesh[0]);
319 _per_type_mesh.clear();
320 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=tmp.begin();it!=tmp.end();it++)
321 mdims.insert((*it)->getDim());
324 int mdim=*mdims.rbegin();
325 _per_type_mesh.resize(mdim+1);
326 for(int dim=mdim+1;dim!=0;dim--)
328 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >& elt=_per_type_mesh[mdim+1-dim];
329 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=tmp.begin();it!=tmp.end();it++)
330 if((*it)->getDim()==dim-1)
333 // suppression of contiguous empty levels at the end of _per_type_mesh.
334 int nbOfUselessLev=0;
336 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> > >::reverse_iterator it2=_per_type_mesh.rbegin();it2!=_per_type_mesh.rend();it2++)
338 if((*it2).empty() && isFirst)
345 _per_type_mesh.resize(_per_type_mesh.size()-nbOfUselessLev);
348 void MEDFileUMeshL2::WriteCoords(med_idt fid, const std::string& mname, int dt, int it, double time, const DataArrayDouble *coords, const DataArrayInt *famCoords, const DataArrayInt *numCoords, const DataArrayAsciiChar *nameCoords)
352 MEDmeshNodeCoordinateWr(fid,mname.c_str(),dt,it,time,MED_FULL_INTERLACE,coords->getNumberOfTuples(),coords->getConstPointer());
354 MEDmeshEntityFamilyNumberWr(fid,mname.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,famCoords->getNumberOfTuples(),famCoords->getConstPointer());
356 MEDmeshEntityNumberWr(fid,mname.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,numCoords->getNumberOfTuples(),numCoords->getConstPointer());
359 if(nameCoords->getNumberOfComponents()!=MED_SNAME_SIZE)
361 std::ostringstream oss; oss << " MEDFileUMeshL2::WriteCoords : expected a name field on nodes with number of components set to " << MED_SNAME_SIZE;
362 oss << " ! The array has " << nameCoords->getNumberOfComponents() << " components !";
363 throw INTERP_KERNEL::Exception(oss.str().c_str());
365 MEDmeshEntityNameWr(fid,mname.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,nameCoords->getNumberOfTuples(),nameCoords->getConstPointer());
369 bool MEDFileUMeshL2::isFamDefinedOnLev(int levId) const
371 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++)
372 if((*it)->getFam()==0)
377 bool MEDFileUMeshL2::isNumDefinedOnLev(int levId) const
379 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++)
380 if((*it)->getNum()==0)
385 bool MEDFileUMeshL2::isNamesDefinedOnLev(int levId) const
387 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++)
388 if((*it)->getNames()==0)
393 MEDFileCMeshL2::MEDFileCMeshL2()
397 void MEDFileCMeshL2::loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it)
399 _name.set(mName.c_str());
402 ParaMEDMEM::MEDCouplingMeshType meshType;
403 std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName.c_str(),meshType,nstep,Mdim);
404 if(meshType!=CARTESIAN)
405 throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected a structured one whereas in file it is not a structured !");
406 _time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
410 med_grid_type gridtype;
411 MEDmeshGridTypeRd(fid,mName.c_str(),&gridtype);
412 if(gridtype!=MED_CARTESIAN_GRID)
413 throw INTERP_KERNEL::Exception("Invalid structured mesh ! Expected cartesian mesh type !");
414 _cmesh=MEDCouplingCMesh::New();
415 for(int i=0;i<Mdim;i++)
417 med_data_type dataTypeReq=GetDataTypeCorrespondingToSpaceId(i);
418 med_bool chgt=MED_FALSE,trsf=MED_FALSE;
419 int nbOfElt=MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,dataTypeReq,MED_NO_CMODE,&chgt,&trsf);
420 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=DataArrayDouble::New();
421 da->alloc(nbOfElt,1);
422 da->setInfoOnComponent(0,infosOnComp[i]);
423 MEDmeshGridIndexCoordinateRd(fid,mName.c_str(),dt,it,i+1,da->getPointer());
424 _cmesh->setCoordsAt(i,da);
428 med_data_type MEDFileCMeshL2::GetDataTypeCorrespondingToSpaceId(int id)
433 return MED_COORDINATE_AXIS1;
435 return MED_COORDINATE_AXIS2;
437 return MED_COORDINATE_AXIS3;
439 throw INTERP_KERNEL::Exception("Invalid meshdim detected in Cartesian Grid !");
443 MEDFileCLMeshL2::MEDFileCLMeshL2()
447 void MEDFileCLMeshL2::loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it)
449 _name.set(mName.c_str());
452 ParaMEDMEM::MEDCouplingMeshType meshType;
453 std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName,meshType,nstep,Mdim);
454 if(meshType!=CURVE_LINEAR)
455 throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected a structured one whereas in file it is not a structured !");
456 _time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
460 _clmesh=MEDCouplingCurveLinearMesh::New();
461 INTERP_KERNEL::AutoPtr<int> stGrid=new int[Mdim];
462 MEDmeshGridStructRd(fid,mName.c_str(),dt,it,stGrid);
463 _clmesh->setNodeGridStructure(stGrid,((int *)stGrid)+Mdim);
464 med_bool chgt=MED_FALSE,trsf=MED_FALSE;
465 int nbNodes=MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&chgt,&trsf);
466 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=DataArrayDouble::New();
467 da->alloc(nbNodes,infosOnComp.size());
468 da->setInfoOnComponents(infosOnComp);
469 MEDmeshNodeCoordinateRd(fid,mName.c_str(),dt,it,MED_FULL_INTERLACE,da->getPointer());
470 _clmesh->setCoords(da);
473 MEDFileUMeshPermCompute::MEDFileUMeshPermCompute(const MEDFileUMeshSplitL1* st):_st(st),_mpt_time(0),_num_time(0)
478 * Warning it returns an instance to deallocate !!!!
480 MEDFileUMeshPermCompute::operator MEDCouplingUMesh *() const
482 _st->_num->updateTime();
483 if((MEDCouplingUMesh *)_m==0)
486 _m=static_cast<MEDCouplingUMesh *>(_st->_m_by_types.getUmesh()->deepCpy());
487 _m->renumberCells(_st->_num->getConstPointer(),true);
492 if(_mpt_time==_st->_m_by_types.getTimeOfThis() && _num_time==_st->_num->getTimeOfThis())
497 _m=static_cast<MEDCouplingUMesh *>(_st->_m_by_types.getUmesh()->deepCpy());
498 _m->renumberCells(_st->_num->getConstPointer(),true);
504 void MEDFileUMeshPermCompute::operator=(MEDCouplingUMesh *m)
509 void MEDFileUMeshPermCompute::updateTime() const
511 _mpt_time=_st->_m_by_types.getTimeOfThis();
512 _num_time=_st->_num->getTimeOfThis();
515 MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshSplitL1& other):RefCountObject(other),_m_by_types(other._m_by_types),_fam(other._fam),_num(other._num),_names(other._names),_rev_num(other._rev_num),_m(this)
519 MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const std::string& mName, int id):_m(this)
521 const std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >& v=l2.getLev(id);
525 std::vector<const MEDCoupling1GTUMesh *> ms(sz);
526 std::vector<const DataArrayInt *> fams(sz),nums(sz);
527 std::vector<const DataArrayChar *> names(sz);
528 for(int i=0;i<sz;i++)
530 MEDCoupling1GTUMesh *elt(v[i]->getMesh());
531 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp2=l2.getCoords();
532 elt->setCoords(tmp2);
535 _m_by_types.assignParts(ms);
536 if(l2.isFamDefinedOnLev(id))
538 for(int i=0;i<sz;i++)
539 fams[i]=v[i]->getFam();
541 _fam=DataArrayInt::Aggregate(fams);
545 _fam=const_cast<DataArrayInt *>(fams[0]);
548 if(l2.isNumDefinedOnLev(id))
550 for(int i=0;i<sz;i++)
551 nums[i]=v[i]->getNum();
553 _num=DataArrayInt::Aggregate(nums);
557 _num=const_cast<DataArrayInt *>(nums[0]);
561 if(l2.isNamesDefinedOnLev(id))
563 for(int i=0;i<sz;i++)
564 names[i]=v[i]->getNames();
565 _names=dynamic_cast<DataArrayAsciiChar *>(DataArrayChar::Aggregate(names));
569 MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCoupling1GTUMesh *m):_m(this)
571 std::vector< const MEDCoupling1GTUMesh * > v(1);
576 MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCouplingUMesh *m):_m(this)
581 MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCouplingUMesh *m, bool newOrOld):_m(this)
583 assignMesh(m,newOrOld);
586 void MEDFileUMeshSplitL1::setName(const std::string& name)
588 _m_by_types.setName(name);
591 std::size_t MEDFileUMeshSplitL1::getHeapMemorySizeWithoutChildren() const
596 std::vector<const BigMemoryObject *> MEDFileUMeshSplitL1::getDirectChildren() const
598 std::vector<const BigMemoryObject *> ret;
599 ret.push_back(&_m_by_types);
600 if((const DataArrayInt*)_fam)
601 ret.push_back((const DataArrayInt*)_fam);
602 if((const DataArrayInt*)_num)
603 ret.push_back((const DataArrayInt*)_num);
604 if((const DataArrayInt*)_rev_num)
605 ret.push_back((const DataArrayInt*)_rev_num);
606 if((const DataArrayAsciiChar*)_names)
607 ret.push_back((const DataArrayAsciiChar*)_names);
611 MEDFileUMeshSplitL1 *MEDFileUMeshSplitL1::deepCpy(DataArrayDouble *coords) const
613 MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> ret=new MEDFileUMeshSplitL1(*this);
614 ret->_m_by_types=_m_by_types.deepCpy(coords);
615 if((const DataArrayInt *)_fam)
616 ret->_fam=_fam->deepCpy();
617 if((const DataArrayInt *)_num)
618 ret->_num=_num->deepCpy();
619 if((const DataArrayInt *)_rev_num)
620 ret->_rev_num=_rev_num->deepCpy();
621 if((const DataArrayAsciiChar *)_names)
622 ret->_names=_names->deepCpy();
626 bool MEDFileUMeshSplitL1::isEqual(const MEDFileUMeshSplitL1 *other, double eps, std::string& what) const
628 if(!_m_by_types.isEqual(other->_m_by_types,eps,what))
630 const DataArrayInt *d1=_fam;
631 const DataArrayInt *d2=other->_fam;
632 if((d1==0 && d2!=0) || (d1!=0 && d2==0))
634 what="Presence of family arr in one sublevel and not in other!";
638 if(!d1->isEqual(*d2))
640 what="family arr at a sublevel are not deeply equal !";
645 if((d1==0 && d2!=0) || (d1!=0 && d2==0))
647 what="Presence of cell numbering arr in one sublevel and not in other!";
651 if(!d1->isEqual(*d2))
653 what="Numbering cell arr at a sublevel are not deeply equal !";
656 const DataArrayAsciiChar *e1=_names;
657 const DataArrayAsciiChar *e2=other->_names;
658 if((e1==0 && e2!=0) || (e1!=0 && e2==0))
660 what="Presence of cell names arr in one sublevel and not in other!";
664 if(!e1->isEqual(*e2))
666 what="Name cell arr at a sublevel are not deeply equal !";
672 void MEDFileUMeshSplitL1::synchronizeTinyInfo(const MEDFileMesh& master) const
674 _m_by_types.synchronizeTinyInfo(master);
677 void MEDFileUMeshSplitL1::clearNonDiscrAttributes() const
679 _m_by_types.clearNonDiscrAttributes();
682 void MEDFileUMeshSplitL1::ClearNonDiscrAttributes(const MEDCouplingMesh *tmp)
686 (const_cast<MEDCouplingMesh *>(tmp))->setName("");
687 (const_cast<MEDCouplingMesh *>(tmp))->setDescription("");
688 (const_cast<MEDCouplingMesh *>(tmp))->setTime(0.,-1,-1);
689 (const_cast<MEDCouplingMesh *>(tmp))->setTimeUnit("");
692 void MEDFileUMeshSplitL1::setCoords(DataArrayDouble *coords)
694 _m_by_types.setCoords(coords);
697 void MEDFileUMeshSplitL1::assignMesh(MEDCouplingUMesh *m, bool newOrOld)
703 _m_by_types.assignUMesh(dynamic_cast<MEDCouplingUMesh *>(m->deepCpy()));
704 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_m_by_types.getUmesh()->getRenumArrForConsecutiveCellTypesSpec(typmai2,typmai2+MED_N_CELL_FIXED_GEO);
705 if(!da->isIdentity())
707 _num=da->invertArrayO2N2N2O(m->getNumberOfCells());
710 _m_by_types.getUmesh()->renumberCells(da->getConstPointer(),false);
715 if(!m->checkConsecutiveCellTypesAndOrder(typmai2,typmai2+MED_N_CELL_FIXED_GEO))
716 throw INTERP_KERNEL::Exception("MEDFileUMeshSplitL1::assignMesh : the mode of mesh setting expects to follow the MED file numbering convention ! it is not the case !");
718 _m_by_types.assignUMesh(m);
723 void MEDFileUMeshSplitL1::forceComputationOfParts() const
725 _m_by_types.forceComputationOfPartsFromUMesh();
728 void MEDFileUMeshSplitL1::assignParts(const std::vector< const MEDCoupling1GTUMesh * >& mParts)
730 _m_by_types.assignParts(mParts);
734 void MEDFileUMeshSplitL1::assignCommonPart()
736 _fam=DataArrayInt::New();
737 _fam->alloc(_m_by_types.getSize(),1);
738 _fam->fillWithValue(0);
741 bool MEDFileUMeshSplitL1::empty() const
743 return _m_by_types.empty();
746 bool MEDFileUMeshSplitL1::presenceOfOneFams(const std::vector<int>& ids) const
748 const DataArrayInt *fam=_fam;
751 return fam->presenceOfValue(ids);
754 int MEDFileUMeshSplitL1::getMeshDimension() const
756 return _m_by_types.getMeshDimension();
759 void MEDFileUMeshSplitL1::simpleRepr(std::ostream& oss) const
761 std::vector<int> code=_m_by_types.getDistributionOfTypes();
762 int nbOfTypes=code.size()/3;
763 for(int i=0;i<nbOfTypes;i++)
765 INTERP_KERNEL::NormalizedCellType typ=(INTERP_KERNEL::NormalizedCellType) code[3*i];
766 oss << " - Number of cells with type " << INTERP_KERNEL::CellModel::GetCellModel(typ).getRepr() << " : " << code[3*i+1] << std::endl;
770 int MEDFileUMeshSplitL1::getSize() const
772 return _m_by_types.getSize();
775 MEDCouplingUMesh *MEDFileUMeshSplitL1::getFamilyPart(const int *idsBg, const int *idsEnd, bool renum) const
777 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> eltsToKeep=_fam->getIdsEqualList(idsBg,idsEnd);
778 MEDCouplingUMesh *m=(MEDCouplingUMesh *)_m_by_types.getUmesh()->buildPartOfMySelf(eltsToKeep->getConstPointer(),eltsToKeep->getConstPointer()+eltsToKeep->getNumberOfTuples(),true);
780 return renumIfNeeded(m,eltsToKeep->getConstPointer());
784 DataArrayInt *MEDFileUMeshSplitL1::getFamilyPartArr(const int *idsBg, const int *idsEnd, bool renum) const
786 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_fam->getIdsEqualList(idsBg,idsEnd);
788 return renumIfNeededArr(da);
792 std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileUMeshSplitL1::getGeoTypes() const
794 return _m_by_types.getGeoTypes();
797 MEDCouplingUMesh *MEDFileUMeshSplitL1::getWholeMesh(bool renum) const
799 MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> tmp;
800 if(renum && ((const DataArrayInt *)_num))
803 { tmp=_m_by_types.getUmesh(); if(tmp) tmp->incrRef(); }
807 DataArrayInt *MEDFileUMeshSplitL1::extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const
809 const DataArrayInt *fam(_fam);
812 int start(0),stop(0);
813 _m_by_types.getStartStopOfGeoTypeWithoutComputation(gt,start,stop);
814 return fam->selectByTupleId2(start,stop,1);
817 DataArrayInt *MEDFileUMeshSplitL1::extractNumberFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const
819 const DataArrayInt *num(_num);
822 int start(0),stop(0);
823 _m_by_types.getStartStopOfGeoTypeWithoutComputation(gt,start,stop);
824 return num->selectByTupleId2(start,stop,1);
827 DataArrayInt *MEDFileUMeshSplitL1::getOrCreateAndGetFamilyField()
829 if((DataArrayInt *)_fam)
831 int nbOfTuples=_m_by_types.getSize();
832 _fam=DataArrayInt::New(); _fam->alloc(nbOfTuples,1); _fam->fillWithZero();
836 const DataArrayInt *MEDFileUMeshSplitL1::getFamilyField() const
841 const DataArrayInt *MEDFileUMeshSplitL1::getNumberField() const
846 const DataArrayInt *MEDFileUMeshSplitL1::getRevNumberField() const
851 const DataArrayAsciiChar *MEDFileUMeshSplitL1::getNameField() const
856 void MEDFileUMeshSplitL1::eraseFamilyField()
858 _fam->fillWithZero();
862 * This method ignores _m and _m_by_types.
864 void MEDFileUMeshSplitL1::setGroupsFromScratch(const std::vector<const MEDCouplingUMesh *>& ms, std::map<std::string,int>& familyIds,
865 std::map<std::string, std::vector<std::string> >& groups) throw(INTERP_KERNEL::Exception)
867 std::vector< DataArrayInt * > corr;
868 _m=MEDCouplingUMesh::FuseUMeshesOnSameCoords(ms,0,corr);
869 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > corrMSafe(corr.begin(),corr.end());
870 std::vector< std::vector<int> > fidsOfGroups;
871 std::vector< const DataArrayInt * > corr2(corr.begin(),corr.end());
872 _fam=DataArrayInt::MakePartition(corr2,((MEDCouplingUMesh *)_m)->getNumberOfCells(),fidsOfGroups);
873 int nbOfCells=((MEDCouplingUMesh *)_m)->getNumberOfCells();
874 std::map<int,std::string> newfams;
875 std::map<int,int> famIdTrad;
876 TraduceFamilyNumber(fidsOfGroups,familyIds,famIdTrad,newfams);
877 int *w=_fam->getPointer();
878 for(int i=0;i<nbOfCells;i++,w++)
882 void MEDFileUMeshSplitL1::write(med_idt fid, const std::string& mName, int mdim) const
884 std::vector<MEDCoupling1GTUMesh *> ms(_m_by_types.getParts());
886 for(std::vector<MEDCoupling1GTUMesh *>::const_iterator it=ms.begin();it!=ms.end();it++)
888 int nbCells=(*it)->getNumberOfCells();
889 int end=start+nbCells;
890 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> fam,num;
891 MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> names;
892 if((const DataArrayInt *)_fam)
893 fam=_fam->substr(start,end);
894 if((const DataArrayInt *)_num)
895 num=_num->substr(start,end);
896 if((const DataArrayAsciiChar *)_names)
897 names=static_cast<DataArrayAsciiChar *>(_names->substr(start,end));
898 MEDFileUMeshPerType::Write(fid,mName,mdim,(*it),fam,num,names);
903 void MEDFileUMeshSplitL1::renumberNodesInConn(const int *newNodeNumbersO2N)
905 MEDCouplingUMesh *m(_m_by_types.getUmesh());
908 m->renumberNodesInConn(newNodeNumbersO2N);
911 void MEDFileUMeshSplitL1::changeFamilyIdArr(int oldId, int newId)
913 DataArrayInt *arr=_fam;
915 arr->changeValue(oldId,newId);
918 void MEDFileUMeshSplitL1::setFamilyArr(DataArrayInt *famArr)
925 int sz(_m_by_types.getSize());
926 famArr->checkNbOfTuplesAndComp(sz,1,"MEDFileUMeshSplitL1::setFamilyArr : Problem in size of Family arr ! ");
931 void MEDFileUMeshSplitL1::setRenumArr(DataArrayInt *renumArr)
939 int sz(_m_by_types.getSize());
940 renumArr->checkNbOfTuplesAndComp(sz,1,"MEDFileUMeshSplitL1::setRenumArr : Problem in size of numbering arr ! ");
946 void MEDFileUMeshSplitL1::setNameArr(DataArrayAsciiChar *nameArr)
953 int sz(_m_by_types.getSize());
954 nameArr->checkNbOfTuplesAndComp(sz,MED_SNAME_SIZE,"MEDFileUMeshSplitL1::setNameArr : Problem in size of name arr ! ");
959 MEDCouplingUMesh *MEDFileUMeshSplitL1::Renumber2(const DataArrayInt *renum, MEDCouplingUMesh *m, const int *cellIds)
964 m->renumberCells(renum->getConstPointer(),true);
967 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> locnum=renum->selectByTupleId(cellIds,cellIds+m->getNumberOfCells());
968 m->renumberCells(locnum->getConstPointer(),true);
973 MEDCouplingUMesh *MEDFileUMeshSplitL1::renumIfNeeded(MEDCouplingUMesh *m, const int *cellIds) const
975 return Renumber2(_num,m,cellIds);
978 DataArrayInt *MEDFileUMeshSplitL1::Renumber(const DataArrayInt *renum, const DataArrayInt *da)
980 if((const DataArrayInt *)renum==0)
983 return const_cast<DataArrayInt *>(da);
985 return renum->selectByTupleId(da->getConstPointer(),da->getConstPointer()+da->getNumberOfTuples());
988 DataArrayInt *MEDFileUMeshSplitL1::renumIfNeededArr(const DataArrayInt *da) const
990 return Renumber(_num,da);
993 std::vector<int> MEDFileUMeshSplitL1::GetNewFamiliesNumber(int nb, const std::map<std::string,int>& families)
996 for(std::map<std::string,int>::const_iterator it=families.begin();it!=families.end();it++)
997 id=std::max(id,(*it).second);
1000 std::vector<int> ret(nb);
1001 for(int i=1;i<=nb;i++)
1006 void MEDFileUMeshSplitL1::TraduceFamilyNumber(const std::vector< std::vector<int> >& fidsGrps, std::map<std::string,int>& familyIds,
1007 std::map<int,int>& famIdTrad, std::map<int,std::string>& newfams)
1009 std::set<int> allfids;
1013 void MEDFileUMeshSplitL1::computeRevNum() const
1016 int maxValue=_num->getMaxValue(pos);
1017 _rev_num=_num->invertArrayN2O2O2N(maxValue+1);
1022 MEDFileUMeshAggregateCompute::MEDFileUMeshAggregateCompute():_mp_time(0),_m_time(0)
1026 void MEDFileUMeshAggregateCompute::setName(const std::string& name)
1028 if(_m_time>=_mp_time)
1030 MEDCouplingUMesh *um(_m);
1034 if(_mp_time>=_m_time)
1036 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1038 MEDCoupling1GTUMesh *tmp(*it);
1045 void MEDFileUMeshAggregateCompute::assignParts(const std::vector< const MEDCoupling1GTUMesh * >& mParts)
1047 std::size_t sz(mParts.size());
1048 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> > ret(sz);
1049 for(std::size_t i=0;i<sz;i++)
1051 const MEDCoupling1GTUMesh *elt(mParts[i]);
1053 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::assignParts : presence of null pointer !");
1054 ret[i]=const_cast<MEDCoupling1GTUMesh *>(elt); elt->incrRef();
1057 _mp_time=std::max(_mp_time,_m_time)+1;
1061 void MEDFileUMeshAggregateCompute::assignUMesh(MEDCouplingUMesh *m)
1065 _m_time=std::max(_mp_time,_m_time)+1;
1068 MEDCouplingUMesh *MEDFileUMeshAggregateCompute::getUmesh() const
1070 if(_mp_time<=_m_time)
1072 std::vector< const MEDCoupling1GTUMesh *> mp(_m_parts.size());
1073 std::copy(_m_parts.begin(),_m_parts.end(),mp.begin());
1074 _m=MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh(mp);
1075 _m_parts.clear();//to avoid memory peak !
1076 _m_time=_mp_time+1;//+1 is important ! That is to say that only _m is OK not _m_parts because cleared !
1080 std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileUMeshAggregateCompute::getGeoTypes() const
1082 if(_mp_time>=_m_time)
1084 std::size_t sz(_m_parts.size());
1085 std::vector<INTERP_KERNEL::NormalizedCellType> ret(sz);
1086 for(std::size_t i=0;i<sz;i++)
1087 ret[i]=_m_parts[i]->getCellModelEnum();
1091 return _m->getAllGeoTypesSorted();
1094 std::vector<MEDCoupling1GTUMesh *> MEDFileUMeshAggregateCompute::getPartsWithoutComputation() const
1096 if(_mp_time<_m_time)
1097 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getPartsWithoutComputation : the parts require a computation !");
1099 std::vector<MEDCoupling1GTUMesh *> ret(_m_parts.size());
1101 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++,i++)
1103 const MEDCoupling1GTUMesh *elt(*it);
1104 ret[i]=const_cast<MEDCoupling1GTUMesh *>(elt);
1109 std::vector<MEDCoupling1GTUMesh *> MEDFileUMeshAggregateCompute::getParts() const
1111 if(_mp_time<_m_time)
1112 forceComputationOfPartsFromUMesh();
1113 return getPartsWithoutComputation();
1116 MEDCoupling1GTUMesh *MEDFileUMeshAggregateCompute::getPartWithoutComputation(INTERP_KERNEL::NormalizedCellType gt) const
1118 std::vector<MEDCoupling1GTUMesh *> v(getPartsWithoutComputation());
1119 std::size_t sz(v.size());
1120 for(std::size_t i=0;i<sz;i++)
1123 if(v[i]->getCellModelEnum()==gt)
1126 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getPartWithoutComputation : the geometric type is not existing !");
1129 void MEDFileUMeshAggregateCompute::getStartStopOfGeoTypeWithoutComputation(INTERP_KERNEL::NormalizedCellType gt, int& start, int& stop) const
1132 std::vector<MEDCoupling1GTUMesh *> v(getPartsWithoutComputation());
1133 std::size_t sz(v.size());
1134 for(std::size_t i=0;i<sz;i++)
1138 if(v[i]->getCellModelEnum()==gt)
1140 stop=start+v[i]->getNumberOfCells();
1144 start+=v[i]->getNumberOfCells();
1147 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getStartStopOfGeoTypeWithoutComputation : the geometric type is not existing !");
1150 void MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh() const
1152 const MEDCouplingUMesh *m(_m);
1154 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh : null UMesh !");
1155 std::vector<MEDCouplingUMesh *> ms(m->splitByType());
1156 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> > msMSafe(ms.begin(),ms.end());
1157 std::size_t sz(msMSafe.size());
1158 _m_parts.resize(sz);
1159 for(std::size_t i=0;i<sz;i++)
1160 _m_parts[i]=MEDCoupling1GTUMesh::New(ms[i]);
1161 _mp_time=std::max(_mp_time,_m_time);
1164 std::size_t MEDFileUMeshAggregateCompute::getTimeOfThis() const
1166 if(_mp_time>_m_time)
1167 return getTimeOfParts();
1168 if(_m_time>_mp_time)
1169 return getTimeOfUMesh();
1170 return std::max(getTimeOfParts(),getTimeOfUMesh());
1173 std::size_t MEDFileUMeshAggregateCompute::getTimeOfParts() const
1176 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1178 const MEDCoupling1GTUMesh *elt(*it);
1180 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getTimeOfParts : null obj in parts !");
1181 ret=std::max(ret,elt->getTimeOfThis());
1184 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getTimeOfParts : parts is empty !");
1188 std::size_t MEDFileUMeshAggregateCompute::getTimeOfUMesh() const
1190 const MEDCouplingUMesh *m(_m);
1192 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getTimeOfUMesh : unmesh is null !");
1193 return m->getTimeOfThis();
1196 std::size_t MEDFileUMeshAggregateCompute::getHeapMemorySizeWithoutChildren() const
1198 std::size_t ret(_m_parts.size()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh>));
1202 std::vector<const BigMemoryObject *> MEDFileUMeshAggregateCompute::getDirectChildren() const
1204 std::vector<const BigMemoryObject *> ret;
1205 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1207 const MEDCoupling1GTUMesh *cur(*it);
1211 const MEDCouplingUMesh *m(_m);
1217 MEDFileUMeshAggregateCompute MEDFileUMeshAggregateCompute::deepCpy(DataArrayDouble *coords) const
1219 MEDFileUMeshAggregateCompute ret;
1220 ret._m_parts.resize(_m_parts.size());
1221 for(std::size_t i=0;i<_m_parts.size();i++)
1223 const MEDCoupling1GTUMesh *elt(_m_parts[i]);
1226 ret._m_parts[i]=static_cast<ParaMEDMEM::MEDCoupling1GTUMesh*>(elt->deepCpy());
1227 ret._m_parts[i]->setCoords(coords);
1230 ret._mp_time=_mp_time; ret._m_time=_m_time;
1231 if((const MEDCouplingUMesh *)_m)
1233 ret._m=static_cast<ParaMEDMEM::MEDCouplingUMesh*>(_m->deepCpy());
1234 ret._m->setCoords(coords);
1239 bool MEDFileUMeshAggregateCompute::isEqual(const MEDFileUMeshAggregateCompute& other, double eps, std::string& what) const
1241 const MEDCouplingUMesh *m1(getUmesh());
1242 const MEDCouplingUMesh *m2(other.getUmesh());
1243 if((m1==0 && m2!=0) || (m1!=0 && m2==0))
1245 what="Presence of mesh in one sublevel and not in other!";
1251 if(!m1->isEqualIfNotWhy(m2,eps,what2))
1253 what=std::string("meshes at a sublevel are not deeply equal (")+what2+std::string(")!");
1260 void MEDFileUMeshAggregateCompute::clearNonDiscrAttributes() const
1262 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1263 MEDFileUMeshSplitL1::ClearNonDiscrAttributes(*it);
1264 MEDFileUMeshSplitL1::ClearNonDiscrAttributes(_m);
1267 void MEDFileUMeshAggregateCompute::synchronizeTinyInfo(const MEDFileMesh& master) const
1269 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1271 const MEDCoupling1GTUMesh *tmp(*it);
1274 (const_cast<MEDCoupling1GTUMesh *>(tmp))->setName(master.getName().c_str());
1275 (const_cast<MEDCoupling1GTUMesh *>(tmp))->setDescription(master.getDescription().c_str());
1276 (const_cast<MEDCoupling1GTUMesh *>(tmp))->setTime(master.getTimeValue(),master.getIteration(),master.getOrder());
1277 (const_cast<MEDCoupling1GTUMesh *>(tmp))->setTimeUnit(master.getTimeUnit());
1280 const MEDCouplingUMesh *m(_m);
1283 (const_cast<MEDCouplingUMesh *>(m))->setName(master.getName().c_str());
1284 (const_cast<MEDCouplingUMesh *>(m))->setDescription(master.getDescription().c_str());
1285 (const_cast<MEDCouplingUMesh *>(m))->setTime(master.getTimeValue(),master.getIteration(),master.getOrder());
1286 (const_cast<MEDCouplingUMesh *>(m))->setTimeUnit(master.getTimeUnit());
1290 bool MEDFileUMeshAggregateCompute::empty() const
1292 if(_mp_time<_m_time)
1293 return ((const MEDCouplingUMesh *)_m)==0;
1294 //else _mp_time>=_m_time)
1295 return _m_parts.empty();
1299 int MEDFileUMeshAggregateCompute::getMeshDimension() const
1301 if(_mp_time<_m_time)
1303 const MEDCouplingUMesh *m(_m);
1305 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getMeshDimension : no umesh in this !");
1306 return m->getMeshDimension();
1310 if(_m_parts.empty())
1311 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getMeshDimension : part mesh is empty !");
1312 const MEDCoupling1GTUMesh *m(_m_parts[0]);
1314 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getMeshDimension : part mesh contains null instance !");
1315 return m->getMeshDimension();
1319 std::vector<int> MEDFileUMeshAggregateCompute::getDistributionOfTypes() const
1321 if(_mp_time<_m_time)
1323 const MEDCouplingUMesh *m(_m);
1325 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getDistributionOfTypes : no umesh in this !");
1326 return m->getDistributionOfTypes();
1330 std::vector<int> ret;
1331 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1333 const MEDCoupling1GTUMesh *tmp(*it);
1335 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getDistributionOfTypes : part mesh contains null instance !");
1336 std::vector<int> ret0(tmp->getDistributionOfTypes());
1337 ret.insert(ret.end(),ret0.begin(),ret0.end());
1343 int MEDFileUMeshAggregateCompute::getSize() const
1345 if(_mp_time<_m_time)
1347 const MEDCouplingUMesh *m(_m);
1349 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getSize : no umesh in this !");
1350 return m->getNumberOfCells();
1355 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1357 const MEDCoupling1GTUMesh *m(*it);
1359 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getSize : part mesh contains null instance !");
1360 ret+=m->getNumberOfCells();
1366 void MEDFileUMeshAggregateCompute::setCoords(DataArrayDouble *coords)
1368 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1370 MEDCoupling1GTUMesh *tmp(*it);
1372 (*it)->setCoords(coords);
1374 MEDCouplingUMesh *m(_m);
1376 m->setCoords(coords);