+
+//=
+
+MEDFileUMeshAggregateCompute::MEDFileUMeshAggregateCompute():_mp_time(0),_m_time(0)
+{
+}
+
+void MEDFileUMeshAggregateCompute::setName(const std::string& name)
+{
+ if(_m_time>=_mp_time)
+ {
+ MEDCouplingUMesh *um(_m);
+ if(um)
+ um->setName(name);
+ }
+ if(_mp_time>=_m_time)
+ {
+ for(std::vector< MCAuto<MEDCoupling1GTUMesh> >::iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ {
+ MEDCoupling1GTUMesh *tmp(*it);
+ if(tmp)
+ tmp->setName(name);
+ }
+ }
+}
+
+void MEDFileUMeshAggregateCompute::assignParts(const std::vector< const MEDCoupling1GTUMesh * >& mParts)
+{
+ std::size_t sz(mParts.size());
+ std::vector< MCAuto<MEDCoupling1GTUMesh> > ret(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const MEDCoupling1GTUMesh *elt(mParts[i]);
+ if(!elt)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::assignParts : presence of null pointer !");
+ ret[i]=const_cast<MEDCoupling1GTUMesh *>(elt); elt->incrRef();
+ }
+ _m_parts=ret;
+ _part_def.clear(); _part_def.resize(sz);
+ _mp_time=std::max(_mp_time,_m_time)+1;
+ _m=0;
+}
+
+void MEDFileUMeshAggregateCompute::assignDefParts(const std::vector<const PartDefinition *>& partDefs)
+{
+ if(_mp_time<_m_time)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::assignDefParts : the parts require a computation !");
+ std::size_t sz(partDefs.size());
+ if(_part_def.size()!=partDefs.size() || _part_def.size()!=_m_parts.size())
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::assignDefParts : sizes of vectors of part definition mismatch !");
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const PartDefinition *elt(partDefs[i]);
+ if(elt)
+ elt->incrRef();
+ _part_def[i]=const_cast<PartDefinition*>(elt);
+ }
+}
+
+void MEDFileUMeshAggregateCompute::assignUMesh(MEDCouplingUMesh *m)
+{
+ _m=m;
+ _m_parts.clear();
+ _m_time=std::max(_mp_time,_m_time)+1;
+}
+
+MEDCouplingUMesh *MEDFileUMeshAggregateCompute::getUmesh() const
+{
+ if(_mp_time<=_m_time)
+ return _m;
+ std::vector< const MEDCoupling1GTUMesh *> mp(_m_parts.size());
+ std::copy(_m_parts.begin(),_m_parts.end(),mp.begin());
+ _m=MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh(mp);
+ _m_parts.clear();//to avoid memory peak !
+ _m_time=_mp_time+1;//+1 is important ! That is to say that only _m is OK not _m_parts because cleared !
+ return _m;
+}
+
+int MEDFileUMeshAggregateCompute::getNumberOfCells() const
+{
+ if(_mp_time<=_m_time)
+ return _m->getNumberOfCells();
+ int ret(0);
+ for(std::vector< MCAuto<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ ret+=(*it)->getNumberOfCells();
+ return ret;
+}
+
+std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileUMeshAggregateCompute::getGeoTypes() const
+{
+ if(_mp_time>=_m_time)
+ {
+ std::size_t sz(_m_parts.size());
+ std::vector<INTERP_KERNEL::NormalizedCellType> ret(sz);
+ for(std::size_t i=0;i<sz;i++)
+ ret[i]=_m_parts[i]->getCellModelEnum();
+ return ret;
+ }
+ else
+ return _m->getAllGeoTypesSorted();
+}
+
+int MEDFileUMeshAggregateCompute::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const
+{
+ if(_mp_time>=_m_time)
+ {
+ for(std::vector< MCAuto<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ {
+ const MEDCoupling1GTUMesh *elt(*it);
+ if(elt && elt->getCellModelEnum()==ct)
+ return elt->getNumberOfCells();
+ }
+ return 0;
+ }
+ else
+ return _m->getNumberOfCellsWithType(ct);
+}
+
+std::vector<MEDCoupling1GTUMesh *> MEDFileUMeshAggregateCompute::retrievePartsWithoutComputation() const
+{
+ if(_mp_time<_m_time)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getPartsWithoutComputation : the parts require a computation !");
+ //
+ std::vector<MEDCoupling1GTUMesh *> ret(_m_parts.size());
+ std::size_t i(0);
+ for(std::vector< MCAuto<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++,i++)
+ {
+ const MEDCoupling1GTUMesh *elt(*it);
+ ret[i]=const_cast<MEDCoupling1GTUMesh *>(elt);
+ }
+ return ret;
+}
+
+std::vector<MEDCoupling1GTUMesh *> MEDFileUMeshAggregateCompute::getParts() const
+{
+ if(_mp_time<_m_time)
+ forceComputationOfPartsFromUMesh();
+ return retrievePartsWithoutComputation();
+}
+
+MEDCoupling1GTUMesh *MEDFileUMeshAggregateCompute::retrievePartWithoutComputation(INTERP_KERNEL::NormalizedCellType gt) const
+{
+ std::vector<MEDCoupling1GTUMesh *> v(retrievePartsWithoutComputation());
+ std::size_t sz(v.size());
+ for(std::size_t i=0;i<sz;i++)
+ {
+ if(v[i])
+ if(v[i]->getCellModelEnum()==gt)
+ return v[i];
+ }
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getPartWithoutComputation : the geometric type is not existing !");
+}
+
+void MEDFileUMeshAggregateCompute::getStartStopOfGeoTypeWithoutComputation(INTERP_KERNEL::NormalizedCellType gt, int& start, int& stop) const
+{
+ start=0; stop=0;
+ std::vector<MEDCoupling1GTUMesh *> v(retrievePartsWithoutComputation());
+ std::size_t sz(v.size());
+ for(std::size_t i=0;i<sz;i++)
+ {
+ if(v[i])
+ {
+ if(v[i]->getCellModelEnum()==gt)
+ {
+ stop=start+v[i]->getNumberOfCells();
+ return;
+ }
+ else
+ start+=v[i]->getNumberOfCells();
+ }
+ }
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getStartStopOfGeoTypeWithoutComputation : the geometric type is not existing !");
+}
+
+void MEDFileUMeshAggregateCompute::renumberNodesInConnWithoutComputation(const int *newNodeNumbersO2N)
+{
+ if(_mp_time>_m_time)
+ {
+ for(std::vector< MCAuto<MEDCoupling1GTUMesh> >::iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ {
+ MEDCoupling1GTUMesh *m(*it);
+ if(m)
+ m->renumberNodesInConn(newNodeNumbersO2N);
+ }
+ }
+ else
+ {
+ MEDCouplingUMesh *m(getUmesh());
+ if(!m)
+ return;
+ m->renumberNodesInConn(newNodeNumbersO2N);
+ }
+}
+
+void MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh() const
+{
+ const MEDCouplingUMesh *m(_m);
+ if(!m)
+ {
+ if(_m_parts.empty())
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh : null UMesh !");
+ else
+ return ;// no needs to compte parts they are already here !
+ }
+ std::vector<MEDCouplingUMesh *> ms(m->splitByType());
+ std::vector< MCAuto<MEDCouplingUMesh> > msMSafe(ms.begin(),ms.end());
+ std::size_t sz(msMSafe.size());
+ _m_parts.resize(sz);
+ for(std::size_t i=0;i<sz;i++)
+ _m_parts[i]=MEDCoupling1GTUMesh::New(ms[i]);
+ _part_def.clear();
+ _part_def.resize(_m_parts.size());
+ _mp_time=std::max(_mp_time,_m_time);
+}
+
+const PartDefinition *MEDFileUMeshAggregateCompute::getPartDefOfWithoutComputation(INTERP_KERNEL::NormalizedCellType gt) const
+{
+ if(_mp_time<_m_time)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getPartDefOfWithoutComputation : the parts require a computation !");
+ if(_m_parts.size()!=_part_def.size())
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getPartDefOfWithoutComputation : size of arrays are expected to be the same !");
+ std::size_t sz(_m_parts.size());
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const MEDCoupling1GTUMesh *mesh(_m_parts[i]);
+ if(mesh)
+ if(mesh->getCellModelEnum()==gt)
+ return _part_def[i];
+ }
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getPartDefOfWithoutComputation : The input geo type is not existing in this !");
+}
+
+void MEDFileUMeshAggregateCompute::serialize(std::vector<int>& tinyInt, std::vector< MCAuto<DataArrayInt> >& bigArraysI) const
+{
+ if(_mp_time<_m_time)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::serialize : the parts require a computation !");
+ std::size_t sz(_m_parts.size());
+ tinyInt.push_back((int)sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const MEDCoupling1GTUMesh *mesh(_m_parts[i]);
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::serialize : one part is empty !");
+ tinyInt.push_back(mesh->getCellModelEnum());
+ const MEDCoupling1SGTUMesh *mesh1(dynamic_cast<const MEDCoupling1SGTUMesh *>(mesh));
+ const MEDCoupling1DGTUMesh *mesh2(dynamic_cast<const MEDCoupling1DGTUMesh *>(mesh));
+ if(mesh1)
+ {
+ DataArrayInt *elt(mesh1->getNodalConnectivity());
+ if(elt)
+ elt->incrRef();
+ MCAuto<DataArrayInt> elt1(elt);
+ bigArraysI.push_back(elt1);
+ }
+ else if(mesh2)
+ {
+ DataArrayInt *elt1(mesh2->getNodalConnectivity()),*elt2(mesh2->getNodalConnectivityIndex());
+ if(elt1)
+ elt1->incrRef();
+ if(elt2)
+ elt2->incrRef();
+ MCAuto<DataArrayInt> elt11(elt1),elt22(elt2);
+ bigArraysI.push_back(elt11); bigArraysI.push_back(elt22);
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::serialize : unrecognized single geo type mesh !");
+ const PartDefinition *pd(_part_def[i]);
+ if(!pd)
+ tinyInt.push_back(-1);
+ else
+ {
+ std::vector<int> tinyTmp;
+ pd->serialize(tinyTmp,bigArraysI);
+ tinyInt.push_back((int)tinyTmp.size());
+ tinyInt.insert(tinyInt.end(),tinyTmp.begin(),tinyTmp.end());
+ }
+ }
+}
+
+void MEDFileUMeshAggregateCompute::unserialize(const std::string& name, DataArrayDouble *coo, std::vector<int>& tinyInt, std::vector< MCAuto<DataArrayInt> >& bigArraysI)
+{
+ int nbParts(tinyInt.back()); tinyInt.pop_back();
+ _part_def.clear(); _part_def.resize(nbParts);
+ _m_parts.clear(); _m_parts.resize(nbParts);
+ for(int i=0;i<nbParts;i++)
+ {
+ INTERP_KERNEL::NormalizedCellType tp((INTERP_KERNEL::NormalizedCellType) tinyInt.back()); tinyInt.pop_back();
+ MCAuto<MEDCoupling1GTUMesh> mesh(MEDCoupling1GTUMesh::New(name,tp));
+ mesh->setCoords(coo);
+ MEDCoupling1SGTUMesh *mesh1(dynamic_cast<MEDCoupling1SGTUMesh *>((MEDCoupling1GTUMesh *) mesh));
+ MEDCoupling1DGTUMesh *mesh2(dynamic_cast<MEDCoupling1DGTUMesh *>((MEDCoupling1GTUMesh *) mesh));
+ if(mesh1)
+ {
+ mesh1->setNodalConnectivity(bigArraysI.back()); bigArraysI.pop_back();
+ }
+ else if(mesh2)
+ {
+ MCAuto<DataArrayInt> elt0,elt1;
+ elt0=bigArraysI.back(); bigArraysI.pop_back();
+ elt1=bigArraysI.back(); bigArraysI.pop_back();
+ mesh2->setNodalConnectivity(elt0,elt1);
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::unserialize : unrecognized single geo type mesh !");
+ _m_parts[i]=mesh;
+ int pdid(tinyInt.back()); tinyInt.pop_back();
+ if(pdid!=-1)
+ _part_def[i]=PartDefinition::Unserialize(tinyInt,bigArraysI);
+ _mp_time=std::max(_mp_time,_m_time)+1;
+ }
+}
+
+/*!
+ * This method returns true if \a this is stored split by type false if stored in a merged unstructured mesh.
+ */
+bool MEDFileUMeshAggregateCompute::isStoredSplitByType() const
+{
+ return _mp_time>=_m_time;
+}
+
+std::size_t MEDFileUMeshAggregateCompute::getTimeOfThis() const
+{
+ if(_mp_time>_m_time)
+ return getTimeOfParts();
+ if(_m_time>_mp_time)
+ return getTimeOfUMesh();
+ return std::max(getTimeOfParts(),getTimeOfUMesh());
+}
+
+std::size_t MEDFileUMeshAggregateCompute::getTimeOfParts() const
+{
+ std::size_t ret(0);
+ for(std::vector< MCAuto<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ {
+ const MEDCoupling1GTUMesh *elt(*it);
+ if(!elt)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getTimeOfParts : null obj in parts !");
+ ret=std::max(ret,elt->getTimeOfThis());
+ }
+ if(ret==0)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getTimeOfParts : parts is empty !");
+ return ret;
+}
+
+std::size_t MEDFileUMeshAggregateCompute::getTimeOfUMesh() const
+{
+ const MEDCouplingUMesh *m(_m);
+ if(!m)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getTimeOfUMesh : unmesh is null !");
+ return m->getTimeOfThis();
+}
+
+std::size_t MEDFileUMeshAggregateCompute::getHeapMemorySizeWithoutChildren() const
+{
+ std::size_t ret(_m_parts.size()*sizeof(MCAuto<MEDCoupling1GTUMesh>));
+ return ret;
+}
+
+std::vector<const BigMemoryObject *> MEDFileUMeshAggregateCompute::getDirectChildrenWithNull() const
+{
+ std::vector<const BigMemoryObject *> ret;
+ for(std::vector< MCAuto<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ ret.push_back((const MEDCoupling1GTUMesh *)*it);
+ ret.push_back((const MEDCouplingUMesh *)_m);
+ return ret;
+}
+
+MEDFileUMeshAggregateCompute MEDFileUMeshAggregateCompute::deepCopy(DataArrayDouble *coords) const
+{
+ MEDFileUMeshAggregateCompute ret;
+ ret._m_parts.resize(_m_parts.size());
+ for(std::size_t i=0;i<_m_parts.size();i++)
+ {
+ const MEDCoupling1GTUMesh *elt(_m_parts[i]);
+ if(elt)
+ {
+ ret._m_parts[i]=static_cast<MEDCoupling::MEDCoupling1GTUMesh*>(elt->deepCopy());
+ ret._m_parts[i]->setCoords(coords);
+ }
+ }
+ ret._mp_time=_mp_time; ret._m_time=_m_time;
+ if((const MEDCouplingUMesh *)_m)
+ {
+ ret._m=static_cast<MEDCoupling::MEDCouplingUMesh*>(_m->deepCopy());
+ ret._m->setCoords(coords);
+ }
+ std::size_t sz(_part_def.size());
+ ret._part_def.clear(); ret._part_def.resize(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const PartDefinition *elt(_part_def[i]);
+ if(elt)
+ ret._part_def[i]=elt->deepCopy();
+ }
+ return ret;
+}
+
+void MEDFileUMeshAggregateCompute::shallowCpyMeshes()
+{
+ for(std::vector< MCAuto<MEDCoupling1GTUMesh> >::iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ {
+ const MEDCoupling1GTUMesh *elt(*it);
+ if(elt)
+ {
+ MCAuto<MEDCouplingMesh> elt2(elt->clone(false));
+ *it=DynamicCastSafe<MEDCouplingMesh,MEDCoupling1GTUMesh>(elt2);
+ }
+ }
+ const MEDCouplingUMesh *m(_m);
+ if(m)
+ _m=m->clone(false);
+}
+
+bool MEDFileUMeshAggregateCompute::isEqual(const MEDFileUMeshAggregateCompute& other, double eps, std::string& what) const
+{
+ const MEDCouplingUMesh *m1(getUmesh());
+ const MEDCouplingUMesh *m2(other.getUmesh());
+ if((m1==0 && m2!=0) || (m1!=0 && m2==0))
+ {
+ what="Presence of mesh in one sublevel and not in other!";
+ return false;
+ }
+ if(m1)
+ {
+ std::string what2;
+ if(!m1->isEqualIfNotWhy(m2,eps,what2))
+ {
+ what=std::string("meshes at a sublevel are not deeply equal (")+what2+std::string(")!");
+ return false;
+ }
+ }
+ std::size_t sz(_part_def.size());
+ if(sz!=other._part_def.size())
+ {
+ what=std::string("number of subdivision per geo type for part definition is not the same !");
+ return false;
+ }
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const PartDefinition *pd0(_part_def[i]),*pd1(other._part_def[i]);
+ if(!pd0 && !pd1)
+ continue;
+ if((!pd0 && pd1) || (pd0 && !pd1))
+ {
+ what=std::string("a cell part def is defined only for one among this or other !");
+ return false;
+ }
+ bool ret(pd0->isEqual(pd1,what));
+ if(!ret)
+ return false;
+ }
+ return true;
+}
+
+void MEDFileUMeshAggregateCompute::checkConsistency() const
+{
+ if(_mp_time >= _m_time)
+ for(std::vector< MCAuto<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();
+ it!=_m_parts.end(); it++)
+ (*it)->checkConsistency();
+ else
+ _m->checkConsistency();
+}
+
+void MEDFileUMeshAggregateCompute::clearNonDiscrAttributes() const
+{
+ for(std::vector< MCAuto<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ MEDFileUMeshSplitL1::ClearNonDiscrAttributes(*it);
+ MEDFileUMeshSplitL1::ClearNonDiscrAttributes(_m);
+}
+
+void MEDFileUMeshAggregateCompute::synchronizeTinyInfo(const MEDFileMesh& master) const
+{
+ for(std::vector< MCAuto<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ {
+ const MEDCoupling1GTUMesh *tmp(*it);
+ if(tmp)
+ {
+ (const_cast<MEDCoupling1GTUMesh *>(tmp))->setName(master.getName().c_str());
+ (const_cast<MEDCoupling1GTUMesh *>(tmp))->setDescription(master.getDescription().c_str());
+ (const_cast<MEDCoupling1GTUMesh *>(tmp))->setTime(master.getTimeValue(),master.getIteration(),master.getOrder());
+ (const_cast<MEDCoupling1GTUMesh *>(tmp))->setTimeUnit(master.getTimeUnit());
+ }
+ }
+ const MEDCouplingUMesh *m(_m);
+ if(m)
+ {
+ (const_cast<MEDCouplingUMesh *>(m))->setName(master.getName().c_str());
+ (const_cast<MEDCouplingUMesh *>(m))->setDescription(master.getDescription().c_str());
+ (const_cast<MEDCouplingUMesh *>(m))->setTime(master.getTimeValue(),master.getIteration(),master.getOrder());
+ (const_cast<MEDCouplingUMesh *>(m))->setTimeUnit(master.getTimeUnit());
+ }
+}
+
+bool MEDFileUMeshAggregateCompute::empty() const
+{
+ if(_mp_time<_m_time)
+ return ((const MEDCouplingUMesh *)_m)==0;
+ //else _mp_time>=_m_time)
+ return _m_parts.empty();
+}
+
+int MEDFileUMeshAggregateCompute::getMeshDimension() const
+{
+ if(_mp_time<_m_time)
+ {
+ const MEDCouplingUMesh *m(_m);
+ if(!m)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getMeshDimension : no umesh in this !");
+ return m->getMeshDimension();
+ }
+ else
+ {
+ if(_m_parts.empty())
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getMeshDimension : part mesh is empty !");
+ const MEDCoupling1GTUMesh *m(_m_parts[0]);
+ if(!m)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getMeshDimension : part mesh contains null instance !");
+ return m->getMeshDimension();
+ }
+}
+
+std::vector<int> MEDFileUMeshAggregateCompute::getDistributionOfTypes() const
+{
+ if(_mp_time<_m_time)
+ {
+ const MEDCouplingUMesh *m(_m);
+ if(!m)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getDistributionOfTypes : no umesh in this !");
+ return m->getDistributionOfTypes();
+ }
+ else
+ {
+ std::vector<int> ret;
+ for(std::vector< MCAuto<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ {
+ const MEDCoupling1GTUMesh *tmp(*it);
+ if(!tmp)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getDistributionOfTypes : part mesh contains null instance !");
+ std::vector<int> ret0(tmp->getDistributionOfTypes());
+ ret.insert(ret.end(),ret0.begin(),ret0.end());
+ }
+ return ret;
+ }
+}
+
+int MEDFileUMeshAggregateCompute::getSize() const
+{
+ if(_mp_time<_m_time)
+ {
+ const MEDCouplingUMesh *m(_m);
+ if(!m)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getSize : no umesh in this !");
+ return m->getNumberOfCells();
+ }
+ else
+ {
+ int ret=0;
+ for(std::vector< MCAuto<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ {
+ const MEDCoupling1GTUMesh *m(*it);
+ if(!m)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getSize : part mesh contains null instance !");
+ ret+=m->getNumberOfCells();
+ }
+ return ret;
+ }
+}
+
+void MEDFileUMeshAggregateCompute::setCoords(DataArrayDouble *coords)
+{
+ for(std::vector< MCAuto<MEDCoupling1GTUMesh> >::iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ {
+ MEDCoupling1GTUMesh *tmp(*it);
+ if(tmp)
+ (*it)->setCoords(coords);
+ }
+ MEDCouplingUMesh *m(_m);
+ if(m)
+ m->setCoords(coords);
+}
+
+MEDFileEltStruct4Mesh *MEDFileEltStruct4Mesh::New(med_idt fid, const std::string& mName, int dt, int it, int iterOnStEltOfMesh, MEDFileMeshReadSelector *mrs)
+{
+ return new MEDFileEltStruct4Mesh(fid,mName,dt,it,iterOnStEltOfMesh,mrs);
+}
+
+std::size_t MEDFileEltStruct4Mesh::getHeapMemorySizeWithoutChildren() const
+{
+ return _geo_type_name.capacity()+_vars.capacity()*sizeof(MCAuto<DataArray>);
+}
+
+std::vector<const MEDCoupling::BigMemoryObject*> MEDFileEltStruct4Mesh::getDirectChildrenWithNull() const
+{
+ std::vector<const MEDCoupling::BigMemoryObject*> ret;
+ ret.push_back(_conn);
+ ret.push_back(_common);
+ for(std::vector< MCAuto<DataArray> >::const_iterator it=_vars.begin();it!=_vars.end();it++)
+ ret.push_back(*it);
+ return ret;
+}
+
+MEDFileEltStruct4Mesh::MEDFileEltStruct4Mesh(med_idt fid, const std::string& mName, int dt, int it, int iterOnStEltOfMesh, MEDFileMeshReadSelector *mrs)
+{
+ med_geometry_type geoType;
+ INTERP_KERNEL::AutoPtr<char> geoTypeName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
+ MEDFILESAFECALLERRD0(MEDmeshEntityInfo,(fid,mName.c_str(),dt,it,MED_STRUCT_ELEMENT,iterOnStEltOfMesh+1,geoTypeName,&geoType));
+ _geo_type=geoType;
+ _geo_type_name=MEDLoaderBase::buildStringFromFortran(geoTypeName,MED_NAME_SIZE);
+ int nCells(0);
+ {
+ med_bool chgt=MED_FALSE,trsf=MED_FALSE;
+ nCells=MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_STRUCT_ELEMENT,geoType,MED_CONNECTIVITY,MED_NODAL,&chgt,&trsf);
+ }
+ MCAuto<MEDFileMeshSupports> mss(MEDFileMeshSupports::New(fid));
+ MCAuto<MEDFileStructureElements> mse(MEDFileStructureElements::New(fid,mss));
+ int nbEntities(mse->getNumberOfNodesPerSE(_geo_type_name));
+ _conn=DataArrayInt::New(); _conn->alloc(nCells*nbEntities);
+ MEDFILESAFECALLERRD0(MEDmeshElementConnectivityRd,(fid,mName.c_str(),dt,it,MED_STRUCT_ELEMENT,_geo_type,MED_NODAL,MED_FULL_INTERLACE,_conn->getPointer()));
+ _conn->applyLin(1,-1);
+ _conn->rearrange(nbEntities);
+ _common=MEDFileUMeshPerTypeCommon::New();
+ _common->loadCommonPart(fid,mName.c_str(),dt,it,nCells,geoType,MED_STRUCT_ELEMENT,mrs);
+ std::vector<std::string> vns(mse->getVarAttsOf(_geo_type_name));
+ std::size_t sz(vns.size());
+ _vars.resize(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const MEDFileSEVarAtt *var(mse->getVarAttOf(_geo_type_name,vns[i]));
+ MCAuto<DataArray> gen(var->getGenerator());
+ MCAuto<DataArray> arr(gen->buildNewEmptyInstance());
+ arr->alloc(nCells,var->getNbOfComponents());
+ arr->setName(vns[i]);
+ MEDFILESAFECALLERRD0(MEDmeshStructElementVarAttRd,(fid,mName.c_str(),dt,it,_geo_type,vns[i].c_str(),arr->getVoidStarPointer()));
+ _vars[i]=arr;
+ }
+}