From: ageay Date: Mon, 18 Jul 2011 06:25:31 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: V6_main_FINAL~1005 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5ee85ff8eb1611abdd49a184884e5a8c87271029;p=tools%2Fmedcoupling.git *** empty log message *** --- diff --git a/doc/doxygen/medcoupling.dox b/doc/doxygen/medcoupling.dox index 82c97d29d..f5a34e77d 100644 --- a/doc/doxygen/medcoupling.dox +++ b/doc/doxygen/medcoupling.dox @@ -346,7 +346,7 @@ The most important pure virtual methods are : - \ref ParaMEDMEM::MEDCouplingFieldDiscretization::getNumberOfTuples "getnumberOfTuples" - \ref ParaMEDMEM::MEDCouplingFieldDiscretization::getValueOn "getValueOn" -- \ref ParaMEDMEM::MEDCouplingFieldDiscretization::getWeightingField "getWeightingField" +- \ref ParaMEDMEM::MEDCouplingFieldDiscretization::getMeasureField "getMeasureField" \section MEDCouplingTemporalDisc Temporal discretization concept diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx index f5eab6bfe..f84fa61e0 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.cxx @@ -793,8 +793,9 @@ MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator=(double value) throw(IN /*! * This method is very similar to this one MEDCouplingMesh::fillFromAnalytic. + * See MEDCouplingMesh::fillFromAnalytic method doc to have more details. * The main difference is that the field as been started to be constructed here. - * An exception is throw if no underlying mesh is set before the call of this method. + * An exception is thrown if no underlying mesh is set before the call of this method. */ void MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, FunctionToEvaluate func) throw(INTERP_KERNEL::Exception) { @@ -806,8 +807,9 @@ void MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, FunctionToEvaluate f /*! * This method is very similar to this one MEDCouplingMesh::fillFromAnalytic. + * See MEDCouplingMesh::fillFromAnalytic method doc to have more details. * The main difference is that the field as been started to be constructed here. - * An exception is throw if no underlying mesh is set before the call of this method. + * An exception is thrown if no underlying mesh is set before the call of this method. */ void MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception) { @@ -819,6 +821,7 @@ void MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const char *func) th /*! * This method is very similar to this one MEDCouplingMesh::fillFromAnalytic2. + * See MEDCouplingMesh::fillFromAnalytic method doc to have more details. * The main difference is that the field as been started to be constructed here. * An exception is throw if no underlying mesh is set before the call of this method. */ @@ -832,8 +835,9 @@ void MEDCouplingFieldDouble::fillFromAnalytic2(int nbOfComp, const char *func) t /*! * This method is very similar to this one MEDCouplingMesh::fillFromAnalytic3. + * See MEDCouplingMesh::fillFromAnalytic method doc to have more details. * The main difference is that the field as been started to be constructed here. - * An exception is throw if no underlying mesh is set before the call of this method. + * An exception is thrown if no underlying mesh is set before the call of this method. */ void MEDCouplingFieldDouble::fillFromAnalytic3(int nbOfComp, const std::vector& varsOrder, const char *func) throw(INTERP_KERNEL::Exception) { diff --git a/src/MEDCoupling/MEDCouplingMesh.cxx b/src/MEDCoupling/MEDCouplingMesh.cxx index 56ca47955..4cf46d526 100644 --- a/src/MEDCoupling/MEDCouplingMesh.cxx +++ b/src/MEDCoupling/MEDCouplingMesh.cxx @@ -174,6 +174,10 @@ bool MEDCouplingMesh::areCompatibleForMerge(const MEDCouplingMesh *other) const * The first array is a in-param of size this->getSpaceDimension and the second an out param of size 'nbOfComp'. * The return field will have type specified by 't'. 't' is also used to determine where values of field will be * evaluate. + * Contrary to other fillFromAnalytic methods this method requests a C++ function pointer as input. + * The 'func' is a callback that takes as first parameter an input array of size 'this->getSpaceDimension()', + * the second parameter is a pointer on a valid zone of size at least equal to 'nbOfComp' values. And too finish + * the returned value is a boolean that is equal to False in case of invalid evaluation (log(0) for example...) * @param t type of field returned and specifies where the evaluation of func will be done. * @param nbOfComp number of components of returned field. * @param func pointer to a function that should return false if the evaluation failed. (division by 0. for example) @@ -216,6 +220,24 @@ void MEDCouplingMesh::copyTinyInfoFrom(const MEDCouplingMesh *other) throw(INTER * 'func' is a string that is the expression to evaluate. * The return field will have type specified by 't'. 't' is also used to determine where values of field will be * evaluate. + * This method is equivalent to those taking a C++ function pointer except that here the 'func' is informed by + * an interpretable input string. + * + * The dynamic interpretor uses \b alphabetical \b order to assign the component id to the var name. + * For example : + * - "2*x+z" func : x stands for component #0 and z stands for component #1 \b NOT #2 ! + * + * Some var names are reserved and have special meaning. IVec stands for (1,0,0,...). JVec stands for (0,1,0...). + * KVec stands for (0,0,1,...)... These keywords allows too differentate the evaluation of output components each other. + * + * If 'nbOfComp' equals to 4 for example and that 'this->getSpaceDimension()' equals to 3. + * + * For the input tuple T = (1.,3.,7.) : + * - '2*x+z' will return (5.,5.,5.,5.) + * - '2*x+0*y+z' will return (9.,9.,9.,9.) + * - '2*x*IVec+(x+z)*LVec' will return (2.,0.,0.,4.) + * - '2*x*IVec+(y+z)*KVec' will return (2.,0.,10.,0.) + * * @param t type of field returned and specifies where the evaluation of func will be done. * @param nbOfComp number of components of returned field. * @param func expression. diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index 7b958119c..dd313c3db 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -253,7 +253,7 @@ try:_type(atype),_father(fath),_profile_it(profileIt) _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE); if(type==ON_CELLS && !_localization.empty()) { - if(_localization!="MED_GAUSS_ELNO") + if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3 setType(ON_GAUSS_PT); else { @@ -928,7 +928,8 @@ void MEDFileFieldPerMesh::SortArraysPerType(const MEDFieldFieldGlobsReal *glob, 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,type,refType,tmpDads,tmpLocs); + std::vector refType2(1,refType); + code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs); if(notNullTmp.empty()) code[3*i+2]=-1; else @@ -940,9 +941,9 @@ void MEDFileFieldPerMesh::SortArraysPerType(const MEDFieldFieldGlobsReal *glob, } /*! - * 'dads' and 'locs' are input parameters that should have same size sz. sz should be >=1. + * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1. */ -int MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFieldFieldGlobsReal *glob, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const std::vector& dads, const std::vector& locs) throw(INTERP_KERNEL::Exception) +int MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFieldFieldGlobsReal *glob, TypeOfField type, const std::vector& geoTypes, const std::vector& dads, const std::vector& locs) throw(INTERP_KERNEL::Exception) { int sz=dads.size(); int ret=0; @@ -954,7 +955,7 @@ int MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFieldFieldGlobsReal *glob, Ty ret+=dads[i]->getNumberOfTuples(); else { - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoType); + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]); ret+=dads[i]->getNumberOfTuples()/cm.getNumberOfNodes(); } } @@ -1031,7 +1032,7 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField t else { MEDCouplingAutoRefCountObjectPtr arr2(arr); - return finishField2(type,glob,dads,locs,mesh,arr,isPfl); + return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl); } } else @@ -1122,6 +1123,9 @@ int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellTyp return ret; } +/*! + * 'dads' and 'locs' input parameters have the same number of elements. + */ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFieldFieldGlobsReal *glob, const std::vector& dads, const std::vector& locs, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception) @@ -1142,7 +1146,8 @@ 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,type,INTERP_KERNEL::NORM_ERROR,dads2,locs2); + const std::vector geoTypes2(1,INTERP_KERNEL::NORM_ERROR); + int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2); MEDCouplingAutoRefCountObjectPtr di=DataArrayInt::New(); di->alloc(nbOfElems,1); di->iota(offset); @@ -1158,17 +1163,19 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const /*! * This method is an extension of MEDFileFieldPerMesh::finishField method. It deals with profiles. This method should be called when type is different from ON_NODES. + * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements. * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support. * The order of cells in the returned field is those imposed by the profile. */ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFieldFieldGlobsReal *glob, const std::vector& dads, const std::vector& locs, + const std::vector& geoTypes, const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception) { if(da->isIdentity()) { int nbOfTuples=da->getNumberOfTuples(); - if(nbOfTuples==ComputeNbOfElems(glob,type,INTERP_KERNEL::NORM_ERROR,dads,locs))//No problem for NORM_ERROR because it is in context of node + if(nbOfTuples==ComputeNbOfElems(glob,type,geoTypes,dads,locs)) return finishField(type,glob,dads,locs,mesh,isPfl); } MEDCouplingAutoRefCountObjectPtr ret=finishField(type,glob,dads,locs,mesh,isPfl); @@ -1190,7 +1197,8 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField3(const MEDFieldFieldGlo if(da->isIdentity()) { int nbOfTuples=da->getNumberOfTuples(); - if(nbOfTuples==ComputeNbOfElems(glob,ON_NODES,INTERP_KERNEL::NORM_ERROR,dads,locs))//No problem for NORM_ERROR because it is in context of node + const std::vector geoTypes2(1,INTERP_KERNEL::NORM_ERROR); + if(nbOfTuples==ComputeNbOfElems(glob,ON_NODES,geoTypes2,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); diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index 17939b7c9..4d0356e1b 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -190,6 +190,7 @@ namespace ParaMEDMEM const std::vector& dads, const std::vector& locs, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *finishField2(TypeOfField type, const MEDFieldFieldGlobsReal *glob, const std::vector& dads, const std::vector& locs, + const std::vector& geoTypes, const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *finishField3(const MEDFieldFieldGlobsReal *glob, const std::vector& dads, const std::vector& locs, @@ -198,7 +199,7 @@ namespace ParaMEDMEM static void SortArraysPerType(const MEDFieldFieldGlobsReal *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 MEDFieldFieldGlobsReal *glob, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const std::vector& dads, const std::vector& locs) throw(INTERP_KERNEL::Exception); + static int ComputeNbOfElems(const MEDFieldFieldGlobsReal *glob, TypeOfField type, const std::vector& geoTypes, 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/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index ffacbfe8b..9b930ca16 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -1411,6 +1411,8 @@ void MEDFileUMesh::setMeshAtLevelGen(int meshDimRelToMax, MEDCouplingUMesh *m, b _ms[sz-1]=new MEDFileUMeshSplitL1(m,newOrOld); } } + else + _ms[-meshDimRelToMax]=new MEDFileUMeshSplitL1(m,newOrOld); } void MEDFileUMesh::setGroupsFromScratch(int meshDimRelToMax, const std::vector& ms) throw(INTERP_KERNEL::Exception) diff --git a/src/MEDLoader/MEDFileUtilities.cxx b/src/MEDLoader/MEDFileUtilities.cxx index 80dcc1218..d7b785f63 100644 --- a/src/MEDLoader/MEDFileUtilities.cxx +++ b/src/MEDLoader/MEDFileUtilities.cxx @@ -39,7 +39,7 @@ med_access_mode MEDFileUtilities::TraduceWriteMode(int medloaderwritemode) throw void MEDFileUtilities::CheckMEDCode(int code, med_idt fid, const char *msg) throw(INTERP_KERNEL::Exception) { - if(code==-1) + if(code<0) { std::ostringstream oss; oss << "MEDFile has returned an error code (" << code <<") : " << msg; diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index 30b73be2e..59dededda 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -714,6 +714,32 @@ class MEDLoaderTest(unittest.TestCase): self.assertTrue(pfl.isEqualWithoutConsideringStr(da)) self.assertTrue(vals.isEqual(e,1e-14)) pass + # Tricky test of the case of in a MED file containing a Field on GAUSS_NE is lying on a profile that is reality represents all the geom entities of a level. + # By default when using setFieldProfile method such profile is not created because it is not useful ! So here a trick is used to force MEDLoader to do that + # for the necessity of the test ! The idea is too create artificially a mesh having one more fictious cell per type and to roll back right after ! + def testMEDField15(self): + fname="Pyfile36.med" + m0=MEDLoaderDataForTest.build2DMesh_1() + m0.renumberCells([0,1,4,2,3,5],False) + tmp=m0.getName(); + m1=m0.buildPartOfMySelf([0,1,1,2,3,3,4,4],True) ; m1.setName(tmp) # suppression of last cell that is a polygon and creation of one more cell per type + mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ; + ff1=MEDFileField1TS.New() + f1=MEDCouplingFieldDouble.New(ON_GAUSS_NE,ONE_TIME) ; f1.setName("F4Node") + d=DataArrayDouble.New() ; d.alloc(2*20,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,1,3,4,6],5,1) ; da.setName("sup1NodeElt") + # + ff1.setFieldProfile(f1,mm1,0,da) + m1=m0.buildPartOfMySelf(range(5),True) ; m1.setName(tmp) ; mm1.setMeshAtLevel(0,m1) ; + mm1.write(fname,2) + ff1.write(fname,0) + f1=ff1.getFieldOnMeshAtLevel(ON_GAUSS_NE,m1,0) + f2,p1=ff1.getFieldWithProfile(ON_GAUSS_NE,0,mm1) + self.assertTrue(p1.isIdentity()) + self.assertEqual(5,p1.getNumberOfTuples()) + self.assertTrue(f1.getArray().isEqual(f2,1e-12)) + pass pass - + unittest.main()