From 16dfbb7400d37fa8be08fcbeb921e9897da9da5f Mon Sep 17 00:00:00 2001 From: ageay Date: Fri, 1 Jul 2011 14:36:36 +0000 Subject: [PATCH] OK for profiles on GAUSS_NE. --- src/MEDLoader/MEDFileField.cxx | 77 +++++++++++++++++----------- src/MEDLoader/MEDFileField.hxx | 14 ++--- src/MEDLoader/Swig/MEDLoaderTest3.py | 57 +++++++++++++++----- 3 files changed, 98 insertions(+), 50 deletions(-) diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index 3ad113321..d958ff5ae 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -163,7 +163,7 @@ void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int offset, int nbO } } -void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(const char *pflName, const DataArrayInt *globIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception) +void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(const char *pflName, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, const DataArrayInt *globIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception) { if(pflName) _profile=pflName; @@ -175,23 +175,26 @@ void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(const char *pflName, { case ON_NODES: { - _nval=globIds->getNumberOfTuples(); + _nval=idsInPfl->getNumberOfTuples(); _arr=da->deepCpy(); break; } case ON_CELLS: { - _nval=globIds->getNumberOfTuples(); - _arr=da->selectByTupleId(globIds->getConstPointer(),globIds->getConstPointer()+_nval); + _nval=idsInPfl->getNumberOfTuples(); + _arr=da->selectByTupleId(idsInPfl->getConstPointer(),idsInPfl->getConstPointer()+_nval); break; } case ON_GAUSS_NE: { MEDCouplingAutoRefCountObjectPtr arr=field->getDiscretization()->getOffsetArr(mesh); - MEDCouplingAutoRefCountObjectPtr tmp=globIds->buildExplicitArrByRanges(arr); + MEDCouplingAutoRefCountObjectPtr arr2=arr->deltaShiftIndex(); + MEDCouplingAutoRefCountObjectPtr arr3=arr2->selectByTupleId(multiTypePfl->getConstPointer(),multiTypePfl->getConstPointer()+multiTypePfl->getNumberOfTuples()); + arr3->computeOffsets2(); + MEDCouplingAutoRefCountObjectPtr tmp=idsInPfl->buildExplicitArrByRanges(arr3); int trueNval=tmp->getNumberOfTuples(); - _nval=globIds->getNumberOfTuples(); - _arr=da->selectByTupleId(tmp->getConstPointer(),tmp->getConstPointer()+trueNval); + _nval=idsInPfl->getNumberOfTuples(); + _arr=da->selectByTupleIdSafe(tmp->getConstPointer(),tmp->getConstPointer()+trueNval); break; } case ON_GAUSS_PT: @@ -382,9 +385,9 @@ void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int offset, int nbOfCells, _field_pm_pt_pd[*it]->assignFieldNoProfile(offset,nbOfCells,field,glob); } -void MEDFileFieldPerMeshPerType::assignFieldProfile(const DataArrayInt *globIds, DataArrayInt *locIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception) +void MEDFileFieldPerMeshPerType::assignFieldProfile(const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, const DataArrayInt *globIds, DataArrayInt *locIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception) { - std::vector pos=addNewEntryIfNecessary(field,globIds); + std::vector pos=addNewEntryIfNecessary(field,idsInPfl); if(locIds) { // @@ -397,12 +400,12 @@ void MEDFileFieldPerMeshPerType::assignFieldProfile(const DataArrayInt *globIds, glob.appendProfile(locIds); // for(std::vector::const_iterator it=pos.begin();it!=pos.end();it++) - _field_pm_pt_pd[*it]->assignFieldProfile(oss.str().c_str(),globIds,field,mesh,glob); + _field_pm_pt_pd[*it]->assignFieldProfile(oss.str().c_str(),multiTypePfl,idsInPfl,globIds,field,mesh,glob); } else { for(std::vector::const_iterator it=pos.begin();it!=pos.end();it++) - _field_pm_pt_pd[*it]->assignFieldProfile(0,globIds,field,mesh,glob); + _field_pm_pt_pd[*it]->assignFieldProfile(0,multiTypePfl,idsInPfl,globIds,field,mesh,glob); } } @@ -425,7 +428,7 @@ void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(const DataArrayInt *pfl, // _field_pm_pt_pd.resize(1); _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3); - _field_pm_pt_pd[0]->assignFieldProfile(oss.str().c_str(),pfl2,field,0,glob);//mesh is not requested so 0 is send. + _field_pm_pt_pd[0]->assignFieldProfile(oss.str().c_str(),pfl,pfl2,0,field,0,glob);//mesh is not requested so 0 is send. Idem for globIds no requested here. } std::vector MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception) @@ -723,7 +726,7 @@ void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(IN mesh->getTime(_mesh_iteration,_mesh_order); } -void MEDFileFieldPerMesh::assignFieldProfile(const std::vector& code, const std::vector& globIdsPerType, const std::vector& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception) +void MEDFileFieldPerMesh::assignFieldProfile(const DataArrayInt *multiTypePfl, const std::vector& code, const std::vector& idsInPflPerType, const std::vector& globIdsPerType, const std::vector& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception) { int nbOfTypes=code.size()/3; bool isProfile=false; @@ -732,13 +735,13 @@ void MEDFileFieldPerMesh::assignFieldProfile(const std::vector& code, const isProfile=true; if(!isProfile) { - if(globIdsPerType.empty()) + if(idsInPflPerType.empty()) assignFieldNoProfileNoRenum(code,field,glob); else - assignFieldProfileGeneral(code,globIdsPerType,idsPerType,field,field->getMesh(),glob); + assignFieldProfileGeneral(multiTypePfl,code,idsInPflPerType,globIdsPerType,idsPerType,field,mesh,glob); } else - assignFieldProfileGeneral(code,globIdsPerType,idsPerType,field,mesh,glob); + assignFieldProfileGeneral(multiTypePfl,code,idsInPflPerType,globIdsPerType,idsPerType,field,mesh,glob); } void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(const std::vector& code, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception) @@ -758,7 +761,7 @@ void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(const std::vector& co /*! * This method is the most general one. No optimization is done here. */ -void MEDFileFieldPerMesh::assignFieldProfileGeneral(const std::vector& code, const std::vector& globIdsPerType, const std::vector& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception) +void MEDFileFieldPerMesh::assignFieldProfileGeneral(const DataArrayInt *multiTypePfl, const std::vector& code, const std::vector& idsInPflPerType, const std::vector& globIdsPerType, const std::vector& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception) { int nbOfTypes=code.size()/3; for(int i=0;i& code DataArrayInt *pfl=0; if(code[3*i+2]!=-1) pfl=idsPerType[code[3*i+2]]; - _field_pm_pt[pos]->assignFieldProfile(globIdsPerType[i],pfl,field,mesh,glob); + _field_pm_pt[pos]->assignFieldProfile(multiTypePfl,idsInPflPerType[i],globIdsPerType[i],pfl,field,mesh,glob); } } @@ -871,14 +874,14 @@ const std::vector& MEDFileFieldPerMesh::getInfo() const } /*! - * geoTypes,dads,pfls,locs are input parameters. They should have the same size. + * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size. * Before the call of this method 'geoTypes','dads','pfls','locs' must be reorganized so that types in geoTypes are contiguous and ordered following typmai2 array. * It returns 2 output vectors : * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes' * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed. * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format. */ -void MEDFileFieldPerMesh::SortArraysPerType(const MEDFieldFieldGlobs *glob, const std::vector& geoTypes, const std::vector& dads, const std::vector& pfls, const std::vector& locs, std::vector& code, std::vector& notNullPfls) +void MEDFileFieldPerMesh::SortArraysPerType(const MEDFieldFieldGlobs *glob, TypeOfField type, const std::vector& geoTypes, const std::vector& dads, const std::vector& pfls, const std::vector& locs, std::vector& code, std::vector& notNullPfls) { int notNullPflsSz=0; int nbOfArrs=geoTypes.size(); @@ -911,7 +914,7 @@ void MEDFileFieldPerMesh::SortArraysPerType(const MEDFieldFieldGlobs *glob, cons std::vector tmpPfls(pfls.begin()+startZone,pfls.begin()+j); std::vector tmpLocs(locs.begin()+startZone,locs.begin()+j); code[3*i]=(int)refType; - code[3*i+1]=ComputeNbOfElems(glob,tmpDads,tmpLocs); + code[3*i+1]=ComputeNbOfElems(glob,type,refType,tmpDads,tmpLocs); if(notNullTmp.empty()) code[3*i+2]=-1; else @@ -925,14 +928,22 @@ void MEDFileFieldPerMesh::SortArraysPerType(const MEDFieldFieldGlobs *glob, cons /*! * 'dads' and 'locs' are input parameters that should have same size sz. sz should be >=1. */ -int MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFieldFieldGlobs *glob, const std::vector& dads, const std::vector& locs) throw(INTERP_KERNEL::Exception) +int MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFieldFieldGlobs *glob, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const std::vector& dads, const std::vector& locs) throw(INTERP_KERNEL::Exception) { int sz=dads.size(); int ret=0; for(int i=0;igetNumberOfTuples(); + { + if(type!=ON_GAUSS_NE) + ret+=dads[i]->getNumberOfTuples(); + else + { + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoType); + ret+=dads[i]->getNumberOfTuples()/cm.getNumberOfNodes(); + } + } else { int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]); @@ -989,7 +1000,7 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField t for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes); // Sort by types - SortArraysPerType(glob,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType); + SortArraysPerType(glob,type,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 !"; @@ -1042,7 +1053,7 @@ DataArrayDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField t for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes); // Sort by types - SortArraysPerType(glob,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType); + SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType); if(code.empty()) { std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << getName() << "\" exists but not with such spatial discretization or such dimension specified !"; @@ -1117,7 +1128,7 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const for(int i=0;i dads2(1,dads[i]); const std::vector locs2(1,locs[i]); - int nbOfElems=ComputeNbOfElems(glob,dads2,locs2); + int nbOfElems=ComputeNbOfElems(glob,type,INTERP_KERNEL::NORM_ERROR,dads2,locs2); MEDCouplingAutoRefCountObjectPtr di=DataArrayInt::New(); di->alloc(nbOfElems,1); di->iota(offset); @@ -1143,7 +1154,7 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, cons if(da->isIdentity()) { int nbOfTuples=da->getNumberOfTuples(); - if(nbOfTuples==ComputeNbOfElems(glob,dads,locs)) + if(nbOfTuples==ComputeNbOfElems(glob,type,INTERP_KERNEL::NORM_ERROR,dads,locs))//No problem for NORM_ERROR because it is in context of node return finishField(type,glob,dads,locs,mesh,isPfl); } MEDCouplingAutoRefCountObjectPtr ret=finishField(type,glob,dads,locs,mesh,isPfl); @@ -1165,7 +1176,7 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField3(const MEDFieldFieldGlo if(da->isIdentity()) { int nbOfTuples=da->getNumberOfTuples(); - if(nbOfTuples==ComputeNbOfElems(glob,dads,locs)) + if(nbOfTuples==ComputeNbOfElems(glob,ON_NODES,INTERP_KERNEL::NORM_ERROR,dads,locs))//No problem for NORM_ERROR because it is in context of node return finishField(ON_NODES,glob,dads,locs,mesh,isPfl); } MEDCouplingAutoRefCountObjectPtr ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl); @@ -1594,7 +1605,7 @@ void MEDFileField1TSWithoutDAS::setFieldNoProfileSBT(const MEDCouplingFieldDoubl std::vector code=MEDFileField1TSWithoutDAS::CheckSBTMesh(mesh); // int pos=addNewEntryIfNecessary(mesh); - _field_per_mesh[pos]->assignFieldProfile(code,dummy,dummy,field,0,glob);//mesh is set to 0 because no external mesh is needed to be sent because no profile. + _field_per_mesh[pos]->assignFieldProfile(0,code,dummy,dummy,dummy,field,0,glob);//mesh is set to 0 because no external mesh is needed to be sent because no profile. } else { @@ -1610,14 +1621,18 @@ void MEDFileField1TSWithoutDAS::setFieldProfile(const MEDCouplingFieldDouble *fi { TypeOfField type=field->getTypeOfField(); copyTinyInfoFrom(field); + std::vector idsInPflPerType; std::vector globIdsPerType; std::vector idsPerType; std::vector code; MEDCouplingAutoRefCountObjectPtr m=mesh->getGenMeshAtLevel(meshDimRelToMax); if(type!=ON_NODES) { - m->splitProfilePerType(profile,code,globIdsPerType,idsPerType); + m->splitProfilePerType(profile,code,idsInPflPerType,globIdsPerType,idsPerType); // + std::vector< MEDCouplingAutoRefCountObjectPtr > idsInPflPerType2(idsInPflPerType.size()); + for(std::size_t i=0;i > globIdsPerType2(globIdsPerType.size()); for(std::size_t i=0;iassignFieldProfile(code,globIdsPerType,idsPerType,field,m,glob); + _field_per_mesh[pos]->assignFieldProfile(profile,code,idsInPflPerType,globIdsPerType,idsPerType,field,m,glob); } else { diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index 336fcabee..af380fe58 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -81,9 +81,9 @@ namespace ParaMEDMEM static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerType *fath, med_idt fid, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception); static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId); void assignFieldNoProfile(int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception); - void assignFieldProfile(const char *pflName, const DataArrayInt *globIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception); + void assignFieldProfile(const char *pflName, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, const DataArrayInt *globIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception); void assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception); - void assignNodeFieldProfile(const char *pflName, const DataArrayInt *globIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception); + void assignNodeFieldProfile(const char *pflName, const DataArrayInt *idsInPfl, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception); void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception); const MEDFileFieldPerMeshPerType *getFather() const; int getIteration() const; @@ -124,7 +124,7 @@ namespace ParaMEDMEM public: static MEDFileFieldPerMeshPerType *New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception); void assignFieldNoProfile(int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception); - void assignFieldProfile(const DataArrayInt *globIds, DataArrayInt *locIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception); + void assignFieldProfile(const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, const DataArrayInt *globIds, DataArrayInt *locIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception); void assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception); void assignNodeFieldProfile(const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception); const MEDFileFieldPerMesh *getFather() const; @@ -161,8 +161,8 @@ namespace ParaMEDMEM static MEDFileFieldPerMesh *New(MEDFileField1TSWithoutDAS *fath, const MEDCouplingMesh *mesh); static MEDFileFieldPerMesh *New(MEDFileField1TSWithoutDAS *fath, int meshCsit, int meshIteration, int meshOrder); void copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception); - void assignFieldProfile(const std::vector& code, const std::vector& globIdsPerType, const std::vector& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception); - void assignFieldProfileGeneral(const std::vector& code, const std::vector& globIdsPerType, const std::vector& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception); + void assignFieldProfile(const DataArrayInt *multiTypePfl, const std::vector& code, const std::vector& idsInPflPerType, const std::vector& globIdsPerType, const std::vector& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception); + void assignFieldProfileGeneral(const DataArrayInt *multiTypePfl, const std::vector& code, const std::vector& idsInPflPerType, const std::vector& globIdsPerType, const std::vector& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception); void assignFieldNoProfileNoRenum(const std::vector& code, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception); void assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception); void assignNodeFieldProfile(const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception); @@ -194,10 +194,10 @@ namespace ParaMEDMEM const std::vector& dads, const std::vector& locs, const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception); DataArrayDouble *finishField4(const std::vector& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception); - static void SortArraysPerType(const MEDFieldFieldGlobs *glob, + static void SortArraysPerType(const MEDFieldFieldGlobs *glob, TypeOfField type, const std::vector& geoTypes, const std::vector& dads, const std::vector& pfls, const std::vector& locs, std::vector& code, std::vector& notNullPfls); - static int ComputeNbOfElems(const MEDFieldFieldGlobs *glob, const std::vector& dads, const std::vector& locs) throw(INTERP_KERNEL::Exception); + static int ComputeNbOfElems(const MEDFieldFieldGlobs *glob, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const std::vector& dads, const std::vector& locs) throw(INTERP_KERNEL::Exception); MEDFileFieldPerMesh(MEDFileField1TSWithoutDAS *fath, int meshCsit, int meshIteration, int meshOrder); MEDFileFieldPerMesh(MEDFileField1TSWithoutDAS *fath, const MEDCouplingMesh *mesh); private: diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index e67f18b9b..fe2520514 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -654,7 +654,7 @@ class MEDLoaderTest(unittest.TestCase): m1=MEDLoaderDataForTest.build2DMesh_1() m1.renumberCells([0,1,4,2,3,5],False) tmp=m1.getName(); - m1=m1.buildPartOfMySelf(range(5),True) ; m1.setName(tmp) + m1=m1.buildPartOfMySelf(range(5),True) ; m1.setName(tmp) # suppression of last cell that is a polygon mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ; mm1.write(fname,2) ff1=MEDFileField1TS.New() @@ -664,18 +664,51 @@ class MEDLoaderTest(unittest.TestCase): da=DataArrayInt.New(); da.setValues([0,2,3],3,1) ; da.setName("sup1NodeElt") # ff1.setFieldProfile(f1,mm1,0,da) - ## ff1.write(fname,0) + ff1.write(fname,0) # - ## vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,0,mm1) - ## print pfl - ## print da - ## self.assertTrue(pfl.isEqualWithoutConsideringStr(da)) - ## self.assertTrue(vals.isEqual(d,1e-14)) - ## # - ## ff2=MEDFileField1TS.New(fname,f1.getName(),-1,-1) - ## vals,pfl=ff2.getFieldWithProfile(GAUSS_NE,0,mm1) - ## self.assertTrue(pfl.isEqualWithoutConsideringStr(da)) - ## self.assertTrue(vals.isEqual(d,1e-14)) + vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,0,mm1) + self.assertTrue(pfl.isEqualWithoutConsideringStr(da)) + self.assertTrue(vals.isEqual(d,1e-14)) + # + ff2=MEDFileField1TS.New(fname,f1.getName(),-1,-1) + vals,pfl=ff2.getFieldWithProfile(ON_GAUSS_NE,0,mm1) + self.assertTrue(pfl.isEqualWithoutConsideringStr(da)) + self.assertTrue(vals.isEqual(d,1e-14)) + pass + + def testMEDField14(self): + fname="Pyfile35.med" + m1=MEDLoaderDataForTest.build2DMesh_1() + m1.renumberCells([0,1,4,2,3,5],False) + tmp=m1.getName(); + m1=m1.buildPartOfMySelf(range(5),True) ; m1.setName(tmp) # suppression of last cell that is a polygon + mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ; + mm1.write(fname,2) + ff1=MEDFileFieldMultiTS.New() + f1=MEDCouplingFieldDouble.New(ON_GAUSS_NE,ONE_TIME) ; f1.setName("F4Node") + d=DataArrayDouble.New() ; d.alloc(2*11,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]") + f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that. + da=DataArrayInt.New(); da.setValues([0,2,3],3,1) ; da.setName("sup1NodeElt") + # + ff1.appendFieldProfile(f1,mm1,0,da) + f1.setTime(1.2,1,2) ; e=d.applyFunc("2*x") ; e.copyStringInfoFrom(d) ; f1.setArray(e) ; + ff1.appendFieldProfile(f1,mm1,0,da) + ff1.write(fname,0) + # + vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,-1,-1,0,mm1) + self.assertTrue(pfl.isEqualWithoutConsideringStr(da)) + self.assertTrue(vals.isEqual(d,1e-14)) + vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,1,2,0,mm1) + self.assertTrue(pfl.isEqualWithoutConsideringStr(da)) + self.assertTrue(vals.isEqual(e,1e-14)) + # + ff2=MEDFileFieldMultiTS.New(fname,f1.getName()) + vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,-1,-1,0,mm1) + self.assertTrue(pfl.isEqualWithoutConsideringStr(da)) + self.assertTrue(vals.isEqual(d,1e-14)) + vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,1,2,0,mm1) + self.assertTrue(pfl.isEqualWithoutConsideringStr(da)) + self.assertTrue(vals.isEqual(e,1e-14)) pass pass -- 2.39.2