From: ageay Date: Fri, 2 Aug 2013 16:12:42 +0000 (+0000) Subject: Start debugging 3D interpolation error on OCTA12 in target mesh X-Git-Tag: DBugPolyhIntersector~52 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2324c0fb9e26db5e521b6101ee26a27b8d206128;p=modules%2Fmed.git Start debugging 3D interpolation error on OCTA12 in target mesh --- diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index abd9d18d5..adc2f0b1c 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -9629,7 +9629,7 @@ DataArrayInt *DataArrayInt::buildExplicitArrOfSliceOnScaledArr(int bg, int end, { if(!isAllocated()) throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr : not allocated array !"); - if(getNumberOfComponents()==1) + if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr : number of components is expected to be equal to one !"); int nbOfTuples(getNumberOfTuples()); if(nbOfTuples==0) diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 3634dfe7d..9c66c9c1b 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -9310,13 +9310,13 @@ DataArrayInt *MEDCouplingUMesh::simplexize3D(int policy, int& nbOfAdditionalPoin { INTERP_KERNEL::SplittingPolicy pol((INTERP_KERNEL::SplittingPolicy)policy); checkConnectivityFullyDefined(); - if(getMeshDimension()!=3 || getSpaceDimension()) + if(getMeshDimension()!=3 || getSpaceDimension()!=3) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::simplexize3D : only available for mesh with meshdim == 3 and spacedim == 3 !"); int nbOfCells(getNumberOfCells()),nbNodes(getNumberOfNodes()); MEDCouplingAutoRefCountObjectPtr ret(DataArrayInt::New()); ret->alloc(nbOfCells,1); int *retPt(ret->getPointer()); - MEDCouplingAutoRefCountObjectPtr newConn(DataArrayInt::New()),newConnI(DataArrayInt::New()); newConnI->alloc(1,0); newConnI->setIJ(0,0,0); - MEDCouplingAutoRefCountObjectPtr addPts(DataArrayDouble::New()); addPts->alloc(0,0); + MEDCouplingAutoRefCountObjectPtr newConn(DataArrayInt::New()),newConnI(DataArrayInt::New()); newConn->alloc(0,1); newConnI->alloc(1,1); newConnI->setIJ(0,0,0); + MEDCouplingAutoRefCountObjectPtr addPts(DataArrayDouble::New()); addPts->alloc(0,1); const int *oldc(_nodal_connec->begin()); const int *oldci(_nodal_connec_index->begin()); const double *coords(_coords->begin()); @@ -9345,9 +9345,12 @@ DataArrayInt *MEDCouplingUMesh::simplexize3D(int policy, int& nbOfAdditionalPoin if(!addPts->empty()) { addPts->rearrange(3); - addPts->copyStringInfoFrom(*getCoords()); + nbOfAdditionalPoints=addPts->getNumberOfTuples(); + addPts=DataArrayDouble::Aggregate(getCoords(),addPts); setCoords(addPts); } + else + nbOfAdditionalPoints=0; setConnectivity(newConn,newConnI,false); _types.clear(); _types.insert(INTERP_KERNEL::NORM_TETRA4); computeTypes(); diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index dae92e8fe..6c16f1695 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -13589,6 +13589,78 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(m3.getNodalConnectivityIndex().isEqual(DataArrayInt([0,9,18,27,36,45,54,63,72,186,286,330,423]))) pass + def testSwig2Simplexize3D1(self): + d=DataArrayInt([0,3,6,10,14,20]) + d2=d.buildExplicitArrOfSliceOnScaledArr(slice(0,5,2)) + self.assertTrue(d2.isEqual(DataArrayInt([0,0,0, 2,2,2,2, 4,4,4,4,4,4]))) + m=MEDCouplingUMesh("Penta6",3) + m.setCoords(DataArrayDouble([0,0,0,0,1,0,1,0,0,0,0,2,0,1,2,1,0,2],6,3)) ; m.getCoords().setInfoOnComponents(["X","YY","ZZZ"]) + m.allocateCells() + m.insertNextCell(NORM_PENTA6,[1,2,0,4,5,3]) + st=m.getCoords().getHiddenCppPointer() + a,b=m.simplexize3D(PLANAR_FACE_5) + m.checkCoherency2() + self.assertTrue(a.isEqual(DataArrayInt([0,0,0]))) + self.assertEqual(0,b) + self.assertEqual(m.getCoords().getHiddenCppPointer(),st) + self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([14,1,2,0,4,14,4,3,5,0,14,5,0,2,4]))) + self.assertTrue(m.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,10,15]))) + del m + # + m2=MEDCouplingUMesh("octa12",3) + coords=DataArrayDouble([1.,0.,0.,0.5,0.8660254037844386,0.,-0.5,0.8660254037844387,0.,-1.,1.2246467991473532e-16,0.,-0.5,-0.8660254037844384,0.,0.5,-0.866025403784439,0.,1.,0.,2.,0.5,0.8660254037844386,2.,-0.5,0.8660254037844387,2.,-1.,1.2246467991473532e-16,2.,-0.5,-0.8660254037844384,2.,0.5,-0.866025403784439,2.0],12,3) + m2.setCoords(coords) + m2.allocateCells() + m2.insertNextCell(NORM_HEXGP12,[3,2,1,0,5,4,9,8,7,6,11,10]) + a,b=m2.simplexize3D(PLANAR_FACE_5) + m2.checkCoherency2() + self.assertTrue(a.isEqual(DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0]))) + self.assertEqual(0,b) + self.assertEqual(m2.getCoords().getHiddenCppPointer(),coords.getHiddenCppPointer()) + self.assertTrue(m2.getNodalConnectivity().isEqual(DataArrayInt([14,3,2,4,9,14,9,10,8,4,14,8,4,2,9,14,2,5,4,8,14,8,10,11,4,14,11,4,5,8,14,2,1,5,8,14,8,11,7,5,14,7,5,1,8,14,1,0,5,7,14,7,11,6,5,14,6,5,0,7]))) + self.assertTrue(m2.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,10,15,20,25,30,35,40,45,50,55,60]))) + del m2,coords + # + coords=DataArrayDouble([0.,0.,0.,1.,0.,0.,1.,1.,0.,0.,1.,0.,0.,0.,2.,1.,0.,2.,1.,1.,2.,0.,1.,2.],8,3) ; coords.setInfoOnComponents(["X","YY","ZZZ"]) + m3=MEDCouplingUMesh("hexa8",3) + m3.setCoords(coords) + m3.allocateCells(0) + m3.insertNextCell(NORM_HEXA8,[3,2,1,0,7,6,5,4]) + st=m3.getCoords().getHiddenCppPointer() + a,b=m3.simplexize3D(PLANAR_FACE_5) + m3.checkCoherency2() + a.isEqual(DataArrayInt([0,0,0,0,0])) + self.assertEqual(0,b) + self.assertEqual(m3.getCoords().getHiddenCppPointer(),coords.getHiddenCppPointer()) + self.assertTrue(m3.getNodalConnectivity().isEqual(DataArrayInt([14,3,6,2,1,14,3,7,6,4,14,3,0,4,1,14,6,4,5,1,14,3,6,1,4]))) + self.assertTrue(m3.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,10,15,20,25]))) + # + m3=MEDCouplingUMesh("hexa8",3) + m3.setCoords(coords) + m3.allocateCells(0) + m3.insertNextCell(NORM_HEXA8,[3,2,1,0,7,6,5,4]) + st=m3.getCoords().getHiddenCppPointer() + a,b=m3.simplexize3D(PLANAR_FACE_6) + m3.checkCoherency2() + a.isEqual(DataArrayInt([0,0,0,0,0,0])) + self.assertEqual(0,b) + self.assertEqual(m3.getCoords().getHiddenCppPointer(),coords.getHiddenCppPointer()) + self.assertTrue(m3.getNodalConnectivity().isEqual(DataArrayInt([14,3,6,2,5,14,3,2,1,5,14,3,7,6,5,14,3,4,7,5,14,3,1,0,5,14,3,0,4,5]))) + self.assertTrue(m3.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,10,15,20,25,30]))) + # + #m3=MEDCouplingUMesh("hexa8",3) + #m3.setCoords(coords) + #m3.allocateCells(0) + #m3.insertNextCell(NORM_HEXA8,[3,2,1,0,7,6,5,4]) + #st=m3.getCoords().getHiddenCppPointer() + #a,b=m3.simplexize3D(GENERAL_24) + #m3.checkCoherency2() + #a.isEqual(DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])) + #self.assertEqual(7,b) + #self.assertTrue(m3.getCoords().getHiddenCppPointer()!=coords.getHiddenCppPointer()) + #self.assertTrue(m3.getCoords()[:8].isEqual(coords,0)) + pass + def setUp(self): pass pass diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index e7359c4d9..3e28a515c 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -269,6 +269,7 @@ using namespace INTERP_KERNEL; %newobject ParaMEDMEM::DataArrayInt::buildUnique; %newobject ParaMEDMEM::DataArrayInt::deltaShiftIndex; %newobject ParaMEDMEM::DataArrayInt::buildExplicitArrByRanges; +%newobject ParaMEDMEM::DataArrayInt::buildExplicitArrOfSliceOnScaledArr; %newobject ParaMEDMEM::DataArrayInt::findRangeIdForEachTuple; %newobject ParaMEDMEM::DataArrayInt::findIdInRangeForEachTuple; %newobject ParaMEDMEM::DataArrayInt::duplicateEachTupleNTimes; @@ -2020,6 +2021,16 @@ namespace ParaMEDMEM PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); return ret; } + + PyObject *simplexize3D(int policy) throw(INTERP_KERNEL::Exception) + { + int ret1(-1); + DataArrayInt *ret0(self->simplexize3D(policy,ret1)); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,PyInt_FromLong(ret1)); + return ret; + } PyObject *checkButterflyCells(double eps=1e-12) throw(INTERP_KERNEL::Exception) { diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index aabcd6a1b..b86a95d2f 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -2558,6 +2558,19 @@ namespace ParaMEDMEM const int *bg=convertObjToPossibleCpp1_Safe(indexArr,sw,sz,val,val2); return self->accumulatePerChunck(bg,bg+sz); } + + DataArrayInt *buildExplicitArrOfSliceOnScaledArr(PyObject *slic) const throw(INTERP_KERNEL::Exception) + { + if(!PySlice_Check(slic)) + throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : expecting a pyslice as second (first) parameter !"); + Py_ssize_t strt=2,stp=2,step=2; + PySliceObject *sly=reinterpret_cast(slic); + if(PySlice_GetIndices(sly,std::numeric_limits::max(),&strt,&stp,&step)!=0) + throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !"); + if(strt==std::numeric_limits::max() || stp==std::numeric_limits::max()) + throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice contains some unknowns that can't be determined in static method ! Call DataArray::getSlice (non static) instead !"); + return self->buildExplicitArrOfSliceOnScaledArr(strt,stp,step); + } static PyObject *BuildOld2NewArrayFromSurjectiveFormat2(int nbOfOldTuples, PyObject *arr, PyObject *arrI) throw(INTERP_KERNEL::Exception) {