From 876a016bccb29895b57edf0662be8060a0fee58b Mon Sep 17 00:00:00 2001 From: geay Date: Mon, 7 Apr 2014 11:46:28 +0200 Subject: [PATCH] Little refactoring of structured meshes to deal with structured meshes with mesh dimension < space dimension. --- src/MEDCoupling/MEDCouplingCMesh.cxx | 112 +++++----------- src/MEDCoupling/MEDCouplingCMesh.hxx | 3 - .../MEDCouplingCurveLinearMesh.cxx | 21 ++- .../MEDCouplingCurveLinearMesh.hxx | 1 - src/MEDCoupling/MEDCouplingStructuredMesh.cxx | 121 ++++++++++++++++-- src/MEDCoupling/MEDCouplingStructuredMesh.hxx | 6 + src/MEDCoupling_Swig/MEDCouplingBasicsTest.py | 99 ++++++++++++++ src/MEDCoupling_Swig/MEDCouplingCommon.i | 1 + src/MEDLoader/Swig/MEDLoaderCommon.i | 20 +-- src/MEDLoader/Swig/MEDLoaderTest3.py | 2 + 10 files changed, 272 insertions(+), 114 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingCMesh.cxx b/src/MEDCoupling/MEDCouplingCMesh.cxx index 060fe57bd..22851038d 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCMesh.cxx @@ -275,30 +275,6 @@ void MEDCouplingCMesh::checkCoherency2(double eps) const checkCoherency1(eps); } -int MEDCouplingCMesh::getNumberOfCells() const -{ - int ret=1; - if(_x_array) - ret*=_x_array->getNbOfElems()-1; - if(_y_array) - ret*=_y_array->getNbOfElems()-1; - if(_z_array) - ret*=_z_array->getNbOfElems()-1; - return ret; -} - -int MEDCouplingCMesh::getNumberOfNodes() const -{ - int ret=1; - if(_x_array) - ret*=_x_array->getNbOfElems(); - if(_y_array) - ret*=_y_array->getNbOfElems(); - if(_z_array) - ret*=_z_array->getNbOfElems(); - return ret; -} - void MEDCouplingCMesh::getSplitCellValues(int *res) const { int meshDim(getMeshDimension()); @@ -325,15 +301,41 @@ void MEDCouplingCMesh::getSplitNodeValues(int *res) const void MEDCouplingCMesh::getNodeGridStructure(int *res) const { - int spaceDim(getSpaceDimension()); - for(int i=0;igetNbOfElems(); + std::vector ret(getNodeGridStructure()); + std::copy(ret.begin(),ret.end(),res); } std::vector MEDCouplingCMesh::getNodeGridStructure() const { - std::vector ret(getSpaceDimension()); - getNodeGridStructure(&ret[0]); + static const char MSG[]="MEDCouplingCMesh::getNodeGridStructure : mesh is invalid ! null vectors (X, Y or Z) must be put contiguously at the end !"; + std::vector ret; + bool isOK(true); + if(_x_array) + { + if(!_x_array->isAllocated() || _x_array->getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("MEDCouplingCMesh::getNodeGridStructure : X array exits but it is not allocated or with nb of components equal to one !"); + ret.push_back(_x_array->getNumberOfTuples()); + } + else + isOK=false; + if(_y_array) + { + if(!_y_array->isAllocated() || _y_array->getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("MEDCouplingCMesh::getNodeGridStructure : Y array exits but it is not allocated or with nb of components equal to one !"); + if(!isOK) + throw INTERP_KERNEL::Exception(MSG); + ret.push_back(_y_array->getNumberOfTuples()); + } + else + isOK=false; + if(_z_array) + { + if(!_z_array->isAllocated() || _z_array->getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("MEDCouplingCMesh::getNodeGridStructure : Z array exits but it is not allocated or with nb of components equal to one !"); + if(!isOK) + throw INTERP_KERNEL::Exception(MSG); + ret.push_back(_z_array->getNumberOfTuples()); + } return ret; } @@ -357,59 +359,11 @@ MEDCouplingStructuredMesh *MEDCouplingCMesh::buildStructuredSubPart(const std::v /*! * Return the space dimension of \a this. It only considers the arrays along X, Y and Z to deduce that. - * This method throws exceptions if the not null arrays defining this are not contiguouly at the end. For example X!=0,Y==0,Z!=0 will throw. + * This method throws exceptions if the not null arrays defining this are not contiguously at the end. For example X!=0,Y==0,Z!=0 will throw. */ int MEDCouplingCMesh::getSpaceDimension() const { - static const char MSG[]="MEDCouplingCMesh::getSpaceDimension : mesh is invalid ! null vectors (X, Y or Z) must be put contiguously at the end !"; - int ret(0); - bool isOK(true); - if(_x_array) - ret++; - else - isOK=false; - if(_y_array) - { - if(!isOK) - throw INTERP_KERNEL::Exception(MSG); - ret++; - } - else - isOK=false; - if(_z_array) - { - if(!isOK) - throw INTERP_KERNEL::Exception(MSG); - ret++; - } - return ret; -} - -/*! - * This method returns the mesh dimension of \a this. It can be different from space dimension in case of a not null dimension contains only one node. - */ -int MEDCouplingCMesh::getMeshDimension() const -{ - int ret(getSpaceDimension()); - if(_x_array) - { - if(_x_array->isAllocated()) - if(_x_array->getNumberOfTuples()==1) - ret--; - } - if(_y_array) - { - if(_y_array->isAllocated()) - if(_y_array->getNumberOfTuples()==1) - ret--; - } - if(_z_array) - { - if(_z_array->isAllocated()) - if(_z_array->getNumberOfTuples()==1) - ret--; - } - return ret; + return (int)getNodeGridStructure().size(); } void MEDCouplingCMesh::getCoordinatesOfNode(int nodeId, std::vector& coo) const diff --git a/src/MEDCoupling/MEDCouplingCMesh.hxx b/src/MEDCoupling/MEDCouplingCMesh.hxx index e675e5e40..8011fb8ca 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.hxx +++ b/src/MEDCoupling/MEDCouplingCMesh.hxx @@ -50,10 +50,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void checkCoherency() const; MEDCOUPLING_EXPORT void checkCoherency1(double eps=1e-12) const; MEDCOUPLING_EXPORT void checkCoherency2(double eps=1e-12) const; - MEDCOUPLING_EXPORT int getNumberOfCells() const; - MEDCOUPLING_EXPORT int getNumberOfNodes() const; MEDCOUPLING_EXPORT int getSpaceDimension() const; - MEDCOUPLING_EXPORT int getMeshDimension() const; MEDCOUPLING_EXPORT void getCoordinatesOfNode(int nodeId, std::vector& coo) const; MEDCOUPLING_EXPORT std::string simpleRepr() const; MEDCOUPLING_EXPORT std::string advancedRepr() const; diff --git a/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx b/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx index 72fc69949..c96ed77f1 100644 --- a/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx @@ -215,19 +215,13 @@ void MEDCouplingCurveLinearMesh::checkCoherency2(double eps) const int MEDCouplingCurveLinearMesh::getNumberOfCells() const { checkCoherency(); - std::size_t nbOfCells=1,i=0; - for(std::vector::const_iterator it=_structure.begin();it!=_structure.end();it++,i++) - nbOfCells*=(*it)-1; - return (int)nbOfCells; + return MEDCouplingStructuredMesh::getNumberOfCells(); } int MEDCouplingCurveLinearMesh::getNumberOfNodes() const { checkCoherency(); - std::size_t nbOfNodes=1; - for(std::vector::const_iterator it=_structure.begin();it!=_structure.end();it++) - nbOfNodes*=(*it); - return (int)nbOfNodes; + return MEDCouplingStructuredMesh::getNumberOfNodes(); } void MEDCouplingCurveLinearMesh::getSplitCellValues(int *res) const @@ -259,6 +253,12 @@ void MEDCouplingCurveLinearMesh::getNodeGridStructure(int *res) const std::copy(_structure.begin(),_structure.end(),res); } +/*! + * MEDCouplingCurveLinearMesh has the property to define 2 space dimensions. One coming from its coordinates. The other coming from the node structure. + * Normally they should be equal ! This method returns the space dimension from coordinates. If the other one is requested call getSpaceDimensionOnNodeStruct. + * + * \sa MEDCouplingStructuredMesh::getSpaceDimensionOnNodeStruct + */ int MEDCouplingCurveLinearMesh::getSpaceDimension() const { if(!((const DataArrayDouble *)_coords)) @@ -266,11 +266,6 @@ int MEDCouplingCurveLinearMesh::getSpaceDimension() const return _coords->getNumberOfComponents(); } -int MEDCouplingCurveLinearMesh::getMeshDimension() const -{ - return (int)_structure.size(); -} - void MEDCouplingCurveLinearMesh::getCoordinatesOfNode(int nodeId, std::vector& coo) const { if(!((const DataArrayDouble *)_coords)) diff --git a/src/MEDCoupling/MEDCouplingCurveLinearMesh.hxx b/src/MEDCoupling/MEDCouplingCurveLinearMesh.hxx index 926c4721c..56505d921 100644 --- a/src/MEDCoupling/MEDCouplingCurveLinearMesh.hxx +++ b/src/MEDCoupling/MEDCouplingCurveLinearMesh.hxx @@ -54,7 +54,6 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT int getNumberOfCells() const; MEDCOUPLING_EXPORT int getNumberOfNodes() const; MEDCOUPLING_EXPORT int getSpaceDimension() const; - MEDCOUPLING_EXPORT int getMeshDimension() const; MEDCOUPLING_EXPORT void getCoordinatesOfNode(int nodeId, std::vector& coo) const; MEDCOUPLING_EXPORT std::string simpleRepr() const; MEDCOUPLING_EXPORT std::string advancedRepr() const; diff --git a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx index 954521368..5c5e4be8c 100644 --- a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx +++ b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx @@ -167,6 +167,48 @@ void MEDCouplingStructuredMesh::getNodeIdsOfCell(int cellId, std::vector& c }; } +/*! + * This method returns the mesh dimension of \a this. It can be different from space dimension in case of a not null dimension contains only one node. + */ +int MEDCouplingStructuredMesh::getMeshDimension() const +{ + std::vector ngs(getNodeGridStructure()); + int ret(0),pos(0); + for(std::vector::const_iterator it=ngs.begin();it!=ngs.end();it++,pos++) + { + if(*it<=0) + { + std::ostringstream oss; oss << "MEDCouplingStructuredMesh::getMeshDimension : At pos #" << pos << " number of nodes is " << *it << " ! Must be > 0 !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + if(*it>1) + ret++; + } + return ret; +} + +/*! + * This method returns the space dimension by only considering the node grid structure. + * For cartesian mesh the returned value is equal to those returned by getSpaceDimension. + * But for curvelinear is could be different ! + */ +int MEDCouplingStructuredMesh::getSpaceDimensionOnNodeStruct() const +{ + std::vector nodeStr(getNodeGridStructure()); + int spd1(0),pos(0); + for(std::vector::const_iterator it=nodeStr.begin();it!=nodeStr.end();it++,pos++) + { + int elt(*it); + if(elt<=0) + { + std::ostringstream oss; oss << "MEDCouplingStructuredMesh::getSpaceDimensionOnNodeStruct : At pos #" << pos << " value of node grid structure is " << *it << " ! must be >=1 !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + spd1++; + } + return spd1; +} + /*! * This method returns the number of cells of unstructured sub level mesh, without building it. */ @@ -287,13 +329,13 @@ void MEDCouplingStructuredMesh::splitProfilePerType(const DataArrayInt *profile, */ MEDCoupling1SGTUMesh *MEDCouplingStructuredMesh::build1SGTUnstructured() const { - int meshDim(getMeshDimension()); - if(meshDim<0 || meshDim>3) - throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::build1SGTUnstructured : meshdim must be in [1,2,3] !"); + int meshDim(getMeshDimension()),spaceDim(getSpaceDimensionOnNodeStruct()); + if((meshDim<0 || meshDim>3) || (spaceDim<0 || spaceDim>3)) + throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::build1SGTUnstructured : meshdim and spacedim must be in [1,2,3] !"); MEDCouplingAutoRefCountObjectPtr coords(getCoordinatesAndOwner()); int ns[3]; getNodeGridStructure(ns); - MEDCouplingAutoRefCountObjectPtr conn(Build1GTNodalConnectivity(ns,ns+meshDim)); + MEDCouplingAutoRefCountObjectPtr conn(Build1GTNodalConnectivity(ns,ns+spaceDim)); MEDCouplingAutoRefCountObjectPtr ret(MEDCoupling1SGTUMesh::New(getName(),GetGeoTypeGivenMeshDimension(meshDim))); ret->setNodalConnectivity(conn); ret->setCoords(coords); return ret.retn(); @@ -566,7 +608,8 @@ void MEDCouplingStructuredMesh::GetReverseNodalConnectivity3(const std::vector3 || spaceDim<1) + throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::ZipNodeStructure : spaceDim must in [1,2,3] !"); + zipNodeSt[0]=0; zipNodeSt[1]=0; zipNodeSt[2]=0; + int zippedI(0); + for(int i=0;i=2) + zipNodeSt[zippedI++]=elt; + } + return zippedI; +} + DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivityOfSubLevelMesh2D(const int *nodeStBg) { std::vector ngs(2); @@ -739,6 +811,39 @@ int MEDCouplingStructuredMesh::getNodeIdFromPos(int i, int j, int k) const return std::accumulate(tmp,tmp+spaceDim,0); } + +int MEDCouplingStructuredMesh::getNumberOfCells() const +{ + std::vector ngs(getNodeGridStructure()); + int ret(1); + bool isCatched(false); + std::size_t ii(0); + for(std::vector::const_iterator it=ngs.begin();it!=ngs.end();it++,ii++) + { + int elt(*it); + if(elt<=0) + { + std::ostringstream oss; oss << "MEDCouplingStructuredMesh::getNumberOfCells : at pos #" << ii << " the number of nodes in nodeStructure is " << *it << " ! Must be > 0 !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + if(elt>1) + { + ret*=elt-1; + isCatched=true; + } + } + return isCatched?ret:0; +} + +int MEDCouplingStructuredMesh::getNumberOfNodes() const +{ + std::vector ngs(getNodeGridStructure()); + int ret(1); + for(std::vector::const_iterator it=ngs.begin();it!=ngs.end();it++) + ret*=*it; + return ret; +} + void MEDCouplingStructuredMesh::GetPosFromId(int nodeId, int meshDim, const int *split, int *res) { int work=nodeId; diff --git a/src/MEDCoupling/MEDCouplingStructuredMesh.hxx b/src/MEDCoupling/MEDCouplingStructuredMesh.hxx index 90861fc99..0729d59e1 100644 --- a/src/MEDCoupling/MEDCouplingStructuredMesh.hxx +++ b/src/MEDCoupling/MEDCouplingStructuredMesh.hxx @@ -59,7 +59,11 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh *build1SGTSubLevelMesh() const; MEDCOUPLING_EXPORT int getCellIdFromPos(int i, int j, int k) const; MEDCOUPLING_EXPORT int getNodeIdFromPos(int i, int j, int k) const; + MEDCOUPLING_EXPORT int getNumberOfCells() const; + MEDCOUPLING_EXPORT int getNumberOfNodes() const; + MEDCOUPLING_EXPORT int getMeshDimension() const; MEDCOUPLING_EXPORT int getNumberOfCellsOfSubLevelMesh() const; + MEDCOUPLING_EXPORT int getSpaceDimensionOnNodeStruct() const; MEDCOUPLING_EXPORT virtual void getNodeGridStructure(int *res) const = 0; MEDCOUPLING_EXPORT virtual void getSplitCellValues(int *res) const = 0; MEDCOUPLING_EXPORT virtual void getSplitNodeValues(int *res) const = 0; @@ -80,6 +84,8 @@ namespace ParaMEDMEM static DataArrayInt *Build1GTNodalConnectivity3D(const int *nodeStBg); static DataArrayInt *Build1GTNodalConnectivityOfSubLevelMesh2D(const int *nodeStBg); static DataArrayInt *Build1GTNodalConnectivityOfSubLevelMesh3D(const int *nodeStBg); + protected: + static int ZipNodeStructure(const int *nodeStBg, const int *nodeStEnd, int zipNodeSt[3]); protected: MEDCOUPLING_EXPORT MEDCouplingStructuredMesh(); MEDCOUPLING_EXPORT MEDCouplingStructuredMesh(const MEDCouplingStructuredMesh& other, bool deepCpy); diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index c01733cb5..e6d186e9b 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -11220,6 +11220,10 @@ class MEDCouplingBasicsTest(unittest.TestCase): cl.checkCoherency2() li4=[sqrt(2.)*elt for elt in [1.,3.,5.,7.]] li4_1=[0.5,0.5,2.5,2.5,6.5,6.5,12.5,12.5] + self.assertEqual(2,cl.getSpaceDimension()) + self.assertEqual(1,cl.getMeshDimension()) + self.assertEqual(4,cl.getNumberOfCells()) + self.assertEqual(5,cl.getNumberOfNodes()) self.assertTrue(cl.getMeasureField(False).getArray().isEqual(DataArrayDouble(li4),1e-14)) self.assertTrue(cl.buildUnstructured().getMeasureField(False).getArray().isEqual(DataArrayDouble(li4),1e-14)) self.assertTrue(cl.getBarycenterAndOwner().isEqual(DataArrayDouble(li4_1,4,2),1e-14)) @@ -14610,6 +14614,101 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(m.getBoundingBoxForBBTree().isEqual(DataArrayDouble([-0.5,0.5,-0.5,0.5,-0.5,0.5,-0.5,-0.31819805153394637],2,4),1e-12)) pass + def testSwig2CartBuildUnstructuredOnExoticCases1(self): + """ Test focusing on traduction from cartesian to unstructured mesh when spaceDim greater than meshDim. + """ + # + m=MEDCouplingCMesh() + arrX=DataArrayDouble(3) ; arrX.iota() + arrY=DataArrayDouble(4) ; arrY.iota() + arrZ=DataArrayDouble(1) ; arrZ.iota() + m.setCoords(arrX,arrY,arrZ) + self.assertEqual(2,m.getMeshDimension()) + self.assertEqual(3,m.getSpaceDimension()) + mu=m.buildUnstructured() + self.assertTrue(mu.getNodalConnectivity().isEqual(DataArrayInt([4,1,0,3,4,4,2,1,4,5,4,4,3,6,7,4,5,4,7,8,4,7,6,9,10,4,8,7,10,11]))) + self.assertTrue(mu.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,10,15,20,25,30]))) + coo0=DataArrayDouble([(0,0,0),(1,0,0),(2,0,0),(0,1,0),(1,1,0),(2,1,0),(0,2,0),(1,2,0),(2,2,0),(0,3,0),(1,3,0),(2,3,0)]) + self.assertTrue(mu.getCoords().isEqual(coo0,1e-12)) + mu.writeVTK("tutu.vtu") + # + m=MEDCouplingCMesh() + arrX=DataArrayDouble(3) ; arrX.iota() + arrY=DataArrayDouble(1) ; arrY.iota() + arrZ=DataArrayDouble(4) ; arrZ.iota() + m.setCoords(arrX,arrY,arrZ) + self.assertEqual(2,m.getMeshDimension()) + self.assertEqual(3,m.getSpaceDimension()) + mu=m.buildUnstructured() + self.assertTrue(mu.getNodalConnectivity().isEqual(DataArrayInt([4,1,0,3,4,4,2,1,4,5,4,4,3,6,7,4,5,4,7,8,4,7,6,9,10,4,8,7,10,11]))) + self.assertTrue(mu.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,10,15,20,25,30]))) + coo1=DataArrayDouble([(0,0,0),(1,0,0),(2,0,0),(0,0,1),(1,0,1),(2,0,1),(0,0,2),(1,0,2),(2,0,2),(0,0,3),(1,0,3),(2,0,3)]) + self.assertTrue(mu.getCoords().isEqual(coo1,1e-12)) + # + m=MEDCouplingCMesh() + arrX=DataArrayDouble(1) ; arrX.iota() ; arrX+=9 + arrY=DataArrayDouble(3) ; arrY.iota() + arrZ=DataArrayDouble(4) ; arrZ.iota() + m.setCoords(arrX,arrY,arrZ) + self.assertEqual(2,m.getMeshDimension()) + self.assertEqual(3,m.getSpaceDimension()) + mu=m.buildUnstructured() + self.assertTrue(mu.getNodalConnectivity().isEqual(DataArrayInt([4,1,0,3,4,4,2,1,4,5,4,4,3,6,7,4,5,4,7,8,4,7,6,9,10,4,8,7,10,11]))) + self.assertTrue(mu.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,10,15,20,25,30]))) + coo2=DataArrayDouble([(9,0,0),(9,1,0),(9,2,0),(9,0,1),(9,1,1),(9,2,1),(9,0,2),(9,1,2),(9,2,2),(9,0,3),(9,1,3),(9,2,3)]) + self.assertTrue(mu.getCoords().isEqual(coo2,1e-12)) + # + m=MEDCouplingCMesh() + arrX=DataArrayDouble(3) ; arrX.iota() + arrY=DataArrayDouble(1) ; arrY.iota(7) + arrZ=DataArrayDouble(1) ; arrZ.iota(8) + m.setCoords(arrX,arrY,arrZ) + self.assertEqual(1,m.getMeshDimension()) + self.assertEqual(3,m.getSpaceDimension()) + mu=m.buildUnstructured() + self.assertTrue(mu.getNodalConnectivity().isEqual(DataArrayInt([1,0,1,1,1,2]))) + self.assertTrue(mu.getNodalConnectivityIndex().isEqual(DataArrayInt([0,3,6]))) + coo3=DataArrayDouble([(0,7,8),(1,7,8),(2,7,8)]) + self.assertTrue(mu.getCoords().isEqual(coo3,1e-12)) + # + m=MEDCouplingCMesh() + arrX=DataArrayDouble(1) ; arrX.iota(7) + arrY=DataArrayDouble(1) ; arrY.iota(8) + arrZ=DataArrayDouble(3) ; arrZ.iota() + m.setCoords(arrX,arrY,arrZ) + self.assertEqual(1,m.getMeshDimension()) + self.assertEqual(3,m.getSpaceDimension()) + mu=m.buildUnstructured() + self.assertTrue(mu.getNodalConnectivity().isEqual(DataArrayInt([1,0,1,1,1,2]))) + self.assertTrue(mu.getNodalConnectivityIndex().isEqual(DataArrayInt([0,3,6]))) + coo4=DataArrayDouble([(7,8,0),(7,8,1),(7,8,2)]) + self.assertTrue(mu.getCoords().isEqual(coo4,1e-12)) + # + m=MEDCouplingCMesh() + arrX=DataArrayDouble(3) ; arrX.iota() + arrY=DataArrayDouble(1) ; arrY.iota(7) + m.setCoords(arrX,arrY) + self.assertEqual(1,m.getMeshDimension()) + self.assertEqual(2,m.getSpaceDimension()) + mu=m.buildUnstructured() + self.assertTrue(mu.getNodalConnectivity().isEqual(DataArrayInt([1,0,1,1,1,2]))) + self.assertTrue(mu.getNodalConnectivityIndex().isEqual(DataArrayInt([0,3,6]))) + coo5=DataArrayDouble([(0,7),(1,7),(2,7)]) + self.assertTrue(mu.getCoords().isEqual(coo5,1e-12)) + # + m=MEDCouplingCMesh() + arrX=DataArrayDouble(1) ; arrX.iota(7) + arrY=DataArrayDouble(3) ; arrY.iota() + m.setCoords(arrX,arrY) + self.assertEqual(1,m.getMeshDimension()) + self.assertEqual(2,m.getSpaceDimension()) + mu=m.buildUnstructured() + self.assertTrue(mu.getNodalConnectivity().isEqual(DataArrayInt([1,0,1,1,1,2]))) + self.assertTrue(mu.getNodalConnectivityIndex().isEqual(DataArrayInt([0,3,6]))) + coo6=DataArrayDouble([(7,0),(7,1),(7,2)]) + self.assertTrue(mu.getCoords().isEqual(coo6,1e-12)) + pass + def setUp(self): pass pass diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 46c499add..1f6e195b2 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -2735,6 +2735,7 @@ namespace ParaMEDMEM int getCellIdFromPos(int i, int j, int k) const throw(INTERP_KERNEL::Exception); int getNodeIdFromPos(int i, int j, int k) const throw(INTERP_KERNEL::Exception); int getNumberOfCellsOfSubLevelMesh() const throw(INTERP_KERNEL::Exception); + int getSpaceDimensionOnNodeStruct() const throw(INTERP_KERNEL::Exception); virtual std::vector getNodeGridStructure() const throw(INTERP_KERNEL::Exception); std::vector getCellGridStructure() const throw(INTERP_KERNEL::Exception); MEDCoupling1SGTUMesh *build1SGTUnstructured() const throw(INTERP_KERNEL::Exception); diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 52621541b..7a53ab79b 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -3001,17 +3001,17 @@ namespace ParaMEDMEM { PyObject *buildVTUArrays() const throw(INTERP_KERNEL::Exception) { - bool isInternal; + bool isInternal; std::vector< DataArrayDouble * > objs(self->buildVTUArrays(isInternal)); std::size_t sz(objs.size()); - PyObject *ret(PyTuple_New(2)); + PyObject *ret(PyTuple_New(2)); PyObject *ret0=PyList_New(sz); for(std::size_t i=0;i ret1; - bool ret2; + bool ret2; self->buildVTUArrays(ret0,ret1,ret2); std::size_t sz(ret1.size()); PyObject *ret=PyTuple_New(3); @@ -3037,9 +3037,9 @@ namespace ParaMEDMEM for(std::size_t i=0;i