X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingStructuredMesh.cxx;h=20982788adddaabd6972ca53d2ba323e4a6fa468;hb=0c9d48870957c4a9f6f82fc8e2c569780a5f886b;hp=2c92df2413901e1b4e860adb3e2751b7fcd20cfa;hpb=70074ec092502051c6338f02e8b1677277883e10;p=modules%2Fmed.git diff --git a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx index 2c92df241..20982788a 100644 --- a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx +++ b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx @@ -40,17 +40,17 @@ MEDCouplingStructuredMesh::~MEDCouplingStructuredMesh() { } -std::size_t MEDCouplingStructuredMesh::getHeapMemorySize() const +std::size_t MEDCouplingStructuredMesh::getHeapMemorySizeWithoutChildren() const { - return MEDCouplingMesh::getHeapMemorySize(); + return MEDCouplingMesh::getHeapMemorySizeWithoutChildren(); } -void MEDCouplingStructuredMesh::copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception) +void MEDCouplingStructuredMesh::copyTinyStringsFrom(const MEDCouplingMesh *other) { MEDCouplingMesh::copyTinyStringsFrom(other); } -bool MEDCouplingStructuredMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception) +bool MEDCouplingStructuredMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const { return MEDCouplingMesh::isEqualIfNotWhy(other,prec,reason); } @@ -60,7 +60,7 @@ INTERP_KERNEL::NormalizedCellType MEDCouplingStructuredMesh::getTypeOfCell(int c return GetGeoTypeGivenMeshDimension(getMeshDimension()); } -INTERP_KERNEL::NormalizedCellType MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(int meshDim) throw(INTERP_KERNEL::Exception) +INTERP_KERNEL::NormalizedCellType MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(int meshDim) { switch(meshDim) { @@ -70,6 +70,8 @@ INTERP_KERNEL::NormalizedCellType MEDCouplingStructuredMesh::GetGeoTypeGivenMesh return INTERP_KERNEL::NORM_QUAD4; case 1: return INTERP_KERNEL::NORM_SEG2; + case 0: + return INTERP_KERNEL::NORM_POINT1; default: throw INTERP_KERNEL::Exception("Unexpected dimension for MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension !"); } @@ -92,7 +94,7 @@ int MEDCouplingStructuredMesh::getNumberOfCellsWithType(INTERP_KERNEL::Normalize throw INTERP_KERNEL::Exception(oss.str().c_str()); } -DataArrayInt *MEDCouplingStructuredMesh::giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception) +DataArrayInt *MEDCouplingStructuredMesh::giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const { MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); if(getTypeOfCell(0)==type) @@ -105,7 +107,7 @@ DataArrayInt *MEDCouplingStructuredMesh::giveCellsWithType(INTERP_KERNEL::Normal return ret.retn(); } -DataArrayInt *MEDCouplingStructuredMesh::computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception) +DataArrayInt *MEDCouplingStructuredMesh::computeNbOfNodesPerCell() const { int nbCells=getNumberOfCells(); MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); @@ -115,7 +117,7 @@ DataArrayInt *MEDCouplingStructuredMesh::computeNbOfNodesPerCell() const throw(I return ret.retn(); } -DataArrayInt *MEDCouplingStructuredMesh::computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception) +DataArrayInt *MEDCouplingStructuredMesh::computeNbOfFacesPerCell() const { int nbCells=getNumberOfCells(); MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); @@ -132,7 +134,7 @@ DataArrayInt *MEDCouplingStructuredMesh::computeNbOfFacesPerCell() const throw(I * * \return DataArrayInt * - new object to be deallocated by the caller. */ -DataArrayInt *MEDCouplingStructuredMesh::computeEffectiveNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception) +DataArrayInt *MEDCouplingStructuredMesh::computeEffectiveNbOfNodesPerCell() const { return computeNbOfNodesPerCell(); } @@ -168,7 +170,7 @@ void MEDCouplingStructuredMesh::getNodeIdsOfCell(int cellId, std::vector& c /*! * See MEDCouplingUMesh::getDistributionOfTypes for more information */ -std::vector MEDCouplingStructuredMesh::getDistributionOfTypes() const throw(INTERP_KERNEL::Exception) +std::vector MEDCouplingStructuredMesh::getDistributionOfTypes() const { //only one type of cell std::vector ret(3); @@ -184,7 +186,7 @@ std::vector MEDCouplingStructuredMesh::getDistributionOfTypes() const throw * * See MEDCouplingUMesh::checkTypeConsistencyAndContig for more information */ -DataArrayInt *MEDCouplingStructuredMesh::checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) +DataArrayInt *MEDCouplingStructuredMesh::checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const { int nbOfCells=getNumberOfCells(); if(code.size()!=3) @@ -242,7 +244,7 @@ DataArrayInt *MEDCouplingStructuredMesh::checkTypeConsistencyAndContig(const std * - After \a code contains [NORM_...,nbCells,0], \a idsInPflPerType [[0,1]] and \a idsPerType is [[1,2]]
*/ -void MEDCouplingStructuredMesh::splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) +void MEDCouplingStructuredMesh::splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& idsPerType) const { if(!profile || !profile->isAllocated()) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::splitProfilePerType : input profile is NULL or not allocated !"); @@ -274,7 +276,7 @@ void MEDCouplingStructuredMesh::splitProfilePerType(const DataArrayInt *profile, * delete this array using decrRef() as it is no more needed. * \throw If \a this->getMeshDimension() is not among [1,2,3]. */ -MEDCoupling1SGTUMesh *MEDCouplingStructuredMesh::build1SGTUnstructured() const throw(INTERP_KERNEL::Exception) +MEDCoupling1SGTUMesh *MEDCouplingStructuredMesh::build1SGTUnstructured() const { int meshDim=getMeshDimension(); if(meshDim<0 || meshDim>3) @@ -283,7 +285,7 @@ MEDCoupling1SGTUMesh *MEDCouplingStructuredMesh::build1SGTUnstructured() const t int ns[3]; getNodeGridStructure(ns); MEDCouplingAutoRefCountObjectPtr conn(Build1GTNodalConnectivity(ns,ns+meshDim)); - MEDCouplingAutoRefCountObjectPtr ret(MEDCoupling1SGTUMesh::New(getName().c_str(),GetGeoTypeGivenMeshDimension(meshDim))); + MEDCouplingAutoRefCountObjectPtr ret(MEDCoupling1SGTUMesh::New(getName(),GetGeoTypeGivenMeshDimension(meshDim))); ret->setNodalConnectivity(conn); ret->setCoords(coords); return ret.retn(); } @@ -294,7 +296,7 @@ MEDCoupling1SGTUMesh *MEDCouplingStructuredMesh::build1SGTUnstructured() const t * delete this array using decrRef() as it is no more needed. * \throw If \a this->getMeshDimension() is not among [1,2,3]. */ -MEDCouplingUMesh *MEDCouplingStructuredMesh::buildUnstructured() const throw(INTERP_KERNEL::Exception) +MEDCouplingUMesh *MEDCouplingStructuredMesh::buildUnstructured() const { MEDCouplingAutoRefCountObjectPtr ret0(build1SGTUnstructured()); return ret0->buildUnstructured(); @@ -345,7 +347,7 @@ MEDCouplingMesh *MEDCouplingStructuredMesh::buildPartAndReduceNodes(const int *s } } -DataArrayInt *MEDCouplingStructuredMesh::simplexize(int policy) throw(INTERP_KERNEL::Exception) +DataArrayInt *MEDCouplingStructuredMesh::simplexize(int policy) { throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::simplexize : not available for Cartesian mesh !"); } @@ -375,14 +377,175 @@ MEDCouplingFieldDouble *MEDCouplingStructuredMesh::buildOrthogonalField() const return ret; } +void MEDCouplingStructuredMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const +{ + std::vector ngs(getNodeGridStructure()); + int dim(getSpaceDimension()); + switch(dim) + { + case 1: + return GetReverseNodalConnectivity1(ngs,revNodal,revNodalIndx); + case 2: + return GetReverseNodalConnectivity2(ngs,revNodal,revNodalIndx); + case 3: + return GetReverseNodalConnectivity3(ngs,revNodal,revNodalIndx); + default: + throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::getReverseNodalConnectivity : only dimensions 1, 2 and 3 are supported !"); + } +} + +void MEDCouplingStructuredMesh::GetReverseNodalConnectivity1(const std::vector& ngs, DataArrayInt *revNodal, DataArrayInt *revNodalIndx) +{ + int nbNodes(ngs[0]); + revNodalIndx->alloc(nbNodes+1,1); + if(nbNodes==0) + { revNodal->alloc(0,1); revNodalIndx->setIJ(0,0,0); return ; } + if(nbNodes==1) + { revNodal->alloc(1,1); revNodal->setIJ(0,0,0); revNodalIndx->setIJ(0,0,0); revNodalIndx->setIJ(1,0,1); return ; } + revNodal->alloc(2*(nbNodes-1),1); + int *rn(revNodal->getPointer()),*rni(revNodalIndx->getPointer()); + *rni++=0; *rni=1; *rn++=0; + for(int i=1;i& ngs, DataArrayInt *revNodal, DataArrayInt *revNodalIndx) +{ + int nbNodesX(ngs[0]),nbNodesY(ngs[1]); + int nbNodes(nbNodesX*nbNodesY); + if(nbNodesX==0 || nbNodesY==0) + { revNodal->alloc(0,1); revNodalIndx->setIJ(0,0,0); return ; } + if(nbNodesX==1 || nbNodesY==1) + { std::vector ngs2(1); ngs2[0]=std::max(nbNodesX,nbNodesY); return GetReverseNodalConnectivity1(ngs2,revNodal,revNodalIndx); } + revNodalIndx->alloc(nbNodes+1,1); + int nbCellsX(nbNodesX-1),nbCellsY(nbNodesY-1); + revNodal->alloc(4*(nbNodesX-2)*(nbNodesY-2)+2*2*(nbNodesX-2)+2*2*(nbNodesY-2)+4,1); + int *rn(revNodal->getPointer()),*rni(revNodalIndx->getPointer()); + *rni++=0; *rni=1; *rn++=0; + for(int i=1;i& ngs, DataArrayInt *revNodal, DataArrayInt *revNodalIndx) +{ + int nbNodesX(ngs[0]),nbNodesY(ngs[1]),nbNodesZ(ngs[2]); + int nbNodes(nbNodesX*nbNodesY*nbNodesZ); + if(nbNodesX==0 || nbNodesY==0 || nbNodesZ==0) + { revNodal->alloc(0,1); revNodalIndx->setIJ(0,0,0); return ; } + if(nbNodesX==1 || nbNodesY==1 || nbNodesZ==1) + { + std::vector ngs2(2); + int pos(0); + bool pass(false); + for(int i=0;i<3;i++) + { + if(pass) + { ngs2[pos++]=ngs[i]; } + else + { + pass=ngs[i]==1; + if(!pass) + { ngs2[pos++]=ngs[i]; } + } + } + return GetReverseNodalConnectivity2(ngs2,revNodal,revNodalIndx); + } + revNodalIndx->alloc(nbNodes+1,1); + int nbCellsX(nbNodesX-1),nbCellsY(nbNodesY-1),nbCellsZ(nbNodesZ-1); + revNodal->alloc(8*(nbNodesX-2)*(nbNodesY-2)*(nbNodesZ-2)+4*(2*(nbNodesX-2)*(nbNodesY-2)+2*(nbNodesX-2)*(nbNodesZ-2)+2*(nbNodesY-2)*(nbNodesZ-2))+2*4*(nbNodesX-2)+2*4*(nbNodesY-2)+2*4*(nbNodesZ-2)+8,1); + int *rn(revNodal->getPointer()),*rni(revNodalIndx->getPointer()); + *rni=0; + for(int k=0;k=1 && j>=1 && i>=1) + *rn++=off00+i-1; + if(k>=1 && j>=1 && i=1 && j=1) + *rn++=off01+i-1; + if(k>=1 && j=1 && i>=1) + *rn++=off10+i-1; + if(k=1 && i=1) + *rn++=off11+i-1; + if(k conn(DataArrayInt::New()); + conn->alloc(1,1); conn->setIJ(0,0,0); + return conn.retn(); + } case 1: return Build1GTNodalConnectivity1D(nodeStBg); case 2: @@ -390,11 +553,11 @@ DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivity(const int *no case 3: return Build1GTNodalConnectivity3D(nodeStBg); default: - throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::Build1GTNodalConnectivity : only dimension in [1,2,3] supported !"); + throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::Build1GTNodalConnectivity : only dimension in [0,1,2,3] supported !"); } } -DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivity1D(const int *nodeStBg) throw(INTERP_KERNEL::Exception) +DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivity1D(const int *nodeStBg) { int nbOfCells(*nodeStBg-1); MEDCouplingAutoRefCountObjectPtr conn(DataArrayInt::New()); @@ -408,7 +571,7 @@ DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivity1D(const int * return conn.retn(); } -DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivity2D(const int *nodeStBg) throw(INTERP_KERNEL::Exception) +DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivity2D(const int *nodeStBg) { int n1=nodeStBg[0]-1; int n2=nodeStBg[1]-1; @@ -427,7 +590,7 @@ DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivity2D(const int * return conn.retn(); } -DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivity3D(const int *nodeStBg) throw(INTERP_KERNEL::Exception) +DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivity3D(const int *nodeStBg) { int n1=nodeStBg[0]-1; int n2=nodeStBg[1]-1; @@ -465,7 +628,7 @@ int MEDCouplingStructuredMesh::getCellIdFromPos(int i, int j, int k) const { int tmp[3]={i,j,k}; int tmp2[3]; - int meshDim=getMeshDimension(); + int meshDim(getMeshDimension()); getSplitCellValues(tmp2); std::transform(tmp,tmp+meshDim,tmp2,tmp,std::multiplies()); return std::accumulate(tmp,tmp+meshDim,0); @@ -482,10 +645,10 @@ int MEDCouplingStructuredMesh::getNodeIdFromPos(int i, int j, int k) const { int tmp[3]={i,j,k}; int tmp2[3]; - int meshDim=getMeshDimension(); + int spaceDim(getSpaceDimension()); getSplitNodeValues(tmp2); - std::transform(tmp,tmp+meshDim,tmp2,tmp,std::multiplies()); - return std::accumulate(tmp,tmp+meshDim,0); + std::transform(tmp,tmp+spaceDim,tmp2,tmp,std::multiplies()); + return std::accumulate(tmp,tmp+spaceDim,0); } void MEDCouplingStructuredMesh::GetPosFromId(int nodeId, int meshDim, const int *split, int *res) @@ -499,7 +662,7 @@ void MEDCouplingStructuredMesh::GetPosFromId(int nodeId, int meshDim, const int } } -std::vector MEDCouplingStructuredMesh::getCellGridStructure() const throw(INTERP_KERNEL::Exception) +std::vector MEDCouplingStructuredMesh::getCellGridStructure() const { std::vector ret(getNodeGridStructure()); std::transform(ret.begin(),ret.end(),ret.begin(),std::bind2nd(std::plus(),-1)); @@ -512,7 +675,7 @@ std::vector MEDCouplingStructuredMesh::getCellGridStructure() const throw(I * * \sa MEDCouplingStructuredMesh::BuildExplicitIdsFrom */ -bool MEDCouplingStructuredMesh::IsPartStructured(const int *startIds, const int *stopIds, const std::vector& st, std::vector< std::pair >& partCompactFormat) throw(INTERP_KERNEL::Exception) +bool MEDCouplingStructuredMesh::IsPartStructured(const int *startIds, const int *stopIds, const std::vector& st, std::vector< std::pair >& partCompactFormat) { int dim((int)st.size()); partCompactFormat.resize(dim); @@ -604,7 +767,7 @@ bool MEDCouplingStructuredMesh::IsPartStructured(const int *startIds, const int * \return DataArrayInt * - a new object. * \sa MEDCouplingStructuredMesh::IsPartStructured */ -DataArrayInt *MEDCouplingStructuredMesh::BuildExplicitIdsFrom(const std::vector& st, const std::vector< std::pair >& partCompactFormat) throw(INTERP_KERNEL::Exception) +DataArrayInt *MEDCouplingStructuredMesh::BuildExplicitIdsFrom(const std::vector& st, const std::vector< std::pair >& partCompactFormat) { if(st.size()!=partCompactFormat.size()) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::BuildExplicitIdsFrom : input arrays must have the same size !");