return _start+nbElems*_step;
}
+void SlicePartDefinition::getSlice(int& start, int& stop, int& step) const
+{
+ start=_start;
+ stop=_stop;
+ step=_step;
+}
+
SlicePartDefinition::SlicePartDefinition(int start, int stop, int step):_start(start),_stop(stop),_step(step)
{
}
MEDCOUPLING_EXPORT std::string getRepr() const;
//specific method
MEDCOUPLING_EXPORT int getEffectiveStop() const;
+ MEDCOUPLING_EXPORT void getSlice(int& start, int& stop, int& step) const;
private:
SlicePartDefinition(int start, int stop, int step);
MEDCOUPLING_EXPORT void updateTime() const;
self.assertTrue(pd.toDAI().isEqual(DataArrayInt([5,8,11,14,17,20])))
self.assertEqual(pd.getNumberOfElems(),6)
self.assertEqual(pd.getEffectiveStop(),23)
+ self.assertEqual(pd.getSlice(),slice(5,23,3))
pd=PartDefinition.New(5,22,1)
self.assertTrue(isinstance(pd,SlicePartDefinition))
self.assertTrue(pd.toDAI().isEqual(DataArrayInt([5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])))
{
return SlicePartDefinition::New(start,stop,step);
}
+
+ PyObject *getSlice() const throw(INTERP_KERNEL::Exception)
+ {
+ int a,b,c;
+ self->getSlice(a,b,c);
+ return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(c));
+ }
std::string __str__() const throw(INTERP_KERNEL::Exception)
{
ret.push_back((const DataArrayInt *)_num_coords);
ret.push_back((const DataArrayInt *)_rev_num_coords);
ret.push_back((const DataArrayAsciiChar *)_name_coords);
+ ret.push_back((const PartDefinition *)_part_coords);
for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++)
ret.push_back((const MEDFileUMeshSplitL1*) *it);
return ret;
_num_coords=loaderl2.getCoordsNum();
if(!mrs || mrs->isNodeNameFieldReading())
_name_coords=loaderl2.getCoordsName();
+ _part_coords=loaderl2.getPartDefOfCoo();
computeRevNum();
}
return l1->getNameField();
}
+/*!
+ * This method returns for a specified relative level \a meshDimRelToMaxExt the part effectively read (if the instance is the result of the read of a file).
+ *
+ * \param [in] meshDimRelToMaxExt - the extended relative level for which the part definition is requested.
+ * \param [in] gt - The input geometric type for which the part definition is requested.
+ * \return the part definition owned by \a this. So no need to deallocate the returned instance.
+ */
+const PartDefinition *MEDFileUMesh::getPartDefAtLevel(int meshDimRelToMaxExt, INTERP_KERNEL::NormalizedCellType gt) const
+{
+ if(meshDimRelToMaxExt==1)
+ return _part_coords;
+ const MEDFileUMeshSplitL1 *l1(getMeshAtLevSafe(meshDimRelToMaxExt));
+ return l1->getPartDef(gt);
+}
+
int MEDFileUMesh::getNumberOfNodes() const
{
const DataArrayDouble *coo=_coords;
return sp->extractNumberFieldOnGeoType(gt);
}
+/*!
+ * This method returns for specified geometric type \a gt the relative level to \a this.
+ * If the relative level is empty an exception will be thrown.
+ */
+int MEDFileUMesh::getRelativeLevOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const
+{
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(gt);
+ int ret((int)cm.getDimension()-getMeshDimension());
+ getMeshAtLevSafe(ret);//To test that returned value corresponds to a valid level.
+ return ret;
+}
+
const MEDFileUMeshSplitL1 *MEDFileUMesh::getMeshAtLevSafe(int meshDimRelToMaxExt) const
{
if(meshDimRelToMaxExt==1)
#include "MEDLoaderDefines.hxx"
#include "MEDFileMeshLL.hxx"
#include "MEDFileUtilities.hxx"
+#include "MEDCouplingPartDefinition.hxx"
#include "MEDFileMeshReadSelector.hxx"
#include <map>
MEDLOADER_EXPORT const DataArrayInt *getNumberFieldAtLevel(int meshDimRelToMaxExt) const;
MEDLOADER_EXPORT const DataArrayInt *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const;
MEDLOADER_EXPORT const DataArrayAsciiChar *getNameFieldAtLevel(int meshDimRelToMaxExt) const;
+ MEDLOADER_EXPORT const PartDefinition *getPartDefAtLevel(int meshDimRelToMaxExt, INTERP_KERNEL::NormalizedCellType gt=INTERP_KERNEL::NORM_ERROR) const;
MEDLOADER_EXPORT int getNumberOfNodes() const;
MEDLOADER_EXPORT bool hasImplicitPart() const;
MEDLOADER_EXPORT int buildImplicitPartIfAny(INTERP_KERNEL::NormalizedCellType gt) const;
MEDLOADER_EXPORT MEDCoupling1GTUMesh *getDirectUndergroundSingleGeoTypeMesh(INTERP_KERNEL::NormalizedCellType gt) const;
MEDLOADER_EXPORT DataArrayInt *extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const;
MEDLOADER_EXPORT DataArrayInt *extractNumberFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const;
+ MEDLOADER_EXPORT int getRelativeLevOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const;
//
MEDLOADER_EXPORT void setFamilyNameAttachedOnId(int id, const std::string& newFamName);
MEDLOADER_EXPORT void setCoords(DataArrayDouble *coords);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_coords;
MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> _name_coords;
mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num_coords;
+ MEDCouplingAutoRefCountObjectPtr<PartDefinition> _part_coords;
};
class MEDFileStructuredMesh : public MEDFileMesh
med_bool changement,transformation;
int curNbOfElem(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_CONNECTIVITY,MED_NODAL,&changement,&transformation));
const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(type));
+ _pd=PartDefinition::New(strt,end,step);
if(!cm.isDynamic())
{
loadPartStaticType(fid,mName,dt,it,mdim,curNbOfElem,geoElt,type,entity,strt,end,step,mrs);
#include "MEDCouplingMemArray.hxx"
#include "MEDCoupling1GTUMesh.hxx"
+#include "MEDCouplingPartDefinition.hxx"
#include "MEDCouplingAutoRefCountObjectPtr.hxx"
#include "NormalizedUnstructuredMesh.hxx"
const DataArrayInt *getFam() const { return _fam; }
const DataArrayInt *getNum() const { return _num; }
const DataArrayAsciiChar *getNames() const { return _names; }
+ const PartDefinition *getPartDef() const { return _pd; }
static void Write(med_idt fid, const std::string& mname, int mdim, const MEDCoupling1GTUMesh *m, const DataArrayInt *fam, const DataArrayInt *num, const DataArrayAsciiChar *names);
private:
MEDFileUMeshPerType();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num;
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam;
MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> _names;
+ MEDCouplingAutoRefCountObjectPtr<PartDefinition> _pd;
med_entity_type _entity;
};
}
/*start*/nMin+1,/*stride*/1,/*count*/1,/*blocksize*/nbNodesToLoad,
/*lastblocksize=useless because count=1*/0,&filter);
MEDmeshNodeCoordinateAdvancedRd(fid,mName.c_str(),dt,it,&filter,_coords->getPointer());
+ _part_coords=PartDefinition::New(nMin,nMax,1);
MEDfilterClose(&filter);
MEDfilterBlockOfEntityCr(fid,nCoords,1,1,MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,
MED_NO_PROFILE,nMin+1,1,1,nbNodesToLoad,0,&filter2);
int sz=v.size();
std::vector<const MEDCoupling1GTUMesh *> ms(sz);
std::vector<const DataArrayInt *> fams(sz),nums(sz);
- std::vector<const DataArrayChar *> names(sz);
+ std::vector<const DataArrayChar *> names(sz);
+ std::vector<const PartDefinition *> pds(sz);
for(int i=0;i<sz;i++)
{
MEDCoupling1GTUMesh *elt(v[i]->getMesh());
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp2=l2.getCoords();
elt->setCoords(tmp2);
ms[i]=elt;
+ pds[i]=v[i]->getPartDef();
}
_m_by_types.assignParts(ms);
+ _m_by_types.assignDefParts(pds);
if(l2.isFamDefinedOnLev(id))
{
for(int i=0;i<sz;i++)
return _names;
}
+const PartDefinition *MEDFileUMeshSplitL1::getPartDef(INTERP_KERNEL::NormalizedCellType gt) const
+{
+ return _m_by_types.getPartDefOfWithoutComputation(gt);
+}
+
void MEDFileUMeshSplitL1::eraseFamilyField()
{
_fam->fillWithZero();
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;
return _m->getAllGeoTypesSorted();
}
-std::vector<MEDCoupling1GTUMesh *> MEDFileUMeshAggregateCompute::getPartsWithoutComputation() const
+std::vector<MEDCoupling1GTUMesh *> MEDFileUMeshAggregateCompute::retrievePartsWithoutComputation() const
{
if(_mp_time<_m_time)
throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getPartsWithoutComputation : the parts require a computation !");
{
if(_mp_time<_m_time)
forceComputationOfPartsFromUMesh();
- return getPartsWithoutComputation();
+ return retrievePartsWithoutComputation();
}
-MEDCoupling1GTUMesh *MEDFileUMeshAggregateCompute::getPartWithoutComputation(INTERP_KERNEL::NormalizedCellType gt) const
+MEDCoupling1GTUMesh *MEDFileUMeshAggregateCompute::retrievePartWithoutComputation(INTERP_KERNEL::NormalizedCellType gt) const
{
- std::vector<MEDCoupling1GTUMesh *> v(getPartsWithoutComputation());
+ std::vector<MEDCoupling1GTUMesh *> v(retrievePartsWithoutComputation());
std::size_t sz(v.size());
for(std::size_t i=0;i<sz;i++)
{
void MEDFileUMeshAggregateCompute::getStartStopOfGeoTypeWithoutComputation(INTERP_KERNEL::NormalizedCellType gt, int& start, int& stop) const
{
start=0; stop=0;
- std::vector<MEDCoupling1GTUMesh *> v(getPartsWithoutComputation());
+ std::vector<MEDCoupling1GTUMesh *> v(retrievePartsWithoutComputation());
std::size_t sz(v.size());
for(std::size_t i=0;i<sz;i++)
{
_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 !");
+}
+
std::size_t MEDFileUMeshAggregateCompute::getTimeOfThis() const
{
if(_mp_time>_m_time)
#include "MEDCouplingUMesh.hxx"
#include "MEDCouplingCMesh.hxx"
#include "MEDCoupling1GTUMesh.hxx"
+#include "MEDCouplingPartDefinition.hxx"
#include "MEDCouplingCurveLinearMesh.hxx"
#include "MEDCouplingAutoRefCountObjectPtr.hxx"
int getIteration() const { return _iteration; }
int getOrder() const { return _order; }
double getTime() const { return _time; }
+ MEDCouplingAutoRefCountObjectPtr<PartDefinition> getPartDefOfCoo() const { return _part_coords; }
std::vector<std::string> getAxisInfoOnMesh(med_idt fid, int mId, const std::string& mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& nstep, int& Mdim);
static int GetMeshIdFromName(med_idt fid, const std::string& mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& dt, int& it, std::string& dtunit1);
static double CheckMeshTimeStep(med_idt fid, const std::string& mname, int nstep, int dt, int it);
int _iteration;
int _order;
double _time;
+ MEDCouplingAutoRefCountObjectPtr<PartDefinition> _part_coords;
};
class MEDFileUMeshL2 : public MEDFileMeshL2
MEDFileUMeshAggregateCompute();
void setName(const std::string& name);
void assignParts(const std::vector< const MEDCoupling1GTUMesh * >& mParts);
+ void assignDefParts(const std::vector<const PartDefinition *>& partDefs);
void assignUMesh(MEDCouplingUMesh *m);
MEDCouplingUMesh *getUmesh() const;
std::vector<MEDCoupling1GTUMesh *> getParts() const;
std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypes() const;
- std::vector<MEDCoupling1GTUMesh *> getPartsWithoutComputation() const;
- MEDCoupling1GTUMesh *getPartWithoutComputation(INTERP_KERNEL::NormalizedCellType gt) const;
+ std::vector<MEDCoupling1GTUMesh *> retrievePartsWithoutComputation() const;
+ MEDCoupling1GTUMesh *retrievePartWithoutComputation(INTERP_KERNEL::NormalizedCellType gt) const;
void getStartStopOfGeoTypeWithoutComputation(INTERP_KERNEL::NormalizedCellType gt, int& start, int& stop) const;
std::size_t getTimeOfThis() const;
std::size_t getHeapMemorySizeWithoutChildren() const;
int getSize() const;
void setCoords(DataArrayDouble *coords);
void forceComputationOfPartsFromUMesh() const;
+ const PartDefinition *getPartDefOfWithoutComputation(INTERP_KERNEL::NormalizedCellType gt) const;
private:
std::size_t getTimeOfParts() const;
std::size_t getTimeOfUMesh() const;
mutable std::size_t _mp_time;
mutable std::size_t _m_time;
mutable MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> _m;
+ mutable std::vector< MEDCouplingAutoRefCountObjectPtr<PartDefinition> > _part_def;
};
class MEDFileUMeshSplitL1 : public RefCountObject
DataArrayInt *getFamilyPartArr(const int *idsBg, const int *idsEnd, bool renum) const;
MEDCouplingUMesh *getWholeMesh(bool renum) const;
std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypes() const;
- std::vector<MEDCoupling1GTUMesh *> getDirectUndergroundSingleGeoTypeMeshes() const { return _m_by_types.getPartsWithoutComputation(); }
- MEDCoupling1GTUMesh *getDirectUndergroundSingleGeoTypeMesh(INTERP_KERNEL::NormalizedCellType gt) const { return _m_by_types.getPartWithoutComputation(gt); }
+ std::vector<MEDCoupling1GTUMesh *> getDirectUndergroundSingleGeoTypeMeshes() const { return _m_by_types.retrievePartsWithoutComputation(); }
+ MEDCoupling1GTUMesh *getDirectUndergroundSingleGeoTypeMesh(INTERP_KERNEL::NormalizedCellType gt) const { return _m_by_types.retrievePartWithoutComputation(gt); }
DataArrayInt *extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const;
DataArrayInt *extractNumberFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const;
std::vector<int> getDistributionOfTypes() const { return _m_by_types.getDistributionOfTypes(); }
const DataArrayInt *getNumberField() const;
const DataArrayAsciiChar *getNameField() const;
const DataArrayInt *getRevNumberField() const;
+ const PartDefinition *getPartDef(INTERP_KERNEL::NormalizedCellType gt) const;
void eraseFamilyField();
void setGroupsFromScratch(const std::vector<const MEDCouplingUMesh *>& ms, std::map<std::string,int>& familyIds,
std::map<std::string, std::vector<std::string> >& groups);
%newobject ParaMEDMEM::MEDFileUMesh::New;
%newobject ParaMEDMEM::MEDFileUMesh::LoadPartOf;
%newobject ParaMEDMEM::MEDFileUMesh::getCoords;
+%newobject ParaMEDMEM::MEDFileUMesh::getPartDefAtLevel;
%newobject ParaMEDMEM::MEDFileUMesh::getGroup;
%newobject ParaMEDMEM::MEDFileUMesh::getGroups;
%newobject ParaMEDMEM::MEDFileUMesh::getFamily;
static MEDFileUMesh *New();
~MEDFileUMesh();
int getSpaceDimension() const throw(INTERP_KERNEL::Exception);
+ int getRelativeLevOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const throw(INTERP_KERNEL::Exception);
//
std::vector<int> getGrpNonEmptyLevels(const std::string& grp) const throw(INTERP_KERNEL::Exception);
std::vector<int> getGrpNonEmptyLevelsExt(const std::string& grp) const throw(INTERP_KERNEL::Exception);
return ret;
}
+ PartDefinition *getPartDefAtLevel(int meshDimRelToMaxExt, INTERP_KERNEL::NormalizedCellType gt=INTERP_KERNEL::NORM_ERROR) const throw(INTERP_KERNEL::Exception)
+ {
+ const PartDefinition *ret(self->getPartDefAtLevel(meshDimRelToMaxExt,gt));
+ if(ret)
+ ret->incrRef();
+ return const_cast<PartDefinition *>(ret);
+ }
+
PyObject *duplicateNodesOnM1Group(const std::string& grpNameM1) throw(INTERP_KERNEL::Exception)
{
DataArrayInt *ret0=0,*ret1=0,*ret2=0;