From 38e8efde43538ffb45332df0a54bec8c8e2f72b1 Mon Sep 17 00:00:00 2001 From: ageay Date: Thu, 30 Jun 2011 17:05:08 +0000 Subject: [PATCH] *** empty log message *** --- src/MEDLoader/MEDFileField.cxx | 36 ++++++++++++++-------------- src/MEDLoader/MEDFileField.hxx | 10 ++++---- src/MEDLoader/Swig/MEDLoaderTest3.py | 29 ++++++++++++++++++++++ 3 files changed, 52 insertions(+), 23 deletions(-) diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index a9d36304e..3ad113321 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, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception) +void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(const char *pflName, const DataArrayInt *globIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception) { if(pflName) _profile=pflName; @@ -187,12 +187,12 @@ void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(const char *pflName, } case ON_GAUSS_NE: { - throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for profiles on gauss NE points !"); - /*MEDCouplingAutoRefCountObjectPtr arr=field->getDiscretization()->getOffsetArr(field->getMesh()); - const int *arrPtr=arr->getConstPointer(); - _nval=nbOfCells; - _arr=da->selectByTupleId(arrPtr[offset],arrPtr[offset+nbOfCells],1); - break;*/ + MEDCouplingAutoRefCountObjectPtr arr=field->getDiscretization()->getOffsetArr(mesh); + MEDCouplingAutoRefCountObjectPtr tmp=globIds->buildExplicitArrByRanges(arr); + int trueNval=tmp->getNumberOfTuples(); + _nval=globIds->getNumberOfTuples(); + _arr=da->selectByTupleId(tmp->getConstPointer(),tmp->getConstPointer()+trueNval); + break; } case ON_GAUSS_PT: { @@ -382,7 +382,7 @@ 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, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception) +void MEDFileFieldPerMeshPerType::assignFieldProfile(const DataArrayInt *globIds, DataArrayInt *locIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception) { std::vector pos=addNewEntryIfNecessary(field,globIds); if(locIds) @@ -397,12 +397,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,glob); + _field_pm_pt_pd[*it]->assignFieldProfile(oss.str().c_str(),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,glob); + _field_pm_pt_pd[*it]->assignFieldProfile(0,globIds,field,mesh,glob); } } @@ -425,7 +425,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,glob); + _field_pm_pt_pd[0]->assignFieldProfile(oss.str().c_str(),pfl2,field,0,glob);//mesh is not requested so 0 is send. } std::vector MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception) @@ -723,7 +723,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, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception) +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) { int nbOfTypes=code.size()/3; bool isProfile=false; @@ -735,10 +735,10 @@ void MEDFileFieldPerMesh::assignFieldProfile(const std::vector& code, const if(globIdsPerType.empty()) assignFieldNoProfileNoRenum(code,field,glob); else - assignFieldProfileGeneral(code,globIdsPerType,idsPerType,field,glob); + assignFieldProfileGeneral(code,globIdsPerType,idsPerType,field,field->getMesh(),glob); } else - assignFieldProfileGeneral(code,globIdsPerType,idsPerType,field,glob); + assignFieldProfileGeneral(code,globIdsPerType,idsPerType,field,mesh,glob); } void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(const std::vector& code, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception) @@ -758,7 +758,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, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception) +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) { 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,glob); + _field_pm_pt[pos]->assignFieldProfile(globIdsPerType[i],pfl,field,mesh,glob); } } @@ -1594,7 +1594,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,glob); + _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. } else { @@ -1626,7 +1626,7 @@ void MEDFileField1TSWithoutDAS::setFieldProfile(const MEDCouplingFieldDouble *fi idsPerType2[i]=idsPerType[i]; // int pos=addNewEntryIfNecessary(m); - _field_per_mesh[pos]->assignFieldProfile(code,globIdsPerType,idsPerType,field,glob); + _field_per_mesh[pos]->assignFieldProfile(code,globIdsPerType,idsPerType,field,m,glob); } else { diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index d129bfbd4..336fcabee 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, 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 assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception); - void assignNodeFieldProfile(const char *pflName, const DataArrayInt *globIds, 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 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, 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 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, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception); - void assignFieldProfileGeneral(const std::vector& code, const std::vector& globIdsPerType, const std::vector& idsPerType, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) 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 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); diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index 84d4ad97e..e67f18b9b 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -648,6 +648,35 @@ class MEDLoaderTest(unittest.TestCase): self.assertTrue(pfl.isEqualWithoutConsideringStr(da)) self.assertTrue(vals.isEqual(d,1e-14)) pass + + def testMEDField13(self): + fname="Pyfile34.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) + mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ; + mm1.write(fname,2) + ff1=MEDFileField1TS.New() + f1=MEDCouplingFieldDouble.New(ON_GAUSS_NE,ONE_TIME) ; f1.setName("F3Node") + 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.setFieldProfile(f1,mm1,0,da) + ## 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)) + pass pass unittest.main() -- 2.39.2