X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingFieldDiscretization.cxx;h=a927a731c068e65c8c6dafb02d2c7831e300dc77;hb=ffe6d640bbaae9d66ac15d1015761d047a495ede;hp=bb7587bc3e9d49ef6b075d2f7ad66b1264054af5;hpb=de8da643a7f441fb2154818cde04b7b24ca76bb4;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx index bb7587bc3..a927a731c 100644 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx @@ -479,6 +479,41 @@ int MEDCouplingFieldDiscretizationP0::getNumberOfTuples(const MEDCouplingMesh *m return mesh->getNumberOfCells(); } +/*! + * mesh is not used here. It is not a bug ! + */ +int MEDCouplingFieldDiscretizationP0::getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) +{ + if(code.size()%3!=0) + throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationP0::getNumberOfTuplesExpectedRegardingCode : invalid input code !"); + int nbOfSplit=(int)idsPerType.size(); + int nbOfTypes=(int)code.size()/3; + int ret=0; + for(int i=0;i=nbOfSplit) + { + std::ostringstream oss; oss << "MEDCouplingFieldDiscretizationP0::getNumberOfTuplesExpectedRegardingCode : input code points to pos " << pos << " in typeid " << i << " ! Should be in [0," << nbOfSplit << ") !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + const DataArrayInt *ids(idsPerType[pos]); + if(!ids || !ids->isAllocated() || ids->getNumberOfComponents()!=1 || ids->getNumberOfTuples()!=nbOfEltInChunk || ids->getMinValueInArray()<0) + { + std::ostringstream oss; oss << "MEDCouplingFieldDiscretizationP0::getNumberOfTuplesExpectedRegardingCode : input pfl chunck at pos " << pos << " should have " << i << " tuples and one component and with ids all >=0 !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + } + ret+=nbOfEltInChunk; + } + return ret; +} + int MEDCouplingFieldDiscretizationP0::getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const { if(!mesh) @@ -684,6 +719,41 @@ int MEDCouplingFieldDiscretizationOnNodes::getNumberOfTuples(const MEDCouplingMe return mesh->getNumberOfNodes(); } +/*! + * mesh is not used here. It is not a bug ! + */ +int MEDCouplingFieldDiscretizationOnNodes::getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) +{ + if(code.size()%3!=0) + throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationOnNodes::getNumberOfTuplesExpectedRegardingCode : invalid input code !"); + int nbOfSplit=(int)idsPerType.size(); + int nbOfTypes=(int)code.size()/3; + int ret=0; + for(int i=0;i=nbOfSplit) + { + std::ostringstream oss; oss << "MEDCouplingFieldDiscretizationOnNodes::getNumberOfTuplesExpectedRegardingCode : input code points to pos " << pos << " in typeid " << i << " ! Should be in [0," << nbOfSplit << ") !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + const DataArrayInt *ids(idsPerType[pos]); + if(!ids || !ids->isAllocated() || ids->getNumberOfComponents()!=1 || ids->getNumberOfTuples()!=nbOfEltInChunk || ids->getMinValueInArray()<0) + { + std::ostringstream oss; oss << "MEDCouplingFieldDiscretizationOnNodes::getNumberOfTuplesExpectedRegardingCode : input pfl chunck at pos " << pos << " should have " << i << " tuples and one component and with ids all >=0 !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + } + ret+=nbOfEltInChunk; + } + return ret; +} + int MEDCouplingFieldDiscretizationOnNodes::getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const { if(!mesh) @@ -789,7 +859,7 @@ MEDCouplingMesh *MEDCouplingFieldDiscretizationOnNodes::buildSubMeshDataRange(co /*! * This method returns a tuple ids selection from cell ids selection [start;end). - * This method is called by MEDCouplingFieldDiscretizationP0::buildSubMeshData to return parameter \b di. + * This method is called by MEDCouplingFieldDiscretizationOnNodes::buildSubMeshData to return parameter \b di. * Here for P1 only nodes fetched by submesh of mesh[startCellIds:endCellIds) is returned ! * * \return a newly allocated array containing ids to select into the DataArrayDouble of the field. @@ -1248,6 +1318,47 @@ const char *MEDCouplingFieldDiscretizationGauss::getRepr() const return REPR; } +/*! + * mesh is not used here. It is not a bug ! + */ +int MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) +{ + if(!_discr_per_cell || !_discr_per_cell->isAllocated() || _discr_per_cell->getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode"); + if(code.size()%3!=0) + throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode : invalid input code !"); + int nbOfSplit=(int)idsPerType.size(); + int nbOfTypes=(int)code.size()/3; + int ret=0; + for(int i=0;i=nbOfSplit) + { + std::ostringstream oss; oss << "MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode : input code points to pos " << pos << " in typeid " << i << " ! Should be in [0," << nbOfSplit << ") !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + const DataArrayInt *ids(idsPerType[pos]); + if(!ids || !ids->isAllocated() || ids->getNumberOfComponents()!=1 || ids->getNumberOfTuples()!=nbOfEltInChunk || ids->getMinValueInArray()<0) + { + std::ostringstream oss; oss << "MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode : input pfl chunck at pos " << pos << " should have " << i << " tuples and one component and with ids all >=0 !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + } + ret+=nbOfEltInChunk; + } + 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() << " !"; + } + return getNumberOfTuples(0);//0 is not an error ! It is to be sure that input mesh is not used +} + int MEDCouplingFieldDiscretizationGauss::getNumberOfTuples(const MEDCouplingMesh *) const throw(INTERP_KERNEL::Exception) { int ret=0; @@ -1255,8 +1366,17 @@ int MEDCouplingFieldDiscretizationGauss::getNumberOfTuples(const MEDCouplingMesh throw INTERP_KERNEL::Exception("Discretization is not initialized!"); const int *dcPtr=_discr_per_cell->getConstPointer(); int nbOfTuples=_discr_per_cell->getNumberOfTuples(); + int maxSz=(int)_loc.size(); for(const int *w=dcPtr;w!=dcPtr+nbOfTuples;w++) - ret+=_loc[*w].getNumberOfGaussPt(); + { + if(*w>=0 && *w& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) +{ + 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; + for(int i=0;i=nbOfSplit) + { + std::ostringstream oss; oss << "MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuplesExpectedRegardingCode : input code points to pos " << pos << " in typeid " << i << " ! Should be in [0," << nbOfSplit << ") !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + const DataArrayInt *ids(idsPerType[pos]); + if(!ids || !ids->isAllocated() || ids->getNumberOfComponents()!=1 || ids->getNumberOfTuples()!=nbOfEltInChunk || ids->getMinValueInArray()<0) + { + std::ostringstream oss; oss << "MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuplesExpectedRegardingCode : input pfl chunck at pos " << pos << " should have " << i << " tuples and one component and with ids all >=0 !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + } + ret+=nbOfEltInChunk; + } + if(!mesh) + throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuplesExpectedRegardingCode : NULL input mesh !"); + if(ret!=mesh->getNumberOfCells()) + { + std::ostringstream oss; oss << "MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuplesExpectedRegardingCode : input code points to " << ret << " number of cells should be " << mesh->getNumberOfCells() << " !"; + } + return getNumberOfTuples(mesh); +} + int MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception) { if(!mesh)