From 3f49cbdf1df65223c38472e967dd386670287780 Mon Sep 17 00:00:00 2001 From: ageay Date: Thu, 10 Oct 2013 09:47:45 +0000 Subject: [PATCH] API modification of MEDCouplingFieldDiscretization::getNumberOfTuplesExpectedRegardingCode --- src/MEDCoupling/MEDCouplingField.cxx | 2 +- .../MEDCouplingFieldDiscretization.cxx | 48 ++++++++++++------- .../MEDCouplingFieldDiscretization.hxx | 10 ++-- .../MEDCouplingFieldDiscretization.i | 4 +- src/MEDLoader/MEDFileField.cxx | 5 -- 5 files changed, 40 insertions(+), 29 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingField.cxx b/src/MEDCoupling/MEDCouplingField.cxx index a4a0534f6..3f50f4c57 100644 --- a/src/MEDCoupling/MEDCouplingField.cxx +++ b/src/MEDCoupling/MEDCouplingField.cxx @@ -617,5 +617,5 @@ int MEDCouplingField::getNumberOfTuplesExpectedRegardingCode(const std::vectorgetNumberOfTuplesExpectedRegardingCode(_mesh,code,idsPerType); + return t->getNumberOfTuplesExpectedRegardingCode(code,idsPerType); } diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx index 504a48654..50ed785a0 100644 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx @@ -484,9 +484,12 @@ int MEDCouplingFieldDiscretizationP0::getNumberOfTuples(const MEDCouplingMesh *m } /*! - * mesh is not used here. It is not a bug ! + * This method returns the number of tuples regarding exclusively the input code \b without \b using \b a \b mesh \b in \b input. + * The input code coherency is also checked regarding spatial discretization of \a this. + * If an incoherency is detected, an exception will be thrown. If the input code is coherent, the number of tuples expected is returned. + * The number of tuples expected is equal to those to have a valid field lying on \a this and having a mesh fitting perfectly the input code (geometric type distribution). */ -int MEDCouplingFieldDiscretizationP0::getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector& code, const std::vector& idsPerType) const +int MEDCouplingFieldDiscretizationP0::getNumberOfTuplesExpectedRegardingCode(const std::vector& code, const std::vector& idsPerType) const { if(code.size()%3!=0) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationP0::getNumberOfTuplesExpectedRegardingCode : invalid input code !"); @@ -725,9 +728,12 @@ int MEDCouplingFieldDiscretizationOnNodes::getNumberOfTuples(const MEDCouplingMe } /*! - * mesh is not used here. It is not a bug ! + * This method returns the number of tuples regarding exclusively the input code \b without \b using \b a \b mesh \b in \b input. + * The input code coherency is also checked regarding spatial discretization of \a this. + * If an incoherency is detected, an exception will be thrown. If the input code is coherent, the number of tuples expected is returned. + * The number of tuples expected is equal to those to have a valid field lying on \a this and having a mesh fitting perfectly the input code (geometric type distribution). */ -int MEDCouplingFieldDiscretizationOnNodes::getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector& code, const std::vector& idsPerType) const +int MEDCouplingFieldDiscretizationOnNodes::getNumberOfTuplesExpectedRegardingCode(const std::vector& code, const std::vector& idsPerType) const { if(code.size()%3!=0) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationOnNodes::getNumberOfTuplesExpectedRegardingCode : invalid input code !"); @@ -1332,9 +1338,12 @@ const char *MEDCouplingFieldDiscretizationGauss::getRepr() const } /*! - * mesh is not used here. It is not a bug ! + * This method returns the number of tuples regarding exclusively the input code \b without \b using \b a \b mesh \b in \b input. + * The input code coherency is also checked regarding spatial discretization of \a this. + * If an incoherency is detected, an exception will be thrown. If the input code is coherent, the number of tuples expected is returned. + * The number of tuples expected is equal to those to have a valid field lying on \a this and having a mesh fitting perfectly the input code (geometric type distribution). */ -int MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector& code, const std::vector& idsPerType) const +int MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode(const std::vector& code, const std::vector& idsPerType) const { if(!_discr_per_cell || !_discr_per_cell->isAllocated() || _discr_per_cell->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode"); @@ -1368,6 +1377,7 @@ int MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode( if(ret!=_discr_per_cell->getNumberOfTuples()) { std::ostringstream oss; oss << "MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode : input code points to " << ret << " cells whereas discretization percell array lgth is " << _discr_per_cell->getNumberOfTuples() << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); } return getNumberOfTuples(0);//0 is not an error ! It is to be sure that input mesh is not used } @@ -2057,15 +2067,27 @@ bool MEDCouplingFieldDiscretizationGaussNE::isEqualIfNotWhy(const MEDCouplingFie return ret; } -int MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector& code, const std::vector& idsPerType) const +/*! + * This method returns the number of tuples regarding exclusively the input code \b without \b using \b a \b mesh \b in \b input. + * The input code coherency is also checked regarding spatial discretization of \a this. + * If an incoherency is detected, an exception will be thrown. If the input code is coherent, the number of tuples expected is returned. + * The number of tuples expected is equal to those to have a valid field lying on \a this and having a mesh fitting perfectly the input code (geometric type distribution). + */ +int MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuplesExpectedRegardingCode(const std::vector& code, const std::vector& idsPerType) const { if(code.size()%3!=0) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuplesExpectedRegardingCode : invalid input code !"); int nbOfSplit=(int)idsPerType.size(); int nbOfTypes=(int)code.size()/3; - int ret=0; + int ret(0); for(int i=0;igetNumberOfCells()) - { - std::ostringstream oss; oss << "MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuplesExpectedRegardingCode : input code points to " << ret << " number of cells should be " << mesh->getNumberOfCells() << " !"; + ret+=nbOfEltInChunk*(int)cm.getNumberOfNodes(); } - return getNumberOfTuples(mesh); + return ret; } int MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuples(const MEDCouplingMesh *mesh) const diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx index 47db887e0..a6f895b89 100644 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx @@ -60,7 +60,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT virtual MEDCouplingFieldDiscretization *clonePartRange(int beginCellIds, int endCellIds, int stepCellIds) const; MEDCOUPLING_EXPORT virtual std::string getStringRepr() const = 0; MEDCOUPLING_EXPORT virtual const char *getRepr() const = 0; - MEDCOUPLING_EXPORT virtual int getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector& code, const std::vector& idsPerType) const = 0; + MEDCOUPLING_EXPORT virtual int getNumberOfTuplesExpectedRegardingCode(const std::vector& code, const std::vector& idsPerType) const = 0; MEDCOUPLING_EXPORT virtual int getNumberOfTuples(const MEDCouplingMesh *mesh) const = 0; MEDCOUPLING_EXPORT virtual int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const = 0; MEDCOUPLING_EXPORT virtual DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const = 0; @@ -122,7 +122,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT std::string getStringRepr() const; MEDCOUPLING_EXPORT const char *getRepr() const; MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const; - MEDCOUPLING_EXPORT int getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector& code, const std::vector& idsPerType) const; + MEDCOUPLING_EXPORT int getNumberOfTuplesExpectedRegardingCode(const std::vector& code, const std::vector& idsPerType) const; MEDCOUPLING_EXPORT int getNumberOfTuples(const MEDCouplingMesh *mesh) const; MEDCOUPLING_EXPORT int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const; MEDCOUPLING_EXPORT DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const; @@ -153,7 +153,7 @@ namespace ParaMEDMEM { public: MEDCOUPLING_EXPORT int getNumberOfTuples(const MEDCouplingMesh *mesh) const; - MEDCOUPLING_EXPORT int getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector& code, const std::vector& idsPerType) const; + MEDCOUPLING_EXPORT int getNumberOfTuplesExpectedRegardingCode(const std::vector& code, const std::vector& idsPerType) const; MEDCOUPLING_EXPORT int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const; MEDCOUPLING_EXPORT DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const; MEDCOUPLING_EXPORT void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector& arrays, @@ -235,7 +235,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT std::string getStringRepr() const; MEDCOUPLING_EXPORT const char *getRepr() const; MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT int getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector& code, const std::vector& idsPerType) const; + MEDCOUPLING_EXPORT int getNumberOfTuplesExpectedRegardingCode(const std::vector& code, const std::vector& idsPerType) const; MEDCOUPLING_EXPORT int getNumberOfTuples(const MEDCouplingMesh *mesh) const; MEDCOUPLING_EXPORT int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const; MEDCOUPLING_EXPORT DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const; @@ -303,7 +303,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT std::string getStringRepr() const; MEDCOUPLING_EXPORT const char *getRepr() const; MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const; - MEDCOUPLING_EXPORT int getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector& code, const std::vector& idsPerType) const; + MEDCOUPLING_EXPORT int getNumberOfTuplesExpectedRegardingCode(const std::vector& code, const std::vector& idsPerType) const; MEDCOUPLING_EXPORT int getNumberOfTuples(const MEDCouplingMesh *mesh) const; MEDCOUPLING_EXPORT int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const; MEDCOUPLING_EXPORT DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const; diff --git a/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i b/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i index cc872bafa..40207ea69 100644 --- a/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i +++ b/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i @@ -89,13 +89,13 @@ namespace ParaMEDMEM return res; } - virtual int getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, PyObject *code, PyObject *idsPerType) const throw(INTERP_KERNEL::Exception) + virtual int getNumberOfTuplesExpectedRegardingCode(PyObject *code, PyObject *idsPerType) const throw(INTERP_KERNEL::Exception) { std::vector inp0; convertPyToNewIntArr4(code,1,3,inp0); std::vector inp1; convertFromPyObjVectorOfObj(idsPerType,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,"DataArrayInt",inp1); - return self->getNumberOfTuplesExpectedRegardingCode(mesh,inp0,inp1); + return self->getNumberOfTuplesExpectedRegardingCode(inp0,inp1); } virtual PyObject *computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, PyObject *tupleIds) const throw(INTERP_KERNEL::Exception) diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index e180dc28d..735e1af6e 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -4325,11 +4325,6 @@ void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDou std::vector idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin()); // start of check MEDCouplingAutoRefCountObjectPtr field2=field->clone(false); - if(type==ON_GAUSS_NE) - { - MEDCouplingAutoRefCountObjectPtr mPart=m->buildPart(profile->begin(),profile->end()); - field2->setMesh(mPart); - } int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3); if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples()) { -- 2.39.2