From: ageay Date: Thu, 21 Apr 2011 10:12:12 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: EndWorkDidier~43 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2bc3365de0b366f6fb7ee3c9daa98cc03690b5c6;p=tools%2Fmedcoupling.git *** empty log message *** --- diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index 3707bef24..27d9aec67 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -63,13 +63,13 @@ void MEDFileFieldLoc::writeLL(med_idt fid) const MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)_geo_type],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT); } -MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, med_idt fid, int profileIt) throw(INTERP_KERNEL::Exception) +MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, med_idt fid, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception) { - return new MEDFileFieldPerMeshPerTypePerDisc(fath,fid,profileIt); + return new MEDFileFieldPerMeshPerTypePerDisc(fath,fid,type,profileIt); } -MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, med_idt fid, int profileIt) throw(INTERP_KERNEL::Exception) -try:_father(fath),_profile_it(profileIt) +MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, med_idt fid, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception) +try:_type(type),_father(fath),_profile_it(profileIt) { INTERP_KERNEL::AutoPtr locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); INTERP_KERNEL::AutoPtr pflname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); @@ -91,6 +91,8 @@ try:_father(fath),_profile_it(profileIt) pflname,MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast(_arr->getPointer())); _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE); _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE); + if(type==ON_CELLS && !_localization.empty()) + setType(ON_GAUSS_PT); } catch(INTERP_KERNEL::Exception& e) { @@ -129,7 +131,12 @@ std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const { - return _father->getType(); + return _type; +} + +void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType) +{ + _type=newType; } INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const @@ -162,9 +169,12 @@ std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const return _localization; } -void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(const MEDFieldFieldGlobs *glob, std::vector& dads, std::vector& pfls, std::vector& locs) const +void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFieldFieldGlobs *glob, std::vector& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const { + if(type!=_type) + return ; dads.push_back(_arr); + geoTypes.push_back(getGeoType()); if(_profile.empty()) pfls.push_back(0); if(_localization.empty()) @@ -186,9 +196,9 @@ void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid) const throw(INTERP_ reinterpret_cast(_arr->getConstPointer())); } -MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception) +MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception) { - return new MEDFileFieldPerMeshPerType(fath,type,geoType); + return new MEDFileFieldPerMeshPerType(fath,geoType); } const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const @@ -196,6 +206,13 @@ const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const return _father; } +void MEDFileFieldPerMeshPerType::getDimension(int& dim) const +{ + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(_geo_type); + int curDim=(int)cm.getDimension(); + dim=std::max(dim,curDim); +} + int MEDFileFieldPerMeshPerType::getIteration() const { return _father->getIteration(); @@ -221,11 +238,6 @@ std::string MEDFileFieldPerMeshPerType::getMeshName() const return _father->getMeshName(); } -TypeOfField MEDFileFieldPerMeshPerType::getType() const -{ - return _type; -} - INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const { return _geo_type; @@ -266,58 +278,31 @@ std::vector MEDFileFieldPerMeshPerType::getLocsReallyUsed() const return ret; } -bool MEDFileFieldPerMeshPerType::isOnNode(int& type, int& number, const DataArrayInt* &arrs) const throw(INTERP_KERNEL::Exception) -{ - if(_type!=ON_NODES) - return false; - type=INTERP_KERNEL::NORM_ERROR; - number=0; - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) - number+=(*it)->getNumberOfTuples(); - return true; -} - -bool MEDFileFieldPerMeshPerType::isOnCell(int dimDimReq, int& type, int& number, const DataArrayInt* &arrs) const throw(INTERP_KERNEL::Exception) +void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFieldFieldGlobs *glob, std::vector& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const { - if(_type!=ON_CELLS) - return false; - type=(int)_geo_type; - number=0; - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) - number+=(*it)->getNumberOfTuples(); - return true; -} - -void MEDFileFieldPerMeshPerType::getFieldAtLevel(TypeOfField type, int meshDim, const MEDFieldFieldGlobs *glob, std::vector& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const -{ - if(type!=_type) - return ; const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(_geo_type); if(meshDim!=(int)cm.getDimension()) return ; for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) - { - geoTypes.push_back(_geo_type); - (*it)->getFieldAtLevel(glob,dads,pfls,locs); - } + (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes); } -MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_type(type),_geo_type(geoType) +MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType) { } -void MEDFileFieldPerMeshPerType::finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception) +void MEDFileFieldPerMeshPerType::finishLoading(med_idt fid, TypeOfField type) throw(INTERP_KERNEL::Exception) { INTERP_KERNEL::NormalizedCellType geoType=getGeoType(); INTERP_KERNEL::AutoPtr pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); INTERP_KERNEL::AutoPtr locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); med_geometry_type mgeoti; - med_entity_type menti=ConvertIntoMEDFileType(getType(),geoType,mgeoti); + med_entity_type menti=ConvertIntoMEDFileType(type,geoType,mgeoti); int nbProfiles=MEDfieldnProfile(fid,getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName); _field_pm_pt_pd.resize(nbProfiles); for(int i=0;i0) { _field_pm_pt.resize(_field_pm_pt.size()+1); - _field_pm_pt.back()=MEDFileFieldPerMeshPerType::New(this,ON_CELLS,typmai2[i]); + _field_pm_pt.back()=MEDFileFieldPerMeshPerType::New(this,typmai2[i]); _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1); - _field_pm_pt.back()->finishLoading(fid); + _field_pm_pt.back()->finishLoading(fid,ON_CELLS); } nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName); if(nbProfile>0) { _field_pm_pt.resize(_field_pm_pt.size()+1); - _field_pm_pt.back()=MEDFileFieldPerMeshPerType::New(this,ON_GAUSS_NE,typmai2[i]); + _field_pm_pt.back()=MEDFileFieldPerMeshPerType::New(this,typmai2[i]); _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1); - _field_pm_pt.back()->finishLoading(fid); + _field_pm_pt.back()->finishLoading(fid,ON_GAUSS_NE); } } int nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName); if(nbProfile>0) { _field_pm_pt.resize(_field_pm_pt.size()+1); - _field_pm_pt.back()=MEDFileFieldPerMeshPerType::New(this,ON_NODES,INTERP_KERNEL::NORM_ERROR); + _field_pm_pt.back()=MEDFileFieldPerMeshPerType::New(this,INTERP_KERNEL::NORM_ERROR); _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1); - _field_pm_pt.back()->finishLoading(fid); + _field_pm_pt.back()->finishLoading(fid,ON_NODES); } } @@ -392,6 +380,12 @@ void MEDFileFieldPerMesh::writeLL(med_idt fid) const throw(INTERP_KERNEL::Except _field_pm_pt[i]->writeLL(fid); } +void MEDFileFieldPerMesh::getDimension(int& dim) const +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + (*it)->getDimension(dim); +} + double MEDFileFieldPerMesh::getTime() const { return _father->getTime(); @@ -569,9 +563,14 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField t std::vector locs,code; std::vector geoTypes; for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) - (*it)->getFieldAtLevel(type,meshDim,glob,dads,pfls,locs,geoTypes); + (*it)->getFieldAtLevel(meshDim,type,glob,dads,pfls,locs,geoTypes); // Sort by types SortArraysPerType(glob,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType); + if(code.empty()) + { + std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << getName() << "\" exists but not with such spatial discretization or such dimension specified !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } // std::vector< MEDCouplingAutoRefCountObjectPtr > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end()); std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end()); @@ -633,46 +632,6 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, cons return 0; } -std::vector MEDFileFieldPerMesh::getDistributionOfTypes(int meshDimRelToMaxExt, int mdim, std::vector& arrs) const throw(INTERP_KERNEL::Exception) -{ - if(meshDimRelToMaxExt>1) - throw INTERP_KERNEL::Exception("Invalid meshDimRelToMaxExt parameter passed ! must be 1 for node and 0,-1,-2,-3 for cells !"); - std::vector ret; - int tmp2,tmp3; - arrs.clear(); - const DataArrayInt *arrTmp=0; - if(meshDimRelToMaxExt==1) - {//On node - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) - if((*it)->isOnNode(tmp2,tmp3,arrTmp)) - { - ret.push_back(-1); - ret.push_back(tmp2); - ret.push_back(tmp3); - if(arrTmp) - arrs.push_back(arrTmp); - } - if(ret.size()>2) - throw INTERP_KERNEL::Exception("Detected on same time step two different discretization ... Should never happen !"); - } - else - { - int dimTarget=mdim+meshDimRelToMaxExt; - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) - if((*it)->isOnCell(dimTarget,tmp2,tmp3,arrTmp)) - { - ret.push_back((int)(*it)->getGeoType()); - ret.push_back(tmp2); - ret.push_back(tmp3); - if(arrTmp) - arrs.push_back(arrTmp); - } - } - if(ret.empty()) - throw INTERP_KERNEL::Exception("No field part correspond to requested meshdimRel !"); - return ret; -} - MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileField1TSWithoutDAS *fath, int meshCsit, int meshIteration, int meshOrder):_mesh_iteration(meshIteration),_mesh_order(meshOrder), _mesh_csit(meshCsit),_father(fath) { @@ -798,6 +757,18 @@ std::vector MEDFieldFieldGlobs::getLocs() const return ret; } +/*! + * This method returns the max dimension of 'this'. + * This method returns -2 if 'this' is empty, -1 if only nodes are defined. + */ +int MEDFileField1TSWithoutDAS::getDimension() const +{ + int ret=-2; + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) + (*it)->getDimension(ret); + return ret; +} + void MEDFileField1TSWithoutDAS::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception) { if(meshDimRelToMax>0) @@ -830,6 +801,24 @@ int MEDFileField1TSWithoutDAS::getMeshOrder() const throw(INTERP_KERNEL::Excepti return _field_per_mesh[0]->getMeshOrder(); } +bool MEDFileField1TSWithoutDAS::isDealingTS(int iteration, int order) const +{ + return iteration==_iteration && order==_order; +} + +std::pair MEDFileField1TSWithoutDAS::getDtIt() const +{ + std::pair p; + fillIteration(p); + return p; +} + +void MEDFileField1TSWithoutDAS::fillIteration(std::pair& p) const +{ + p.first=_iteration; + p.second=_order; +} + void MEDFileField1TSWithoutDAS::finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception) { med_int numdt,numit; @@ -895,21 +884,46 @@ void MEDFileField1TSWithoutDAS::writeLL(med_idt fid) const throw(INTERP_KERNEL:: MEDCouplingFieldDouble *MEDFileField1TSWithoutDAS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFieldFieldGlobs *glob) const throw(INTERP_KERNEL::Exception) { MEDCouplingAutoRefCountObjectPtr mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder()); + return MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm); +} + +MEDCouplingFieldDouble *MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFieldFieldGlobs *glob, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception) +{ CheckMeshDimRel(meshDimRelToMax); if(renumPol==0) { - MEDCouplingAutoRefCountObjectPtr m=mm->getGenMeshAtLevel(meshDimRelToMax,false); + MEDCouplingAutoRefCountObjectPtr m=mesh->getGenMeshAtLevel(meshDimRelToMax,false); int dimRequested=m->getMeshDimension(); //no need to test _field_per_mesh.empty() because geMeshName has already done it return _field_per_mesh[0]->getFieldOnMeshAtLevel(type,dimRequested,glob,m); } + if(renumPol==1) + { + MEDCouplingAutoRefCountObjectPtr m=mesh->getGenMeshAtLevel(meshDimRelToMax,false); + int dimRequested=m->getMeshDimension(); + //no need to test _field_per_mesh.empty() because geMeshName has already done it + MEDCouplingAutoRefCountObjectPtr ret=_field_per_mesh[0]->getFieldOnMeshAtLevel(type,dimRequested,glob,m); + const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax); + if(d) + { + if(d->getNbOfElems()!=m->getNumberOfCells()) + { + std::ostringstream oss; oss << "MEDFileField1TSWithoutDAS::getFieldAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field "; + oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + ret->renumberCells(d->getConstPointer(),true); + } + ret->incrRef(); + return ret; + } else - throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::getFieldAtLevel : unsupported renum policy ! Dealing with policy 0 !"); + throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::getFieldAtLevel : unsupported renum policy ! Dealing with policy 0 and 1 !"); } -MEDCouplingFieldDouble *MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFieldFieldGlobs *glob, const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception) +MEDCouplingFieldDouble *MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFieldFieldGlobs *glob, const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception) { - return _field_per_mesh[0]->getFieldOnMeshAtLevel(type,meshDimRelToMax,glob,mesh); + return 0;//_field_per_mesh[0]->getFieldOnMeshAtLevel(type,0/* tony */,glob,mesh); } MEDFileField1TSWithoutDAS::MEDFileField1TSWithoutDAS(const char *fieldName, int csit, int iteration, int order, @@ -1022,19 +1036,38 @@ std::vector MEDFileField1TS::getLocsReallyUsed() const return getLocsReallyUsed2(); } +/*! + * This method requests underlying file to perform the job, for mesh reading. If the current instance is not coming from a file and has been constructed from scratch + * an exception will be thrown. In this case you should use MEDFileField1TS::getFieldOnMeshAtLevel method instead. + * \b WARNING ! Parameter 'meshDimRelToMax' is relative from read mesh in file that can be different from the field in MED file ! + * It leads that the returned field of this method is always coherent. + */ MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception) { + if(_file_name.empty()) + throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !"); return MEDFileField1TSWithoutDAS::getFieldAtLevel(type,meshDimRelToMax,renumPol,this); } -MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception) +/*! + * \b WARNING, there is a main difference with the two close methods (MEDFileField1TS::getFieldAtLevel and MEDFileField1TS::getFieldOnMeshAtLevel method) ! + * Here the mesh-dimension of 'mesh' is used by this to automatically request the right geoTypes regarding 'type'. + * If no such element fufilled the deduced dimension and 'type' an exception will be thrown. + * It leads that the returned field of this method is always coherent. + */ +MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception) { - return 0;//tony MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(meshDimRelToMaxExt,this,mesh); + return MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(type,renumPol,this,mesh); } -MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMaxExt, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception) +/*! + * This method can be called whatever the mode of instance feeding of this (MED file or from scratch). + * But the parameter ''meshDimRelToMax' is applyied on 'mesh' (like MEDFileField1TS::getFieldAtLevel does). \b WARNING the dim of 'this' can be different from those in 'mesh' ! + * It leads that the returned field of this method is always coherent. + */ +MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception) { - return 0;//tony MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(meshDimRelToMaxExt,this,mesh); + return MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh); } MEDFileFieldMultiTSWithoutDAS *MEDFileFieldMultiTSWithoutDAS::New(med_idt fid, const char *fieldName, int id, const std::vector& infos, int nbOfStep) throw(INTERP_KERNEL::Exception) @@ -1122,6 +1155,73 @@ int MEDFileFieldMultiTSWithoutDAS::getNumberOfTS() const return _time_steps.size(); } +std::vector< std::pair > MEDFileFieldMultiTSWithoutDAS::getIterations() const +{ + int lgth=_time_steps.size(); + std::vector< std::pair > ret(lgth); + for(int i=0;ifillIteration(ret[i]); + return ret; +} + +const MEDFileField1TSWithoutDAS& MEDFileFieldMultiTSWithoutDAS::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception) +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) + if((*it)->isDealingTS(iteration,order)) + return *(*it); + std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepEntry : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n"; + std::vector< std::pair > vp=getIterations(); + for(std::vector< std::pair >::const_iterator it2=vp.begin();it2!=vp.end();it2++) + oss << "(" << (*it2).first << "," << (*it2).second << ") "; + throw INTERP_KERNEL::Exception(oss.str().c_str()); +} + +MEDFileField1TSWithoutDAS& MEDFileFieldMultiTSWithoutDAS::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception) +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_time_steps.begin();it!=_time_steps.end();it++) + if((*it)->isDealingTS(iteration,order)) + return *(*it); + std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepEntry : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n"; + std::vector< std::pair > vp=getIterations(); + for(std::vector< std::pair >::const_iterator it2=vp.begin();it2!=vp.end();it2++) + oss << "(" << (*it2).first << "," << (*it2).second << ") "; + throw INTERP_KERNEL::Exception(oss.str().c_str()); +} + +std::vector MEDFileFieldMultiTSWithoutDAS::getPflsReallyUsed2() const +{ + std::vector ret; + std::set ret2; + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutDAS > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) + { + std::vector tmp=(*it)->getPflsReallyUsed2(); + for(std::vector::const_iterator it2=tmp.begin();it2!=tmp.end();it2++) + if(ret2.find(*it2)==ret2.end()) + { + ret.push_back(*it2); + ret2.insert(*it2); + } + } + return ret; +} + +std::vector MEDFileFieldMultiTSWithoutDAS::getLocsReallyUsed2() const +{ + std::vector ret; + std::set ret2; + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutDAS > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) + { + std::vector tmp=(*it)->getLocsReallyUsed2(); + for(std::vector::const_iterator it2=tmp.begin();it2!=tmp.end();it2++) + if(ret2.find(*it2)==ret2.end()) + { + ret.push_back(*it2); + ret2.insert(*it2); + } + } + return ret; +} + MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception) { return new MEDFileFieldMultiTS(fileName,fieldName); @@ -1135,6 +1235,36 @@ void MEDFileFieldMultiTS::write(const char *fileName, int mode) const throw(INTE writeLL(fid); } +/*! + * Performs the job than MEDFileField1TS::getFieldAtLevel except that (iteration,order) couple should be specified ! + * If such couple does not exist an exception is thrown. + */ +MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception) +{ + const MEDFileField1TSWithoutDAS& myF1TS=getTimeStepEntry(iteration,order); + return myF1TS.getFieldAtLevel(type,meshDimRelToMax,renumPol,this); +} + +/*! + * Performs the job than MEDFileField1TS::getFieldOnMeshAtLevel except that (iteration,order) couple should be specified ! + * If such couple does not exist an exception is thrown. + */ +MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception) +{ + const MEDFileField1TSWithoutDAS& myF1TS=getTimeStepEntry(iteration,order); + return myF1TS.getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh); +} + +/*! + * Performs the job than MEDFileField1TS::getFieldOnMeshAtLevel except that (iteration,order) couple should be specified ! + * If such couple does not exist an exception is thrown. + */ +MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception) +{ + const MEDFileField1TSWithoutDAS& myF1TS=getTimeStepEntry(iteration,order); + return myF1TS.getFieldOnMeshAtLevel(type,renumPol,this,mesh); +} + MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception) try:MEDFileFieldMultiTSWithoutDAS(fieldName),MEDFieldFieldGlobs(fileName) { @@ -1183,36 +1313,12 @@ catch(INTERP_KERNEL::Exception& e) std::vector MEDFileFieldMultiTS::getPflsReallyUsed() const { - std::vector ret; - std::set ret2; - for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutDAS > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) - { - std::vector tmp=(*it)->getPflsReallyUsed2(); - for(std::vector::const_iterator it2=tmp.begin();it2!=tmp.end();it2++) - if(ret2.find(*it2)==ret2.end()) - { - ret.push_back(*it2); - ret2.insert(*it2); - } - } - return ret; + return getPflsReallyUsed2(); } std::vector MEDFileFieldMultiTS::getLocsReallyUsed() const { - std::vector ret; - std::set ret2; - for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutDAS > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) - { - std::vector tmp=(*it)->getLocsReallyUsed2(); - for(std::vector::const_iterator it2=tmp.begin();it2!=tmp.end();it2++) - if(ret2.find(*it2)==ret2.end()) - { - ret.push_back(*it2); - ret2.insert(*it2); - } - } - return ret; + return getLocsReallyUsed2(); } MEDFileFields *MEDFileFields::New(const char *fileName) throw(INTERP_KERNEL::Exception) @@ -1261,11 +1367,35 @@ catch(INTERP_KERNEL::Exception& e) std::vector MEDFileFields::getPflsReallyUsed() const { - return std::vector();//tony + std::vector ret; + std::set ret2; + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutDAS > >::const_iterator it=_fields.begin();it!=_fields.end();it++) + { + std::vector tmp=(*it)->getPflsReallyUsed2(); + for(std::vector::const_iterator it2=tmp.begin();it2!=tmp.end();it2++) + if(ret2.find(*it2)==ret2.end()) + { + ret.push_back(*it2); + ret2.insert(*it2); + } + } + return ret; } std::vector MEDFileFields::getLocsReallyUsed() const { - return std::vector();//tony + std::vector ret; + std::set ret2; + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutDAS > >::const_iterator it=_fields.begin();it!=_fields.end();it++) + { + std::vector tmp=(*it)->getLocsReallyUsed2(); + for(std::vector::const_iterator it2=tmp.begin();it2!=tmp.end();it2++) + if(ret2.find(*it2)==ret2.end()) + { + ret.push_back(*it2); + ret2.insert(*it2); + } + } + return ret; } diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index 284438580..20007d42c 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -75,7 +75,7 @@ namespace ParaMEDMEM class MEDFileFieldPerMeshPerTypePerDisc : public RefCountObject, public MEDFileWritable { public: - static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerType *fath, med_idt fid, int profileIt) throw(INTERP_KERNEL::Exception); + static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerType *fath, med_idt fid, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception); void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception); const MEDFileFieldPerMeshPerType *getFather() const; int getIteration() const; @@ -84,17 +84,20 @@ namespace ParaMEDMEM std::string getName() const; std::string getMeshName() const; TypeOfField getType() const; + void setType(TypeOfField newType); INTERP_KERNEL::NormalizedCellType getGeoType() const; int getNumberOfComponents() const; int getNumberOfTuples() const; const std::vector& getInfo() const; std::string getProfile() const; std::string getLocalization() const; - void getFieldAtLevel(const MEDFieldFieldGlobs *glob, std::vector& dads, std::vector& pfls, std::vector& locs) const; + void getFieldAtLevel(TypeOfField type, const MEDFieldFieldGlobs *glob, std::vector& dads, std::vector& pfls, std::vector& locs, + std::vector& geoTypes) const; private: - MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, med_idt fid, int profileIt) throw(INTERP_KERNEL::Exception); + MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, med_idt fid, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception); private: + TypeOfField _type; MEDFileFieldPerMeshPerType *_father; MEDCouplingAutoRefCountObjectPtr< DataArrayDouble > _arr; int _nval; @@ -106,31 +109,28 @@ namespace ParaMEDMEM class MEDFileFieldPerMeshPerType : public RefCountObject, public MEDFileWritable { public: - static MEDFileFieldPerMeshPerType *New(MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception); + static MEDFileFieldPerMeshPerType *New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception); const MEDFileFieldPerMesh *getFather() const; - void finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception); + void finishLoading(med_idt fid, TypeOfField type) throw(INTERP_KERNEL::Exception); void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception); + void getDimension(int& dim) const; int getIteration() const; int getOrder() const; double getTime() const; std::string getName() const; std::string getMeshName() const; - TypeOfField getType() const; INTERP_KERNEL::NormalizedCellType getGeoType() const; int getNumberOfComponents() const; const std::vector& getInfo() const; std::vector getPflsReallyUsed() const; std::vector getLocsReallyUsed() const; - bool isOnNode(int& type, int& number, const DataArrayInt* &arrs) const throw(INTERP_KERNEL::Exception); - bool isOnCell(int dimDimReq, int& type, int& number, const DataArrayInt* &arrs) const throw(INTERP_KERNEL::Exception); - void getFieldAtLevel(TypeOfField type, int meshDim, const MEDFieldFieldGlobs *glob, std::vector& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const; + void getFieldAtLevel(int meshDim, TypeOfField type, const MEDFieldFieldGlobs *glob, std::vector& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const; static med_entity_type ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType); private: - MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception); + MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception); private: MEDFileFieldPerMesh *_father; std::vector< MEDCouplingAutoRefCountObjectPtr > _field_pm_pt_pd; - TypeOfField _type; INTERP_KERNEL::NormalizedCellType _geo_type; }; @@ -140,6 +140,7 @@ namespace ParaMEDMEM static MEDFileFieldPerMesh *New(MEDFileField1TSWithoutDAS *fath, int meshCsit, int meshIteration, int meshOrder); void finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception); void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception); + void getDimension(int& dim) const; double getTime() const; int getIteration() const; int getOrder() const; @@ -152,7 +153,6 @@ namespace ParaMEDMEM const std::vector& getInfo() const; std::vector getPflsReallyUsed() const; std::vector getLocsReallyUsed() const; - std::vector getDistributionOfTypes(int meshDimRelToMax, int mdim, std::vector& arrs) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDim, const MEDFieldFieldGlobs *glob, const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception); private: MEDCouplingFieldDouble *finishField(TypeOfField type, const MEDFieldFieldGlobs *glob, @@ -200,6 +200,7 @@ namespace ParaMEDMEM class MEDFileField1TSWithoutDAS : public RefCountObject, public MEDFileWritable { public: + int getDimension() const; int getIteration() const { return _iteration; } int getOrder() const { return _order; } double getTime() const { return _dt; } @@ -209,6 +210,9 @@ namespace ParaMEDMEM int getMeshIteration() const throw(INTERP_KERNEL::Exception); int getMeshOrder() const throw(INTERP_KERNEL::Exception); int getNumberOfComponents() const { return _infos.size(); } + bool isDealingTS(int iteration, int order) const; + std::pair getDtIt() const; + void fillIteration(std::pair& p) const; const std::vector& getInfo() const { return _infos; } // static MEDFileField1TSWithoutDAS *New(const char *fieldName, int csit, int iteration, int order, const std::vector& infos); @@ -217,9 +221,10 @@ namespace ParaMEDMEM std::vector getPflsReallyUsed2() const; std::vector getLocsReallyUsed2() const; static void CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception); - protected: + public: MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFieldFieldGlobs *glob) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFieldFieldGlobs *glob, const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFieldFieldGlobs *glob, const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFieldFieldGlobs *glob, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception); protected: MEDFileField1TSWithoutDAS(const char *fieldName, int csit, int iteration, int order, const std::vector& infos); protected: @@ -243,8 +248,8 @@ namespace ParaMEDMEM void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); void setFileName(const char *fileName); MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); private: std::vector getPflsReallyUsed() const; std::vector getLocsReallyUsed() const; @@ -256,7 +261,13 @@ namespace ParaMEDMEM public: static MEDFileFieldMultiTSWithoutDAS *New(med_idt fid, const char *fieldName, int id, const std::vector& infos, int nbOfStep) throw(INTERP_KERNEL::Exception); int getNumberOfTS() const; + std::vector< std::pair > getIterations() const; + public: + std::vector getPflsReallyUsed2() const; + std::vector getLocsReallyUsed2() const; protected: + const MEDFileField1TSWithoutDAS& getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception); + MEDFileField1TSWithoutDAS& getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception); const std::vector& getInfo() const throw(INTERP_KERNEL::Exception); std::string getMeshName() const throw(INTERP_KERNEL::Exception); std::string getDtUnit() const throw(INTERP_KERNEL::Exception); @@ -278,6 +289,9 @@ namespace ParaMEDMEM public: static MEDFileFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception); void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); private: std::vector getPflsReallyUsed() const; std::vector getLocsReallyUsed() const; diff --git a/src/MEDLoader/Swig/MEDLoader.i b/src/MEDLoader/Swig/MEDLoader.i index 6006d787b..9f969e5d0 100644 --- a/src/MEDLoader/Swig/MEDLoader.i +++ b/src/MEDLoader/Swig/MEDLoader.i @@ -75,6 +75,8 @@ using namespace ParaMEDMEM; %newobject ParaMEDMEM::MEDFileFields::New; %newobject ParaMEDMEM::MEDFileFieldMultiTS::New; +%newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldAtLevel; +%newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldOnMeshAtLevel; %newobject ParaMEDMEM::MEDFileField1TS::New; %newobject ParaMEDMEM::MEDFileField1TS::getFieldAtLevel; %newobject ParaMEDMEM::MEDFileField1TS::getFieldOnMeshAtLevel; @@ -450,12 +452,25 @@ namespace ParaMEDMEM class MEDFileField1TSWithoutDAS : public RefCountObject { public: + int getDimension() const; int getIteration() const; int getOrder() const; std::string getName(); std::string getMeshName(); int getNumberOfComponents() const; + bool isDealingTS(int iteration, int order) const; const std::vector& getInfo() const; + %extend + { + PyObject *getDtIt() const + { + std::pair res=self->getDtIt(); + PyObject *elt=PyTuple_New(2); + PyTuple_SetItem(elt,0,SWIG_From_int(res.first)); + PyTuple_SetItem(elt,1,SWIG_From_int(res.second)); + return elt; + } + } }; class MEDFileField1TS : public MEDFileField1TSWithoutDAS, public MEDFieldFieldGlobs, public MEDFileWritable @@ -464,7 +479,7 @@ namespace ParaMEDMEM static MEDFileField1TS *New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); }; @@ -472,6 +487,23 @@ namespace ParaMEDMEM { public: int getNumberOfTS() const; + %extend + { + PyObject *getIterations() const + { + std::vector< std::pair > res=self->getIterations(); + PyObject *ret=PyList_New(res.size()); + int rk=0; + for(std::vector< std::pair >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++) + { + PyObject *elt=PyTuple_New(2); + PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first)); + PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second)); + PyList_SetItem(ret,rk,elt); + } + return ret; + } + } }; class MEDFileFieldMultiTS : public MEDFileFieldMultiTSWithoutDAS, public MEDFieldFieldGlobs, public MEDFileWritable @@ -479,6 +511,9 @@ namespace ParaMEDMEM public: static MEDFileFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception); void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); }; class MEDFileFields : public RefCountObject, public MEDFieldFieldGlobs, public MEDFileWritable diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index ab4c0bacc..ff00b9722 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -356,6 +356,10 @@ class MEDLoaderTest(unittest.TestCase): mm.write("Pyfile13_bis.med",2) ff=MEDFileFieldMultiTS.New("Pyfile13.med","MyFirstFieldOnGaussPoint") ff.write("Pyfile13_bis.med",0) + ff=MEDFileField1TS.New("Pyfile13.med","MyFirstFieldOnGaussPoint",1,5) + f=ff.getFieldAtLevel(ON_GAUSS_PT,0) + f2=MEDLoader.ReadFieldGauss("Pyfile13.med",'2DMesh_2',0,'MyFirstFieldOnGaussPoint',1,5) + self.assertTrue(f.isEqual(f2,1e-12,1e-12)) pass #gauss NE @@ -364,6 +368,10 @@ class MEDLoaderTest(unittest.TestCase): mm.write("Pyfile14_bis.med",2) ff=MEDFileFieldMultiTS.New("Pyfile14.med","MyFieldOnGaussNE") ff.write("Pyfile14_bis.med",0) + ff=MEDFileField1TS.New("Pyfile14.med","MyFieldOnGaussNE",1,5) + f=ff.getFieldAtLevel(ON_GAUSS_NE,0) + f2=MEDLoader.ReadFieldGaussNE("Pyfile14.med",'2DMesh_2',0,"MyFieldOnGaussNE",1,5) + self.assertTrue(f.isEqual(f2,1e-12,1e-12)) pass # MEDField get/set on pointe.med