From: vbd Date: Tue, 11 Jan 2011 16:51:35 +0000 (+0000) Subject: bug correction on MEDCouplingUMesh::MergeUMeshes X-Git-Tag: MEDPartitioner_first_compilable_version~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e85becf1ac2e3b72941d71fc54fb9fcb9b6f5ed7;p=tools%2Fmedcoupling.git bug correction on MEDCouplingUMesh::MergeUMeshes --- diff --git a/src/MEDCoupling/MEDCouplingCMesh.cxx b/src/MEDCoupling/MEDCouplingCMesh.cxx index 9ec8bec95..17c5dfaf4 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCMesh.cxx @@ -275,7 +275,7 @@ int MEDCouplingCMesh::getNodeIdFromPos(int i, int j, int k) const return std::accumulate(tmp,tmp+spaceDim,0); } -void MEDCouplingCMesh::getPosFromId(int nodeId, int spaceDim, const int *split, int *res) +void MEDCouplingCMesh::GetPosFromId(int nodeId, int spaceDim, const int *split, int *res) { int work=nodeId; for(int i=spaceDim-1;i>=0;i--) @@ -351,7 +351,7 @@ void MEDCouplingCMesh::getCoordinatesOfNode(int nodeId, std::vector& coo getSplitNodeValues(tmp); const DataArrayDouble *tabs[3]={getCoordsAt(0),getCoordsAt(1),getCoordsAt(2)}; int tmp2[3]; - getPosFromId(nodeId,spaceDim,tmp,tmp2); + GetPosFromId(nodeId,spaceDim,tmp,tmp2); for(int j=0;jgetConstPointer()[tmp2[j]]); @@ -522,7 +522,7 @@ MEDCouplingFieldDouble *MEDCouplingCMesh::getMeasureField(bool isAbs) const for(int icell=0;icell& conn) const; diff --git a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx b/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx index dc58eb215..0005977fd 100644 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx +++ b/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx @@ -323,7 +323,7 @@ void MEDCouplingExtrudedMesh::renumberCells(const int *old2NewBg, bool check) th MEDCouplingUMesh *MEDCouplingExtrudedMesh::build3DUnstructuredMesh() const { - MEDCouplingUMesh *ret=_mesh2D->buildExtrudedMeshFromThis(_mesh1D,0); + MEDCouplingUMesh *ret=_mesh2D->buildExtrudedMesh(_mesh1D,0); const int *renum=_mesh3D_ids->getConstPointer(); ret->renumberCells(renum,false); ret->setName(getName()); @@ -499,7 +499,7 @@ void MEDCouplingExtrudedMesh::computeBaryCenterOfFace(const std::vector& no std::transform(zoneToUpdate,zoneToUpdate+3,zoneToUpdate,std::bind2nd(std::multiplies(),(double)(1./nodalConnec.size()))); } -int MEDCouplingExtrudedMesh::findCorrespCellByNodalConn(const std::vector& nodalConnec, const int *revNodalPtr, const int *revNodalIndxPtr) throw(INTERP_KERNEL::Exception) +int MEDCouplingExtrudedMesh::FindCorrespCellByNodalConn(const std::vector& nodalConnec, const int *revNodalPtr, const int *revNodalIndxPtr) throw(INTERP_KERNEL::Exception) { std::vector::const_iterator iter=nodalConnec.begin(); std::set s1(revNodalPtr+revNodalIndxPtr[*iter],revNodalPtr+revNodalIndxPtr[*iter+1]); @@ -533,11 +533,11 @@ int MEDCouplingExtrudedMesh::findCorrespCellByNodalConn(const std::vector& * @param v is the output normalized vector of the common direction of 'm1' and 'm2' * @throw in case that m1 and m2 are not compatible each other. */ -void MEDCouplingExtrudedMesh::project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps, +void MEDCouplingExtrudedMesh::Project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps, MEDCouplingUMesh *&m1r, MEDCouplingUMesh *&m2r, double *v) throw(INTERP_KERNEL::Exception) { if(m1->getSpaceDimension()!=3 || m1->getSpaceDimension()!=3) - throw INTERP_KERNEL::Exception("Input meshes are expected to have a spaceDim==3 for projec1D !"); + throw INTERP_KERNEL::Exception("Input meshes are expected to have a spaceDim==3 for Projec1D !"); m1r=m1->clone(true); m2r=m2->clone(true); m1r->changeSpaceDimension(1); @@ -665,7 +665,7 @@ void MEDCouplingExtrudedMesh::computeExtrusionAlg(const MEDCouplingUMesh *mesh3D std::vector nodalConnec(nodal2D+nodal2DIndx[i]+1,nodal2D+nodal2DIndx[i+1]); try { - idInSubMesh=findCorrespCellByNodalConn(nodalConnec,revNodal2DPtr,revNodalIndx2DPtr); + idInSubMesh=FindCorrespCellByNodalConn(nodalConnec,revNodal2DPtr,revNodalIndx2DPtr); } catch(INTERP_KERNEL::Exception& e) { diff --git a/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx b/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx index d5025341e..91c5a80ca 100644 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx +++ b/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx @@ -70,9 +70,9 @@ namespace ParaMEDMEM MEDCouplingFieldDouble *getMeasureFieldOnNode(bool) const; MEDCouplingFieldDouble *buildOrthogonalField() const; int getCellContainingPoint(const double *pos, double eps) const; - static int findCorrespCellByNodalConn(const std::vector& nodalConnec, + static int FindCorrespCellByNodalConn(const std::vector& nodalConnec, const int *revNodalPtr, const int *revNodalIndxPtr) throw(INTERP_KERNEL::Exception); - static void project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps, + static void Project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps, MEDCouplingUMesh *&m1r, MEDCouplingUMesh *&m2r, double *v) throw(INTERP_KERNEL::Exception); void rotate(const double *center, const double *vector, double angle); void translate(const double *vector); diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx index d5c1a1e8c..ab0604dec 100644 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx @@ -338,7 +338,7 @@ void MEDCouplingFieldDiscretizationP0::renumberArraysForCell(const MEDCouplingMe { const int *array=old2NewBg; if(check) - array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells()); + array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells()); for(std::vector::const_iterator it=arrays.begin();it!=arrays.end();it++) { if(*it) @@ -637,7 +637,7 @@ void MEDCouplingFieldDiscretizationPerCell::renumberCells(const int *old2NewBg, int nbCells=_discr_per_cell->getNumberOfTuples(); const int *array=old2NewBg; if(check) - array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+nbCells); + array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+nbCells); // DataArrayInt *dpc=_discr_per_cell->renumber(array); _discr_per_cell->decrRef(); @@ -729,7 +729,7 @@ void MEDCouplingFieldDiscretizationGauss::renumberArraysForCell(const MEDCouplin { const int *array=old2NewBg; if(check) - array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells()); + array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells()); int nbOfCells=_discr_per_cell->getNumberOfTuples(); int nbOfTuples=getNumberOfTuples(0); const int *dcPtr=_discr_per_cell->getConstPointer(); @@ -1113,7 +1113,7 @@ void MEDCouplingFieldDiscretizationGaussNE::renumberArraysForCell(const MEDCoupl { const int *array=old2NewBg; if(check) - array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells()); + array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells()); int nbOfCells=mesh->getNumberOfCells(); int nbOfTuples=getNumberOfTuples(mesh); int *array2=new int[nbOfTuples];//stores the final conversion array old2New to give to arrays in renumberInPlace. diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx index d24f36c12..7edb7fbb9 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.cxx @@ -1282,10 +1282,10 @@ void MEDCouplingFieldDouble::sortPerTuple(bool asc) throw(INTERP_KERNEL::Excepti _time_discr->sortPerTuple(asc); } -MEDCouplingFieldDouble *MEDCouplingFieldDouble::mergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) +MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) { if(!f1->areCompatibleForMerge(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply mergeFields on them !"); + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MergeFields on them !"); const MEDCouplingMesh *m1=f1->getMesh(); const MEDCouplingMesh *m2=f2->getMesh(); MEDCouplingMesh *m=m1->mergeMyselfWith(m2); @@ -1299,10 +1299,10 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::mergeFields(const MEDCouplingFie return ret; } -MEDCouplingFieldDouble *MEDCouplingFieldDouble::mergeFields(const std::vector& a) throw(INTERP_KERNEL::Exception) +MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const std::vector& a) throw(INTERP_KERNEL::Exception) { if(a.size()<=1) - throw INTERP_KERNEL::Exception("FieldDouble::mergeFields : size of array must be > 1 !"); + throw INTERP_KERNEL::Exception("FieldDouble::MergeFields : size of array must be > 1 !"); std::vector< MEDCouplingAutoRefCountObjectPtr > ms(a.size()); std::vector< const MEDCouplingUMesh *> ms2(a.size()); std::vector< const MEDCouplingTimeDiscretization *> tds(a.size()); @@ -1310,16 +1310,16 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::mergeFields(const std::vectorareCompatibleForMerge(*it)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply mergeFields on them !"); + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MergeFields on them !"); for(int i=0;i<(int)a.size();i++) { if(!a[i]->getMesh()) - throw INTERP_KERNEL::Exception("mergeFields : A field as no underlying mesh !"); + throw INTERP_KERNEL::Exception("MergeFields : A field as no underlying mesh !"); ms[i]=a[i]->getMesh()->buildUnstructured(); ms2[i]=ms[i]; tds[i]=a[i]->_time_discr; } - MEDCouplingAutoRefCountObjectPtr m=MEDCouplingUMesh::mergeUMeshes(ms2); + MEDCouplingAutoRefCountObjectPtr m=MEDCouplingUMesh::MergeUMeshes(ms2); MEDCouplingTimeDiscretization *td=tds[0]->aggregate(tds); td->copyTinyAttrFrom(*(a[0]->_time_discr)); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(a[0]->getNature(),td,a[0]->_type->clone()); @@ -1329,10 +1329,10 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::mergeFields(const std::vectorareCompatibleForMeld(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply meldFields on them !"); + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MeldFields on them !"); MEDCouplingTimeDiscretization *td=f1->_time_discr->meld(f2->_time_discr); td->copyTinyAttrFrom(*f1->_time_discr); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); @@ -1340,10 +1340,10 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::meldFields(const MEDCouplingFiel return ret; } -MEDCouplingFieldDouble *MEDCouplingFieldDouble::dotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) +MEDCouplingFieldDouble *MEDCouplingFieldDouble::DotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) { if(!f1->areStrictlyCompatible(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply dotFields on them !"); + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply DotFields on them !"); MEDCouplingTimeDiscretization *td=f1->_time_discr->dot(f2->_time_discr); td->copyTinyAttrFrom(*f1->_time_discr); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); @@ -1351,10 +1351,10 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::dotFields(const MEDCouplingField return ret; } -MEDCouplingFieldDouble *MEDCouplingFieldDouble::crossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) +MEDCouplingFieldDouble *MEDCouplingFieldDouble::CrossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) { if(!f1->areStrictlyCompatible(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply crossProductFields on them !"); + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply CrossProductFields on them !"); MEDCouplingTimeDiscretization *td=f1->_time_discr->crossProduct(f2->_time_discr); td->copyTinyAttrFrom(*f1->_time_discr); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); @@ -1362,10 +1362,10 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::crossProductFields(const MEDCoup return ret; } -MEDCouplingFieldDouble *MEDCouplingFieldDouble::maxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) +MEDCouplingFieldDouble *MEDCouplingFieldDouble::MaxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) { if(!f1->areStrictlyCompatible(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply maxFields on them !"); + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MaxFields on them !"); MEDCouplingTimeDiscretization *td=f1->_time_discr->max(f2->_time_discr); td->copyTinyAttrFrom(*f1->_time_discr); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); @@ -1373,10 +1373,10 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::maxFields(const MEDCouplingField return ret; } -MEDCouplingFieldDouble *MEDCouplingFieldDouble::minFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) +MEDCouplingFieldDouble *MEDCouplingFieldDouble::MinFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) { if(!f1->areStrictlyCompatible(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply minFields on them !"); + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MinFields on them !"); MEDCouplingTimeDiscretization *td=f1->_time_discr->min(f2->_time_discr); td->copyTinyAttrFrom(*f1->_time_discr); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); @@ -1384,10 +1384,10 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::minFields(const MEDCouplingField return ret; } -MEDCouplingFieldDouble *MEDCouplingFieldDouble::addFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) +MEDCouplingFieldDouble *MEDCouplingFieldDouble::AddFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) { if(!f1->areStrictlyCompatible(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply addFields on them !"); + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply AddFields on them !"); MEDCouplingTimeDiscretization *td=f1->_time_discr->add(f2->_time_discr); td->copyTinyAttrFrom(*f1->_time_discr); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); @@ -1403,10 +1403,10 @@ const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator+=(const MEDCoupli return *this; } -MEDCouplingFieldDouble *MEDCouplingFieldDouble::substractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) +MEDCouplingFieldDouble *MEDCouplingFieldDouble::SubstractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) { if(!f1->areStrictlyCompatible(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply substractFields on them !"); + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply SubstractFields on them !"); MEDCouplingTimeDiscretization *td=f1->_time_discr->substract(f2->_time_discr); td->copyTinyAttrFrom(*f1->_time_discr); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); @@ -1422,10 +1422,10 @@ const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator-=(const MEDCoupli return *this; } -MEDCouplingFieldDouble *MEDCouplingFieldDouble::multiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) +MEDCouplingFieldDouble *MEDCouplingFieldDouble::MultiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) { if(!f1->areCompatibleForMul(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply multiplyFields on them !"); + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MultiplyFields on them !"); MEDCouplingTimeDiscretization *td=f1->_time_discr->multiply(f2->_time_discr); td->copyTinyAttrFrom(*f1->_time_discr); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); @@ -1441,10 +1441,10 @@ const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator*=(const MEDCoupli return *this; } -MEDCouplingFieldDouble *MEDCouplingFieldDouble::divideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) +MEDCouplingFieldDouble *MEDCouplingFieldDouble::DivideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) { if(!f1->areCompatibleForDiv(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply divideFields on them !"); + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply DivideFields on them !"); MEDCouplingTimeDiscretization *td=f1->_time_discr->divide(f2->_time_discr); td->copyTinyAttrFrom(*f1->_time_discr); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.hxx b/src/MEDCoupling/MEDCouplingFieldDouble.hxx index 719bc41c8..6c4a7c0b7 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.hxx @@ -60,6 +60,12 @@ namespace ParaMEDMEM void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception); void setTimeTolerance(double val) { _time_discr->setTimeTolerance(val); } double getTimeTolerance() const { return _time_discr->getTimeTolerance(); } + void setIteration(int it) throw(INTERP_KERNEL::Exception) { _time_discr->setIteration(it); } + void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _time_discr->setEndIteration(it); } + void setOrder(int order) throw(INTERP_KERNEL::Exception) { _time_discr->setOrder(order); } + void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _time_discr->setEndOrder(order); } + void setTimeValue(double val) throw(INTERP_KERNEL::Exception) { _time_discr->setTimeValue(val); } + void setEndTimeValue(double val) throw(INTERP_KERNEL::Exception) { _time_discr->setEndTimeValue(val); } void setTime(double val, int iteration, int order) { _time_discr->setTime(val,iteration,order); } void setStartTime(double val, int iteration, int order) { _time_discr->setStartTime(val,iteration,order); } void setEndTime(double val, int iteration, int order) { _time_discr->setEndTime(val,iteration,order); } @@ -132,29 +138,29 @@ namespace ParaMEDMEM MEDCouplingFieldDouble *keepSelectedComponents(const std::vector& compoIds) const throw(INTERP_KERNEL::Exception); void setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector& compoIds) throw(INTERP_KERNEL::Exception); void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception); - static MEDCouplingFieldDouble *mergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); - static MEDCouplingFieldDouble *mergeFields(const std::vector& a) throw(INTERP_KERNEL::Exception); - static MEDCouplingFieldDouble *meldFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); - static MEDCouplingFieldDouble *dotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *dot(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return dotFields(this,&other); } - static MEDCouplingFieldDouble *crossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *crossProduct(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return crossProductFields(this,&other); } - static MEDCouplingFieldDouble *maxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *max(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return maxFields(this,&other); } - static MEDCouplingFieldDouble *minFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *min(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return minFields(this,&other); } - MEDCouplingFieldDouble *operator+(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return addFields(this,&other); } + static MEDCouplingFieldDouble *MergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *MergeFields(const std::vector& a) throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *MeldFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *DotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *dot(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return DotFields(this,&other); } + static MEDCouplingFieldDouble *CrossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *crossProduct(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return CrossProductFields(this,&other); } + static MEDCouplingFieldDouble *MaxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *max(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return MaxFields(this,&other); } + static MEDCouplingFieldDouble *MinFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *min(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return MinFields(this,&other); } + MEDCouplingFieldDouble *operator+(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return AddFields(this,&other); } const MEDCouplingFieldDouble &operator+=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception); - static MEDCouplingFieldDouble *addFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *operator-(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return substractFields(this,&other); } + static MEDCouplingFieldDouble *AddFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *operator-(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return SubstractFields(this,&other); } const MEDCouplingFieldDouble &operator-=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception); - static MEDCouplingFieldDouble *substractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *operator*(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return multiplyFields(this,&other); } + static MEDCouplingFieldDouble *SubstractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *operator*(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return MultiplyFields(this,&other); } const MEDCouplingFieldDouble &operator*=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception); - static MEDCouplingFieldDouble *multiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *operator/(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return divideFields(this,&other); } + static MEDCouplingFieldDouble *MultiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *operator/(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return DivideFields(this,&other); } const MEDCouplingFieldDouble &operator/=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception); - static MEDCouplingFieldDouble *divideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *DivideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); private: MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td); MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCpy); diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 8c94de8b4..bdb858bf9 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -196,6 +197,14 @@ bool DataArrayDouble::isUniform(double val, double eps) const return true; } +void DataArrayDouble::sort() throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayDouble::sort : only supported with 'this' array with ONE component !"); + _mem.sort(); +} + std::string DataArrayDouble::repr() const { std::ostringstream ret; @@ -436,8 +445,8 @@ DataArrayDouble *DataArrayDouble::substr(int tupleIdBg, int tupleIdEnd) const th int nbt=getNumberOfTuples(); if(tupleIdBg<0) throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter must be greater than 0 !"); - if(tupleIdBg>=nbt) - throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter is greater or equal than number of tuples !"); + if(tupleIdBg>nbt) + throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter is greater than number of tuples !"); int trueEnd=tupleIdEnd; if(tupleIdEnd!=-1) { @@ -484,6 +493,25 @@ DataArrayDouble *DataArrayDouble::changeNbOfComponents(int newNbOfComp, double d return ret; } +/*! + * Contrary to DataArrayDouble::changeNbOfComponents method this method is \b not const. The content + * This method \b do \b not change the content of data but changes the splitting of this data seen by the caller. + * This method makes the assumption that 'this' is already allocated. If not an exception will be thrown. + * This method checks that getNbOfElems()%newNbOfCompo==0. If not an exception will be throw ! + * This method erases all components info set before call ! + */ +void DataArrayDouble::rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + int nbOfElems=getNbOfElems(); + if(nbOfElems%newNbOfCompo!=0) + throw INTERP_KERNEL::Exception("DataArrayDouble::rearrange : nbOfElems%newNbOfCompo!=0 !"); + _nb_of_tuples=nbOfElems/newNbOfCompo; + _info_on_compo.clear(); + _info_on_compo.resize(newNbOfCompo); + declareAsNew(); +} + DataArrayDouble *DataArrayDouble::keepSelectedComponents(const std::vector& compoIds) const throw(INTERP_KERNEL::Exception) { checkAllocated(); @@ -546,7 +574,7 @@ void DataArrayDouble::setSelectedComponents(const DataArrayDouble *a, const std: nc[nbOfCompo*i+compoIds[j]]=*ac; } -void DataArrayDouble::setArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet) +void DataArrayDouble::SetArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet) { if(newArray!=arrayToSet) { @@ -1087,24 +1115,24 @@ DataArrayInt *DataArrayDouble::getIdsInRange(double vmin, double vmax) const thr return ret; } -DataArrayDouble *DataArrayDouble::aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) +DataArrayDouble *DataArrayDouble::Aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) { std::vector tmp(2); tmp[0]=a1; tmp[1]=a2; - return aggregate(tmp); + return Aggregate(tmp); } -DataArrayDouble *DataArrayDouble::aggregate(const std::vector& a) throw(INTERP_KERNEL::Exception) +DataArrayDouble *DataArrayDouble::Aggregate(const std::vector& a) throw(INTERP_KERNEL::Exception) { if(a.empty()) - throw INTERP_KERNEL::Exception("DataArrayDouble::aggregate : input list must be NON EMPTY !"); + throw INTERP_KERNEL::Exception("DataArrayDouble::Aggregate : input list must be NON EMPTY !"); std::vector::const_iterator it=a.begin(); int nbOfComp=(*it)->getNumberOfComponents(); int nbt=(*it++)->getNumberOfTuples(); for(int i=1;it!=a.end();it++,i++) { if((*it)->getNumberOfComponents()!=nbOfComp) - throw INTERP_KERNEL::Exception("DataArrayDouble::aggregate : Nb of components mismatch for array aggregation !"); + throw INTERP_KERNEL::Exception("DataArrayDouble::Aggregate : Nb of components mismatch for array aggregation !"); nbt+=(*it)->getNumberOfTuples(); } DataArrayDouble *ret=DataArrayDouble::New(); @@ -1116,17 +1144,17 @@ DataArrayDouble *DataArrayDouble::aggregate(const std::vector arr(2); arr[0]=a1; arr[1]=a2; - return meld(arr); + return Meld(arr); } -DataArrayDouble *DataArrayDouble::meld(const std::vector& a) throw(INTERP_KERNEL::Exception) +DataArrayDouble *DataArrayDouble::Meld(const std::vector& a) throw(INTERP_KERNEL::Exception) { if(a.empty()) - throw INTERP_KERNEL::Exception("DataArrayDouble::meld : array must be NON empty !"); + throw INTERP_KERNEL::Exception("DataArrayDouble::Meld : array must be NON empty !"); std::vector::const_iterator it; for(it=a.begin();it!=a.end();it++) (*it)->checkAllocated(); @@ -1139,7 +1167,7 @@ DataArrayDouble *DataArrayDouble::meld(const std::vectorgetNumberOfTuples()) - throw INTERP_KERNEL::Exception("DataArrayDouble::meld : mismatch of number of tuples !"); + throw INTERP_KERNEL::Exception("DataArrayDouble::Meld : mismatch of number of tuples !"); nbc[i]=(*it)->getNumberOfComponents(); pts[i]=(*it)->getConstPointer(); } @@ -1160,16 +1188,16 @@ DataArrayDouble *DataArrayDouble::meld(const std::vectorcheckAllocated(); a2->checkAllocated(); int nbOfComp=a1->getNumberOfComponents(); if(nbOfComp!=a2->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array dot !"); + throw INTERP_KERNEL::Exception("Nb of components mismatch for array Dot !"); int nbOfTuple=a1->getNumberOfTuples(); if(nbOfTuple!=a2->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array dot !"); + throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Dot !"); DataArrayDouble *ret=DataArrayDouble::New(); ret->alloc(nbOfTuple,1); double *retPtr=ret->getPointer(); @@ -1187,7 +1215,7 @@ DataArrayDouble *DataArrayDouble::dot(const DataArrayDouble *a1, const DataArray return ret; } -DataArrayDouble *DataArrayDouble::crossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) +DataArrayDouble *DataArrayDouble::CrossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) { int nbOfComp=a1->getNumberOfComponents(); if(nbOfComp!=a2->getNumberOfComponents()) @@ -1212,14 +1240,14 @@ DataArrayDouble *DataArrayDouble::crossProduct(const DataArrayDouble *a1, const return ret; } -DataArrayDouble *DataArrayDouble::max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) +DataArrayDouble *DataArrayDouble::Max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) { int nbOfComp=a1->getNumberOfComponents(); if(nbOfComp!=a2->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array max !"); + throw INTERP_KERNEL::Exception("Nb of components mismatch for array Max !"); int nbOfTuple=a1->getNumberOfTuples(); if(nbOfTuple!=a2->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array max !"); + throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Max !"); DataArrayDouble *ret=DataArrayDouble::New(); ret->alloc(nbOfTuple,nbOfComp); double *retPtr=ret->getPointer(); @@ -1232,7 +1260,7 @@ DataArrayDouble *DataArrayDouble::max(const DataArrayDouble *a1, const DataArray return ret; } -DataArrayDouble *DataArrayDouble::min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) +DataArrayDouble *DataArrayDouble::Min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) { int nbOfComp=a1->getNumberOfComponents(); if(nbOfComp!=a2->getNumberOfComponents()) @@ -1252,7 +1280,7 @@ DataArrayDouble *DataArrayDouble::min(const DataArrayDouble *a1, const DataArray return ret; } -DataArrayDouble *DataArrayDouble::add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) +DataArrayDouble *DataArrayDouble::Add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) { int nbOfComp=a1->getNumberOfComponents(); if(nbOfComp!=a2->getNumberOfComponents()) @@ -1279,14 +1307,14 @@ void DataArrayDouble::addEqual(const DataArrayDouble *other) throw(INTERP_KERNEL declareAsNew(); } -DataArrayDouble *DataArrayDouble::substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) +DataArrayDouble *DataArrayDouble::Substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) { int nbOfComp=a1->getNumberOfComponents(); if(nbOfComp!=a2->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array substract !"); + throw INTERP_KERNEL::Exception("Nb of components mismatch for array Substract !"); int nbOfTuple=a1->getNumberOfTuples(); if(nbOfTuple!=a2->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array substract !"); + throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Substract !"); DataArrayDouble *ret=DataArrayDouble::New(); ret->alloc(nbOfTuple,nbOfComp); std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::minus()); @@ -1306,7 +1334,7 @@ void DataArrayDouble::substractEqual(const DataArrayDouble *other) throw(INTERP_ declareAsNew(); } -DataArrayDouble *DataArrayDouble::multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) +DataArrayDouble *DataArrayDouble::Multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) { int nbOfTuple=a1->getNumberOfTuples(); int nbOfTuple2=a2->getNumberOfTuples(); @@ -1380,7 +1408,7 @@ void DataArrayDouble::multiplyEqual(const DataArrayDouble *other) throw(INTERP_K declareAsNew(); } -DataArrayDouble *DataArrayDouble::divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) +DataArrayDouble *DataArrayDouble::Divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) { int nbOfTuple=a1->getNumberOfTuples(); int nbOfTuple2=a2->getNumberOfTuples(); @@ -1599,6 +1627,60 @@ bool DataArrayInt::isEqualWithoutConsideringStr(const DataArrayInt& other) const return _mem.isEqual(other._mem,0); } +bool DataArrayInt::isEqualWithoutConsideringStrAndOrder(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception) +{ + MEDCouplingAutoRefCountObjectPtr a=deepCpy(); + MEDCouplingAutoRefCountObjectPtr b=other.deepCpy(); + a->sort(); + b->sort(); + return a->isEqualWithoutConsideringStr(*b); +} + +void DataArrayInt::sort() throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::sort : only supported with 'this' array with ONE component !"); + _mem.sort(); +} + +/*! + * This method expects that 'this' and 'other' have the same number of tuples and exactly one component both. If not an exception will be thrown. + * This method retrieves a newly created array with same number of tuples than 'this' and 'other' with one component. + * The returned array 'ret' contains the correspondance from 'this' to 'other' that is to say for every i so that 0<=igetIJ(ret->getIJ(i),0) + * If such permutation is not possible because it exists some elements in 'other' not in 'this', an exception will be thrown. + */ +DataArrayInt *DataArrayInt::buildPermutationArr(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception) +{ + if(getNumberOfComponents()!=1 || other.getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::buildPermutationArr : 'this' and 'other' have to have exactly ONE component !"); + int nbTuple=getNumberOfTuples(); + if(nbTuple!=other.getNumberOfTuples()) + throw INTERP_KERNEL::Exception("DataArrayInt::buildPermutationArr : 'this' and 'other' must have the same number of tuple !"); + MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + ret->alloc(nbTuple,1); + ret->fillWithValue(-1); + const int *pt=getConstPointer(); + std::map mm; + for(int i=0;igetPointer(); + for(int i=0;i::const_iterator it=mm.find(pt[i]); + if(it==mm.end()) + { + std::ostringstream oss; oss << "DataArrayInt::buildPermutationArr : Arrays mismatch : element (" << pt[i] << ") in 'other' not findable in 'this' !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + retToFill[i]=(*it).second; + } + ret->incrRef(); + return ret; +} + void DataArrayInt::useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo) { _nb_of_tuples=nbOfTuple; @@ -1801,8 +1883,8 @@ DataArrayInt *DataArrayInt::substr(int tupleIdBg, int tupleIdEnd) const throw(IN int nbt=getNumberOfTuples(); if(tupleIdBg<0) throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter must be greater than 0 !"); - if(tupleIdBg>=nbt) - throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter is greater or equal than number of tuples !"); + if(tupleIdBg>nbt) + throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter is greater than number of tuples !"); int trueEnd=tupleIdEnd; if(tupleIdEnd!=-1) { @@ -1819,6 +1901,25 @@ DataArrayInt *DataArrayInt::substr(int tupleIdBg, int tupleIdEnd) const throw(IN return ret; } +/*! + * Contrary to DataArrayInt::changeNbOfComponents method this method is \b not const. The content + * This method \b do \b not change the content of data but changes the splitting of this data seen by the caller. + * This method makes the assumption that 'this' is already allocated. If not an exception will be thrown. + * This method checks that getNbOfElems()%newNbOfCompo==0. If not an exception will be throw ! + * This method erases all components info set before call ! + */ +void DataArrayInt::rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + int nbOfElems=getNbOfElems(); + if(nbOfElems%newNbOfCompo!=0) + throw INTERP_KERNEL::Exception("DataArrayInt::rearrange : nbOfElems%newNbOfCompo!=0 !"); + _nb_of_tuples=nbOfElems/newNbOfCompo; + _info_on_compo.clear(); + _info_on_compo.resize(newNbOfCompo); + declareAsNew(); +} + /*! * This method builds a new instance of DataArrayInt (to deal with) that is reduction or an extension of 'this'. * if 'newNbOfComp' < this->getNumberOfComponents() a reduction is done and for each tuple 'newNbOfComp' first components are kept. @@ -1919,7 +2020,7 @@ void DataArrayInt::setSelectedComponents(const DataArrayInt *a, const std::vecto nc[nbOfCompo*i+compoIds[j]]=*ac; } -void DataArrayInt::setArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet) +void DataArrayInt::SetArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet) { if(newArray!=arrayToSet) { @@ -1964,11 +2065,11 @@ DataArrayInt *DataArrayInt::getIdsEqualList(const std::vector& vals) const return ret; } -DataArrayInt *DataArrayInt::aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2) +DataArrayInt *DataArrayInt::Aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2) { int nbOfComp=a1->getNumberOfComponents(); if(nbOfComp!=a2->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array aggregation !"); + throw INTERP_KERNEL::Exception("Nb of components mismatch for array Aggregation !"); int nbOfTuple1=a1->getNumberOfTuples(); int nbOfTuple2=a2->getNumberOfTuples(); DataArrayInt *ret=DataArrayInt::New(); @@ -1979,6 +2080,28 @@ DataArrayInt *DataArrayInt::aggregate(const DataArrayInt *a1, const DataArrayInt return ret; } +DataArrayInt *DataArrayInt::Aggregate(const std::vector& a) throw(INTERP_KERNEL::Exception) +{ + if(a.empty()) + throw INTERP_KERNEL::Exception("DataArrayInt::Aggregate : input list must be NON EMPTY !"); + std::vector::const_iterator it=a.begin(); + int nbOfComp=(*it)->getNumberOfComponents(); + int nbt=(*it++)->getNumberOfTuples(); + for(int i=1;it!=a.end();it++,i++) + { + if((*it)->getNumberOfComponents()!=nbOfComp) + throw INTERP_KERNEL::Exception("DataArrayInt::Aggregate : Nb of components mismatch for array aggregation !"); + nbt+=(*it)->getNumberOfTuples(); + } + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(nbt,nbOfComp); + int *pt=ret->getPointer(); + for(it=a.begin();it!=a.end();it++) + pt=std::copy((*it)->getConstPointer(),(*it)->getConstPointer()+(*it)->getNbOfElems(),pt); + ret->copyStringInfoFrom(*(a[0])); + return ret; +} + int DataArrayInt::getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception) { if(getNumberOfComponents()!=1) @@ -2005,17 +2128,28 @@ int DataArrayInt::getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception return *loc; } -DataArrayInt *DataArrayInt::meld(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception) +void DataArrayInt::applyLin(int a, int b, int compoId) throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + int *ptr=getPointer()+compoId; + int nbOfComp=getNumberOfComponents(); + int nbOfTuple=getNumberOfTuples(); + for(int i=0;i arr(2); arr[0]=a1; arr[1]=a2; - return meld(arr); + return Meld(arr); } -DataArrayInt *DataArrayInt::meld(const std::vector& a) throw(INTERP_KERNEL::Exception) +DataArrayInt *DataArrayInt::Meld(const std::vector& a) throw(INTERP_KERNEL::Exception) { if(a.empty()) - throw INTERP_KERNEL::Exception("DataArrayInt::meld : array must be NON empty !"); + throw INTERP_KERNEL::Exception("DataArrayInt::Meld : array must be NON empty !"); std::vector::const_iterator it; for(it=a.begin();it!=a.end();it++) (*it)->checkAllocated(); @@ -2058,14 +2192,14 @@ DataArrayInt *DataArrayInt::meld(const std::vector& a) thr * @param newNb specifies size of whole set. Must be at least equal to max eltid in 'groups'. * @return an array of size newNb specifying fid of each item. */ -DataArrayInt *DataArrayInt::makePartition(const std::vector& groups, int newNb, std::vector< std::vector >& fidsOfGroups) +DataArrayInt *DataArrayInt::MakePartition(const std::vector& groups, int newNb, std::vector< std::vector >& fidsOfGroups) { DataArrayInt *ret=DataArrayInt::New(); ret->alloc(newNb,1); int *retPtr=ret->getPointer(); std::fill(retPtr,retPtr+newNb,0); int fid=1; - for(std::vector::const_iterator iter=groups.begin();iter!=groups.end();iter++) + for(std::vector::const_iterator iter=groups.begin();iter!=groups.end();iter++) { const int *ptr=(*iter)->getConstPointer(); int nbOfElem=(*iter)->getNbOfElems(); @@ -2088,7 +2222,7 @@ DataArrayInt *DataArrayInt::makePartition(const std::vector& gro fidsOfGroups.clear(); fidsOfGroups.resize(groups.size()); int grId=0; - for(std::vector::const_iterator iter=groups.begin();iter!=groups.end();iter++,grId++) + for(std::vector::const_iterator iter=groups.begin();iter!=groups.end();iter++,grId++) { std::set tmp; const int *ptr=(*iter)->getConstPointer(); @@ -2100,6 +2234,68 @@ DataArrayInt *DataArrayInt::makePartition(const std::vector& gro return ret; } +DataArrayInt *DataArrayInt::BuildUnion(const std::vector& a) throw(INTERP_KERNEL::Exception) +{ + int valm=std::numeric_limits::max(); + for(std::vector::const_iterator it=a.begin();it!=a.end();it++) + { + (*it)->checkAllocated(); + if((*it)->getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::BuildUnion : only single component allowed !"); + int tmp1; + valm=std::min((*it)->getMinValue(tmp1),valm); + } + if(valm<0) + throw INTERP_KERNEL::Exception("DataArrayInt::BuildUnion : a negative value has been detected !"); + // + std::set r; + for(std::vector::const_iterator it=a.begin();it!=a.end();it++) + { + const int *pt=(*it)->getConstPointer(); + int nbOfTuples=(*it)->getNumberOfTuples(); + r.insert(pt,pt+nbOfTuples); + } + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(r.size(),1); + std::copy(r.begin(),r.end(),ret->getPointer()); + return ret; +} + +DataArrayInt *DataArrayInt::BuildIntersection(const std::vector& a) throw(INTERP_KERNEL::Exception) +{ + int valm=std::numeric_limits::max(); + for(std::vector::const_iterator it=a.begin();it!=a.end();it++) + { + (*it)->checkAllocated(); + if((*it)->getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::BuildUnion : only single component allowed !"); + int tmp1; + valm=std::min((*it)->getMinValue(tmp1),valm); + } + if(valm<0) + throw INTERP_KERNEL::Exception("DataArrayInt::BuildUnion : a negative value has been detected !"); + // + std::set r; + for(std::vector::const_iterator it=a.begin();it!=a.end();it++) + { + const int *pt=(*it)->getConstPointer(); + int nbOfTuples=(*it)->getNumberOfTuples(); + std::set s1(pt,pt+nbOfTuples); + if(it!=a.begin()) + { + std::set r2; + std::set_intersection(r.begin(),r.end(),s1.begin(),s1.end(),inserter(r2,r2.end())); + r=r2; + } + else + r=s1; + } + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(r.size(),1); + std::copy(r.begin(),r.end(),ret->getPointer()); + return ret; +} + DataArrayInt *DataArrayInt::buildComplement(int nbOfElement) const throw(INTERP_KERNEL::Exception) { checkAllocated(); @@ -2148,58 +2344,16 @@ DataArrayInt *DataArrayInt::buildSubstraction(const DataArrayInt *other) const t DataArrayInt *DataArrayInt::buildUnion(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception) { - checkAllocated(); - other->checkAllocated(); - if(getNumberOfComponents()!=1) - throw INTERP_KERNEL::Exception("DataArrayInt::buildUnion : only single component allowed !"); - if(other->getNumberOfComponents()!=1) - throw INTERP_KERNEL::Exception("DataArrayInt::buildUnion : only single component allowed for other type !"); - int tmp1; - int valm=getMinValue(tmp1); - valm=std::min(other->getMinValue(tmp1),valm); - if(valm<0) - throw INTERP_KERNEL::Exception("DataArrayInt::buildUnion : a negative value has been detected !"); - // - const int *pt=getConstPointer(); - int nbOfTuples=getNumberOfTuples(); - std::set s1(pt,pt+nbOfTuples); - pt=other->getConstPointer(); - nbOfTuples=other->getNumberOfTuples(); - std::set s2(pt,pt+nbOfTuples); - std::vector r; - std::set_union(s1.begin(),s1.end(),s2.begin(),s2.end(),std::back_insert_iterator< std::vector >(r)); - DataArrayInt *ret=DataArrayInt::New(); - ret->alloc(r.size(),1); - std::copy(r.begin(),r.end(),ret->getPointer()); - return ret; + std::vectorarrs(2); + arrs[0]=this; arrs[1]=other; + return BuildUnion(arrs); } DataArrayInt *DataArrayInt::buildIntersection(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception) { - checkAllocated(); - other->checkAllocated(); - if(getNumberOfComponents()!=1) - throw INTERP_KERNEL::Exception("DataArrayInt::buildIntersection : only single component allowed !"); - if(other->getNumberOfComponents()!=1) - throw INTERP_KERNEL::Exception("DataArrayInt::buildIntersection : only single component allowed for other type !"); - int tmp1; - int valm=getMinValue(tmp1); - valm=std::min(other->getMinValue(tmp1),valm); - if(valm<0) - throw INTERP_KERNEL::Exception("DataArrayInt::buildIntersection : a negative value has been detected !"); - // - const int *pt=getConstPointer(); - int nbOfTuples=getNumberOfTuples(); - std::set s1(pt,pt+nbOfTuples); - pt=other->getConstPointer(); - nbOfTuples=other->getNumberOfTuples(); - std::set s2(pt,pt+nbOfTuples); - std::vector r; - std::set_intersection(s1.begin(),s1.end(),s2.begin(),s2.end(),std::back_insert_iterator< std::vector >(r)); - DataArrayInt *ret=DataArrayInt::New(); - ret->alloc(r.size(),1); - std::copy(r.begin(),r.end(),ret->getPointer()); - return ret; + std::vectorarrs(2); + arrs[0]=this; arrs[1]=other; + return BuildIntersection(arrs); } /*! @@ -2226,7 +2380,18 @@ DataArrayInt *DataArrayInt::deltaShiftIndex() const throw(INTERP_KERNEL::Excepti return ret; } -int *DataArrayInt::checkAndPreparePermutation(const int *start, const int *end) +/*! + * This method returns all different values found in 'this'. + */ +std::set DataArrayInt::getDifferentValues() const throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + std::set ret; + ret.insert(getConstPointer(),getConstPointer()+getNbOfElems()); + return ret; +} + +int *DataArrayInt::CheckAndPreparePermutation(const int *start, const int *end) { int sz=std::distance(start,end); int *ret=new int[sz]; diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index 354f73253..cf24a438c 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -25,6 +25,7 @@ #include "MEDCouplingRefCountObject.hxx" #include "InterpKernelException.hxx" +#include #include #include #include @@ -67,6 +68,7 @@ namespace ParaMEDMEM void fillWithValue(const T& val); T *fromNoInterlace(int nbOfComp) const; T *toNoInterlace(int nbOfComp) const; + void sort(); void alloc(int nbOfElements); void reAlloc(int newNbOfElements); void useArray(const T *array, bool ownership, DeallocType type, int nbOfElem); @@ -125,6 +127,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void fillWithValue(double val) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void iota(double init=0.) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT bool isUniform(double val, double eps) const; + MEDCOUPLING_EXPORT void sort() throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT std::string repr() const; MEDCOUPLING_EXPORT std::string reprZip() const; MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const; @@ -146,6 +149,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const; MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayDouble *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayDouble *changeNbOfComponents(int newNbOfComp, double dftValue) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector& compoIds) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void meldWith(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); @@ -155,7 +159,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, double newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); } MEDCOUPLING_EXPORT void setIJSilent(int tupleId, int compoId, double newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; } MEDCOUPLING_EXPORT double *getPointer() const { return _mem.getPointer(); } - MEDCOUPLING_EXPORT static void setArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet); + MEDCOUPLING_EXPORT static void SetArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet); MEDCOUPLING_EXPORT const double *getConstPointer() const { return _mem.getConstPointer(); } MEDCOUPLING_EXPORT void useArray(const double *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo); MEDCOUPLING_EXPORT void writeOnPlace(int id, double element0, const double *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); } @@ -187,21 +191,21 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *aggregate(const std::vector& a) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *meld(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *meld(const std::vector& a) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *dot(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *crossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const std::vector& a) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Meld(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Meld(const std::vector& a) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Dot(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *CrossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void addEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void substractEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void multiplyEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void divideEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); //! nothing to do here because this class does not aggregate any TimeLabel instance. MEDCOUPLING_EXPORT void updateTime() { } @@ -222,6 +226,9 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void alloc(int nbOfTuple, int nbOfCompo); MEDCOUPLING_EXPORT bool isEqual(const DataArrayInt& other) const; MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayInt& other) const; + MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStrAndOrder(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *buildPermutationArr(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void sort() throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void fillWithZero(); MEDCOUPLING_EXPORT void fillWithValue(int val); MEDCOUPLING_EXPORT void iota(int init=0) throw(INTERP_KERNEL::Exception); @@ -249,6 +256,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT bool isIdentity() const; MEDCOUPLING_EXPORT bool isUniform(int val) const; MEDCOUPLING_EXPORT DataArrayInt *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *changeNbOfComponents(int newNbOfComp, int dftValue) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *keepSelectedComponents(const std::vector& compoIds) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void meldWith(const DataArrayInt *other) throw(INTERP_KERNEL::Exception); @@ -258,27 +266,32 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, int newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); } MEDCOUPLING_EXPORT void setIJSilent(int tupleId, int compoId, int newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; } MEDCOUPLING_EXPORT int *getPointer() const { return _mem.getPointer(); } - MEDCOUPLING_EXPORT static void setArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet); + MEDCOUPLING_EXPORT static void SetArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet); MEDCOUPLING_EXPORT const int *getConstPointer() const { return _mem.getConstPointer(); } MEDCOUPLING_EXPORT DataArrayInt *getIdsEqual(int val) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *getIdsEqualList(const std::vector& vals) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT int getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT int getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayInt *aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2); - MEDCOUPLING_EXPORT static DataArrayInt *meld(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayInt *meld(const std::vector& a) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayInt *makePartition(const std::vector& groups, int newNb, std::vector< std::vector >& fidsOfGroups); + MEDCOUPLING_EXPORT void applyLin(int a, int b, int compoId) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayInt *Aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2); + MEDCOUPLING_EXPORT static DataArrayInt *Aggregate(const std::vector& a) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayInt *Meld(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayInt *Meld(const std::vector& a) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayInt *MakePartition(const std::vector& groups, int newNb, std::vector< std::vector >& fidsOfGroups); + MEDCOUPLING_EXPORT static DataArrayInt *BuildUnion(const std::vector& a) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayInt *BuildIntersection(const std::vector& a) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *buildComplement(int nbOfElement) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *buildSubstraction(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *buildUnion(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *buildIntersection(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *deltaShiftIndex() const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT std::set getDifferentValues() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo); MEDCOUPLING_EXPORT void writeOnPlace(int id, int element0, const int *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); } //! nothing to do here because this class does not aggregate any TimeLabel instance. MEDCOUPLING_EXPORT void updateTime() { } public: - MEDCOUPLING_EXPORT static int *checkAndPreparePermutation(const int *start, const int *end); + MEDCOUPLING_EXPORT static int *CheckAndPreparePermutation(const int *start, const int *end); private: DataArrayInt() { } private: diff --git a/src/MEDCoupling/MEDCouplingMemArray.txx b/src/MEDCoupling/MEDCouplingMemArray.txx index 1c6e8cefc..bc4cec63c 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.txx +++ b/src/MEDCoupling/MEDCouplingMemArray.txx @@ -207,6 +207,13 @@ namespace ParaMEDMEM return ret; } + template + void MemArray::sort() + { + T *pt=_pointer.getPointer(); + std::sort(pt,pt+_nb_of_elem); + } + template void MemArray::alloc(int nbOfElements) { diff --git a/src/MEDCoupling/MEDCouplingMesh.cxx b/src/MEDCoupling/MEDCouplingMesh.cxx index cd3157568..81ccda0b7 100644 --- a/src/MEDCoupling/MEDCouplingMesh.cxx +++ b/src/MEDCoupling/MEDCouplingMesh.cxx @@ -208,7 +208,7 @@ MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic(TypeOfField t, int nbO * retruns a newly created mesh with counter=1 * that is the union of mesh1 and mesh2 if possible. The cells of mesh2 will appear after cells of 'mesh1'. Idem for nodes. */ -MEDCouplingMesh *MEDCouplingMesh::mergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2) +MEDCouplingMesh *MEDCouplingMesh::MergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2) { return mesh1->mergeMyselfWith(mesh2); } diff --git a/src/MEDCoupling/MEDCouplingMesh.hxx b/src/MEDCoupling/MEDCouplingMesh.hxx index d5b828676..27c5cb6ad 100644 --- a/src/MEDCoupling/MEDCouplingMesh.hxx +++ b/src/MEDCoupling/MEDCouplingMesh.hxx @@ -95,7 +95,7 @@ namespace ParaMEDMEM virtual MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception) = 0; virtual DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception) = 0; virtual bool areCompatibleForMerge(const MEDCouplingMesh *other) const; - static MEDCouplingMesh *mergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2); + static MEDCouplingMesh *MergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2); //serialisation-unserialization virtual void getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const = 0; virtual void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const = 0; diff --git a/src/MEDCoupling/MEDCouplingPointSet.cxx b/src/MEDCoupling/MEDCouplingPointSet.cxx index d4812d83a..4fa44dc4f 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.cxx +++ b/src/MEDCoupling/MEDCouplingPointSet.cxx @@ -545,18 +545,18 @@ void MEDCouplingPointSet::findNodesOnPlane(const double *pt, const double *vec, /*! * merge _coords arrays of m1 and m2 and returns the union. The returned instance is newly created with ref count == 1. */ -DataArrayDouble *MEDCouplingPointSet::mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) throw(INTERP_KERNEL::Exception) +DataArrayDouble *MEDCouplingPointSet::MergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) throw(INTERP_KERNEL::Exception) { int spaceDim=m1->getSpaceDimension(); if(spaceDim!=m2->getSpaceDimension()) - throw INTERP_KERNEL::Exception("Mismatch in SpaceDim during call of mergeNodesArray !"); - return DataArrayDouble::aggregate(m1->getCoords(),m2->getCoords()); + throw INTERP_KERNEL::Exception("Mismatch in SpaceDim during call of MergeNodesArray !"); + return DataArrayDouble::Aggregate(m1->getCoords(),m2->getCoords()); } -DataArrayDouble *MEDCouplingPointSet::mergeNodesArray(const std::vector& ms) throw(INTERP_KERNEL::Exception) +DataArrayDouble *MEDCouplingPointSet::MergeNodesArray(const std::vector& ms) throw(INTERP_KERNEL::Exception) { if(ms.empty()) - throw INTERP_KERNEL::Exception("MEDCouplingPointSet::mergeNodesArray : input array must be NON EMPTY !"); + throw INTERP_KERNEL::Exception("MEDCouplingPointSet::MergeNodesArray : input array must be NON EMPTY !"); std::vector::const_iterator it=ms.begin(); std::vector coo(ms.size()); int spaceDim=(*it)->getSpaceDimension(); @@ -569,19 +569,19 @@ DataArrayDouble *MEDCouplingPointSet::mergeNodesArray(const std::vectorgetSpaceDimension()==spaceDim) coo[i]=tmp; else - throw INTERP_KERNEL::Exception("Mismatch in SpaceDim during call of mergeNodesArray !"); + throw INTERP_KERNEL::Exception("Mismatch in SpaceDim during call of MergeNodesArray !"); } else - throw INTERP_KERNEL::Exception("Empty coords detected during call of mergeNodesArray !"); + throw INTERP_KERNEL::Exception("Empty coords detected during call of MergeNodesArray !"); } - return DataArrayDouble::aggregate(coo); + return DataArrayDouble::Aggregate(coo); } /*! * Factory to build new instance of instanciable subclasses of MEDCouplingPointSet. * This method is used during unserialization process. */ -MEDCouplingPointSet *MEDCouplingPointSet::buildInstanceFromMeshType(MEDCouplingMeshType type) +MEDCouplingPointSet *MEDCouplingPointSet::BuildInstanceFromMeshType(MEDCouplingMeshType type) { switch(type) { @@ -740,14 +740,14 @@ void MEDCouplingPointSet::rotate3D(const double *center, const double *vect, dou { double *coords=_coords->getPointer(); int nbNodes=getNumberOfNodes(); - rotate3DAlg(center,vect,angle,nbNodes,coords); + Rotate3DAlg(center,vect,angle,nbNodes,coords); } /*! * Low static method that operates 3D rotation of 'nbNodes' 3D nodes whose coordinates are arranged in 'coords' * around an axe ('center','vect') and with angle 'angle'. */ -void MEDCouplingPointSet::rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords) +void MEDCouplingPointSet::Rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords) { double sina=sin(angle); double cosa=cos(angle); @@ -813,14 +813,14 @@ void MEDCouplingPointSet::rotate2D(const double *center, double angle) { double *coords=_coords->getPointer(); int nbNodes=getNumberOfNodes(); - rotate2DAlg(center,angle,nbNodes,coords); + Rotate2DAlg(center,angle,nbNodes,coords); } /*! * Low static method that operates 3D rotation of 'nbNodes' 3D nodes whose coordinates are arranged in 'coords' * around the center point 'center' and with angle 'angle'. */ -void MEDCouplingPointSet::rotate2DAlg(const double *center, double angle, int nbNodes, double *coords) +void MEDCouplingPointSet::Rotate2DAlg(const double *center, double angle, int nbNodes, double *coords) { double cosa=cos(angle); double sina=sin(angle); diff --git a/src/MEDCoupling/MEDCouplingPointSet.hxx b/src/MEDCoupling/MEDCouplingPointSet.hxx index 4a51adf5b..0085f7f40 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.hxx +++ b/src/MEDCoupling/MEDCouplingPointSet.hxx @@ -71,11 +71,11 @@ namespace ParaMEDMEM void tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception); virtual void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) = 0; void findNodesOnPlane(const double *pt, const double *vec, double eps, std::vector& nodes) const throw(INTERP_KERNEL::Exception); - static DataArrayDouble *mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) throw(INTERP_KERNEL::Exception); - static DataArrayDouble *mergeNodesArray(const std::vector& ms) throw(INTERP_KERNEL::Exception); - static MEDCouplingPointSet *buildInstanceFromMeshType(MEDCouplingMeshType type); - static void rotate2DAlg(const double *center, double angle, int nbNodes, double *coords); - static void rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords); + static DataArrayDouble *MergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) throw(INTERP_KERNEL::Exception); + static DataArrayDouble *MergeNodesArray(const std::vector& ms) throw(INTERP_KERNEL::Exception); + static MEDCouplingPointSet *BuildInstanceFromMeshType(MEDCouplingMeshType type); + static void Rotate2DAlg(const double *center, double angle, int nbNodes, double *coords); + static void Rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords); MEDCouplingMesh *buildPart(const int *start, const int *end) const; MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const; virtual MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const = 0; diff --git a/src/MEDCoupling/MEDCouplingRemapper.cxx b/src/MEDCoupling/MEDCouplingRemapper.cxx index bb494899b..76026ff8c 100644 --- a/src/MEDCoupling/MEDCouplingRemapper.cxx +++ b/src/MEDCoupling/MEDCouplingRemapper.cxx @@ -316,7 +316,7 @@ int MEDCouplingRemapper::prepareEE(const char *method) throw(INTERP_KERNEL::Exce int nbCols2D=interpolation2D.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,matrix2D,method); MEDCouplingUMesh *s1D,*t1D; double v[3]; - MEDCouplingExtrudedMesh::project1DMeshes(src_mesh->getMesh1D(),target_mesh->getMesh1D(),getPrecision(),s1D,t1D,v); + MEDCouplingExtrudedMesh::Project1DMeshes(src_mesh->getMesh1D(),target_mesh->getMesh1D(),getPrecision(),s1D,t1D,v); MEDCouplingNormalizedUnstructuredMesh<1,1> s1DWrapper(s1D); MEDCouplingNormalizedUnstructuredMesh<1,1> t1DWrapper(t1D); std::vector > matrix1D; diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx index 8757e8c10..057e350e4 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx @@ -773,7 +773,7 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const MEDCoupli const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::aggregation on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::aggregate(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Aggregate(getArray(),other->getArray()); MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; ret->setArray(arr,0); arr->decrRef(); @@ -791,7 +791,7 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const std::vect throw INTERP_KERNEL::Exception("NoTimeLabel::aggregate on mismatched time discretization !"); a[i]=itC->getArray(); } - DataArrayDouble *arr=DataArrayDouble::aggregate(a); + DataArrayDouble *arr=DataArrayDouble::Aggregate(a); MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; ret->setArray(arr,0); arr->decrRef(); @@ -803,7 +803,7 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::meld(const MEDCouplingTim const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::meld on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::meld(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Meld(getArray(),other->getArray()); MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; ret->setTimeTolerance(getTimeTolerance()); ret->setArray(arr,0); @@ -816,7 +816,7 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::dot(const MEDCouplingTime const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::dot on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::dot(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Dot(getArray(),other->getArray()); MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; ret->setArray(arr,0); arr->decrRef(); @@ -828,7 +828,7 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::crossProduct(const MEDCou const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::crossProduct on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::crossProduct(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::CrossProduct(getArray(),other->getArray()); MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; ret->setArray(arr,0); arr->decrRef(); @@ -840,7 +840,7 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::max(const MEDCouplingTime const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::max(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Max(getArray(),other->getArray()); MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; ret->setArray(arr,0); arr->decrRef(); @@ -852,7 +852,7 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::min(const MEDCouplingTime const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::min(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Min(getArray(),other->getArray()); MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; ret->setArray(arr,0); arr->decrRef(); @@ -864,7 +864,7 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::add(const MEDCouplingTime const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::add on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::add(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Add(getArray(),other->getArray()); MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; ret->setArray(arr,0); arr->decrRef(); @@ -884,7 +884,7 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::substract(const MEDCoupli const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::substract on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::substract(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Substract(getArray(),other->getArray()); MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; ret->setArray(arr,0); arr->decrRef(); @@ -904,7 +904,7 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::multiply(const MEDCouplin const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::multiply on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::multiply(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Multiply(getArray(),other->getArray()); MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; ret->setArray(arr,0); arr->decrRef(); @@ -924,7 +924,7 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::divide(const MEDCouplingT const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("divide on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::divide(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Divide(getArray(),other->getArray()); MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; ret->setArray(arr,0); arr->decrRef(); @@ -979,6 +979,36 @@ double MEDCouplingNoTimeLabel::getEndTime(int& iteration, int& order) const thro throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } +void MEDCouplingNoTimeLabel::setStartIteration(int it) throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception(EXCEPTION_MSG); +} + +void MEDCouplingNoTimeLabel::setEndIteration(int it) throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception(EXCEPTION_MSG); +} + +void MEDCouplingNoTimeLabel::setStartOrder(int order) throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception(EXCEPTION_MSG); +} + +void MEDCouplingNoTimeLabel::setEndOrder(int order) throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception(EXCEPTION_MSG); +} + +void MEDCouplingNoTimeLabel::setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception(EXCEPTION_MSG); +} + +void MEDCouplingNoTimeLabel::setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception(EXCEPTION_MSG); +} + void MEDCouplingNoTimeLabel::setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { throw INTERP_KERNEL::Exception(EXCEPTION_MSG); @@ -1118,7 +1148,7 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const MEDCoupl const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::aggregation on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::aggregate(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Aggregate(getArray(),other->getArray()); MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; ret->setArray(arr,0); arr->decrRef(); @@ -1136,7 +1166,7 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const std::vec throw INTERP_KERNEL::Exception("WithTimeStep::aggregate on mismatched time discretization !"); a[i]=itC->getArray(); } - DataArrayDouble *arr=DataArrayDouble::aggregate(a); + DataArrayDouble *arr=DataArrayDouble::Aggregate(a); MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; ret->setArray(arr,0); arr->decrRef(); @@ -1148,7 +1178,7 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::meld(const MEDCouplingTi const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::meld on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::meld(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Meld(getArray(),other->getArray()); MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; ret->setArray(arr,0); arr->decrRef(); @@ -1161,7 +1191,7 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::dot(const MEDCouplingTim if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::dot on mismatched time discretization !"); MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - DataArrayDouble *arr=DataArrayDouble::dot(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Dot(getArray(),other->getArray()); ret->setArray(arr,0); arr->decrRef(); return ret; @@ -1172,7 +1202,7 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::crossProduct(const MEDCo const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::crossProduct on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::crossProduct(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::CrossProduct(getArray(),other->getArray()); MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; ret->setArray(arr,0); arr->decrRef(); @@ -1184,7 +1214,7 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::max(const MEDCouplingTim const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::max on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::max(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Max(getArray(),other->getArray()); MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; ret->setArray(arr,0); arr->decrRef(); @@ -1196,7 +1226,7 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::min(const MEDCouplingTim const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::min on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::min(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Min(getArray(),other->getArray()); MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; ret->setArray(arr,0); arr->decrRef(); @@ -1208,7 +1238,7 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::add(const MEDCouplingTim const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::add on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::add(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Add(getArray(),other->getArray()); MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; ret->setArray(arr,0); arr->decrRef(); @@ -1231,7 +1261,7 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::substract(const MEDCoupl const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::substract on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::substract(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Substract(getArray(),other->getArray()); MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; ret->setArray(arr,0); arr->decrRef(); @@ -1254,7 +1284,7 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::multiply(const MEDCoupli const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::multiply on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::multiply(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Multiply(getArray(),other->getArray()); MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; ret->setArray(arr,0); arr->decrRef(); @@ -1277,7 +1307,7 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::divide(const MEDCoupling const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::divide on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::divide(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Divide(getArray(),other->getArray()); MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; ret->setArray(arr,0); arr->decrRef(); @@ -1556,7 +1586,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const M const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregation on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::aggregate(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Aggregate(getArray(),other->getArray()); MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; ret->setArray(arr,0); arr->decrRef(); @@ -1574,7 +1604,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const s throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregate on mismatched time discretization !"); a[i]=itC->getArray(); } - DataArrayDouble *arr=DataArrayDouble::aggregate(a); + DataArrayDouble *arr=DataArrayDouble::Aggregate(a); MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; ret->setArray(arr,0); arr->decrRef(); @@ -1586,7 +1616,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::meld(const MEDCou const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::meld on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::meld(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Meld(getArray(),other->getArray()); MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; ret->setTimeTolerance(getTimeTolerance()); ret->setArray(arr,0); @@ -1599,7 +1629,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::dot(const MEDCoup const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::dot on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::dot(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Dot(getArray(),other->getArray()); MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; ret->setArray(arr,0); arr->decrRef(); @@ -1611,7 +1641,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::crossProduct(cons const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::crossProduct on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::crossProduct(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::CrossProduct(getArray(),other->getArray()); MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; ret->setArray(arr,0); arr->decrRef(); @@ -1623,7 +1653,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::max(const MEDCoup const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::max on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::max(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Max(getArray(),other->getArray()); MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; ret->setArray(arr,0); arr->decrRef(); @@ -1635,7 +1665,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::min(const MEDCoup const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::min on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::min(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Min(getArray(),other->getArray()); MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; ret->setArray(arr,0); arr->decrRef(); @@ -1647,7 +1677,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::add(const MEDCoup const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::add on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::add(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Add(getArray(),other->getArray()); MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; ret->setArray(arr,0); arr->decrRef(); @@ -1672,7 +1702,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::substract(const M const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substract on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::substract(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Substract(getArray(),other->getArray()); MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; ret->setArray(arr,0); arr->decrRef(); @@ -1697,7 +1727,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::multiply(const ME const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("multiply on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::multiply(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Multiply(getArray(),other->getArray()); MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; ret->setArray(arr,0); arr->decrRef(); @@ -1722,7 +1752,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::divide(const MEDC const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("divide on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::divide(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Divide(getArray(),other->getArray()); MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; ret->setArray(arr,0); arr->decrRef(); @@ -2126,8 +2156,8 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const MEDCouplin const MEDCouplingLinearTime *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::aggregation on mismatched time discretization !"); - DataArrayDouble *arr1=DataArrayDouble::aggregate(getArray(),other->getArray()); - DataArrayDouble *arr2=DataArrayDouble::aggregate(getEndArray(),other->getEndArray()); + DataArrayDouble *arr1=DataArrayDouble::Aggregate(getArray(),other->getArray()); + DataArrayDouble *arr2=DataArrayDouble::Aggregate(getEndArray(),other->getEndArray()); MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; ret->setArray(arr1,0); arr1->decrRef(); @@ -2149,8 +2179,8 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const std::vecto a[i]=itC->getArray(); b[i]=itC->getEndArray(); } - DataArrayDouble *arr=DataArrayDouble::aggregate(a); - DataArrayDouble *arr2=DataArrayDouble::aggregate(b); + DataArrayDouble *arr=DataArrayDouble::Aggregate(a); + DataArrayDouble *arr2=DataArrayDouble::Aggregate(b); MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; ret->setArray(arr,0); arr->decrRef(); @@ -2164,8 +2194,8 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::meld(const MEDCouplingTime const MEDCouplingLinearTime *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::meld on mismatched time discretization !"); - DataArrayDouble *arr1=DataArrayDouble::meld(getArray(),other->getArray()); - DataArrayDouble *arr2=DataArrayDouble::meld(getEndArray(),other->getEndArray()); + DataArrayDouble *arr1=DataArrayDouble::Meld(getArray(),other->getArray()); + DataArrayDouble *arr2=DataArrayDouble::Meld(getEndArray(),other->getEndArray()); MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; ret->setTimeTolerance(getTimeTolerance()); ret->setArray(arr1,0); @@ -2180,8 +2210,8 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::dot(const MEDCouplingTimeD const MEDCouplingLinearTime *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::dot on mismatched time discretization !"); - DataArrayDouble *arr1=DataArrayDouble::dot(getArray(),other->getArray()); - DataArrayDouble *arr2=DataArrayDouble::dot(getEndArray(),other->getEndArray()); + DataArrayDouble *arr1=DataArrayDouble::Dot(getArray(),other->getArray()); + DataArrayDouble *arr2=DataArrayDouble::Dot(getEndArray(),other->getEndArray()); MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; ret->setArray(arr1,0); arr1->decrRef(); @@ -2195,8 +2225,8 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::crossProduct(const MEDCoup const MEDCouplingLinearTime *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::crossProduct on mismatched time discretization !"); - DataArrayDouble *arr1=DataArrayDouble::crossProduct(getArray(),other->getArray()); - DataArrayDouble *arr2=DataArrayDouble::crossProduct(getEndArray(),other->getEndArray()); + DataArrayDouble *arr1=DataArrayDouble::CrossProduct(getArray(),other->getArray()); + DataArrayDouble *arr2=DataArrayDouble::CrossProduct(getEndArray(),other->getEndArray()); MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; ret->setArray(arr1,0); arr1->decrRef(); @@ -2211,10 +2241,10 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::max(const MEDCouplingTimeD if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::max on mismatched time discretization !"); MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; - DataArrayDouble *arr1=DataArrayDouble::max(getArray(),other->getArray()); + DataArrayDouble *arr1=DataArrayDouble::Max(getArray(),other->getArray()); ret->setArray(arr1,0); arr1->decrRef(); - DataArrayDouble *arr2=DataArrayDouble::max(getEndArray(),other->getEndArray()); + DataArrayDouble *arr2=DataArrayDouble::Max(getEndArray(),other->getEndArray()); ret->setEndArray(arr2,0); arr2->decrRef(); return ret; @@ -2225,8 +2255,8 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::min(const MEDCouplingTimeD const MEDCouplingLinearTime *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::min on mismatched time discretization !"); - DataArrayDouble *arr1=DataArrayDouble::min(getArray(),other->getArray()); - DataArrayDouble *arr2=DataArrayDouble::min(getEndArray(),other->getEndArray()); + DataArrayDouble *arr1=DataArrayDouble::Min(getArray(),other->getArray()); + DataArrayDouble *arr2=DataArrayDouble::Min(getEndArray(),other->getEndArray()); MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; ret->setArray(arr1,0); arr1->decrRef(); @@ -2240,8 +2270,8 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::add(const MEDCouplingTimeD const MEDCouplingLinearTime *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::add on mismatched time discretization !"); - DataArrayDouble *arr1=DataArrayDouble::add(getArray(),other->getArray()); - DataArrayDouble *arr2=DataArrayDouble::add(getEndArray(),other->getEndArray()); + DataArrayDouble *arr1=DataArrayDouble::Add(getArray(),other->getArray()); + DataArrayDouble *arr2=DataArrayDouble::Add(getEndArray(),other->getEndArray()); MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; ret->setArray(arr1,0); arr1->decrRef(); @@ -2264,8 +2294,8 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::substract(const MEDCouplin const MEDCouplingLinearTime *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::substract on mismatched time discretization !"); - DataArrayDouble *arr1=DataArrayDouble::substract(getArray(),other->getArray()); - DataArrayDouble *arr2=DataArrayDouble::substract(getEndArray(),other->getEndArray()); + DataArrayDouble *arr1=DataArrayDouble::Substract(getArray(),other->getArray()); + DataArrayDouble *arr2=DataArrayDouble::Substract(getEndArray(),other->getEndArray()); MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; ret->setArray(arr1,0); arr1->decrRef(); @@ -2288,8 +2318,8 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::multiply(const MEDCoupling const MEDCouplingLinearTime *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::multiply on mismatched time discretization !"); - DataArrayDouble *arr1=DataArrayDouble::multiply(getArray(),other->getArray()); - DataArrayDouble *arr2=DataArrayDouble::multiply(getEndArray(),other->getEndArray()); + DataArrayDouble *arr1=DataArrayDouble::Multiply(getArray(),other->getArray()); + DataArrayDouble *arr2=DataArrayDouble::Multiply(getEndArray(),other->getEndArray()); MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; ret->setArray(arr1,0); arr1->decrRef(); @@ -2312,8 +2342,8 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::divide(const MEDCouplingTi const MEDCouplingLinearTime *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::divide on mismatched time discretization !"); - DataArrayDouble *arr1=DataArrayDouble::divide(getArray(),other->getArray()); - DataArrayDouble *arr2=DataArrayDouble::divide(getEndArray(),other->getEndArray()); + DataArrayDouble *arr1=DataArrayDouble::Divide(getArray(),other->getArray()); + DataArrayDouble *arr2=DataArrayDouble::Divide(getEndArray(),other->getEndArray()); MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; ret->setArray(arr1,0); arr1->decrRef(); diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx index 88b020eb1..de9fff53a 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx @@ -93,6 +93,15 @@ namespace ParaMEDMEM virtual double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) = 0; virtual double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) = 0; void setTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { setStartTime(time,iteration,order); } + void setIteration(int it) throw(INTERP_KERNEL::Exception) { setStartIteration(it); } + void setOrder(int order) throw(INTERP_KERNEL::Exception) { setStartOrder(order); } + void setTimeValue(double val) throw(INTERP_KERNEL::Exception) { setStartTimeValue(val); } + virtual void setStartIteration(int it) throw(INTERP_KERNEL::Exception) = 0; + virtual void setEndIteration(int it) throw(INTERP_KERNEL::Exception) = 0; + virtual void setStartOrder(int order) throw(INTERP_KERNEL::Exception) = 0; + virtual void setEndOrder(int order) throw(INTERP_KERNEL::Exception) = 0; + virtual void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) = 0; + virtual void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) = 0; virtual void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) = 0; virtual void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) = 0; virtual void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception) = 0; @@ -167,6 +176,12 @@ namespace ParaMEDMEM bool isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception); double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception); double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception); + void setStartIteration(int it) throw(INTERP_KERNEL::Exception); + void setEndIteration(int it) throw(INTERP_KERNEL::Exception); + void setStartOrder(int order) throw(INTERP_KERNEL::Exception); + void setEndOrder(int order) throw(INTERP_KERNEL::Exception); + void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception); + void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception); void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception); void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception); void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception); @@ -219,6 +234,12 @@ namespace ParaMEDMEM void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _time=time; _iteration=iteration; _order=order; } double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_iteration; order=_order; return _time; } double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_iteration; order=_order; return _time; } + void setStartIteration(int it) throw(INTERP_KERNEL::Exception) { _iteration=it; } + void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _iteration=it; } + void setStartOrder(int order) throw(INTERP_KERNEL::Exception) { _order=order; } + void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _order=order; } + void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) { _time=time; } + void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) { _time=time; } std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception); void getValueForTime(double time, const std::vector& vals, double *res) const; void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception); @@ -277,6 +298,12 @@ namespace ParaMEDMEM void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _end_time=time; _end_iteration=iteration; _end_order=order; } double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_start_iteration; order=_start_order; return _start_time; } double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_end_iteration; order=_end_order; return _end_time; } + void setStartIteration(int it) throw(INTERP_KERNEL::Exception) { _start_iteration=it; } + void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _end_iteration=it; } + void setStartOrder(int order) throw(INTERP_KERNEL::Exception) { _start_order=order; } + void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _end_order=order; } + void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) { _start_time=time; } + void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) { _end_time=time; } void checkNoTimePresence() const throw(INTERP_KERNEL::Exception); void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception); public: @@ -315,6 +342,12 @@ namespace ParaMEDMEM void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _end_time=time; _end_iteration=iteration; _end_order=order; } double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_start_iteration; order=_start_order; return _start_time; } double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_end_iteration; order=_end_order; return _end_time; } + void setStartIteration(int it) throw(INTERP_KERNEL::Exception) { _start_iteration=it; } + void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _end_iteration=it; } + void setStartOrder(int order) throw(INTERP_KERNEL::Exception) { _start_order=order; } + void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _end_order=order; } + void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) { _start_time=time; } + void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) { _end_time=time; } void getTinySerializationIntInformation(std::vector& tinyInfo) const; void getTinySerializationDbleInformation(std::vector& tinyInfo) const; void getTinySerializationStrInformation(std::vector& tinyInfo) const; diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 6af9408e1..def173789 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -30,6 +30,7 @@ #include "InterpKernelGeo2DEdgeArcCircle.hxx" #include "MEDCouplingAutoRefCountObjectPtr.hxx" + #include #include #include @@ -115,6 +116,15 @@ void MEDCouplingUMesh::checkCoherency() const throw(INTERP_KERNEL::Exception) throw INTERP_KERNEL::Exception("Nodal connectivity index array is expected to be with number of components set to one !"); if(_nodal_connec_index->getInfoOnComponent(0)!="") throw INTERP_KERNEL::Exception("Nodal connectivity index array is expected to have no info on its single component !"); + int curNbOfCell=getNumberOfCells(); + const int *curCI=_nodal_connec_index->getConstPointer(); + for (int i=0; i cell "<getNbOfElems()-1; + if(_iterator>=nbOfElems) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::insertNextCell : allocation of cells was wide enough ! Call insertNextCell with higher value or call finishInsertingCells !"); int *pt=_nodal_connec_index->getPointer(); int idx=pt[_iterator]; @@ -265,7 +280,7 @@ void MEDCouplingUMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int ce MEDCouplingMesh::checkFastEquivalWith(other,prec); if(_types!=otherC->_types) throw INTERP_KERNEL::Exception("checkDeepEquivalWith : Types are not equal !"); - MEDCouplingAutoRefCountObjectPtr m=mergeUMeshes(this,otherC); + MEDCouplingAutoRefCountObjectPtr m=MergeUMeshes(this,otherC); bool areNodesMerged; int newNbOfNodes; int oldNbOfNodes=getNumberOfNodes(); @@ -324,10 +339,10 @@ void MEDCouplingUMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *ot throw INTERP_KERNEL::Exception("checkDeepEquivalOnSameNodesWith : Types are not equal !"); if(_coords!=otherC->_coords) throw INTERP_KERNEL::Exception("checkDeepEquivalOnSameNodesWith : meshes do not share the same coordinates ! Use tryToShareSameCoordinates or call checkDeepEquivalWith !"); - std::vector ms(2); - ms[0]=const_cast(this); - ms[1]=const_cast(otherC); - MEDCouplingAutoRefCountObjectPtr m=mergeUMeshesOnSameCoords(ms); + std::vector ms(2); + ms[0]=this; + ms[1]=otherC; + MEDCouplingAutoRefCountObjectPtr m=MergeUMeshesOnSameCoords(ms); MEDCouplingAutoRefCountObjectPtr da=m->zipConnectivityTraducer(cellCompPol); int maxId=*std::max_element(da->getConstPointer(),da->getConstPointer()+getNumberOfCells()); const int *pt=std::find_if(da->getConstPointer()+getNumberOfCells(),da->getConstPointer()+da->getNbOfElems(),std::bind2nd(std::greater(),maxId)); @@ -917,11 +932,14 @@ DataArrayInt *MEDCouplingUMesh::zipConnectivityTraducer(int compType) throw(INTE */ bool MEDCouplingUMesh::areCellsIncludedIn(const MEDCouplingUMesh *other, int compType, DataArrayInt *& arr) const throw(INTERP_KERNEL::Exception) { - MEDCouplingAutoRefCountObjectPtr mesh=mergeUMeshesOnSameCoords(this,other); + MEDCouplingAutoRefCountObjectPtr mesh=MergeUMeshesOnSameCoords(this,other); MEDCouplingAutoRefCountObjectPtr o2n=mesh->zipConnectivityTraducer(compType); int nbOfCells=getNumberOfCells(); arr=o2n->substr(nbOfCells); + arr->setName(other->getName()); int tmp; + if(other->getNumberOfCells()==0) + return true; return arr->getMaxValue(tmp)_coords==other->_coords. If not a exception is thrown this remains unchanged. + * this->_coords==other->_coords. If an exception is thrown 'this' remains unchanged. + * Contrary to MEDCouplingUMesh::tryToShareSameCoords method this method makes a deeper analyze of coordinates (and so more expensive) than simple equality. + * Two nodes one in 'this' and other in 'other' are considered equal if the distance between the two is lower than epsilon. */ void MEDCouplingUMesh::tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) { @@ -960,7 +980,7 @@ void MEDCouplingUMesh::tryToShareSameCoordsPermute(const MEDCouplingPointSet& ot if(!_coords) throw INTERP_KERNEL::Exception("tryToShareSameCoordsPermute : No coords specified in this whereas there is any in other !"); int otherNbOfNodes=other.getNumberOfNodes(); - MEDCouplingAutoRefCountObjectPtr newCoords=mergeNodesArray(&other,this); + MEDCouplingAutoRefCountObjectPtr newCoords=MergeNodesArray(&other,this); _coords->incrRef(); MEDCouplingAutoRefCountObjectPtr oldCoords=_coords; setCoords(newCoords); @@ -1220,7 +1240,7 @@ void MEDCouplingUMesh::renumberCells(const int *old2NewBg, bool check) throw(INT int nbCells=getNumberOfCells(); const int *array=old2NewBg; if(check) - array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+nbCells); + array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+nbCells); // const int *conn=_nodal_connec->getConstPointer(); const int *connI=_nodal_connec_index->getConstPointer(); @@ -1490,14 +1510,29 @@ int MEDCouplingUMesh::getNumberOfNodesInCell(int cellId) const return std::count_if(pt+ptI[cellId]+1,pt+ptI[cellId+1],std::bind2nd(std::not_equal_to(),-1)); } +/*! + * This method is equivalent to MEDCouplingUMesh::getAllTypes excecpt that it returns only types of submesh which cell ids are in [begin,end). + * This method avoids to compute explicitely submesh to get its types. + */ +std::set MEDCouplingUMesh::getTypesOfPart(const int *begin, const int *end) const throw(INTERP_KERNEL::Exception) +{ + checkFullyDefined(); + std::set ret; + const int *conn=_nodal_connec->getConstPointer(); + const int *connIndex=_nodal_connec_index->getConstPointer(); + for(const int *w=begin;w!=end;w++) + ret.insert((INTERP_KERNEL::NormalizedCellType)conn[connIndex[*w]]); + return ret; +} + /*! * Method reserved for advanced users having prepared their connectivity before. * Arrays 'conn' and 'connIndex' will be aggregated without any copy and their counter will be incremented. */ void MEDCouplingUMesh::setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes) { - DataArrayInt::setArrayIn(conn,_nodal_connec); - DataArrayInt::setArrayIn(connIndex,_nodal_connec_index); + DataArrayInt::SetArrayIn(conn,_nodal_connec); + DataArrayInt::SetArrayIn(connIndex,_nodal_connec_index); if(isComputingTypes) computeTypes(); declareAsNew(); @@ -1751,6 +1786,47 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureField(bool isAbs) const return field; } +/*! + * This method is equivalent to MEDCouplingUMesh::getMeasureField except that only part defined by [begin,end) is returned ! + * This method avoids to build explicitely part of this to perform the work. + */ +MEDCouplingFieldDouble *MEDCouplingUMesh::getPartMeasureField(bool isAbs, const int *begin, const int *end) const +{ + std::string name="PartMeasureOfMesh_"; + name+=getName(); + int nbelem=std::distance(begin,end); + MEDCouplingFieldDouble *field=MEDCouplingFieldDouble::New(ON_CELLS); + field->setName(name.c_str()); + DataArrayDouble* array=DataArrayDouble::New(); + array->alloc(nbelem,1); + double *area_vol=array->getPointer(); + field->setArray(array) ; + array->decrRef(); + field->setMesh(const_cast(this)); + if(getMeshDimension()!=-1) + { + int ipt; + INTERP_KERNEL::NormalizedCellType type; + int dim_space=getSpaceDimension(); + const double *coords=getCoords()->getConstPointer(); + const int *connec=getNodalConnectivity()->getConstPointer(); + const int *connec_index=getNodalConnectivityIndex()->getConstPointer(); + for(const int *iel=begin;iel!=end;iel++) + { + ipt=connec_index[*iel]; + type=(INTERP_KERNEL::NormalizedCellType)connec[ipt]; + *area_vol++=INTERP_KERNEL::computeVolSurfOfCell2(type,connec+ipt+1,connec_index[*iel+1]-ipt-1,coords,dim_space); + } + if(isAbs) + std::transform(array->getPointer(),area_vol,array->getPointer(),std::ptr_fun(fabs)); + } + else + { + area_vol[0]=std::numeric_limits::max(); + } + return field; +} + /*! * This methods returns a field on nodes and no time. This method is usefull to check "P1*" conservative interpolators. * This field returns the getMeasureField of the dualMesh in P1 sens of 'this'. @@ -1842,6 +1918,63 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildOrthogonalField() const return ret; } +/*! + * This method is equivalent to MEDCouplingUMesh::buildOrthogonalField except that only part defined by [begin,end) is returned ! + * This method avoids to build explicitely part of this to perform the work. + */ +MEDCouplingFieldDouble *MEDCouplingUMesh::buildPartOrthogonalField(const int *begin, const int *end) const +{ + if((getMeshDimension()!=2) && (getMeshDimension()!=1 || getSpaceDimension()!=2)) + throw INTERP_KERNEL::Exception("Expected a umesh with ( meshDim == 2 spaceDim == 2 or 3 ) or ( meshDim == 1 spaceDim == 2 ) !"); + MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); + DataArrayDouble *array=DataArrayDouble::New(); + int nbelems=std::distance(begin,end); + int nbComp=getMeshDimension()+1; + array->alloc(nbelems,nbComp); + double *vals=array->getPointer(); + const int *connI=_nodal_connec_index->getConstPointer(); + const int *conn=_nodal_connec->getConstPointer(); + const double *coords=_coords->getConstPointer(); + if(getMeshDimension()==2) + { + if(getSpaceDimension()==3) + { + DataArrayDouble *loc=getPartBarycenterAndOwner(begin,end); + const double *locPtr=loc->getConstPointer(); + for(const int *i=begin;i!=end;i++,vals+=3,locPtr+=3) + { + int offset=connI[*i]; + INTERP_KERNEL::crossprod<3>(locPtr,coords+3*conn[offset+1],coords+3*conn[offset+2],vals); + double n=INTERP_KERNEL::norm<3>(vals); + std::transform(vals,vals+3,vals,std::bind2nd(std::multiplies(),1./n)); + } + loc->decrRef(); + } + else + { + for(int i=0;i()); + double n=INTERP_KERNEL::norm<2>(tmp); + std::transform(tmp,tmp+2,tmp,std::bind2nd(std::multiplies(),1./n)); + *vals++=-tmp[1]; + *vals++=tmp[0]; + } + } + ret->setArray(array); + array->decrRef(); + ret->setMesh(this); + return ret; +} + /*! * This methods returns a vector newly created field on cells that represents the direction vector of each 1D cell of this. * This method is only callable on mesh with meshdim == 1 containing only SEG2. @@ -2095,18 +2228,18 @@ void MEDCouplingUMesh::checkButterflyCells(std::vector& cells) const * \b 1 for translation and rotation around point of 'mesh1D'. * @return an unstructured mesh with meshDim==3 and spaceDim==3. The returned mesh has the same coords than 'this'. */ -MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMeshFromThis(const MEDCouplingUMesh *mesh1D, int policy) +MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMesh(const MEDCouplingUMesh *mesh1D, int policy) { checkFullyDefined(); mesh1D->checkFullyDefined(); if(!mesh1D->isContiguous1D()) - throw INTERP_KERNEL::Exception("buildExtrudedMeshFromThis : 1D mesh passed in parameter is not contiguous !"); + throw INTERP_KERNEL::Exception("buildExtrudedMesh : 1D mesh passed in parameter is not contiguous !"); if(getSpaceDimension()!=mesh1D->getSpaceDimension()) - throw INTERP_KERNEL::Exception("Invalid call to buildExtrudedMeshFromThis this and mesh1D must have same dimension !"); + throw INTERP_KERNEL::Exception("Invalid call to buildExtrudedMesh this and mesh1D must have same dimension !"); if((getMeshDimension()!=2 || getSpaceDimension()!=3) && (getMeshDimension()!=1 || getSpaceDimension()!=2)) - throw INTERP_KERNEL::Exception("Invalid 'this' for buildExtrudedMeshFromThis method : must be (meshDim==2 and spaceDim==3) or (meshDim==1 and spaceDim==2) !"); + throw INTERP_KERNEL::Exception("Invalid 'this' for buildExtrudedMesh method : must be (meshDim==2 and spaceDim==3) or (meshDim==1 and spaceDim==2) !"); if(mesh1D->getMeshDimension()!=1) - throw INTERP_KERNEL::Exception("Invalid 'mesh1D' for buildExtrudedMeshFromThis method : must be meshDim==1 !"); + throw INTERP_KERNEL::Exception("Invalid 'mesh1D' for buildExtrudedMesh method : must be meshDim==1 !"); bool isQuad=false; if(isPresenceOfQuadratic()) { @@ -2141,7 +2274,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMeshFromThis(const MEDCouplingU } /*! - * This method incarnates the policy 0 for MEDCouplingUMesh::buildExtrudedMeshFromThis method. + * This method incarnates the policy 0 for MEDCouplingUMesh::buildExtrudedMesh method. * @param mesh1D is the input 1D mesh used for translation computation. * @return newCoords new coords filled by this method. */ @@ -2187,7 +2320,7 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslation(const MEDCoupli } /*! - * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMeshFromThis method. + * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMesh method. * @param mesh1D is the input 1D mesh used for translation and automatic rotation computation. * @return newCoords new coords filled by this method. */ @@ -2201,7 +2334,7 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation(const } /*! - * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMeshFromThis method. + * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMesh method. * @param mesh1D is the input 1D mesh used for translation and automatic rotation computation. * @return newCoords new coords filled by this method. */ @@ -2247,7 +2380,7 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D(con } /*! - * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMeshFromThis method. + * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMesh method. * @param mesh1D is the input 1D mesh used for translation and automatic rotation computation. * @return newCoords new coords filled by this method. */ @@ -2317,7 +2450,7 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D(con /*! * This method is private because not easy to use for end user. This method is const contrary to - * MEDCouplingUMesh::buildExtrudedMeshFromThis method because this->_coords are expected to contain + * MEDCouplingUMesh::buildExtrudedMesh method because this->_coords are expected to contain * the coords sorted slice by slice. * @param isQuad specifies presence of quadratic cells. */ @@ -2670,7 +2803,7 @@ void MEDCouplingUMesh::are2DCellsNotCorrectlyOriented(const double *vec, bool po INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]]; if(!polyOnly || type==INTERP_KERNEL::NORM_POLYGON) { - if(!isPolygonWellOriented(vec,conn+connI[i]+1,conn+connI[i+1],coordsPtr)) + if(!IsPolygonWellOriented(vec,conn+connI[i]+1,conn+connI[i+1],coordsPtr)) cells.push_back(i); } } @@ -2694,7 +2827,7 @@ void MEDCouplingUMesh::orientCorrectly2DCells(const double *vec, bool polyOnly) { INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]]; if(!polyOnly || type==INTERP_KERNEL::NORM_POLYGON) - if(!isPolygonWellOriented(vec,conn+connI[i]+1,conn+connI[i+1],coordsPtr)) + if(!IsPolygonWellOriented(vec,conn+connI[i]+1,conn+connI[i+1],coordsPtr)) { isModified=true; std::vector tmp(connI[i+1]-connI[i]-2); @@ -2725,7 +2858,7 @@ void MEDCouplingUMesh::arePolyhedronsNotCorrectlyOriented(std::vector& cell INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]]; if(type==INTERP_KERNEL::NORM_POLYHED) { - if(!isPolyhedronWellOriented(conn+connI[i]+1,conn+connI[i+1],coordsPtr)) + if(!IsPolyhedronWellOriented(conn+connI[i]+1,conn+connI[i+1],coordsPtr)) cells.push_back(i); } } @@ -2748,9 +2881,9 @@ void MEDCouplingUMesh::orientCorrectlyPolyhedrons() throw(INTERP_KERNEL::Excepti { INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]]; if(type==INTERP_KERNEL::NORM_POLYHED) - if(!isPolyhedronWellOriented(conn+connI[i]+1,conn+connI[i+1],coordsPtr)) + if(!IsPolyhedronWellOriented(conn+connI[i]+1,conn+connI[i+1],coordsPtr)) { - tryToCorrectPolyhedronOrientation(conn+connI[i]+1,conn+connI[i+1],coordsPtr); + TryToCorrectPolyhedronOrientation(conn+connI[i]+1,conn+connI[i+1],coordsPtr); isModified=true; } } @@ -3193,6 +3326,25 @@ std::vector MEDCouplingUMesh::splitByType() const return ret; } +/*! + * This method returns a newly created DataArrayInt instance. + * This method retrieves cell ids in [begin,end) that have the type 'type'. + */ +DataArrayInt *MEDCouplingUMesh::keepCellIdsByType(INTERP_KERNEL::NormalizedCellType type, const int *begin, const int *end) const throw(INTERP_KERNEL::Exception) +{ + checkFullyDefined(); + std::vector r; + const int *conn=_nodal_connec->getConstPointer(); + const int *connIndex=_nodal_connec_index->getConstPointer(); + for(const int *w=begin;w!=end;w++) + if((INTERP_KERNEL::NormalizedCellType)conn[connIndex[*w]]==type) + r.push_back(*w); + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(r.size(),1); + std::copy(r.begin(),r.end(),ret->getPointer()); + return ret; +} + /*! * This method makes the assumption that da->getNumberOfTuples()getNumberOfCells(). This method makes the assumption that ids contained in 'da' * are in [0:getNumberOfCells()) @@ -3262,7 +3414,7 @@ MEDCouplingMesh *MEDCouplingUMesh::mergeMyselfWith(const MEDCouplingMesh *other) if(other->getType()!=UNSTRUCTURED) throw INTERP_KERNEL::Exception("Merge of umesh only available with umesh each other !"); const MEDCouplingUMesh *otherC=static_cast(other); - return mergeUMeshes(this,otherC); + return MergeUMeshes(this,otherC); } /*! @@ -3291,21 +3443,47 @@ DataArrayDouble *MEDCouplingUMesh::getBarycenterAndOwner() const return ret; } +/*! + * This method is similar to MEDCouplingUMesh::getBarycenterAndOwner except that it works on subPart of 'this' without + * building explicitely it. The input part is defined by an array [begin,end). All ids contained in this array should be less than this->getNumberOfCells(). + * No check of that will be done ! + */ +DataArrayDouble *MEDCouplingUMesh::getPartBarycenterAndOwner(const int *begin, const int *end) const +{ + DataArrayDouble *ret=DataArrayDouble::New(); + int spaceDim=getSpaceDimension(); + int nbOfTuple=std::distance(begin,end); + ret->alloc(nbOfTuple,spaceDim); + double *ptToFill=ret->getPointer(); + double *tmp=new double[spaceDim]; + const int *nodal=_nodal_connec->getConstPointer(); + const int *nodalI=_nodal_connec_index->getConstPointer(); + const double *coor=_coords->getConstPointer(); + for(const int *w=begin;w!=end;w++) + { + INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)nodal[nodalI[*w]]; + INTERP_KERNEL::computeBarycenter2(type,nodal+nodalI[*w]+1,nodalI[*w+1]-nodalI[*w]-1,coor,spaceDim,ptToFill); + ptToFill+=spaceDim; + } + delete [] tmp; + return ret; +} + /*! * Returns a newly created mesh (with ref count ==1) that contains merge of 'mesh1' and 'other'. * The coords of 'mesh2' are added at the end of coords of 'mesh1'. */ -MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception) +MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception) { std::vector tmp(2); tmp[0]=const_cast(mesh1); tmp[1]=const_cast(mesh2); - return mergeUMeshes(tmp); + return MergeUMeshes(tmp); } -MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshes(std::vector& a) throw(INTERP_KERNEL::Exception) +MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshes(std::vector& a) throw(INTERP_KERNEL::Exception) { if(a.empty()) - throw INTERP_KERNEL::Exception("MEDCouplingUMesh::mergeUMeshes : input array must be NON EMPTY !"); + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::MergeUMeshes : input array must be NON EMPTY !"); std::vector::const_iterator it=a.begin(); int meshDim=(*it)->getMeshDimension(); int nbOfCells=(*it)->getNumberOfCells(); @@ -3313,13 +3491,13 @@ MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshes(std::vectorgetMeshDimension()) - throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, mergeMeshes impossible !"); + throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, MergeUMeshes impossible !"); nbOfCells+=(*it)->getNumberOfCells(); meshLgth+=(*it)->getMeshLength(); } std::vector aps(a.size()); std::copy(a.begin(),a.end(),aps.begin()); - DataArrayDouble *pts=mergeNodesArray(aps); + DataArrayDouble *pts=MergeNodesArray(aps); MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingUMesh::New("merge",meshDim); ret->setCoords(pts); pts->decrRef(); @@ -3350,7 +3528,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshes(std::vectorgetNumberOfNodes(); } // @@ -3362,27 +3540,27 @@ MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshes(std::vector tmp(2); - tmp[0]=const_cast(mesh1); tmp[1]=const_cast(mesh2); - return mergeUMeshesOnSameCoords(tmp); + std::vector tmp(2); + tmp[0]=mesh1; tmp[1]=mesh2; + return MergeUMeshesOnSameCoords(tmp); } /*! - * Idem mergeUMeshes except that 'meshes' are expected to lyie on the same coords and 'meshes' have the same meshdim. + * Idem MergeUMeshes except that 'meshes' are expected to lyie on the same coords and 'meshes' have the same meshdim. * 'meshes' must be a non empty vector. */ -MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshesOnSameCoords(const std::vector& meshes) +MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesOnSameCoords(const std::vector& meshes) { if(meshes.empty()) throw INTERP_KERNEL::Exception("meshes input parameter is expected to be non empty."); DataArrayDouble *coords=meshes.front()->getCoords(); int meshDim=meshes.front()->getMeshDimension(); - std::vector::const_iterator iter=meshes.begin(); + std::vector::const_iterator iter=meshes.begin(); int meshLgth=0; int meshIndexLgth=0; for(;iter!=meshes.end();iter++) @@ -3390,7 +3568,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshesOnSameCoords(const std::vectorgetCoords()) throw INTERP_KERNEL::Exception("meshes does not share the same coords ! Try using tryToShareSameCoords method !"); if(meshDim!=(*iter)->getMeshDimension()) - throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, fuseUMeshesOnSameCoords impossible !"); + throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, FuseUMeshesOnSameCoords impossible !"); meshLgth+=(*iter)->getMeshLength(); meshIndexLgth+=(*iter)->getNumberOfCells(); } @@ -3436,10 +3614,10 @@ MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshesOnSameCoords(const std::vector& meshes, int compType, std::vector& corr) +MEDCouplingUMesh *MEDCouplingUMesh::FuseUMeshesOnSameCoords(const std::vector& meshes, int compType, std::vector& corr) { - //All checks are delegated to mergeUMeshesOnSameCoords - MEDCouplingUMesh *ret=mergeUMeshesOnSameCoords(meshes); + //All checks are delegated to MergeUMeshesOnSameCoords + MEDCouplingUMesh *ret=MergeUMeshesOnSameCoords(meshes); DataArrayInt *o2n=ret->zipConnectivityTraducer(compType); corr.resize(meshes.size()); int nbOfMeshes=meshes.size(); @@ -3452,6 +3630,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::fuseUMeshesOnSameCoords(const std::vectoralloc(curNbOfCells,1); std::copy(o2nPtr+offset,o2nPtr+offset+curNbOfCells,tmp->getPointer()); offset+=curNbOfCells; + tmp->setName(meshes[i]->getName()); corr[i]=tmp; } o2n->decrRef(); @@ -3472,7 +3651,7 @@ void MEDCouplingUMesh::appendExtrudedCell(const int *connBg, const int *connEnd, int deltaz=isQuad?2*nbOfNodesPerLev:nbOfNodesPerLev; switch(flatType) { - case INTERP_KERNEL::NORM_POINT0: + case INTERP_KERNEL::NORM_POINT1: { ret.push_back(connBg[1]); ret.push_back(connBg[1]+nbOfNodesPerLev); @@ -3544,7 +3723,7 @@ void MEDCouplingUMesh::appendExtrudedCell(const int *connBg, const int *connEnd, /*! * This static operates only for coords in 3D. The polygon is specfied by its connectivity nodes in [begin,end). */ -bool MEDCouplingUMesh::isPolygonWellOriented(const double *vec, const int *begin, const int *end, const double *coords) +bool MEDCouplingUMesh::IsPolygonWellOriented(const double *vec, const int *begin, const int *end, const double *coords) { double v[3]={0.,0.,0.}; int sz=std::distance(begin,end); @@ -3560,7 +3739,7 @@ bool MEDCouplingUMesh::isPolygonWellOriented(const double *vec, const int *begin /*! * The polyhedron is specfied by its connectivity nodes in [begin,end). */ -bool MEDCouplingUMesh::isPolyhedronWellOriented(const int *begin, const int *end, const double *coords) +bool MEDCouplingUMesh::IsPolyhedronWellOriented(const int *begin, const int *end, const double *coords) { std::vector > edges; int nbOfFaces=std::count(begin,end,-1)+1; @@ -3585,7 +3764,7 @@ bool MEDCouplingUMesh::isPolyhedronWellOriented(const int *begin, const int *end * This method tries to obtain a well oriented polyhedron. * If the algorithm fails, an exception will be thrown. */ -void MEDCouplingUMesh::tryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords) throw(INTERP_KERNEL::Exception) +void MEDCouplingUMesh::TryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords) throw(INTERP_KERNEL::Exception) { std::vector > edges; int nbOfFaces=std::count(begin,end,-1)+1; diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index 0bc87d2dc..aee00442a 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -50,6 +50,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void finishInsertingCells(); MEDCOUPLING_EXPORT const std::set& getAllTypes() const { return _types; } + MEDCOUPLING_EXPORT std::set getTypesOfPart(const int *begin, const int *end) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes=true); MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivity() const { return _nodal_connec; } MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivityIndex() const { return _nodal_connec_index; } @@ -100,8 +101,10 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const double *bbox, double eps, std::vector& elems); MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector& elems); MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getPartMeasureField(bool isAbs, const int *begin, const int *end) const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildPartOrthogonalField(const int *begin, const int *end) const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildDirectionVectorField() const; MEDCOUPLING_EXPORT bool isContiguous1D() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void project1D(const double *pt, const double *v, double eps, double *res) const; @@ -110,7 +113,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, std::vector& elts, std::vector& eltsIndex) const; MEDCOUPLING_EXPORT void checkButterflyCells(std::vector& cells) const; MEDCOUPLING_EXPORT void getBoundingBoxForBBTree(std::vector& bbox) const; - MEDCOUPLING_EXPORT MEDCouplingUMesh *buildExtrudedMeshFromThis(const MEDCouplingUMesh *mesh1D, int policy); + MEDCOUPLING_EXPORT MEDCouplingUMesh *buildExtrudedMesh(const MEDCouplingUMesh *mesh1D, int policy); MEDCOUPLING_EXPORT bool isFullyQuadratic() const; MEDCOUPLING_EXPORT bool isPresenceOfQuadratic() const; MEDCOUPLING_EXPORT void convertQuadraticCellsToLinear() throw(INTERP_KERNEL::Exception); @@ -133,19 +136,21 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT DataArrayInt *getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const; MEDCOUPLING_EXPORT DataArrayInt *rearrange2ConsecutiveCellTypes(); MEDCOUPLING_EXPORT std::vector splitByType() const; + MEDCOUPLING_EXPORT DataArrayInt *keepCellIdsByType(INTERP_KERNEL::NormalizedCellType type, const int *begin, const int *end) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *convertCellArrayPerGeoType(const DataArrayInt *da) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT MEDCouplingUMesh *keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, const std::vector& idsPerGeoType) const; // MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const; MEDCOUPLING_EXPORT DataArrayDouble *getBarycenterAndOwner() const; - MEDCOUPLING_EXPORT static MEDCouplingUMesh *mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static MEDCouplingUMesh *mergeUMeshes(std::vector& a) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static MEDCouplingUMesh *mergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static MEDCouplingUMesh *mergeUMeshesOnSameCoords(const std::vector& meshes); - MEDCOUPLING_EXPORT static MEDCouplingUMesh *fuseUMeshesOnSameCoords(const std::vector& meshes, int compType, std::vector& corr); - MEDCOUPLING_EXPORT static bool isPolygonWellOriented(const double *vec, const int *begin, const int *end, const double *coords); - MEDCOUPLING_EXPORT static bool isPolyhedronWellOriented(const int *begin, const int *end, const double *coords); - MEDCOUPLING_EXPORT static void tryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayDouble *getPartBarycenterAndOwner(const int *begin, const int *end) const; + MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshes(std::vector& a) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshesOnSameCoords(const std::vector& meshes); + MEDCOUPLING_EXPORT static MEDCouplingUMesh *FuseUMeshesOnSameCoords(const std::vector& meshes, int compType, std::vector& corr); + MEDCOUPLING_EXPORT static bool IsPolygonWellOriented(const double *vec, const int *begin, const int *end, const double *coords); + MEDCOUPLING_EXPORT static bool IsPolyhedronWellOriented(const int *begin, const int *end, const double *coords); + MEDCOUPLING_EXPORT static void TryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords) throw(INTERP_KERNEL::Exception); private: MEDCouplingUMesh(); MEDCouplingUMesh(const MEDCouplingUMesh& other, bool deepCpy); diff --git a/src/MEDCoupling/MEDCouplingUMeshDesc.cxx b/src/MEDCoupling/MEDCouplingUMeshDesc.cxx index e0cff180d..3a68c1536 100644 --- a/src/MEDCoupling/MEDCouplingUMeshDesc.cxx +++ b/src/MEDCoupling/MEDCouplingUMeshDesc.cxx @@ -167,10 +167,10 @@ std::string MEDCouplingUMeshDesc::advancedRepr() const void MEDCouplingUMeshDesc::setConnectivity(DataArrayInt *descConn, DataArrayInt *descConnIndex, DataArrayInt *nodalFaceConn, DataArrayInt *nodalFaceConnIndx) { - DataArrayInt::setArrayIn(descConn,_desc_connec); - DataArrayInt::setArrayIn(descConnIndex,_desc_connec_index); - DataArrayInt::setArrayIn(nodalFaceConn,_nodal_connec_face); - DataArrayInt::setArrayIn(nodalFaceConnIndx,_nodal_connec_face_index); + DataArrayInt::SetArrayIn(descConn,_desc_connec); + DataArrayInt::SetArrayIn(descConnIndex,_desc_connec_index); + DataArrayInt::SetArrayIn(nodalFaceConn,_nodal_connec_face); + DataArrayInt::SetArrayIn(nodalFaceConnIndx,_nodal_connec_face_index); computeTypes(); } diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx index 076a59565..909c241c7 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx @@ -174,6 +174,16 @@ namespace ParaMEDMEM CPPUNIT_TEST( testBuildOrthogonalField2 ); CPPUNIT_TEST( testUMInsertNextCell1 ); CPPUNIT_TEST( testFieldOperatorDivDiffComp1 ); + CPPUNIT_TEST( testDARearrange1 ); + CPPUNIT_TEST( testGetDifferentValues1 ); + CPPUNIT_TEST( testDAIBuildPermutationArr1 ); + CPPUNIT_TEST( testAreCellsIncludedIn2 ); + CPPUNIT_TEST( testUMeshGetPartBarycenterAndOwner1 ); + CPPUNIT_TEST( testUMeshGetPartMeasureField1 ); + CPPUNIT_TEST( testUMeshBuildPartOrthogonalField1 ); + CPPUNIT_TEST( testUMeshGetTypesOfPart1 ); + CPPUNIT_TEST( testUMeshKeepCellIdsByType1 ); + CPPUNIT_TEST( testDAIAggregateMulti1 ); //MEDCouplingBasicsTestInterp.cxx CPPUNIT_TEST( test2DInterpP0P0_1 ); CPPUNIT_TEST( test2DInterpP0P0PL_1 ); @@ -376,6 +386,16 @@ namespace ParaMEDMEM void testBuildOrthogonalField2(); void testUMInsertNextCell1(); void testFieldOperatorDivDiffComp1(); + void testDARearrange1(); + void testGetDifferentValues1(); + void testDAIBuildPermutationArr1(); + void testAreCellsIncludedIn2(); + void testUMeshGetPartBarycenterAndOwner1(); + void testUMeshGetPartMeasureField1(); + void testUMeshBuildPartOrthogonalField1(); + void testUMeshGetTypesOfPart1(); + void testUMeshKeepCellIdsByType1(); + void testDAIAggregateMulti1(); //MEDCouplingBasicsTestInterp.cxx void test2DInterpP0P0_1(); void test2DInterpP0P0PL_1(); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx index 5dd1c85d7..72df7f58c 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx @@ -258,18 +258,18 @@ void MEDCouplingBasicsTest::testMesh() void MEDCouplingBasicsTest::testMeshPointsCloud() { double targetCoords[27]={-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5}; - int *targetConn=0; + const int targetConn[]={0,1,2,3,4,5,7,6}; MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); targetMesh->setMeshDimension(0); targetMesh->allocateCells(8); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+1); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+2); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+3); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+4); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+5); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+6); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+7); targetMesh->finishInsertingCells(); DataArrayDouble *myCoords=DataArrayDouble::New(); myCoords->alloc(9,3); @@ -730,10 +730,10 @@ void MEDCouplingBasicsTest::testZipConnectivity() CPPUNIT_ASSERT(m3); m2->decrRef(); MEDCouplingUMesh *m4=build2DSourceMesh_1(); - MEDCouplingUMesh *m5=MEDCouplingUMesh::mergeUMeshes(m1,m3); + MEDCouplingUMesh *m5=MEDCouplingUMesh::MergeUMeshes(m1,m3); m1->decrRef(); m3->decrRef(); - MEDCouplingUMesh *m6=MEDCouplingUMesh::mergeUMeshes(m5,m4); + MEDCouplingUMesh *m6=MEDCouplingUMesh::MergeUMeshes(m5,m4); m4->decrRef(); m5->decrRef(); // @@ -1049,7 +1049,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh2() } /*! - * This test check MEDCouplingUMesh::buildExtrudedMeshFromThis method. + * This test check MEDCouplingUMesh::buildExtrudedMesh method. */ void MEDCouplingBasicsTest::testExtrudedMesh3() { @@ -1060,7 +1060,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh3() double center[3]={0.,0.,0.}; double vector[3]={0,1,0}; m2->rotate(center,vector,-M_PI/2.); - MEDCouplingUMesh *m3=m1->buildExtrudedMeshFromThis(m2,0); + MEDCouplingUMesh *m3=m1->buildExtrudedMesh(m2,0); // MEDCouplingExtrudedMesh *m4=MEDCouplingExtrudedMesh::New(m3,m1,0); CPPUNIT_ASSERT_EQUAL(15,m4->getNumberOfCells()); @@ -1085,7 +1085,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh3() //play with polygons and polyedrons std::vector cells(2); cells[0]=2; cells[1]=3; m1->convertToPolyTypes(cells); - m3=m1->buildExtrudedMeshFromThis(m2,0); + m3=m1->buildExtrudedMesh(m2,0); CPPUNIT_ASSERT_EQUAL((int)INTERP_KERNEL::NORM_HEXA8,(int)m3->getTypeOfCell(0)); CPPUNIT_ASSERT_EQUAL((int)INTERP_KERNEL::NORM_PENTA6,(int)m3->getTypeOfCell(1)); CPPUNIT_ASSERT_EQUAL((int)INTERP_KERNEL::NORM_POLYHED,(int)m3->getTypeOfCell(2)); @@ -1107,7 +1107,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh3() } /*! - * This test check MEDCouplingUMesh::buildExtrudedMeshFromThis method, but also, MEDCouplingExtrudedMesh following methods : + * This test check MEDCouplingUMesh::buildExtrudedMesh method, but also, MEDCouplingExtrudedMesh following methods : * getCellContainingPoint getMeasureField getNodeIdsOfCell getCoordinateOfNode getTypeOfCell build3DUnstructuredMesh. */ void MEDCouplingBasicsTest::testExtrudedMesh4() @@ -1121,7 +1121,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh4() double center[3]={0.,0.,0.}; double vector[3]={0.,1.,0.}; m2->rotate(center,vector,-M_PI/2.); - MEDCouplingUMesh *m3=m1->buildExtrudedMeshFromThis(m2,0); + MEDCouplingUMesh *m3=m1->buildExtrudedMesh(m2,0); const int expected1[15]= {1,3,2,0,6,5,7,10,11,8,12,9,14,13,4}; const int rexpected1[15]={3, 0, 2, 1, 14, 5, 4, 6, 9, 11, 7, 8, 10, 13, 12}; m3->renumberCells(expected1,false); @@ -1319,9 +1319,9 @@ void MEDCouplingBasicsTest::testMergeMeshOnSameCoords1() m1->tryToShareSameCoords(*m2,1e-12); MEDCouplingUMesh *m3=build2DTargetMesh_1(); m3->tryToShareSameCoords(*m2,1e-12); - std::vector meshes; + std::vector meshes; meshes.push_back(m1); meshes.push_back(m2); meshes.push_back(m3); - MEDCouplingUMesh *m4=MEDCouplingUMesh::mergeUMeshesOnSameCoords(meshes); + MEDCouplingUMesh *m4=MEDCouplingUMesh::MergeUMeshesOnSameCoords(meshes); m4->checkCoherency(); CPPUNIT_ASSERT(m4->getCoords()==m1->getCoords()); CPPUNIT_ASSERT_EQUAL(15,m4->getNumberOfCells()); @@ -1353,7 +1353,7 @@ void MEDCouplingBasicsTest::testMergeField1() m2->translate(vec); MEDCouplingFieldDouble *f1=m1->getMeasureField(true); MEDCouplingFieldDouble *f2=m2->getMeasureField(true); - MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::mergeFields(f1,f2); + MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::MergeFields(f1,f2); f3->checkCoherency(); MEDCouplingUMesh *m4=build2DTargetMeshMerged_1(); CPPUNIT_ASSERT(f3->getMesh()->isEqual(m4,1.e-12)); @@ -1978,7 +1978,8 @@ void MEDCouplingBasicsTest::testSplitByType() MEDCouplingUMesh *m1=build3DSurfTargetMesh_1(); std::vector v=m1->splitByType(); CPPUNIT_ASSERT_EQUAL(3,(int)v.size()); - MEDCouplingUMesh *m2=MEDCouplingUMesh::mergeUMeshesOnSameCoords(v); + std::vector v2(v.begin(),v.end()); + MEDCouplingUMesh *m2=MEDCouplingUMesh::MergeUMeshesOnSameCoords(v2); m2->setName(m1->getName()); CPPUNIT_ASSERT(m1->isEqual(m2,1.e-12)); for(std::vector::const_iterator iter=v.begin();iter!=v.end();iter++) @@ -1989,7 +1990,7 @@ void MEDCouplingBasicsTest::testSplitByType() void MEDCouplingBasicsTest::testFuseUMeshesOnSameCoords() { - std::vector meshes; + std::vector meshes; MEDCouplingUMesh *m2=build2DTargetMesh_1(); int cells1[3]={2,3,4}; MEDCouplingPointSet *m3_1=m2->buildPartOfMySelf(cells1,cells1+3,true); @@ -2009,7 +2010,7 @@ void MEDCouplingBasicsTest::testFuseUMeshesOnSameCoords() m2->decrRef(); // std::vector corr; - MEDCouplingUMesh *m7=MEDCouplingUMesh::fuseUMeshesOnSameCoords(meshes,0,corr); + MEDCouplingUMesh *m7=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,0,corr); CPPUNIT_ASSERT_EQUAL(4,m7->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(3,(int)corr.size()); const int expectedVals1[3]={3,3,2}; @@ -2025,7 +2026,8 @@ void MEDCouplingBasicsTest::testFuseUMeshesOnSameCoords() CPPUNIT_ASSERT_EQUAL(expectedVals2[i][j],vals[j]); } std::vector< std::vector > fidsOfGroups; - DataArrayInt *arr2=DataArrayInt::makePartition(corr,m7->getNumberOfCells(),fidsOfGroups); + std::vector corr2(corr.begin(),corr.end()); + DataArrayInt *arr2=DataArrayInt::MakePartition(corr2,m7->getNumberOfCells(),fidsOfGroups); const int fidExp[4]={5,1,3,4}; const int fidsGrp[3][3]={{1,3,5},{3,4,5},{4,5,23344}}; CPPUNIT_ASSERT_EQUAL(3,(int)fidsOfGroups.size()); @@ -2057,13 +2059,13 @@ void MEDCouplingBasicsTest::testFuseUMeshesOnSameCoords2() MEDCouplingUMesh *m3=(MEDCouplingUMesh *)m1->buildPartOfMySelf(part1,part1+5,true); const int part2[4]={5,6,4,7}; MEDCouplingUMesh *m4=(MEDCouplingUMesh *)m1->buildPartOfMySelf(part2,part2+4,true); - std::vector meshes; + std::vector meshes; meshes.push_back(m1); meshes.push_back(m3); meshes.push_back(m3); meshes.push_back(m4); std::vector corr; - MEDCouplingUMesh *m5=MEDCouplingUMesh::fuseUMeshesOnSameCoords(meshes,0,corr); + MEDCouplingUMesh *m5=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,0,corr); CPPUNIT_ASSERT_EQUAL(18,m5->getNumberOfCells()); std::vector::iterator it=corr.begin(); const int exp1[4]={18,5,5,4}; @@ -2139,7 +2141,7 @@ void MEDCouplingBasicsTest::testGetCellsContainingPoint() CPPUNIT_ASSERT(std::equal(t2.begin(),t2.end(),expectedValues2)); //2D with no help of bounding box. double center[2]={0.2,0.2}; - MEDCouplingPointSet::rotate2DAlg(center,0.78539816339744830962,6,pos); + MEDCouplingPointSet::Rotate2DAlg(center,0.78539816339744830962,6,pos); targetMesh->rotate(center,0,0.78539816339744830962); t1.clear(); t2.clear(); targetMesh->getCellsContainingPoints(pos,6,1e-12,t1,t2); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx index 7b2b12146..9c3a20394 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx @@ -215,7 +215,7 @@ void MEDCouplingBasicsTest::testCellOrientation2() double center[3]={0.,0.,0.}; double vector[3]={0.,1.,0.}; m4->rotate(center,vector,-M_PI/2.); - MEDCouplingUMesh *m5=m3->buildExtrudedMeshFromThis(m4,0); + MEDCouplingUMesh *m5=m3->buildExtrudedMesh(m4,0); res1.clear(); m5->arePolyhedronsNotCorrectlyOriented(res1); CPPUNIT_ASSERT_EQUAL(15,(int)res1.size()); @@ -2367,10 +2367,10 @@ void MEDCouplingBasicsTest::testFieldDoubleZipConnectivity1() CPPUNIT_ASSERT(m3); m2->decrRef(); MEDCouplingUMesh *m4=build2DSourceMesh_1(); - MEDCouplingUMesh *m5=MEDCouplingUMesh::mergeUMeshes(m1,m3); + MEDCouplingUMesh *m5=MEDCouplingUMesh::MergeUMeshes(m1,m3); m1->decrRef(); m3->decrRef(); - MEDCouplingUMesh *m6=MEDCouplingUMesh::mergeUMeshes(m5,m4); + MEDCouplingUMesh *m6=MEDCouplingUMesh::MergeUMeshes(m5,m4); m4->decrRef(); m5->decrRef(); // @@ -3233,7 +3233,7 @@ void MEDCouplingBasicsTest::testGetNodeIdsNearPoints1() tmp->alloc(3,2); const double vals[6]={0.2,0.2,0.1,0.2,0.2,0.2}; std::copy(vals,vals+6,tmp->getPointer()); - DataArrayDouble *tmp2=DataArrayDouble::aggregate(coords,tmp); + DataArrayDouble *tmp2=DataArrayDouble::Aggregate(coords,tmp); tmp->decrRef(); mesh->setCoords(tmp2); tmp2->decrRef(); @@ -3376,7 +3376,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh5() DataArrayDouble *g=f->getCoords()->applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec"); DataArrayDouble *h=g->fromPolarToCart(); f->setCoords(h); - MEDCouplingUMesh *i=c->buildExtrudedMeshFromThis(f,1); + MEDCouplingUMesh *i=c->buildExtrudedMesh(f,1); CPPUNIT_ASSERT_EQUAL(52,i->getNumberOfNodes()); bool tmp2; int tmp3; @@ -3440,7 +3440,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh6() // const double center[2]={0.,0.}; f->rotate(center,0,M_PI/3); - MEDCouplingUMesh *g=c->buildExtrudedMeshFromThis(f,0); + MEDCouplingUMesh *g=c->buildExtrudedMesh(f,0); g->checkCoherency(); const double expected1[]={ 0.4330127018922193, 0.4330127018922193, 0.649519052838329, 1.2990381056766578, 1.299038105676658, 1.948557158514987, 2.1650635094610955, 2.1650635094610964, 3.2475952641916446, 3.031088913245533, 3.0310889132455352, 4.546633369868303 }; MEDCouplingFieldDouble *f1=g->getMeasureField(true); @@ -3488,7 +3488,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh7() DataArrayDouble *g=f->getCoords()->applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec"); DataArrayDouble *h=g->fromPolarToCart(); f->setCoords(h); - MEDCouplingUMesh *i=c->buildExtrudedMeshFromThis(f,1); + MEDCouplingUMesh *i=c->buildExtrudedMesh(f,1); CPPUNIT_ASSERT_EQUAL(52,i->getNumberOfNodes()); bool tmp2; int tmp3; @@ -3502,7 +3502,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh7() DataArrayDouble *g2=h->applyFunc(3,"13.5/3.5*x*IVec+0*JVec+13.5/3.5*y*KVec"); f->setCoords(g2); i->changeSpaceDimension(3); - MEDCouplingUMesh *i3=i->buildExtrudedMeshFromThis(f,1); + MEDCouplingUMesh *i3=i->buildExtrudedMesh(f,1); MEDCouplingFieldDouble *f2=i3->getMeasureField(true); tmp=i->mergeNodes(1e-9,tmp2,tmp3); CPPUNIT_ASSERT(tmp2); @@ -3663,7 +3663,7 @@ void MEDCouplingBasicsTest::testDAMeld1() for(int i=0;i<35;i++) CPPUNIT_ASSERT_EQUAL((int)expected1[i],dai1->getIJ(0,i)); // test of static method DataArrayDouble::meld - DataArrayDouble *da4=DataArrayDouble::meld(da1C,da3); + DataArrayDouble *da4=DataArrayDouble::Meld(da1C,da3); CPPUNIT_ASSERT_EQUAL(5,da4->getNumberOfComponents()); CPPUNIT_ASSERT_EQUAL(7,da4->getNumberOfTuples()); CPPUNIT_ASSERT(da4->getInfoOnComponent(0)=="c0da1"); @@ -3676,7 +3676,7 @@ void MEDCouplingBasicsTest::testDAMeld1() // test of static method DataArrayInt::meld dai1->decrRef(); dai1=da1C->convertToIntArr(); - DataArrayInt *dai4=DataArrayInt::meld(dai1,dai3); + DataArrayInt *dai4=DataArrayInt::Meld(dai1,dai3); CPPUNIT_ASSERT_EQUAL(5,dai4->getNumberOfComponents()); CPPUNIT_ASSERT_EQUAL(7,dai4->getNumberOfTuples()); CPPUNIT_ASSERT(dai4->getInfoOnComponent(0)=="c0da1"); @@ -3720,7 +3720,7 @@ void MEDCouplingBasicsTest::testFieldMeld1() f2->getArray()->setInfoOnComponent(1,"ccc"); f2->checkCoherency(); // - MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::meldFields(f2,f1); + MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::MeldFields(f2,f1); f3->checkCoherency(); CPPUNIT_ASSERT_EQUAL(5,f3->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(3,f3->getNumberOfComponents()); @@ -3738,7 +3738,7 @@ void MEDCouplingBasicsTest::testFieldMeld1() // MEDCouplingFieldDouble *f4=f2->buildNewTimeReprFromThis(NO_TIME,false); MEDCouplingFieldDouble *f5=f1->buildNewTimeReprFromThis(NO_TIME,false); - MEDCouplingFieldDouble *f6=MEDCouplingFieldDouble::meldFields(f4,f5); + MEDCouplingFieldDouble *f6=MEDCouplingFieldDouble::MeldFields(f4,f5); f6->checkCoherency(); CPPUNIT_ASSERT_EQUAL(5,f6->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(3,f6->getNumberOfComponents()); @@ -3768,7 +3768,7 @@ void MEDCouplingBasicsTest::testMergeNodes2() std::vector tmp(2); tmp[0]=m1; tmp[1]=m2; - MEDCouplingUMesh *m3=MEDCouplingUMesh::mergeUMeshes(tmp); + MEDCouplingUMesh *m3=MEDCouplingUMesh::MergeUMeshes(tmp); bool b; int newNbOfNodes; DataArrayInt *da=m3->mergeNodes2(0.01,b,newNbOfNodes); @@ -3810,7 +3810,7 @@ void MEDCouplingBasicsTest::testMergeField2() // std::vector tmp(3); tmp[0]=f1; tmp[1]=f2; tmp[2]=f3; - MEDCouplingFieldDouble *f4=MEDCouplingFieldDouble::mergeFields(tmp); + MEDCouplingFieldDouble *f4=MEDCouplingFieldDouble::MergeFields(tmp); CPPUNIT_ASSERT_EQUAL(15,f4->getMesh()->getNumberOfCells()); const double expected1[30]={2.,2.,2.,2.,2.,2.,2.,2.,2.,2., 5.,5.,5.,5.,5.,5.,5.,5.,5.,5., 7.,7.,7.,7.,7.,7.,7.,7.,7.,7.}; for(int i=0;i<30;i++) @@ -4020,7 +4020,7 @@ void MEDCouplingBasicsTest::testUMInsertNextCell1() targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn); CPPUNIT_ASSERT_THROW(targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn),INTERP_KERNEL::Exception); CPPUNIT_ASSERT_THROW(targetMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,targetConn),INTERP_KERNEL::Exception); - CPPUNIT_ASSERT_THROW(targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,1,targetConn),INTERP_KERNEL::Exception); + CPPUNIT_ASSERT_THROW(targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn),INTERP_KERNEL::Exception); targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4); targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7); targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10); @@ -4075,3 +4075,284 @@ void MEDCouplingBasicsTest::testFieldOperatorDivDiffComp1() d4->decrRef(); m->decrRef(); } + +void MEDCouplingBasicsTest::testDARearrange1() +{ + DataArrayInt *da1=DataArrayInt::New(); + da1->alloc(12,1); + da1->iota(0); + const int *ptr=da1->getConstPointer(); + // + CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(1,da1->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(12,da1->getNumberOfTuples()); + da1->rearrange(4); + CPPUNIT_ASSERT(ptr==da1->getConstPointer()); + CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfTuples()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i)); + // + da1->rearrange(6); + CPPUNIT_ASSERT(ptr==da1->getConstPointer()); + CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(6,da1->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(2,da1->getNumberOfTuples()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i)); + // + CPPUNIT_ASSERT_THROW(da1->rearrange(7),INTERP_KERNEL::Exception); + // + da1->rearrange(12); + CPPUNIT_ASSERT(ptr==da1->getConstPointer()); + CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(12,da1->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(1,da1->getNumberOfTuples()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i)); + // + da1->rearrange(3); + CPPUNIT_ASSERT(ptr==da1->getConstPointer()); + CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfTuples()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i)); + //double + DataArrayDouble *da2=da1->convertToDblArr(); + da1->decrRef(); + const double *ptr2=da2->getConstPointer(); + // + CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples()); + da2->rearrange(4); + CPPUNIT_ASSERT(ptr2==da2->getConstPointer()); + CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfTuples()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14); + // + da2->rearrange(6); + CPPUNIT_ASSERT(ptr2==da2->getConstPointer()); + CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(6,da2->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(2,da2->getNumberOfTuples()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14); + // + CPPUNIT_ASSERT_THROW(da2->rearrange(7),INTERP_KERNEL::Exception); + // + da2->rearrange(1); + CPPUNIT_ASSERT(ptr2==da2->getConstPointer()); + CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(12,da2->getNumberOfTuples()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14); + // + da2->rearrange(3); + CPPUNIT_ASSERT(ptr2==da2->getConstPointer()); + CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14); + da2->decrRef(); +} + +void MEDCouplingBasicsTest::testGetDifferentValues1() +{ + DataArrayInt *da1=DataArrayInt::New(); + const int arr[12]={1,2,3,2,2,3,5,1,5,5,2,2}; + da1->alloc(4,3); + std::copy(arr,arr+12,da1->getPointer()); + std::set s=da1->getDifferentValues(); + const int expected1[4]={1,2,3,5}; + CPPUNIT_ASSERT_EQUAL(4,(int)s.size()); + CPPUNIT_ASSERT(std::equal(expected1,expected1+4,s.begin())); + da1->decrRef(); +} + +void MEDCouplingBasicsTest::testDAIBuildPermutationArr1() +{ + DataArrayInt *a=DataArrayInt::New(); + const int vala[5]={4,5,6,7,8}; + a->alloc(5,1); + std::copy(vala,vala+5,a->getPointer()); + DataArrayInt *b=DataArrayInt::New(); + const int valb[5]={5,4,8,6,7}; + b->alloc(5,1); + std::copy(valb,valb+5,b->getPointer()); + DataArrayInt *c=a->buildPermutationArr(*b); + const int expect1[5]={1,0,4,2,3}; + CPPUNIT_ASSERT_EQUAL(5,c->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,c->getNumberOfComponents()); + CPPUNIT_ASSERT(std::equal(expect1,expect1+5,c->getConstPointer())); + CPPUNIT_ASSERT(a->isEqualWithoutConsideringStrAndOrder(*b)); + b->setIJ(0,0,9); + CPPUNIT_ASSERT(!a->isEqualWithoutConsideringStrAndOrder(*b)); + CPPUNIT_ASSERT_THROW(a->buildPermutationArr(*b),INTERP_KERNEL::Exception); + a->setIJ(3,0,4); + b->setIJ(0,0,5); + b->setIJ(4,0,4);//;a==[4,5,6,4,8] and b==[5,4,8,6,4] + CPPUNIT_ASSERT(a->isEqualWithoutConsideringStrAndOrder(*b)); + c->decrRef(); + c=a->buildPermutationArr(*b); + const int expect2[5]={1,3,4,2,3}; + CPPUNIT_ASSERT(std::equal(expect2,expect2+5,c->getConstPointer())); + DataArrayDouble *d=b->convertToDblArr(); + b->sort(); + const int expect3[5]={4,4,5,6,8}; + CPPUNIT_ASSERT(std::equal(expect3,expect3+5,b->getConstPointer())); + d->sort(); + CPPUNIT_ASSERT_EQUAL(5,d->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,d->getNumberOfComponents()); + for(int i=0;i<5;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(double(expect3[i]),d->getIJ(i,0),1e-14); + // + d->decrRef(); + c->decrRef(); + a->decrRef(); + b->decrRef(); +} + +void MEDCouplingBasicsTest::testAreCellsIncludedIn2() +{ + const char myName[]="Vitoo"; + MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); + MEDCouplingUMesh *m2=(MEDCouplingUMesh *)m->buildPartOfMySelf(0,0,true); + CPPUNIT_ASSERT_EQUAL(0,m2->getNumberOfCells()); + CPPUNIT_ASSERT_EQUAL(3,m2->getSpaceDimension()); + CPPUNIT_ASSERT_EQUAL(2,m2->getMeshDimension()); + m2->setName(myName); + DataArrayInt *tmp; + CPPUNIT_ASSERT(m->areCellsIncludedIn(m2,0,tmp)); + CPPUNIT_ASSERT(std::string(myName)==tmp->getName()); + CPPUNIT_ASSERT_EQUAL(0,tmp->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,tmp->getNumberOfComponents()); + m->decrRef(); + m2->decrRef(); + tmp->decrRef(); +} + +void MEDCouplingBasicsTest::testUMeshGetPartBarycenterAndOwner1() +{ + MEDCouplingUMesh *m1=build2DTargetMesh_1(); + const int part[3]={1,0,4}; + DataArrayDouble *b=m1->getPartBarycenterAndOwner(part,part+3); + CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(3,b->getNumberOfTuples()); + const double expected1[6]={0.36666666666666665,-0.13333333333333333,-0.05,-0.05,0.45,0.45}; + for(int i=0;i<6;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14); + b->decrRef(); + m1->decrRef(); +} + +void MEDCouplingBasicsTest::testUMeshGetPartMeasureField1() +{ + MEDCouplingUMesh *m1=build2DTargetMesh_1(); + const int part[3]={1,0,4}; + MEDCouplingFieldDouble *b=m1->getPartMeasureField(true,part,part+3); + CPPUNIT_ASSERT_EQUAL(1,b->getArray()->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(3,b->getArray()->getNumberOfTuples()); + const double expected1[3]={0.125,0.25,0.25}; + for(int i=0;i<3;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getArray()->getIJ(0,i),1e-14); + b->decrRef(); + m1->decrRef(); +} + +void MEDCouplingBasicsTest::testUMeshBuildPartOrthogonalField1() +{ + MEDCouplingUMesh *m1=build2DTargetMesh_1(); + m1->changeSpaceDimension(3); + const int part[3]={1,0,4}; + MEDCouplingFieldDouble *b=m1->buildPartOrthogonalField(part,part+3); + CPPUNIT_ASSERT_EQUAL(3,b->getArray()->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(3,b->getArray()->getNumberOfTuples()); + const double expected1[9]={0.,0.,-1.,0.,0.,-1.,0.,0.,-1.}; + for(int i=0;i<9;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getArray()->getIJ(0,i),1e-14); + b->decrRef(); + m1->decrRef(); +} + +void MEDCouplingBasicsTest::testUMeshGetTypesOfPart1() +{ + MEDCouplingUMesh *m1=build2DTargetMesh_1(); + const int part1[]={0,3,4}; + std::set s; + s=m1->getTypesOfPart(part1,part1+3); + CPPUNIT_ASSERT(s.size()==1); + CPPUNIT_ASSERT(*s.begin()==INTERP_KERNEL::NORM_QUAD4); + const int part2[]={2,2,2,1}; + s=m1->getTypesOfPart(part2,part2+4); + CPPUNIT_ASSERT(s.size()==1); + CPPUNIT_ASSERT(*s.begin()==INTERP_KERNEL::NORM_TRI3); + const int part3[]={3,2,1}; + s=m1->getTypesOfPart(part3,part3+3); + CPPUNIT_ASSERT(s.size()==2); + CPPUNIT_ASSERT(*s.begin()==INTERP_KERNEL::NORM_TRI3); + CPPUNIT_ASSERT(*(++s.begin())==INTERP_KERNEL::NORM_QUAD4); + m1->decrRef(); +} + +void MEDCouplingBasicsTest::testUMeshKeepCellIdsByType1() +{ + MEDCouplingUMesh *m1=build2DTargetMesh_1(); + const int part1[3]={0,3,4}; + DataArrayInt *a=m1->keepCellIdsByType(INTERP_KERNEL::NORM_TRI3,part1,part1+3); + CPPUNIT_ASSERT_EQUAL(1,a->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(0,a->getNumberOfTuples()); + a->decrRef(); + // + const int part2[5]={3,2,0,2,4}; + a=m1->keepCellIdsByType(INTERP_KERNEL::NORM_TRI3,part2,part2+5); + CPPUNIT_ASSERT_EQUAL(1,a->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(2,a->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,a->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(2,a->getIJ(1,0)); + a->decrRef(); + // + a=m1->keepCellIdsByType(INTERP_KERNEL::NORM_QUAD4,part2,part2+5); + CPPUNIT_ASSERT_EQUAL(1,a->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(3,a->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(3,a->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(0,a->getIJ(1,0)); + CPPUNIT_ASSERT_EQUAL(4,a->getIJ(2,0)); + // + a->decrRef(); + m1->decrRef(); +} + +void MEDCouplingBasicsTest::testDAIAggregateMulti1() +{ + DataArrayInt *a=DataArrayInt::New(); + a->setName("aa"); + a->alloc(4,1); + a->iota(0); + a->rearrange(2); + DataArrayInt *b=DataArrayInt::New(); + b->setName("bb"); + b->alloc(6,1); + b->iota(0); + b->rearrange(2); + // + std::vector v(2); + v[0]=a; v[1]=b; + DataArrayInt *c=DataArrayInt::Aggregate(v); + CPPUNIT_ASSERT_EQUAL(5,c->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,c->getNumberOfComponents()); + CPPUNIT_ASSERT(c->getName()=="aa"); + const int expect1[10]={0,1,2,3,0,1,2,3,4,5}; + for(int i=0;i<10;i++) + CPPUNIT_ASSERT_EQUAL(expect1[i],c->getIJ(0,i)); + // + c->decrRef(); + a->decrRef(); + b->decrRef(); +}