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 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 char *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,>);
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,1,&numdt,&numit,&dtt);
121 double MEDFileMeshL2::CheckMeshTimeStep(med_idt fid, const char *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,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 char *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,>);
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 char *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);
201 for(int i=0;i<nfam;i++)
203 int ngro=MEDnFamilyGroup(fid,meshName,i+1);
204 med_int natt=MEDnFamily23Attribute(fid,meshName,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,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 char *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,famName,(*it).second,ngro,groName);
242 MEDFileUMeshL2::MEDFileUMeshL2()
246 void MEDFileUMeshL2::loadAll(med_idt fid, int mId, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
251 ParaMEDMEM::MEDCouplingMeshType meshType;
252 std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName,meshType,nstep,Mdim);
253 if(meshType!=UNSTRUCTURED)
254 throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected an unstructured one whereas in file it is not an unstructured !");
255 _time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
258 loadConnectivity(fid,Mdim,mName,dt,it,mrs);//to improve check (dt,it) coherency
259 loadCoords(fid,mId,infosOnComp,mName,dt,it);
262 void MEDFileUMeshL2::loadConnectivity(med_idt fid, int mdim, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
264 _per_type_mesh.resize(1);
265 _per_type_mesh[0].clear();
266 for(int j=0;j<MED_N_CELL_FIXED_GEO;j++)
268 MEDFileUMeshPerType *tmp=MEDFileUMeshPerType::New(fid,mName,dt,it,mdim,typmai[j],typmai2[j],mrs);
270 _per_type_mesh[0].push_back(tmp);
275 void MEDFileUMeshL2::loadCoords(med_idt fid, int mId, const std::vector<std::string>& infosOnComp, const char *mName, int dt, int it)
277 int spaceDim=infosOnComp.size();
278 med_bool changement,transformation;
279 int nCoords=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation);
280 _coords=DataArrayDouble::New();
281 _coords->alloc(nCoords,spaceDim);
282 double *coordsPtr=_coords->getPointer();
283 MEDmeshNodeCoordinateRd(fid,mName,dt,it,MED_FULL_INTERLACE,coordsPtr);
284 if(MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0)
286 _fam_coords=DataArrayInt::New();
287 _fam_coords->alloc(nCoords,1);
288 MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,_fam_coords->getPointer());
292 if(MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,MED_NUMBER,MED_NODAL,&changement,&transformation)>0)
294 _num_coords=DataArrayInt::New();
295 _num_coords->alloc(nCoords,1);
296 MEDmeshEntityNumberRd(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,_num_coords->getPointer());
300 if(MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,MED_NAME,MED_NODAL,&changement,&transformation)>0)
302 _name_coords=DataArrayAsciiChar::New();
303 _name_coords->alloc(nCoords+1,MED_SNAME_SIZE);//not a bug to avoid the memory corruption due to last \0 at the end
304 MEDmeshEntityNameRd(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,_name_coords->getPointer());
305 _name_coords->reAlloc(nCoords);//not a bug to avoid the memory corruption due to last \0 at the end
309 for(int i=0;i<spaceDim;i++)
310 _coords->setInfoOnComponent(i,infosOnComp[i].c_str());
313 void MEDFileUMeshL2::sortTypes()
316 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> > tmp(_per_type_mesh[0]);
317 _per_type_mesh.clear();
318 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=tmp.begin();it!=tmp.end();it++)
319 mdims.insert((*it)->getDim());
322 int mdim=*mdims.rbegin();
323 _per_type_mesh.resize(mdim+1);
324 for(int dim=mdim+1;dim!=0;dim--)
326 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >& elt=_per_type_mesh[mdim+1-dim];
327 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=tmp.begin();it!=tmp.end();it++)
328 if((*it)->getDim()==dim-1)
331 // suppression of contiguous empty levels at the end of _per_type_mesh.
332 int nbOfUselessLev=0;
334 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> > >::reverse_iterator it2=_per_type_mesh.rbegin();it2!=_per_type_mesh.rend();it2++)
336 if((*it2).empty() && isFirst)
343 _per_type_mesh.resize(_per_type_mesh.size()-nbOfUselessLev);
346 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)
350 MEDmeshNodeCoordinateWr(fid,mname,dt,it,time,MED_FULL_INTERLACE,coords->getNumberOfTuples(),coords->getConstPointer());
352 MEDmeshEntityFamilyNumberWr(fid,mname,dt,it,MED_NODE,MED_NO_GEOTYPE,famCoords->getNumberOfTuples(),famCoords->getConstPointer());
354 MEDmeshEntityNumberWr(fid,mname,dt,it,MED_NODE,MED_NO_GEOTYPE,numCoords->getNumberOfTuples(),numCoords->getConstPointer());
357 if(nameCoords->getNumberOfComponents()!=MED_SNAME_SIZE)
359 std::ostringstream oss; oss << " MEDFileUMeshL2::WriteCoords : expected a name field on nodes with number of components set to " << MED_SNAME_SIZE;
360 oss << " ! The array has " << nameCoords->getNumberOfComponents() << " components !";
361 throw INTERP_KERNEL::Exception(oss.str().c_str());
363 MEDmeshEntityNameWr(fid,mname,dt,it,MED_NODE,MED_NO_GEOTYPE,nameCoords->getNumberOfTuples(),nameCoords->getConstPointer());
367 bool MEDFileUMeshL2::isFamDefinedOnLev(int levId) const
369 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++)
370 if((*it)->getFam()==0)
375 bool MEDFileUMeshL2::isNumDefinedOnLev(int levId) const
377 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++)
378 if((*it)->getNum()==0)
383 bool MEDFileUMeshL2::isNamesDefinedOnLev(int levId) const
385 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++)
386 if((*it)->getNames()==0)
391 MEDFileCMeshL2::MEDFileCMeshL2()
395 void MEDFileCMeshL2::loadAll(med_idt fid, int mId, const char *mName, int dt, int it)
400 ParaMEDMEM::MEDCouplingMeshType meshType;
401 std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName,meshType,nstep,Mdim);
402 if(meshType!=CARTESIAN)
403 throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected a structured one whereas in file it is not a structured !");
404 _time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
408 med_grid_type gridtype;
409 MEDmeshGridTypeRd(fid,mName,&gridtype);
410 if(gridtype!=MED_CARTESIAN_GRID)
411 throw INTERP_KERNEL::Exception("Invalid structured mesh ! Expected cartesian mesh type !");
412 _cmesh=MEDCouplingCMesh::New();
413 for(int i=0;i<Mdim;i++)
415 med_data_type dataTypeReq=GetDataTypeCorrespondingToSpaceId(i);
416 med_bool chgt=MED_FALSE,trsf=MED_FALSE;
417 int nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,dataTypeReq,MED_NO_CMODE,&chgt,&trsf);
418 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=DataArrayDouble::New();
419 da->alloc(nbOfElt,1);
420 da->setInfoOnComponent(0,infosOnComp[i].c_str());
421 MEDmeshGridIndexCoordinateRd(fid,mName,dt,it,i+1,da->getPointer());
422 _cmesh->setCoordsAt(i,da);
426 med_data_type MEDFileCMeshL2::GetDataTypeCorrespondingToSpaceId(int id)
431 return MED_COORDINATE_AXIS1;
433 return MED_COORDINATE_AXIS2;
435 return MED_COORDINATE_AXIS3;
437 throw INTERP_KERNEL::Exception("Invalid meshdim detected in Cartesian Grid !");
441 MEDFileCLMeshL2::MEDFileCLMeshL2()
445 void MEDFileCLMeshL2::loadAll(med_idt fid, int mId, const char *mName, int dt, int it)
450 ParaMEDMEM::MEDCouplingMeshType meshType;
451 std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName,meshType,nstep,Mdim);
452 if(meshType!=CURVE_LINEAR)
453 throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected a structured one whereas in file it is not a structured !");
454 _time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
458 _clmesh=MEDCouplingCurveLinearMesh::New();
459 INTERP_KERNEL::AutoPtr<int> stGrid=new int[Mdim];
460 MEDmeshGridStructRd(fid,mName,dt,it,stGrid);
461 _clmesh->setNodeGridStructure(stGrid,((int *)stGrid)+Mdim);
462 med_bool chgt=MED_FALSE,trsf=MED_FALSE;
463 int nbNodes=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&chgt,&trsf);
464 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=DataArrayDouble::New();
465 da->alloc(nbNodes,infosOnComp.size());
466 da->setInfoOnComponents(infosOnComp);
467 MEDmeshNodeCoordinateRd(fid,mName,dt,it,MED_FULL_INTERLACE,da->getPointer());
468 _clmesh->setCoords(da);
471 MEDFileUMeshPermCompute::MEDFileUMeshPermCompute(const MEDFileUMeshSplitL1* st):_st(st),_mpt_time(0),_num_time(0)
476 * Warning it returns an instance to deallocate !!!!
478 MEDFileUMeshPermCompute::operator MEDCouplingUMesh *() const
480 _st->_num->updateTime();
481 if((MEDCouplingUMesh *)_m==0)
484 _m=static_cast<MEDCouplingUMesh *>(_st->_m_by_types.getUmesh()->deepCpy());
485 _m->renumberCells(_st->_num->getConstPointer(),true);
490 if(_mpt_time==_st->_m_by_types.getTimeOfThis() && _num_time==_st->_num->getTimeOfThis())
495 _m=static_cast<MEDCouplingUMesh *>(_st->_m_by_types.getUmesh()->deepCpy());
496 _m->renumberCells(_st->_num->getConstPointer(),true);
502 void MEDFileUMeshPermCompute::operator=(MEDCouplingUMesh *m)
507 void MEDFileUMeshPermCompute::updateTime() const
509 _mpt_time=_st->_m_by_types.getTimeOfThis();
510 _num_time=_st->_num->getTimeOfThis();
513 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)
517 MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const char *mName, int id):_m(this)
519 const std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >& v=l2.getLev(id);
523 std::vector<const MEDCoupling1GTUMesh *> ms(sz);
524 std::vector<const DataArrayInt *> fams(sz),nums(sz);
525 std::vector<const DataArrayChar *> names(sz);
526 for(int i=0;i<sz;i++)
528 MEDCoupling1GTUMesh *elt(v[i]->getMesh());
529 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp2=l2.getCoords();
530 elt->setCoords(tmp2);
533 _m_by_types.assignParts(ms);
534 if(l2.isFamDefinedOnLev(id))
536 for(int i=0;i<sz;i++)
537 fams[i]=v[i]->getFam();
539 _fam=DataArrayInt::Aggregate(fams);
543 _fam=const_cast<DataArrayInt *>(fams[0]);
546 if(l2.isNumDefinedOnLev(id))
548 for(int i=0;i<sz;i++)
549 nums[i]=v[i]->getNum();
551 _num=DataArrayInt::Aggregate(nums);
555 _num=const_cast<DataArrayInt *>(nums[0]);
559 if(l2.isNamesDefinedOnLev(id))
561 for(int i=0;i<sz;i++)
562 names[i]=v[i]->getNames();
563 _names=dynamic_cast<DataArrayAsciiChar *>(DataArrayChar::Aggregate(names));
567 MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCoupling1GTUMesh *m):_m(this)
569 std::vector< const MEDCoupling1GTUMesh * > v(1);
574 MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCouplingUMesh *m):_m(this)
579 MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCouplingUMesh *m, bool newOrOld):_m(this)
581 assignMesh(m,newOrOld);
584 std::size_t MEDFileUMeshSplitL1::getHeapMemorySizeWithoutChildren() const
589 std::vector<const BigMemoryObject *> MEDFileUMeshSplitL1::getDirectChildren() const
591 std::vector<const BigMemoryObject *> ret;
592 ret.push_back(&_m_by_types);
593 if((const DataArrayInt*)_fam)
594 ret.push_back((const DataArrayInt*)_fam);
595 if((const DataArrayInt*)_num)
596 ret.push_back((const DataArrayInt*)_num);
597 if((const DataArrayInt*)_rev_num)
598 ret.push_back((const DataArrayInt*)_rev_num);
599 if((const DataArrayAsciiChar*)_names)
600 ret.push_back((const DataArrayAsciiChar*)_names);
604 MEDFileUMeshSplitL1 *MEDFileUMeshSplitL1::deepCpy(DataArrayDouble *coords) const
606 MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> ret=new MEDFileUMeshSplitL1(*this);
607 ret->_m_by_types=_m_by_types.deepCpy(coords);
608 if((const DataArrayInt *)_fam)
609 ret->_fam=_fam->deepCpy();
610 if((const DataArrayInt *)_num)
611 ret->_num=_num->deepCpy();
612 if((const DataArrayInt *)_rev_num)
613 ret->_rev_num=_rev_num->deepCpy();
614 if((const DataArrayAsciiChar *)_names)
615 ret->_names=_names->deepCpy();
619 bool MEDFileUMeshSplitL1::isEqual(const MEDFileUMeshSplitL1 *other, double eps, std::string& what) const
621 if(!_m_by_types.isEqual(other->_m_by_types,eps,what))
623 const DataArrayInt *d1=_fam;
624 const DataArrayInt *d2=other->_fam;
625 if((d1==0 && d2!=0) || (d1!=0 && d2==0))
627 what="Presence of family arr in one sublevel and not in other!";
631 if(!d1->isEqual(*d2))
633 what="family arr at a sublevel are not deeply equal !";
638 if((d1==0 && d2!=0) || (d1!=0 && d2==0))
640 what="Presence of cell numbering arr in one sublevel and not in other!";
644 if(!d1->isEqual(*d2))
646 what="Numbering cell arr at a sublevel are not deeply equal !";
649 const DataArrayAsciiChar *e1=_names;
650 const DataArrayAsciiChar *e2=other->_names;
651 if((e1==0 && e2!=0) || (e1!=0 && e2==0))
653 what="Presence of cell names arr in one sublevel and not in other!";
657 if(!e1->isEqual(*e2))
659 what="Name cell arr at a sublevel are not deeply equal !";
665 void MEDFileUMeshSplitL1::synchronizeTinyInfo(const MEDFileMesh& master) const
667 _m_by_types.synchronizeTinyInfo(master);
670 void MEDFileUMeshSplitL1::clearNonDiscrAttributes() const
672 _m_by_types.clearNonDiscrAttributes();
675 void MEDFileUMeshSplitL1::ClearNonDiscrAttributes(const MEDCouplingMesh *tmp)
679 (const_cast<MEDCouplingMesh *>(tmp))->setName("");
680 (const_cast<MEDCouplingMesh *>(tmp))->setDescription("");
681 (const_cast<MEDCouplingMesh *>(tmp))->setTime(0.,-1,-1);
682 (const_cast<MEDCouplingMesh *>(tmp))->setTimeUnit("");
685 void MEDFileUMeshSplitL1::setCoords(DataArrayDouble *coords)
687 _m_by_types.setCoords(coords);
690 void MEDFileUMeshSplitL1::assignMesh(MEDCouplingUMesh *m, bool newOrOld)
696 _m_by_types.assignUMesh(dynamic_cast<MEDCouplingUMesh *>(m->deepCpy()));
697 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_m_by_types.getUmesh()->getRenumArrForConsecutiveCellTypesSpec(typmai2,typmai2+MED_N_CELL_FIXED_GEO);
698 if(!da->isIdentity())
700 _num=da->invertArrayO2N2N2O(m->getNumberOfCells());
703 _m_by_types.getUmesh()->renumberCells(da->getConstPointer(),false);
708 if(!m->checkConsecutiveCellTypesAndOrder(typmai2,typmai2+MED_N_CELL_FIXED_GEO))
709 throw INTERP_KERNEL::Exception("MEDFileUMeshSplitL1::assignMesh : the mode of mesh setting expects to follow the MED file numbering convention ! it is not the case !");
711 _m_by_types.assignUMesh(m);
716 void MEDFileUMeshSplitL1::assignParts(const std::vector< const MEDCoupling1GTUMesh * >& mParts)
718 _m_by_types.assignParts(mParts);
722 void MEDFileUMeshSplitL1::assignCommonPart()
724 _fam=DataArrayInt::New();
725 _fam->alloc(_m_by_types.getSize(),1);
726 _fam->fillWithValue(0);
729 bool MEDFileUMeshSplitL1::empty() const
731 return _m_by_types.empty();
734 bool MEDFileUMeshSplitL1::presenceOfOneFams(const std::vector<int>& ids) const
736 const DataArrayInt *fam=_fam;
739 return fam->presenceOfValue(ids);
742 int MEDFileUMeshSplitL1::getMeshDimension() const
744 return _m_by_types.getMeshDimension();
747 void MEDFileUMeshSplitL1::simpleRepr(std::ostream& oss) const
749 std::vector<int> code=_m_by_types.getDistributionOfTypes();
750 int nbOfTypes=code.size()/3;
751 for(int i=0;i<nbOfTypes;i++)
753 INTERP_KERNEL::NormalizedCellType typ=(INTERP_KERNEL::NormalizedCellType) code[3*i];
754 oss << " - Number of cells with type " << INTERP_KERNEL::CellModel::GetCellModel(typ).getRepr() << " : " << code[3*i+1] << std::endl;
758 int MEDFileUMeshSplitL1::getSize() const
760 return _m_by_types.getSize();
763 MEDCouplingUMesh *MEDFileUMeshSplitL1::getFamilyPart(const int *idsBg, const int *idsEnd, bool renum) const
765 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> eltsToKeep=_fam->getIdsEqualList(idsBg,idsEnd);
766 MEDCouplingUMesh *m=(MEDCouplingUMesh *)_m_by_types.getUmesh()->buildPartOfMySelf(eltsToKeep->getConstPointer(),eltsToKeep->getConstPointer()+eltsToKeep->getNumberOfTuples(),true);
768 return renumIfNeeded(m,eltsToKeep->getConstPointer());
772 DataArrayInt *MEDFileUMeshSplitL1::getFamilyPartArr(const int *idsBg, const int *idsEnd, bool renum) const
774 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_fam->getIdsEqualList(idsBg,idsEnd);
776 return renumIfNeededArr(da);
780 MEDCouplingUMesh *MEDFileUMeshSplitL1::getWholeMesh(bool renum) const
782 MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> tmp;
783 if(renum && ((const DataArrayInt *)_num))
786 { tmp=_m_by_types.getUmesh(); if(tmp) tmp->incrRef(); }
790 DataArrayInt *MEDFileUMeshSplitL1::extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const
792 const DataArrayInt *fam(_fam);
795 int start(0),stop(0);
796 _m_by_types.getStartStopOfGeoTypeWithoutComputation(gt,start,stop);
797 return fam->selectByTupleId2(start,stop,1);
800 DataArrayInt *MEDFileUMeshSplitL1::extractNumberFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const
802 const DataArrayInt *num(_num);
805 int start(0),stop(0);
806 _m_by_types.getStartStopOfGeoTypeWithoutComputation(gt,start,stop);
807 return num->selectByTupleId2(start,stop,1);
810 DataArrayInt *MEDFileUMeshSplitL1::getOrCreateAndGetFamilyField()
812 if((DataArrayInt *)_fam)
814 int nbOfTuples=_m_by_types.getSize();
815 _fam=DataArrayInt::New(); _fam->alloc(nbOfTuples,1); _fam->fillWithZero();
819 const DataArrayInt *MEDFileUMeshSplitL1::getFamilyField() const
824 const DataArrayInt *MEDFileUMeshSplitL1::getNumberField() const
829 const DataArrayInt *MEDFileUMeshSplitL1::getRevNumberField() const
834 const DataArrayAsciiChar *MEDFileUMeshSplitL1::getNameField() const
839 void MEDFileUMeshSplitL1::eraseFamilyField()
841 _fam->fillWithZero();
845 * This method ignores _m and _m_by_types.
847 void MEDFileUMeshSplitL1::setGroupsFromScratch(const std::vector<const MEDCouplingUMesh *>& ms, std::map<std::string,int>& familyIds,
848 std::map<std::string, std::vector<std::string> >& groups) throw(INTERP_KERNEL::Exception)
850 std::vector< DataArrayInt * > corr;
851 _m=MEDCouplingUMesh::FuseUMeshesOnSameCoords(ms,0,corr);
852 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > corrMSafe(corr.begin(),corr.end());
853 std::vector< std::vector<int> > fidsOfGroups;
854 std::vector< const DataArrayInt * > corr2(corr.begin(),corr.end());
855 _fam=DataArrayInt::MakePartition(corr2,((MEDCouplingUMesh *)_m)->getNumberOfCells(),fidsOfGroups);
856 int nbOfCells=((MEDCouplingUMesh *)_m)->getNumberOfCells();
857 std::map<int,std::string> newfams;
858 std::map<int,int> famIdTrad;
859 TraduceFamilyNumber(fidsOfGroups,familyIds,famIdTrad,newfams);
860 int *w=_fam->getPointer();
861 for(int i=0;i<nbOfCells;i++,w++)
865 void MEDFileUMeshSplitL1::write(med_idt fid, const char *mName, int mdim) const
867 std::vector<MEDCoupling1GTUMesh *> ms(_m_by_types.getParts());
869 for(std::vector<MEDCoupling1GTUMesh *>::const_iterator it=ms.begin();it!=ms.end();it++)
871 int nbCells=(*it)->getNumberOfCells();
872 int end=start+nbCells;
873 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> fam,num;
874 MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> names;
875 if((const DataArrayInt *)_fam)
876 fam=_fam->substr(start,end);
877 if((const DataArrayInt *)_num)
878 num=_num->substr(start,end);
879 if((const DataArrayAsciiChar *)_names)
880 names=static_cast<DataArrayAsciiChar *>(_names->substr(start,end));
881 MEDFileUMeshPerType::Write(fid,mName,mdim,(*it),fam,num,names);
886 void MEDFileUMeshSplitL1::renumberNodesInConn(const int *newNodeNumbersO2N)
888 MEDCouplingUMesh *m(_m_by_types.getUmesh());
891 m->renumberNodesInConn(newNodeNumbersO2N);
894 void MEDFileUMeshSplitL1::changeFamilyIdArr(int oldId, int newId)
896 DataArrayInt *arr=_fam;
898 arr->changeValue(oldId,newId);
901 void MEDFileUMeshSplitL1::setFamilyArr(DataArrayInt *famArr)
908 int sz(_m_by_types.getSize());
909 famArr->checkNbOfTuplesAndComp(sz,1,"MEDFileUMeshSplitL1::setFamilyArr : Problem in size of Family arr ! ");
914 void MEDFileUMeshSplitL1::setRenumArr(DataArrayInt *renumArr)
922 int sz(_m_by_types.getSize());
923 renumArr->checkNbOfTuplesAndComp(sz,1,"MEDFileUMeshSplitL1::setRenumArr : Problem in size of numbering arr ! ");
929 void MEDFileUMeshSplitL1::setNameArr(DataArrayAsciiChar *nameArr)
936 int sz(_m_by_types.getSize());
937 nameArr->checkNbOfTuplesAndComp(sz,MED_SNAME_SIZE,"MEDFileUMeshSplitL1::setNameArr : Problem in size of name arr ! ");
942 MEDCouplingUMesh *MEDFileUMeshSplitL1::Renumber2(const DataArrayInt *renum, MEDCouplingUMesh *m, const int *cellIds)
947 m->renumberCells(renum->getConstPointer(),true);
950 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> locnum=renum->selectByTupleId(cellIds,cellIds+m->getNumberOfCells());
951 m->renumberCells(locnum->getConstPointer(),true);
956 MEDCouplingUMesh *MEDFileUMeshSplitL1::renumIfNeeded(MEDCouplingUMesh *m, const int *cellIds) const
958 return Renumber2(_num,m,cellIds);
961 DataArrayInt *MEDFileUMeshSplitL1::Renumber(const DataArrayInt *renum, const DataArrayInt *da)
963 if((const DataArrayInt *)renum==0)
966 return const_cast<DataArrayInt *>(da);
968 return renum->selectByTupleId(da->getConstPointer(),da->getConstPointer()+da->getNumberOfTuples());
971 DataArrayInt *MEDFileUMeshSplitL1::renumIfNeededArr(const DataArrayInt *da) const
973 return Renumber(_num,da);
976 std::vector<int> MEDFileUMeshSplitL1::GetNewFamiliesNumber(int nb, const std::map<std::string,int>& families)
979 for(std::map<std::string,int>::const_iterator it=families.begin();it!=families.end();it++)
980 id=std::max(id,(*it).second);
983 std::vector<int> ret(nb);
984 for(int i=1;i<=nb;i++)
989 void MEDFileUMeshSplitL1::TraduceFamilyNumber(const std::vector< std::vector<int> >& fidsGrps, std::map<std::string,int>& familyIds,
990 std::map<int,int>& famIdTrad, std::map<int,std::string>& newfams)
992 std::set<int> allfids;
996 void MEDFileUMeshSplitL1::computeRevNum() const
999 int maxValue=_num->getMaxValue(pos);
1000 _rev_num=_num->invertArrayN2O2O2N(maxValue+1);
1005 MEDFileUMeshAggregateCompute::MEDFileUMeshAggregateCompute():_mp_time(0),_m_time(0)
1009 void MEDFileUMeshAggregateCompute::assignParts(const std::vector< const MEDCoupling1GTUMesh * >& mParts)
1011 std::size_t sz(mParts.size());
1012 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> > ret(sz);
1013 for(std::size_t i=0;i<sz;i++)
1015 const MEDCoupling1GTUMesh *elt(mParts[i]);
1017 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::assignParts : presence of null pointer !");
1018 ret[i]=const_cast<MEDCoupling1GTUMesh *>(elt); elt->incrRef();
1021 _mp_time=std::max(_mp_time,_m_time)+1;
1025 void MEDFileUMeshAggregateCompute::assignUMesh(MEDCouplingUMesh *m)
1029 _m_time=std::max(_mp_time,_m_time)+1;
1032 MEDCouplingUMesh *MEDFileUMeshAggregateCompute::getUmesh() const
1034 if(_mp_time<=_m_time)
1036 std::vector< const MEDCoupling1GTUMesh *> mp(_m_parts.size());
1037 std::copy(_m_parts.begin(),_m_parts.end(),mp.begin());
1038 _m=MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh(mp);
1039 _m_parts.clear();//to avoid memory peak !
1040 _m_time=_mp_time+1;//+1 is important ! That is to say that only _m is OK not _m_parts because cleared !
1044 std::vector<MEDCoupling1GTUMesh *> MEDFileUMeshAggregateCompute::getPartsWithoutComputation() const
1046 if(_mp_time<_m_time)
1047 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getPartsWithoutComputation : the parts require a computation !");
1049 std::vector<MEDCoupling1GTUMesh *> ret(_m_parts.size());
1051 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++,i++)
1053 const MEDCoupling1GTUMesh *elt(*it);
1054 ret[i]=const_cast<MEDCoupling1GTUMesh *>(elt);
1059 std::vector<MEDCoupling1GTUMesh *> MEDFileUMeshAggregateCompute::getParts() const
1061 if(_mp_time<_m_time)
1062 forceComputationOfPartsFromUMesh();
1063 return getPartsWithoutComputation();
1066 MEDCoupling1GTUMesh *MEDFileUMeshAggregateCompute::getPartWithoutComputation(INTERP_KERNEL::NormalizedCellType gt) const
1068 std::vector<MEDCoupling1GTUMesh *> v(getPartsWithoutComputation());
1069 std::size_t sz(v.size());
1070 for(std::size_t i=0;i<sz;i++)
1073 if(v[i]->getCellModelEnum()==gt)
1076 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getPartWithoutComputation : the geometric type is not existing !");
1079 void MEDFileUMeshAggregateCompute::getStartStopOfGeoTypeWithoutComputation(INTERP_KERNEL::NormalizedCellType gt, int& start, int& stop) const
1082 std::vector<MEDCoupling1GTUMesh *> v(getPartsWithoutComputation());
1083 std::size_t sz(v.size());
1084 for(std::size_t i=0;i<sz;i++)
1088 if(v[i]->getCellModelEnum()==gt)
1090 stop=start+v[i]->getNumberOfCells();
1094 start+=v[i]->getNumberOfCells();
1097 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getStartStopOfGeoTypeWithoutComputation : the geometric type is not existing !");
1100 void MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh() const
1102 const MEDCouplingUMesh *m(_m);
1104 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh : null UMesh !");
1105 std::vector<MEDCouplingUMesh *> ms(m->splitByType());
1106 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> > msMSafe(ms.begin(),ms.end());
1107 std::size_t sz(msMSafe.size());
1108 _m_parts.resize(sz);
1109 for(std::size_t i=0;i<sz;i++)
1110 _m_parts[i]=MEDCoupling1GTUMesh::New(ms[i]);
1111 _mp_time=std::max(_mp_time,_m_time)+1;
1114 std::size_t MEDFileUMeshAggregateCompute::getTimeOfThis() const
1116 if(_mp_time>_m_time)
1117 return getTimeOfParts();
1118 if(_m_time>_mp_time)
1119 return getTimeOfUMesh();
1120 return std::max(getTimeOfParts(),getTimeOfUMesh());
1123 std::size_t MEDFileUMeshAggregateCompute::getTimeOfParts() const
1126 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1128 const MEDCoupling1GTUMesh *elt(*it);
1130 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getTimeOfParts : null obj in parts !");
1131 ret=std::max(ret,elt->getTimeOfThis());
1134 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getTimeOfParts : parts is empty !");
1138 std::size_t MEDFileUMeshAggregateCompute::getTimeOfUMesh() const
1140 const MEDCouplingUMesh *m(_m);
1142 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getTimeOfUMesh : unmesh is null !");
1143 return m->getTimeOfThis();
1146 std::size_t MEDFileUMeshAggregateCompute::getHeapMemorySizeWithoutChildren() const
1148 std::size_t ret(_m_parts.size()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh>));
1152 std::vector<const BigMemoryObject *> MEDFileUMeshAggregateCompute::getDirectChildren() const
1154 std::vector<const BigMemoryObject *> ret;
1155 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1157 const MEDCoupling1GTUMesh *cur(*it);
1161 const MEDCouplingUMesh *m(_m);
1167 MEDFileUMeshAggregateCompute MEDFileUMeshAggregateCompute::deepCpy(DataArrayDouble *coords) const
1169 MEDFileUMeshAggregateCompute ret;
1170 ret._m_parts.resize(_m_parts.size());
1171 for(std::size_t i=0;i<_m_parts.size();i++)
1173 const MEDCoupling1GTUMesh *elt(_m_parts[i]);
1176 ret._m_parts[i]=static_cast<ParaMEDMEM::MEDCoupling1GTUMesh*>(elt->deepCpy());
1177 ret._m_parts[i]->setCoords(coords);
1180 ret._mp_time=_mp_time; ret._m_time=_m_time;
1181 if((const MEDCouplingUMesh *)_m)
1183 ret._m=static_cast<ParaMEDMEM::MEDCouplingUMesh*>(_m->deepCpy());
1184 ret._m->setCoords(coords);
1189 bool MEDFileUMeshAggregateCompute::isEqual(const MEDFileUMeshAggregateCompute& other, double eps, std::string& what) const
1191 const MEDCouplingUMesh *m1(getUmesh());
1192 const MEDCouplingUMesh *m2(other.getUmesh());
1193 if((m1==0 && m2!=0) || (m1!=0 && m2==0))
1195 what="Presence of mesh in one sublevel and not in other!";
1201 if(!m1->isEqualIfNotWhy(m2,eps,what2))
1203 what=std::string("meshes at a sublevel are not deeply equal (")+what2+std::string(")!");
1210 void MEDFileUMeshAggregateCompute::clearNonDiscrAttributes() const
1212 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1213 MEDFileUMeshSplitL1::ClearNonDiscrAttributes(*it);
1214 MEDFileUMeshSplitL1::ClearNonDiscrAttributes(_m);
1217 void MEDFileUMeshAggregateCompute::synchronizeTinyInfo(const MEDFileMesh& master) const
1219 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1221 const MEDCoupling1GTUMesh *tmp(*it);
1224 (const_cast<MEDCoupling1GTUMesh *>(tmp))->setName(master.getName().c_str());
1225 (const_cast<MEDCoupling1GTUMesh *>(tmp))->setDescription(master.getDescription().c_str());
1226 (const_cast<MEDCoupling1GTUMesh *>(tmp))->setTime(master.getTimeValue(),master.getIteration(),master.getOrder());
1227 (const_cast<MEDCoupling1GTUMesh *>(tmp))->setTimeUnit(master.getTimeUnit());
1230 const MEDCouplingUMesh *m(_m);
1233 (const_cast<MEDCouplingUMesh *>(m))->setName(master.getName().c_str());
1234 (const_cast<MEDCouplingUMesh *>(m))->setDescription(master.getDescription().c_str());
1235 (const_cast<MEDCouplingUMesh *>(m))->setTime(master.getTimeValue(),master.getIteration(),master.getOrder());
1236 (const_cast<MEDCouplingUMesh *>(m))->setTimeUnit(master.getTimeUnit());
1240 bool MEDFileUMeshAggregateCompute::empty() const
1242 if(_mp_time<_m_time)
1243 return ((const MEDCouplingUMesh *)_m)==0;
1244 //else _mp_time>=_m_time)
1245 return _m_parts.empty();
1249 int MEDFileUMeshAggregateCompute::getMeshDimension() const
1251 if(_mp_time<_m_time)
1253 const MEDCouplingUMesh *m(_m);
1255 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getMeshDimension : no umesh in this !");
1256 return m->getMeshDimension();
1260 if(_m_parts.empty())
1261 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getMeshDimension : part mesh is empty !");
1262 const MEDCoupling1GTUMesh *m(_m_parts[0]);
1264 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getMeshDimension : part mesh contains null instance !");
1265 return m->getMeshDimension();
1269 std::vector<int> MEDFileUMeshAggregateCompute::getDistributionOfTypes() const
1271 if(_mp_time<_m_time)
1273 const MEDCouplingUMesh *m(_m);
1275 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getDistributionOfTypes : no umesh in this !");
1276 return m->getDistributionOfTypes();
1280 std::vector<int> ret;
1281 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1283 const MEDCoupling1GTUMesh *tmp(*it);
1285 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getDistributionOfTypes : part mesh contains null instance !");
1286 std::vector<int> ret0(tmp->getDistributionOfTypes());
1287 ret.insert(ret.end(),ret0.begin(),ret0.end());
1293 int MEDFileUMeshAggregateCompute::getSize() const
1295 if(_mp_time<_m_time)
1297 const MEDCouplingUMesh *m(_m);
1299 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getSize : no umesh in this !");
1300 return m->getNumberOfCells();
1305 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1307 const MEDCoupling1GTUMesh *m(*it);
1309 throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getSize : part mesh contains null instance !");
1310 ret+=m->getNumberOfCells();
1316 void MEDFileUMeshAggregateCompute::setCoords(DataArrayDouble *coords)
1318 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::iterator it=_m_parts.begin();it!=_m_parts.end();it++)
1320 MEDCoupling1GTUMesh *tmp(*it);
1322 (*it)->setCoords(coords);
1324 MEDCouplingUMesh *m(_m);
1326 m->setCoords(coords);