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 "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 int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const char *mname, ParaMEDMEM::MEDCouplingMeshType& meshType, int& dt, int& it, std::string& dtunit1) throw(INTERP_KERNEL::Exception)
45 med_mesh_type type_maillage;
46 char maillage_description[MED_COMMENT_SIZE+1];
47 char dtunit[MED_LNAME_SIZE+1];
49 char nommaa[MED_NAME_SIZE+1];
50 med_int n=MEDnMesh(fid);
53 med_sorting_type stype;
54 std::vector<std::string> ms;
56 med_axis_type axistype;
57 for(int i=0;i<n && !found;i++)
59 int naxis=MEDmeshnAxis(fid,i+1);
60 INTERP_KERNEL::AutoPtr<char> axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
61 INTERP_KERNEL::AutoPtr<char> axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
62 MEDmeshInfo(fid,i+1,nommaa,&spaceDim,&dim,&type_maillage,maillage_description,dtunit,&stype,&nstep,&axistype,axisname,axisunit);
63 dtunit1=MEDLoaderBase::buildStringFromFortran(dtunit,sizeof(dtunit));
64 std::string cur=MEDLoaderBase::buildStringFromFortran(nommaa,sizeof(nommaa));
74 std::ostringstream oss;
75 oss << "No such meshname (" << mname << ") in file ! Must be in : ";
76 std::copy(ms.begin(),ms.end(),std::ostream_iterator<std::string>(oss,", "));
77 throw INTERP_KERNEL::Exception(oss.str().c_str());
81 case MED_UNSTRUCTURED_MESH:
82 meshType=UNSTRUCTURED;
84 case MED_STRUCTURED_MESH:
87 MEDmeshGridTypeRd(fid,mname,>);
90 case MED_CARTESIAN_GRID:
93 case MED_CURVILINEAR_GRID:
94 meshType=CURVE_LINEAR;
97 throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getMeshIdFromName : unrecognized structured mesh type ! Supported are :\n - cartesian\n - curve linear\n");
102 throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getMeshIdFromName : unrecognized mesh type !");
106 MEDmeshComputationStepInfo(fid,mname,1,&numdt,&numit,&dtt);
111 double MEDFileMeshL2::CheckMeshTimeStep(med_idt fid, const char *mName, int nstep, int dt, int it) throw(INTERP_KERNEL::Exception)
116 std::vector< std::pair<int,int> > p(nstep);
117 for(int i=0;i<nstep;i++)
119 MEDmeshComputationStepInfo(fid,mName,i+1,&numdt,&numit,&dtt);
120 p[i]=std::make_pair<int,int>(numdt,numit);
121 found=(numdt==dt) && (numit==numit);
125 std::ostringstream oss; oss << "No such iteration=" << dt << ",order=" << it << " numbers found for mesh '" << mName << "' ! ";
126 oss << "Possibilities are : ";
127 for(int i=0;i<nstep;i++)
128 oss << "(" << p[i].first << "," << p[i].second << "), ";
129 throw INTERP_KERNEL::Exception(oss.str().c_str());
134 std::vector<std::string> MEDFileMeshL2::getAxisInfoOnMesh(med_idt fid, int mId, const char *mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& nstep, int& Mdim) throw(INTERP_KERNEL::Exception)
136 med_mesh_type type_maillage;
138 med_sorting_type stype;
139 med_axis_type axistype;
140 int naxis=MEDmeshnAxis(fid,mId);
141 INTERP_KERNEL::AutoPtr<char> nameTmp=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
142 INTERP_KERNEL::AutoPtr<char> axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
143 INTERP_KERNEL::AutoPtr<char> axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
144 INTERP_KERNEL::AutoPtr<char> univTmp=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
145 if(MEDmeshInfo(fid,mId,nameTmp,&spaceDim,&Mdim,&type_maillage,_description.getPointer(),_dt_unit.getPointer(),
146 &stype,&nstep,&axistype,axisname,axisunit)!=0)
147 throw INTERP_KERNEL::Exception("A problem has been detected when trying to get info on mesh !");
148 MEDmeshUniversalNameRd(fid,nameTmp,_univ_name.getPointer());
149 switch(type_maillage)
151 case MED_UNSTRUCTURED_MESH:
152 meshType=UNSTRUCTURED;
154 case MED_STRUCTURED_MESH:
157 MEDmeshGridTypeRd(fid,mName,>);
160 case MED_CARTESIAN_GRID:
163 case MED_CURVILINEAR_GRID:
164 meshType=CURVE_LINEAR;
167 throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getAxisInfoOnMesh : unrecognized structured mesh type ! Supported are :\n - cartesian\n - curve linear\n");
172 throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getMeshIdFromName : unrecognized mesh type !");
175 std::vector<std::string> infosOnComp(naxis);
176 for(int i=0;i<naxis;i++)
178 std::string info=MEDLoaderBase::buildUnionUnit(((char *)axisname)+i*MED_SNAME_SIZE,MED_SNAME_SIZE,((char *)axisunit)+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
184 void MEDFileMeshL2::ReadFamiliesAndGrps(med_idt fid, const char *meshName, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps, MEDFileMeshReadSelector *mrs)
186 if(mrs && !(mrs->isCellFamilyFieldReading() || mrs->isNodeFamilyFieldReading()))
188 char nomfam[MED_NAME_SIZE+1];
190 int nfam=MEDnFamily(fid,meshName);
191 for(int i=0;i<nfam;i++)
193 int ngro=MEDnFamilyGroup(fid,meshName,i+1);
194 med_int natt=MEDnFamily23Attribute(fid,meshName,i+1);
195 INTERP_KERNEL::AutoPtr<med_int> attide=new med_int[natt];
196 INTERP_KERNEL::AutoPtr<med_int> attval=new med_int[natt];
197 INTERP_KERNEL::AutoPtr<char> attdes=new char[MED_COMMENT_SIZE*natt+1];
198 INTERP_KERNEL::AutoPtr<char> gro=new char[MED_LNAME_SIZE*ngro+1];
199 MEDfamily23Info(fid,meshName,i+1,nomfam,attide,attval,attdes,&numfam,gro);
200 std::string famName=MEDLoaderBase::buildStringFromFortran(nomfam,MED_NAME_SIZE);
201 fams[famName]=numfam;
202 for(int j=0;j<ngro;j++)
204 std::string groupname=MEDLoaderBase::buildStringFromFortran(gro+j*MED_LNAME_SIZE,MED_LNAME_SIZE);
205 grps[groupname].push_back(famName);
210 void MEDFileMeshL2::WriteFamiliesAndGrps(med_idt fid, const char *mname, const std::map<std::string,int>& fams, const std::map<std::string, std::vector<std::string> >& grps, int tooLongStrPol)
212 for(std::map<std::string,int>::const_iterator it=fams.begin();it!=fams.end();it++)
214 std::vector<std::string> grpsOfFam;
215 for(std::map<std::string, std::vector<std::string> >::const_iterator it1=grps.begin();it1!=grps.end();it1++)
217 if(std::find((*it1).second.begin(),(*it1).second.end(),(*it).first)!=(*it1).second.end())
218 grpsOfFam.push_back((*it1).first);
220 int ngro=grpsOfFam.size();
221 INTERP_KERNEL::AutoPtr<char> groName=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE*ngro);
223 for(std::vector<std::string>::const_iterator it2=grpsOfFam.begin();it2!=grpsOfFam.end();it2++,i++)
224 MEDLoaderBase::safeStrCpy2((*it2).c_str(),MED_LNAME_SIZE-1,groName+i*MED_LNAME_SIZE,tooLongStrPol);
225 INTERP_KERNEL::AutoPtr<char> famName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
226 MEDLoaderBase::safeStrCpy((*it).first.c_str(),MED_NAME_SIZE,famName,tooLongStrPol);
227 int ret=MEDfamilyCr(fid,mname,famName,(*it).second,ngro,groName);
232 MEDFileUMeshL2::MEDFileUMeshL2()
236 void MEDFileUMeshL2::loadAll(med_idt fid, int mId, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
241 ParaMEDMEM::MEDCouplingMeshType meshType;
242 std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName,meshType,nstep,Mdim);
243 if(meshType!=UNSTRUCTURED)
244 throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected an unstructured one whereas in file it is not an unstructured !");
245 _time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
248 loadConnectivity(fid,Mdim,mName,dt,it,mrs);//to improve check (dt,it) coherency
249 loadCoords(fid,mId,infosOnComp,mName,dt,it);
252 void MEDFileUMeshL2::loadConnectivity(med_idt fid, int mdim, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
254 _per_type_mesh.resize(1);
255 _per_type_mesh[0].clear();
256 for(int j=0;j<MED_N_CELL_FIXED_GEO;j++)
258 MEDFileUMeshPerType *tmp=MEDFileUMeshPerType::New(fid,mName,dt,it,mdim,typmai[j],typmai2[j],mrs);
260 _per_type_mesh[0].push_back(tmp);
265 void MEDFileUMeshL2::loadCoords(med_idt fid, int mId, const std::vector<std::string>& infosOnComp, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception)
267 int spaceDim=infosOnComp.size();
268 med_bool changement,transformation;
269 int nCoords=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation);
270 _coords=DataArrayDouble::New();
271 _coords->alloc(nCoords,spaceDim);
272 double *coordsPtr=_coords->getPointer();
273 MEDmeshNodeCoordinateRd(fid,mName,dt,it,MED_FULL_INTERLACE,coordsPtr);
274 if(MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0)
276 _fam_coords=DataArrayInt::New();
277 _fam_coords->alloc(nCoords,1);
278 MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,_fam_coords->getPointer());
282 if(MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,MED_NUMBER,MED_NODAL,&changement,&transformation)>0)
284 _num_coords=DataArrayInt::New();
285 _num_coords->alloc(nCoords,1);
286 MEDmeshEntityNumberRd(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,_num_coords->getPointer());
290 if(MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,MED_NAME,MED_NODAL,&changement,&transformation)>0)
292 _name_coords=DataArrayAsciiChar::New();
293 _name_coords->alloc(nCoords+1,MED_SNAME_SIZE);//not a bug to avoid the memory corruption due to last \0 at the end
294 MEDmeshEntityNameRd(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,_name_coords->getPointer());
295 _name_coords->reAlloc(nCoords);//not a bug to avoid the memory corruption due to last \0 at the end
299 for(int i=0;i<spaceDim;i++)
300 _coords->setInfoOnComponent(i,infosOnComp[i].c_str());
303 void MEDFileUMeshL2::sortTypes()
306 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> > tmp(_per_type_mesh[0]);
307 _per_type_mesh.clear();
308 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=tmp.begin();it!=tmp.end();it++)
309 mdims.insert((*it)->getDim());
312 int mdim=*mdims.rbegin();
313 _per_type_mesh.resize(mdim+1);
314 for(int dim=mdim+1;dim!=0;dim--)
316 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >& elt=_per_type_mesh[mdim+1-dim];
317 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=tmp.begin();it!=tmp.end();it++)
318 if((*it)->getDim()==dim-1)
321 // suppression of contiguous empty levels at the end of _per_type_mesh.
322 int nbOfUselessLev=0;
324 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> > >::reverse_iterator it2=_per_type_mesh.rbegin();it2!=_per_type_mesh.rend();it2++)
326 if((*it2).empty() && isFirst)
333 _per_type_mesh.resize(_per_type_mesh.size()-nbOfUselessLev);
336 void MEDFileUMeshL2::WriteCoords(med_idt fid, const char *mname, int dt, int it, double time, const DataArrayDouble *coords, const DataArrayInt *famCoords, const DataArrayInt *numCoords, const DataArrayAsciiChar *nameCoords)
340 MEDmeshNodeCoordinateWr(fid,mname,dt,it,time,MED_FULL_INTERLACE,coords->getNumberOfTuples(),coords->getConstPointer());
342 MEDmeshEntityFamilyNumberWr(fid,mname,dt,it,MED_NODE,MED_NO_GEOTYPE,famCoords->getNumberOfTuples(),famCoords->getConstPointer());
344 MEDmeshEntityNumberWr(fid,mname,dt,it,MED_NODE,MED_NO_GEOTYPE,numCoords->getNumberOfTuples(),numCoords->getConstPointer());
347 if(nameCoords->getNumberOfComponents()!=MED_SNAME_SIZE)
349 std::ostringstream oss; oss << " MEDFileUMeshL2::WriteCoords : expected a name field on nodes with number of components set to " << MED_SNAME_SIZE;
350 oss << " ! The array has " << nameCoords->getNumberOfComponents() << " components !";
351 throw INTERP_KERNEL::Exception(oss.str().c_str());
353 MEDmeshEntityNameWr(fid,mname,dt,it,MED_NODE,MED_NO_GEOTYPE,nameCoords->getNumberOfTuples(),nameCoords->getConstPointer());
357 bool MEDFileUMeshL2::isFamDefinedOnLev(int levId) const
359 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++)
360 if((*it)->getFam()==0)
365 bool MEDFileUMeshL2::isNumDefinedOnLev(int levId) const
367 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++)
368 if((*it)->getNum()==0)
373 bool MEDFileUMeshL2::isNamesDefinedOnLev(int levId) const
375 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++)
376 if((*it)->getNames()==0)
381 MEDFileCMeshL2::MEDFileCMeshL2()
385 void MEDFileCMeshL2::loadAll(med_idt fid, int mId, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception)
390 ParaMEDMEM::MEDCouplingMeshType meshType;
391 std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName,meshType,nstep,Mdim);
392 if(meshType!=CARTESIAN)
393 throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected a structured one whereas in file it is not a structured !");
394 _time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
398 med_grid_type gridtype;
399 MEDmeshGridTypeRd(fid,mName,&gridtype);
400 if(gridtype!=MED_CARTESIAN_GRID)
401 throw INTERP_KERNEL::Exception("Invalid structured mesh ! Expected cartesian mesh type !");
402 _cmesh=MEDCouplingCMesh::New();
403 for(int i=0;i<Mdim;i++)
405 med_data_type dataTypeReq=GetDataTypeCorrespondingToSpaceId(i);
406 med_bool chgt=MED_FALSE,trsf=MED_FALSE;
407 int nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,dataTypeReq,MED_NO_CMODE,&chgt,&trsf);
408 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=DataArrayDouble::New();
409 da->alloc(nbOfElt,1);
410 da->setInfoOnComponent(0,infosOnComp[i].c_str());
411 MEDmeshGridIndexCoordinateRd(fid,mName,dt,it,i+1,da->getPointer());
412 _cmesh->setCoordsAt(i,da);
416 med_data_type MEDFileCMeshL2::GetDataTypeCorrespondingToSpaceId(int id) throw(INTERP_KERNEL::Exception)
421 return MED_COORDINATE_AXIS1;
423 return MED_COORDINATE_AXIS2;
425 return MED_COORDINATE_AXIS3;
427 throw INTERP_KERNEL::Exception("Invalid meshdim detected in Cartesian Grid !");
431 MEDFileCLMeshL2::MEDFileCLMeshL2()
435 void MEDFileCLMeshL2::loadAll(med_idt fid, int mId, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception)
440 ParaMEDMEM::MEDCouplingMeshType meshType;
441 std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName,meshType,nstep,Mdim);
442 if(meshType!=CURVE_LINEAR)
443 throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected a structured one whereas in file it is not a structured !");
444 _time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
448 _clmesh=MEDCouplingCurveLinearMesh::New();
449 INTERP_KERNEL::AutoPtr<int> stGrid=new int[Mdim];
450 MEDmeshGridStructRd(fid,mName,dt,it,stGrid);
451 _clmesh->setNodeGridStructure(stGrid,((int *)stGrid)+Mdim);
452 med_bool chgt=MED_FALSE,trsf=MED_FALSE;
453 int nbNodes=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&chgt,&trsf);
454 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=DataArrayDouble::New();
455 da->alloc(nbNodes,infosOnComp.size());
456 da->setInfoOnComponents(infosOnComp);
457 MEDmeshNodeCoordinateRd(fid,mName,dt,it,MED_FULL_INTERLACE,da->getPointer());
458 _clmesh->setCoords(da);
461 MEDFileUMeshPermCompute::MEDFileUMeshPermCompute(const MEDFileUMeshSplitL1* st):_st(st),_mpt_time(0),_num_time(0)
466 * Warning it returns an instance to deallocate !!!!
468 MEDFileUMeshPermCompute::operator MEDCouplingUMesh *() const
470 _st->_num->updateTime();
471 if((MEDCouplingUMesh *)_m==0)
474 _m=static_cast<MEDCouplingUMesh *>(_st->_m_by_types.getUmesh()->deepCpy());
475 _m->renumberCells(_st->_num->getConstPointer(),true);
480 if(_mpt_time==_st->_m_by_types.getTimeOfThis() && _num_time==_st->_num->getTimeOfThis())
485 _m=static_cast<MEDCouplingUMesh *>(_st->_m_by_types.getUmesh()->deepCpy());
486 _m->renumberCells(_st->_num->getConstPointer(),true);
492 void MEDFileUMeshPermCompute::operator=(MEDCouplingUMesh *m)
497 void MEDFileUMeshPermCompute::updateTime() const
499 _mpt_time=_st->_m_by_types.getTimeOfThis();
500 _num_time=_st->_num->getTimeOfThis();
503 MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshSplitL1& other):_m_by_types(other._m_by_types),_fam(other._fam),_num(other._num),_names(other._names),_rev_num(other._rev_num),_m(this)
507 MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const char *mName, int id):_m(this)
509 const std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >& v=l2.getLev(id);
513 std::vector<const MEDCoupling1GTUMesh *> ms(sz);
514 std::vector<const DataArrayInt *> fams(sz),nums(sz);
515 std::vector<const DataArrayChar *> names(sz);
516 for(int i=0;i<sz;i++)
518 MEDCoupling1GTUMesh *elt(v[i]->getMesh());
519 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp2=l2.getCoords();
520 elt->setCoords(tmp2);
523 _m_by_types.assignParts(ms);
524 if(l2.isFamDefinedOnLev(id))
526 for(int i=0;i<sz;i++)
527 fams[i]=v[i]->getFam();
528 _fam=DataArrayInt::Aggregate(fams);
530 if(l2.isNumDefinedOnLev(id))
532 for(int i=0;i<sz;i++)
533 nums[i]=v[i]->getNum();
534 _num=DataArrayInt::Aggregate(nums);
537 if(l2.isNamesDefinedOnLev(id))
539 for(int i=0;i<sz;i++)
540 names[i]=v[i]->getNames();
541 _names=dynamic_cast<DataArrayAsciiChar *>(DataArrayChar::Aggregate(names));
545 MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCouplingUMesh *m):_m(this)
550 MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCouplingUMesh *m, bool newOrOld):_m(this)
552 assignMesh(m,newOrOld);
555 std::size_t MEDFileUMeshSplitL1::getHeapMemorySize() const
558 ret+=_m_by_types.getHeapMemorySize();
559 if((const DataArrayInt*)_fam)
560 ret+=_fam->getHeapMemorySize();
561 if((const DataArrayInt*)_num)
562 ret+=_num->getHeapMemorySize();
563 if((const DataArrayInt*)_rev_num)
564 ret+=_rev_num->getHeapMemorySize();
565 if((const DataArrayAsciiChar*)_names)
566 ret+=_names->getHeapMemorySize();
570 MEDFileUMeshSplitL1 *MEDFileUMeshSplitL1::deepCpy(DataArrayDouble *coords) const
572 MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> ret=new MEDFileUMeshSplitL1(*this);
573 ret->_m_by_types=_m_by_types.deepCpy(coords);
574 if((const DataArrayInt *)_fam)
575 ret->_fam=_fam->deepCpy();
576 if((const DataArrayInt *)_num)
577 ret->_num=_num->deepCpy();
578 if((const DataArrayInt *)_rev_num)
579 ret->_rev_num=_rev_num->deepCpy();
580 if((const DataArrayAsciiChar *)_names)
581 ret->_names=_names->deepCpy();
585 bool MEDFileUMeshSplitL1::isEqual(const MEDFileUMeshSplitL1 *other, double eps, std::string& what) const
587 if(!_m_by_types.isEqual(other->_m_by_types,eps,what))
589 const DataArrayInt *d1=_fam;
590 const DataArrayInt *d2=other->_fam;
591 if((d1==0 && d2!=0) || (d1!=0 && d2==0))
593 what="Presence of family arr in one sublevel and not in other!";
597 if(!d1->isEqual(*d2))
599 what="family arr at a sublevel are not deeply equal !";
604 if((d1==0 && d2!=0) || (d1!=0 && d2==0))
606 what="Presence of cell numbering arr in one sublevel and not in other!";
610 if(!d1->isEqual(*d2))
612 what="Numbering cell arr at a sublevel are not deeply equal !";
615 const DataArrayAsciiChar *e1=_names;
616 const DataArrayAsciiChar *e2=other->_names;
617 if((e1==0 && e2!=0) || (e1!=0 && e2==0))
619 what="Presence of cell names arr in one sublevel and not in other!";
623 if(!e1->isEqual(*e2))
625 what="Name cell arr at a sublevel are not deeply equal !";
631 void MEDFileUMeshSplitL1::synchronizeTinyInfo(const MEDFileMesh& master) const
633 _m_by_types.synchronizeTinyInfo(master);
636 void MEDFileUMeshSplitL1::clearNonDiscrAttributes() const
638 _m_by_types.clearNonDiscrAttributes();
641 void MEDFileUMeshSplitL1::ClearNonDiscrAttributes(const MEDCouplingMesh *tmp)
645 (const_cast<MEDCouplingMesh *>(tmp))->setName("");
646 (const_cast<MEDCouplingMesh *>(tmp))->setDescription("");
647 (const_cast<MEDCouplingMesh *>(tmp))->setTime(0.,-1,-1);
648 (const_cast<MEDCouplingMesh *>(tmp))->setTimeUnit("");
651 void MEDFileUMeshSplitL1::setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception)
653 _m_by_types.setCoords(coords);
656 void MEDFileUMeshSplitL1::assignMesh(MEDCouplingUMesh *m, bool newOrOld) throw(INTERP_KERNEL::Exception)
662 _m_by_types.assignUMesh(dynamic_cast<MEDCouplingUMesh *>(m->deepCpy()));
663 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_m_by_types.getUmesh()->getRenumArrForConsecutiveCellTypesSpec(typmai2,typmai2+MED_N_CELL_FIXED_GEO);
664 if(!da->isIdentity())
666 _num=da->invertArrayO2N2N2O(m->getNumberOfCells());
669 _m_by_types.getUmesh()->renumberCells(da->getConstPointer(),false);
674 if(!m->checkConsecutiveCellTypesAndOrder(typmai2,typmai2+MED_N_CELL_FIXED_GEO))
675 throw INTERP_KERNEL::Exception("MEDFileUMeshSplitL1::assignMesh : the mode of mesh setting expects to follow the MED file numbering convention ! it is not the case !");
677 _m_by_types.assignUMesh(m);
679 _fam=DataArrayInt::New();
680 _fam->alloc(m->getNumberOfCells(),1);
681 _fam->fillWithValue(0);
684 bool MEDFileUMeshSplitL1::empty() const
686 return _m_by_types.empty();
689 bool MEDFileUMeshSplitL1::presenceOfOneFams(const std::vector<int>& ids) const
691 const DataArrayInt *fam=_fam;
694 return fam->presenceOfValue(ids);
697 int MEDFileUMeshSplitL1::getMeshDimension() const
699 return _m_by_types.getMeshDimension();
702 void MEDFileUMeshSplitL1::simpleRepr(std::ostream& oss) const
704 std::vector<int> code=_m_by_types.getDistributionOfTypes();
705 int nbOfTypes=code.size()/3;
706 for(int i=0;i<nbOfTypes;i++)
708 INTERP_KERNEL::NormalizedCellType typ=(INTERP_KERNEL::NormalizedCellType) code[3*i];
709 oss << " - Number of cells with type " << INTERP_KERNEL::CellModel::GetCellModel(typ).getRepr() << " : " << code[3*i+1] << std::endl;
713 int MEDFileUMeshSplitL1::getSize() const throw(INTERP_KERNEL::Exception)
715 return _m_by_types.getSize();
718 MEDCouplingUMesh *MEDFileUMeshSplitL1::getFamilyPart(const int *idsBg, const int *idsEnd, bool renum) const
720 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> eltsToKeep=_fam->getIdsEqualList(idsBg,idsEnd);
721 MEDCouplingUMesh *m=(MEDCouplingUMesh *)_m_by_types.getUmesh()->buildPartOfMySelf(eltsToKeep->getConstPointer(),eltsToKeep->getConstPointer()+eltsToKeep->getNumberOfTuples(),true);
723 return renumIfNeeded(m,eltsToKeep->getConstPointer());
727 DataArrayInt *MEDFileUMeshSplitL1::getFamilyPartArr(const int *idsBg, const int *idsEnd, bool renum) const
729 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_fam->getIdsEqualList(idsBg,idsEnd);
731 return renumIfNeededArr(da);
735 MEDCouplingUMesh *MEDFileUMeshSplitL1::getWholeMesh(bool renum) const
737 MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> tmp;
738 if(renum && ((const DataArrayInt *)_num))
741 { tmp=_m_by_types.getUmesh(); if(tmp) tmp->incrRef(); }
745 DataArrayInt *MEDFileUMeshSplitL1::getOrCreateAndGetFamilyField() throw(INTERP_KERNEL::Exception)
747 if((DataArrayInt *)_fam)
749 int nbOfTuples=_m_by_types.getSize();
750 _fam=DataArrayInt::New(); _fam->alloc(nbOfTuples,1); _fam->fillWithZero();
754 const DataArrayInt *MEDFileUMeshSplitL1::getFamilyField() const
759 const DataArrayInt *MEDFileUMeshSplitL1::getNumberField() const
764 const DataArrayInt *MEDFileUMeshSplitL1::getRevNumberField() const
769 const DataArrayAsciiChar *MEDFileUMeshSplitL1::getNameField() const
774 void MEDFileUMeshSplitL1::eraseFamilyField()
776 _fam->fillWithZero();
780 * This method ignores _m and _m_by_types.
782 void MEDFileUMeshSplitL1::setGroupsFromScratch(const std::vector<const MEDCouplingUMesh *>& ms, std::map<std::string,int>& familyIds,
783 std::map<std::string, std::vector<std::string> >& groups) throw(INTERP_KERNEL::Exception)
785 std::vector< DataArrayInt * > corr;
786 _m=MEDCouplingUMesh::FuseUMeshesOnSameCoords(ms,0,corr);
787 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > corrMSafe(corr.begin(),corr.end());
788 std::vector< std::vector<int> > fidsOfGroups;
789 std::vector< const DataArrayInt * > corr2(corr.begin(),corr.end());
790 _fam=DataArrayInt::MakePartition(corr2,((MEDCouplingUMesh *)_m)->getNumberOfCells(),fidsOfGroups);
791 int nbOfCells=((MEDCouplingUMesh *)_m)->getNumberOfCells();
792 std::map<int,std::string> newfams;
793 std::map<int,int> famIdTrad;
794 TraduceFamilyNumber(fidsOfGroups,familyIds,famIdTrad,newfams);
795 int *w=_fam->getPointer();
796 for(int i=0;i<nbOfCells;i++,w++)
800 void MEDFileUMeshSplitL1::write(med_idt fid, const char *mName, int mdim) const
802 std::vector<MEDCoupling1GTUMesh *> ms(_m_by_types.getParts());
804 for(std::vector<MEDCoupling1GTUMesh *>::const_iterator it=ms.begin();it!=ms.end();it++)
806 int nbCells=(*it)->getNumberOfCells();
807 int end=start+nbCells;
808 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> fam,num;
809 MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> names;
810 if((const DataArrayInt *)_fam)
811 fam=_fam->substr(start,end);
812 if((const DataArrayInt *)_num)
813 num=_num->substr(start,end);
814 if((const DataArrayAsciiChar *)_names)
815 names=static_cast<DataArrayAsciiChar *>(_names->substr(start,end));
816 MEDFileUMeshPerType::Write(fid,mName,mdim,(*it),fam,num,names);
821 void MEDFileUMeshSplitL1::renumberNodesInConn(const int *newNodeNumbersO2N) throw(INTERP_KERNEL::Exception)
823 MEDCouplingUMesh *m(_m_by_types.getUmesh());
826 m->renumberNodesInConn(newNodeNumbersO2N);
829 void MEDFileUMeshSplitL1::changeFamilyIdArr(int oldId, int newId) throw(INTERP_KERNEL::Exception)
831 DataArrayInt *arr=_fam;
833 arr->changeValue(oldId,newId);
836 void MEDFileUMeshSplitL1::setFamilyArr(DataArrayInt *famArr)
843 int sz(_m_by_types.getSize());
844 famArr->checkNbOfTuplesAndComp(sz,1,"MEDFileUMeshSplitL1::setFamilyArr : Problem in size of Family arr ! ");
849 void MEDFileUMeshSplitL1::setRenumArr(DataArrayInt *renumArr)
857 int sz(_m_by_types.getSize());
858 renumArr->checkNbOfTuplesAndComp(sz,1,"MEDFileUMeshSplitL1::setRenumArr : Problem in size of numbering arr ! ");
864 void MEDFileUMeshSplitL1::setNameArr(DataArrayAsciiChar *nameArr)
871 int sz(_m_by_types.getSize());
872 nameArr->checkNbOfTuplesAndComp(sz,MED_SNAME_SIZE,"MEDFileUMeshSplitL1::setNameArr : Problem in size of name arr ! ");
877 MEDCouplingUMesh *MEDFileUMeshSplitL1::Renumber2(const DataArrayInt *renum, MEDCouplingUMesh *m, const int *cellIds)
882 m->renumberCells(renum->getConstPointer(),true);
885 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> locnum=renum->selectByTupleId(cellIds,cellIds+m->getNumberOfCells());
886 m->renumberCells(locnum->getConstPointer(),true);
891 MEDCouplingUMesh *MEDFileUMeshSplitL1::renumIfNeeded(MEDCouplingUMesh *m, const int *cellIds) const
893 return Renumber2(_num,m,cellIds);
896 DataArrayInt *MEDFileUMeshSplitL1::Renumber(const DataArrayInt *renum, const DataArrayInt *da)
898 if((const DataArrayInt *)renum==0)
901 return const_cast<DataArrayInt *>(da);
903 return renum->selectByTupleId(da->getConstPointer(),da->getConstPointer()+da->getNumberOfTuples());
906 DataArrayInt *MEDFileUMeshSplitL1::renumIfNeededArr(const DataArrayInt *da) const
908 return Renumber(_num,da);
911 std::vector<int> MEDFileUMeshSplitL1::GetNewFamiliesNumber(int nb, const std::map<std::string,int>& families)
914 for(std::map<std::string,int>::const_iterator it=families.begin();it!=families.end();it++)
915 id=std::max(id,(*it).second);
918 std::vector<int> ret(nb);
919 for(int i=1;i<=nb;i++)
924 void MEDFileUMeshSplitL1::TraduceFamilyNumber(const std::vector< std::vector<int> >& fidsGrps, std::map<std::string,int>& familyIds,
925 std::map<int,int>& famIdTrad, std::map<int,std::string>& newfams)
927 std::set<int> allfids;
931 void MEDFileUMeshSplitL1::computeRevNum() const
934 int maxValue=_num->getMaxValue(pos);
935 _rev_num=_num->invertArrayN2O2O2N(maxValue+1);
940 MEDFileUMeshAggregateCompute::MEDFileUMeshAggregateCompute():_mp_time(0),_m_time(0)
944 void MEDFileUMeshAggregateCompute::assignParts(const std::vector< const MEDCoupling1GTUMesh * >& mParts)
946 std::size_t sz(mParts.size());
947 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> > ret(sz);
948 for(std::size_t i=0;i<sz;i++)
950 const MEDCoupling1GTUMesh *elt(mParts[i]);
952 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::assignParts : presence of null pointer !");
953 ret[i]=const_cast<MEDCoupling1GTUMesh *>(elt); elt->incrRef();
956 _mp_time=std::max(_mp_time,_m_time)+1;
960 void MEDFileUMeshAggregateCompute::assignUMesh(MEDCouplingUMesh *m)
964 _m_time=std::max(_mp_time,_m_time)+1;
967 MEDCouplingUMesh *MEDFileUMeshAggregateCompute::getUmesh() const
969 if(_mp_time<=_m_time)
971 std::vector< const MEDCoupling1GTUMesh *> mp(_m_parts.size());
972 std::copy(_m_parts.begin(),_m_parts.end(),mp.begin());
973 _m=MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh(mp);
974 _m_parts.clear();//to avoid memory peak !
975 _m_time=_mp_time+1;//+1 is important ! That is to say that only _m is OK not _m_parts because cleared !
979 std::vector<MEDCoupling1GTUMesh *> MEDFileUMeshAggregateCompute::getPartsWithoutComputation() const throw(INTERP_KERNEL::Exception)
982 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getPartsWithoutComputation : the parts require a computation !");
984 std::vector<MEDCoupling1GTUMesh *> ret(_m_parts.size());
986 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++,i++)
988 const MEDCoupling1GTUMesh *elt(*it);
989 ret[i]=const_cast<MEDCoupling1GTUMesh *>(elt);
994 std::vector<MEDCoupling1GTUMesh *> MEDFileUMeshAggregateCompute::getParts() const
997 forceComputationOfPartsFromUMesh();
998 return getPartsWithoutComputation();
1001 MEDCoupling1GTUMesh *MEDFileUMeshAggregateCompute::getPartWithoutComputation(INTERP_KERNEL::NormalizedCellType gt) const throw(INTERP_KERNEL::Exception)
1003 std::vector<MEDCoupling1GTUMesh *> v(getPartsWithoutComputation());
1004 std::size_t sz(v.size());
1005 for(std::size_t i=0;i<sz;i++)
1008 if(v[i]->getCellModelEnum()==gt)
1011 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getPartWithoutComputation : the geometric type is not existing !");
1014 void MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh() const
1016 const MEDCouplingUMesh *m(_m);
1018 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh : null UMesh !");
1019 std::vector<MEDCouplingUMesh *> ms(m->splitByType());
1020 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> > msMSafe(ms.begin(),ms.end());
1021 std::size_t sz(msMSafe.size());
1022 _m_parts.resize(sz);
1023 for(std::size_t i=0;i<sz;i++)
1024 _m_parts[i]=MEDCoupling1GTUMesh::New(ms[i]);
1025 _mp_time=std::max(_mp_time,_m_time)+1;
1028 std::size_t MEDFileUMeshAggregateCompute::getTimeOfThis() const
1030 if(_mp_time>_m_time)
1031 return getTimeOfParts();
1032 if(_m_time>_mp_time)
1033 return getTimeOfUMesh();
1034 return std::max(getTimeOfParts(),getTimeOfUMesh());
1037 std::size_t MEDFileUMeshAggregateCompute::getTimeOfParts() const
1040 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1042 const MEDCoupling1GTUMesh *elt(*it);
1044 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getTimeOfParts : null obj in parts !");
1045 ret=std::max(ret,elt->getTimeOfThis());
1048 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getTimeOfParts : parts is empty !");
1052 std::size_t MEDFileUMeshAggregateCompute::getTimeOfUMesh() const
1054 const MEDCouplingUMesh *m(_m);
1056 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getTimeOfUMesh : unmesh is null !");
1057 return m->getTimeOfThis();
1061 * Coordinates pointer is not counted because father instance already count it !
1063 std::size_t MEDFileUMeshAggregateCompute::getHeapMemorySize() const
1066 ret+=_m_parts.size()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh>);
1067 std::size_t sz(_m_parts.size());
1068 for(std::size_t i=0;i<sz;i++)
1070 const MEDCoupling1GTUMesh *pt(_m_parts[i]);
1073 ret+=pt->getHeapMemorySize();
1074 const DataArrayDouble *coo(pt->getCoords());
1076 ret-=coo->getHeapMemorySize();
1079 const MEDCouplingUMesh *m(_m);
1082 ret+=m->getHeapMemorySize();
1083 const DataArrayDouble *coo(m->getCoords());
1085 ret-=coo->getHeapMemorySize();
1090 MEDFileUMeshAggregateCompute MEDFileUMeshAggregateCompute::deepCpy(DataArrayDouble *coords) const
1092 MEDFileUMeshAggregateCompute ret;
1093 ret._m_parts.resize(_m_parts.size());
1094 for(std::size_t i=0;i<_m_parts.size();i++)
1096 const MEDCoupling1GTUMesh *elt(_m_parts[i]);
1099 ret._m_parts[i]=static_cast<ParaMEDMEM::MEDCoupling1GTUMesh*>(elt->deepCpy());
1100 ret._m_parts[i]->setCoords(coords);
1103 ret._mp_time=_mp_time; ret._m_time=_m_time;
1104 if((const MEDCouplingUMesh *)_m)
1106 ret._m=static_cast<ParaMEDMEM::MEDCouplingUMesh*>(_m->deepCpy());
1107 ret._m->setCoords(coords);
1112 bool MEDFileUMeshAggregateCompute::isEqual(const MEDFileUMeshAggregateCompute& other, double eps, std::string& what) const
1114 const MEDCouplingUMesh *m1(getUmesh());
1115 const MEDCouplingUMesh *m2(other.getUmesh());
1116 if((m1==0 && m2!=0) || (m1!=0 && m2==0))
1118 what="Presence of mesh in one sublevel and not in other!";
1124 if(!m1->isEqualIfNotWhy(m2,eps,what2))
1126 what=std::string("meshes at a sublevel are not deeply equal (")+what2+std::string(")!");
1133 void MEDFileUMeshAggregateCompute::clearNonDiscrAttributes() const
1135 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1136 MEDFileUMeshSplitL1::ClearNonDiscrAttributes(*it);
1137 MEDFileUMeshSplitL1::ClearNonDiscrAttributes(_m);
1140 void MEDFileUMeshAggregateCompute::synchronizeTinyInfo(const MEDFileMesh& master) const
1142 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1144 const MEDCoupling1GTUMesh *tmp(*it);
1147 (const_cast<MEDCoupling1GTUMesh *>(tmp))->setName(master.getName());
1148 (const_cast<MEDCoupling1GTUMesh *>(tmp))->setDescription(master.getDescription());
1149 (const_cast<MEDCoupling1GTUMesh *>(tmp))->setTime(master.getTimeValue(),master.getIteration(),master.getOrder());
1150 (const_cast<MEDCoupling1GTUMesh *>(tmp))->setTimeUnit(master.getTimeUnit());
1153 const MEDCouplingUMesh *m(_m);
1156 (const_cast<MEDCouplingUMesh *>(m))->setName(master.getName());
1157 (const_cast<MEDCouplingUMesh *>(m))->setDescription(master.getDescription());
1158 (const_cast<MEDCouplingUMesh *>(m))->setTime(master.getTimeValue(),master.getIteration(),master.getOrder());
1159 (const_cast<MEDCouplingUMesh *>(m))->setTimeUnit(master.getTimeUnit());
1163 bool MEDFileUMeshAggregateCompute::empty() const
1165 if(_mp_time<_m_time)
1166 return ((const MEDCouplingUMesh *)_m)==0;
1167 //else _mp_time>=_m_time)
1168 return _m_parts.empty();
1172 int MEDFileUMeshAggregateCompute::getMeshDimension() const
1174 if(_mp_time<_m_time)
1176 const MEDCouplingUMesh *m(_m);
1178 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getMeshDimension : no umesh in this !");
1179 return m->getMeshDimension();
1183 if(_m_parts.empty())
1184 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getMeshDimension : part mesh is empty !");
1185 const MEDCoupling1GTUMesh *m(_m_parts[0]);
1187 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getMeshDimension : part mesh contains null instance !");
1188 return m->getMeshDimension();
1192 std::vector<int> MEDFileUMeshAggregateCompute::getDistributionOfTypes() const
1194 if(_mp_time<_m_time)
1196 const MEDCouplingUMesh *m(_m);
1198 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getDistributionOfTypes : no umesh in this !");
1199 return m->getDistributionOfTypes();
1203 std::vector<int> ret;
1204 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1206 const MEDCoupling1GTUMesh *tmp(*it);
1208 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getDistributionOfTypes : part mesh contains null instance !");
1209 std::vector<int> ret0(tmp->getDistributionOfTypes());
1210 ret.insert(ret.end(),ret0.begin(),ret0.end());
1216 int MEDFileUMeshAggregateCompute::getSize() const throw(INTERP_KERNEL::Exception)
1218 if(_mp_time<_m_time)
1220 const MEDCouplingUMesh *m(_m);
1222 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getSize : no umesh in this !");
1223 return m->getNumberOfCells();
1228 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1230 const MEDCoupling1GTUMesh *m(*it);
1232 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getSize : part mesh contains null instance !");
1233 ret+=m->getNumberOfCells();
1239 void MEDFileUMeshAggregateCompute::setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception)
1241 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1243 MEDCoupling1GTUMesh *tmp(*it);
1245 (*it)->setCoords(coords);
1247 MEDCouplingUMesh *m(_m);
1249 m->setCoords(coords);