return const_cast<DataArrayDouble *>(ret);
}
+void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startTupleId, int& startEntryId, std::vector< std::pair<std::pair<int,int>,std::pair<int,int> > >& entries, double *vals) const
+{
+ int endTupleId=startTupleId+_arr->getNumberOfTuples();
+ entries[startEntryId]=std::pair<std::pair<int,int> ,std::pair<int,int> >(std::pair<int,int>((int)getGeoType(),discId),std::pair<int,int>(startTupleId,endTupleId));
+ std::copy(_arr->begin(),_arr->end(),vals+startTupleId*_arr->getNumberOfComponents());
+ startEntryId++;
+ startTupleId=endTupleId;
+}
+
void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
{
TypeOfField type=getType();
return _father->getMeshName();
}
+void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
+ {
+ globalSz+=(*it)->getUndergroundDataArray()->getNumberOfTuples();
+ }
+ nbOfEntries+=(int)_field_pm_pt_pd.size();
+}
+
INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
{
return _geo_type;
return _field_pm_pt_pd[0]->getUndergroundDataArray();
}
+void MEDFileFieldPerMeshPerType::fillValues(int& startTupleId, int& startEntryId, std::vector< std::pair<std::pair<int,int>,std::pair<int,int> > >& entries, double *vals) const
+{
+ int i=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
+ {
+ (*it)->fillValues(i,startTupleId,startEntryId,entries,vals);
+ }
+}
+
MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
{
}
return _field_pm_pt[0]->getUndergroundDataArray();
}
+DataArrayDouble *MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<int,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
+{
+ int globalSz=0;
+ int nbOfEntries=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ {
+ (*it)->getSizes(globalSz,nbOfEntries);
+ }
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
+ int nbOfComponents=_father->getInfo().size();
+ ret->alloc(globalSz,nbOfComponents);
+ ret->setInfoOnComponents(_father->getInfo());
+ entries.resize(nbOfEntries);
+ double *pt=ret->getPointer();
+ globalSz=0;
+ nbOfEntries=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ {
+ (*it)->fillValues(globalSz,nbOfEntries,entries,pt);
+ }
+ ret->incrRef();
+ return ret;
+}
+
int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
{
int i=0;
if(!arr)
throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::copyTinyInfoFrom : no array set !");
_dt=field->getTime(_iteration,_order);
- _infos=arr->getInfoOnComponent();
+ _infos=arr->getInfoOnComponents();
}
std::string MEDFileField1TSWithoutDAS::getMeshName() const throw(INTERP_KERNEL::Exception)
}
/*!
- * This method retrieves direct access to the underground ParaMEDMEM::DataArrayDouble instance.
+ * This method retrieves direct access to the underground ParaMEDMEM::DataArrayDouble instance. The returned array is not a newly
+ * created array so it should \b not be dealed by the caller.
* This method allows to the user a direct access to the values.
* This method throws an exception if 'this' is composed with multiple arrays due to cell type splitting (field on cells and field on gauss points).
*/
return _field_per_mesh[0]->getUndergroundDataArray();
}
+/*!
+ * This method returns an array that the caller must deal with (contrary to those returned by MEDFileField1TSWithoutDAS::getUndergroundDataArray method).
+ * The returned array is the result of the aggregation of all sub arrays stored in the MED file. So to allow the caller to select the output param
+ * 'entries' is returned. This output param is a vector of a pair of 2 pairs. The first pair of pair informs of the geometric type it refers to and the discretization
+ * id attached to it. The second pair of pair precise the range [begin,end) into the returned array.
+ * This method makes the hypothesis that the field lies only on one mesh. If it is not the case an exception will be thrown.
+ */
+DataArrayDouble *MEDFileField1TSWithoutDAS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<int,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
+{
+ if(_field_per_mesh.size()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
+ if(_field_per_mesh[0]==0)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::getUndergroundDataArrayExt : no field specified !");
+ return _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
+}
+
MEDFileField1TSWithoutDAS::MEDFileField1TSWithoutDAS(const char *fieldName, int csit, int iteration, int order,
const std::vector<std::string>& infos):_name(fieldName),_infos(infos),_csit(csit),_iteration(iteration),_order(order)
{
return _time_steps[0]->getInfo();
}
+/*!
+ * See doc at MEDFileField1TSWithoutDAS::getUndergroundDataArray
+ */
+DataArrayDouble *MEDFileFieldMultiTSWithoutDAS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
+{
+ return getTimeStepEntry(iteration,order).getUndergroundDataArray();
+}
+
+/*!
+ * See doc at MEDFileField1TSWithoutDAS::getUndergroundDataArrayExt
+ */
+DataArrayDouble *MEDFileFieldMultiTSWithoutDAS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<int,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
+{
+ return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
+}
+
std::string MEDFileFieldMultiTSWithoutDAS::getMeshName() const throw(INTERP_KERNEL::Exception)
{
if(_time_steps.empty())
const DataArrayDouble *arr=field->getArray();
if(!arr)
throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutDAS::copyTinyInfoFrom : no array set !");
- _infos=arr->getInfoOnComponent();
+ _infos=arr->getInfoOnComponents();
}
void MEDFileFieldMultiTSWithoutDAS::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field) const throw(INTERP_KERNEL::Exception)
const DataArrayDouble *arr=field->getArray();
if(!arr)
throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutDAS::checkCoherencyOfTinyInfo : no array set !");
- if(_infos!=arr->getInfoOnComponent())
+ if(_infos!=arr->getInfoOnComponents())
{
std::ostringstream oss; oss << MSG << "components ! should be \"";
std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
oss << " But compo in input fields are : ";
- std::vector<std::string> tmp=arr->getInfoOnComponent();
+ std::vector<std::string> tmp=arr->getInfoOnComponents();
std::copy(tmp.begin(),tmp.end(),std::ostream_iterator<std::string>(oss,", "));
oss << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
void getFieldAtLevel(TypeOfField type, const MEDFieldFieldGlobsReal *glob, std::vector<const DataArrayDouble *>& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs,
std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const;
DataArrayDouble *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception);
+ void fillValues(int discId, int& startTupleId, int& startEntryId, std::vector< std::pair<std::pair<int,int>,std::pair<int,int> > >& entries, double *vals) const;
static int ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception);
private:
MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, med_idt fid, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception);
double getTime() const;
std::string getName() const;
std::string getMeshName() const;
+ void getSizes(int& globalSz, int& nbOfEntries) const;
INTERP_KERNEL::NormalizedCellType getGeoType() const;
int getNumberOfComponents() const;
const std::vector<std::string>& getInfo() const;
std::vector<std::string> getLocsReallyUsed() const;
void getFieldAtLevel(int meshDim, TypeOfField type, const MEDFieldFieldGlobsReal *glob, std::vector<const DataArrayDouble *>& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const;
DataArrayDouble *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception);
+ void fillValues(int& startTupleId, int& startEntryId, std::vector< std::pair<std::pair<int,int>,std::pair<int,int> > >& entries, double *vals) const;
static med_entity_type ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType);
private:
std::vector<int> addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDFieldFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception);
DataArrayDouble *getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFieldFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception);
DataArrayDouble *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<int,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
private:
int addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type);
MEDCouplingFieldDouble *finishField(TypeOfField type, const MEDFieldFieldGlobsReal *glob,
MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFieldFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum) const throw(INTERP_KERNEL::Exception);
DataArrayDouble *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFieldFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception);
DataArrayDouble *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<int,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
protected:
int addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
int getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception);
std::vector< std::pair<int,int> > getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception);
std::string getMeshName() const throw(INTERP_KERNEL::Exception);
const std::vector<std::string>& getInfo() const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<int,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
public:
std::vector<std::string> getPflsReallyUsed2() const;
std::vector<std::string> getLocsReallyUsed2() const;
int mid=MEDFileUMeshL2::GetMeshIdFromName(fid,mName,meshType,dummy0,dummy1,dummy2);
if(meshType!=UNSTRUCTURED)
{
- std::ostringstream oss; oss << "Trying to load as unstructured an existing mesh with name '" << mName << "' !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ std::ostringstream oss; oss << "Trying to load as unstructured an existing mesh with name '" << mName << "' !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
}
loaderl2.loadAll(fid,mid,mName,dt,it);
int lev=loaderl2.getNumberOfLevels();
return ret;
}
+std::vector< std::pair<std::string,std::string> > MEDLoader::GetComponentsNamesOfField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+{
+ CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ med_int nbFields=MEDnField(fid);
+ std::vector<std::string> fields(nbFields);
+ med_field_type typcha;
+ for(int i=0;i<nbFields;i++)
+ {
+ med_int ncomp=MEDfieldnComponent(fid,i+1);
+ INTERP_KERNEL::AutoPtr<char> comp=new char[ncomp*MED_SNAME_SIZE+1];
+ INTERP_KERNEL::AutoPtr<char> unit=new char[ncomp*MED_SNAME_SIZE+1];
+ INTERP_KERNEL::AutoPtr<char> dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
+ med_int nbPdt;
+ med_bool localmesh;
+ INTERP_KERNEL::AutoPtr<char> maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+ MEDfieldInfo(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt);
+ std::string meshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE);
+ std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1);
+ if(curFieldName==fieldName)
+ {
+ std::vector< std::pair<std::string,std::string> > ret(ncomp);
+ for(int j=0;j<ncomp;j++)
+ ret[j]=std::pair<std::string,std::string>(MEDLoaderBase::buildStringFromFortran(((char *)comp)+j*MED_SNAME_SIZE,MED_SNAME_SIZE),
+ MEDLoaderBase::buildStringFromFortran(((char *)unit)+j*MED_SNAME_SIZE,MED_SNAME_SIZE));
+ return ret;
+ }
+ fields[i]=curFieldName;
+ }
+ std::ostringstream oss; oss << "MEDLoader::GetComponentsNamesOfField : no such field \"" << fieldName << "\" in file \"" << fileName << "\" !" << std::endl;
+ oss << "Possible field names are : " << std::endl;
+ std::copy(fields.begin(),fields.end(),std::ostream_iterator<std::string>(oss," "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
+/*!
+ * Given a 'fileName' and a 'meshName' this method returns global information concerning this mesh.
+ * It returns, in this order :
+ * - number of cells sorted by dimension and by geometry type. The first entry in the vector is the maximal dimension, the 2nd in the vector is the maximal dimension-1...
+ * - the mesh dimension
+ * - the space dimension
+ * - the number of nodes
+ */
+std::vector< std::vector< std::pair<int,int> > > MEDLoader::GetUMeshGlobalInfo(const char *fileName, const char *meshName, int &meshDim, int& spaceDim, int& numberOfNodes) throw(INTERP_KERNEL::Exception)
+{
+ CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ std::set<int> poss;
+ char nommaa[MED_NAME_SIZE+1];
+ char maillage_description[MED_COMMENT_SIZE+1];
+ med_mesh_type type_maillage;
+ std::string trueMeshName;
+ med_int meshId=MEDLoaderNS::getIdFromMeshName(fid,meshName,trueMeshName);
+ INTERP_KERNEL::AutoPtr<char> dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
+ med_sorting_type sortingType;
+ med_int nstep;
+ med_axis_type axisType;
+ int naxis=MEDmeshnAxis(fid,meshId);
+ INTERP_KERNEL::AutoPtr<char> axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
+ MEDmeshInfo(fid,meshId,nommaa,&spaceDim,&meshDim,&type_maillage,maillage_description,dt_unit,&sortingType,&nstep,&axisType,axisname,axisunit);
+ if(type_maillage!=MED_UNSTRUCTURED_MESH)
+ {
+ std::ostringstream oss; oss << "MEDLoader::GetUMeshGlobalInfo : Mesh \""<< meshName << "\" in file \"" << fileName;
+ oss << "\" exists but it is not an unstructured mesh ! This method is not relevant for mesh types that are not unstructured !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ // limitation
+ if(nstep!=1)
+ throw INTERP_KERNEL::Exception("MEDLoader::GetUMeshGlobalInfo : multisteps on mesh not managed !");
+ med_int numdt,numit;
+ med_float dt;
+ MEDmeshComputationStepInfo(fid,nommaa,1,&numdt,&numit,&dt);
+ // endlimitation
+ std::vector<int> dims;
+ std::vector< std::pair<int,int> > geoTypes;
+ med_bool changement,transformation;
+ for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
+ {
+ med_geometry_type curMedType=typmai[i];
+ int curNbOfElemM=MEDmeshnEntity(fid,nommaa,numdt,numit,MED_CELL,curMedType,MED_CONNECTIVITY,MED_NODAL,&changement,&transformation);
+ if(curNbOfElemM>0)
+ {
+ INTERP_KERNEL::NormalizedCellType typp=typmai2[i];
+ int mdimCell=INTERP_KERNEL::CellModel::GetCellModel(typp).getDimension();
+ dims.push_back(mdimCell);
+ geoTypes.push_back(std::pair<int,int>((int)typp,curNbOfElemM));
+ }
+ }
+ int maxLev=*std::max_element(dims.begin(),dims.end());
+ int lowLev=*std::min_element(dims.begin(),dims.end());
+ int nbOfLevels=maxLev-lowLev+1;
+ std::vector< std::vector< std::pair<int,int> > > ret(nbOfLevels);
+ for(std::size_t i=0;i<dims.size();i++)
+ {
+ ret[maxLev-dims[i]].push_back(geoTypes[i]);
+ }
+ numberOfNodes=MEDmeshnEntity(fid,nommaa,numdt,numit,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation);
+ return ret;
+}
+
std::vector<std::string> MEDLoader::GetMeshNamesOnField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
{
CheckFileForRead(fileName);
static void setTooLongStrPolicy(int val) throw(INTERP_KERNEL::Exception);
static void CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception);
static std::vector<std::string> GetMeshNames(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static std::vector< std::vector< std::pair<int,int> > > GetUMeshGlobalInfo(const char *fileName, const char *meshName, int &meshDim, int& spaceDim, int& numberOfNodes) throw(INTERP_KERNEL::Exception);
+ static std::vector< std::pair<std::string,std::string> > GetComponentsNamesOfField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
static std::vector<std::string> GetMeshNamesOnField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
static std::vector<std::string> GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
static std::vector<std::string> GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
%newobject ParaMEDMEM::MEDFileField1TS::getFieldAtTopLevel;
%newobject ParaMEDMEM::MEDFileField1TS::getFieldOnMeshAtLevel;
%newobject ParaMEDMEM::MEDFileField1TS::getFieldAtLevelOld;
+%newobject ParaMEDMEM::MEDFileFieldMultiTSWithoutDAS::getUndergroundDataArray;
%newobject ParaMEDMEM::MEDFileData::New;
%newobject ParaMEDMEM::MEDFileData::getMeshes;
}
return ret;
}
+ static PyObject *GetComponentsNamesOfField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair<std::string,std::string> > res=MEDLoader::GetComponentsNamesOfField(fileName,fieldName);
+ PyObject *ret=PyList_New(res.size());
+ int rk=0;
+ for(std::vector< std::pair<std::string,std::string> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
+ {
+ PyObject *elt=PyTuple_New(2);
+ PyTuple_SetItem(elt,0,PyString_FromString((*iter).first.c_str()));
+ PyTuple_SetItem(elt,1,PyString_FromString((*iter).second.c_str()));
+ PyList_SetItem(ret,rk,elt);
+ }
+ return ret;
+ }
+ static PyObject *GetUMeshGlobalInfo(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception)
+ {
+ int meshDim,spaceDim,numberOfNodes;
+ std::vector< std::vector< std::pair<int,int> > > res=MEDLoader::GetUMeshGlobalInfo(fileName,meshName,meshDim,spaceDim,numberOfNodes);
+ PyObject *ret=PyTuple_New(4);
+ PyObject *elt0=PyList_New(res.size());
+ int i=0;
+ for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=res.begin();it!=res.end();it++,i++)
+ {
+ const std::vector< std::pair<int,int> >&obj2=(*it);
+ int j=0;
+ PyObject *elt1=PyList_New(obj2.size());
+ for(std::vector< std::pair<int,int> >::const_iterator it2=obj2.begin();it2!=obj2.end();it2++,j++)
+ {
+ PyObject *elt2=PyTuple_New(2);
+ PyTuple_SetItem(elt2,0,SWIG_From_int((*it2).first));
+ PyTuple_SetItem(elt2,1,SWIG_From_int((*it2).second));
+ PyList_SetItem(elt1,j,elt2);
+ }
+ PyList_SetItem(elt0,i,elt1);
+ }
+ PyTuple_SetItem(ret,0,elt0);
+ PyTuple_SetItem(ret,1,SWIG_From_int(meshDim));
+ PyTuple_SetItem(ret,2,SWIG_From_int(spaceDim));
+ PyTuple_SetItem(ret,3,SWIG_From_int(numberOfNodes));
+ return ret;
+ }
static PyObject *ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax,
const char *fieldName, PyObject *liIts) throw(INTERP_KERNEL::Exception)
{
ret->incrRef();
return ret;
}
+
+ PyObject *getUndergroundDataArrayExt() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair<std::pair<int,int>,std::pair<int,int> > > elt1Cpp;
+ DataArrayDouble *elt0=self->getUndergroundDataArrayExt(elt1Cpp);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(elt0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ std::size_t sz=elt1Cpp.size();
+ PyObject *elt=PyList_New(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ PyObject *elt1=PyTuple_New(2);
+ PyObject *elt2=PyTuple_New(2);
+ PyTuple_SetItem(elt2,0,SWIG_From_int(elt1Cpp[i].first.first));
+ PyTuple_SetItem(elt2,1,SWIG_From_int(elt1Cpp[i].first.second));
+ PyObject *elt3=PyTuple_New(2);
+ PyTuple_SetItem(elt3,0,SWIG_From_int(elt1Cpp[i].second.first));
+ PyTuple_SetItem(elt3,1,SWIG_From_int(elt1Cpp[i].second.second));
+ PyTuple_SetItem(elt1,0,elt2);
+ PyTuple_SetItem(elt1,1,elt3);
+ PyList_SetItem(elt,i,elt1);
+ }
+ PyTuple_SetItem(ret,1,elt);
+ return ret;
+ }
}
};
}
return ret2;
}
+ DataArrayDouble *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayDouble *ret=self->getUndergroundDataArray(iteration,order);
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+ PyObject *getUndergroundDataArrayExt(int iteration, int order) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair<std::pair<int,int>,std::pair<int,int> > > elt1Cpp;
+ DataArrayDouble *elt0=self->getUndergroundDataArrayExt(iteration,order,elt1Cpp);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(elt0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ std::size_t sz=elt1Cpp.size();
+ PyObject *elt=PyList_New(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ PyObject *elt1=PyTuple_New(2);
+ PyObject *elt2=PyTuple_New(2);
+ PyTuple_SetItem(elt2,0,SWIG_From_int(elt1Cpp[i].first.first));
+ PyTuple_SetItem(elt2,1,SWIG_From_int(elt1Cpp[i].first.second));
+ PyObject *elt3=PyTuple_New(2);
+ PyTuple_SetItem(elt3,0,SWIG_From_int(elt1Cpp[i].second.first));
+ PyTuple_SetItem(elt3,1,SWIG_From_int(elt1Cpp[i].second.second));
+ PyTuple_SetItem(elt1,0,elt2);
+ PyTuple_SetItem(elt1,1,elt3);
+ PyList_SetItem(elt,i,elt1);
+ }
+ PyTuple_SetItem(ret,1,elt);
+ return ret;
+ }
}
};
mbis=mm.getMeshAtLevel(0)
m.setName(mm.getName()) ; m.setDescription(mm.getDescription())
self.assertTrue(m.isEqual(mbis,1e-12));
+ #
+ self.assertEqual(([[(3, 2), (4, 1), (5, 8)], [(1, 2), (2, 1)], [(0, 4)]], 2, 2, 9),MEDLoader.GetUMeshGlobalInfo(outFileName,"MyFirstMEDCouplingMEDmesh"))
pass
# this test is the testMEDMesh3 except that permutation is dealed here
mm.write("Pyfile19_bis.med",2)
ff=MEDFileFieldMultiTS.New("Pyfile19.med","VFieldOnNodes")
ff.write("Pyfile19_bis.med",0)
+ self.assertEqual([('tyty', 'mm'), ('uiop', 'MW')],MEDLoader.GetComponentsNamesOfField("Pyfile19_bis.med","VFieldOnNodes"))
pass
#gauss points
ff1.setTime(2.3,3,4)
ti,itt,orr=ff1.getTime()
self.assertEqual(3,itt); self.assertEqual(4,orr); self.assertAlmostEqual(2.3,ti,14);
+ da,infos=ff1.getUndergroundDataArrayExt()
+ self.assertTrue(da.isEqual(f2.getArray(),1e-12))
+ self.assertEqual([((3, 0), (0, 2)), ((4, 0), (2, 4)), ((6, 0), (4, 5)), ((5, 0), (5, 6))],infos)
#
fname="Pyfile26.med"
f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1();
ff1.write(fname,0)
f2=MEDLoader.ReadFieldGaussNE(fname,f1.getMesh().getName(),0,f1.getName(),f1.getTime()[1],f1.getTime()[2])
self.assertTrue(f1.isEqual(f2,1e-12,1e-12))
+ da,infos=ff1.getUndergroundDataArrayExt()
+ self.assertTrue(da.isEqual(f2.getArray(),1e-12))
+ self.assertEqual([((3, 0), (0, 6)), ((4, 0), (6, 14)), ((6, 0), (14, 20))],infos)
#
fname="Pyfile28.med"
f1=MEDLoaderDataForTest.buildVecFieldOnGauss_2_Simpler();
self.assertEqual(6,loc1.getNumberOfPointsInCells())
self.assertEqual(3,loc1.getNumberOfGaussPoints())
self.assertEqual(2,loc1.getDimension())
+ da,infos=ff2.getUndergroundDataArrayExt()
+ self.assertTrue(da.isEqual(f2.getArray(),1e-12))
+ self.assertEqual(53,da.getNumberOfTuples())
+ self.assertEqual([((3, 0), (0, 18)), ((3, 1), (18, 30)), ((3, 2), (30, 36)), ((4, 0), (36, 42)), ((4, 1), (42, 44)), ((6, 0), (44, 53))],infos)
#
pass
pass
unittest.main()
+