]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Start debugging 3D interpolation error on OCTA12 in target mesh
authorageay <ageay>
Fri, 2 Aug 2013 16:12:42 +0000 (16:12 +0000)
committerageay <ageay>
Fri, 2 Aug 2013 16:12:42 +0000 (16:12 +0000)
src/MEDCoupling/MEDCouplingMemArray.cxx
src/MEDCoupling/MEDCouplingUMesh.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py
src/MEDCoupling_Swig/MEDCouplingCommon.i
src/MEDCoupling_Swig/MEDCouplingMemArray.i

index abd9d18d5fabd758cd869fb9b63eec2bd5d97875..adc2f0b1c71587f8f95a602d4745d155b940e6ee 100644 (file)
@@ -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)
index 3634dfe7d75a10cfbc335c6892716bff8a40f9e0..9c66c9c1b83486f142d741c8bfc81357a875728a 100644 (file)
@@ -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<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(nbOfCells,1);
   int *retPt(ret->getPointer());
-  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newConn(DataArrayInt::New()),newConnI(DataArrayInt::New()); newConnI->alloc(1,0); newConnI->setIJ(0,0,0);
-  MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> addPts(DataArrayDouble::New()); addPts->alloc(0,0);
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newConn(DataArrayInt::New()),newConnI(DataArrayInt::New()); newConn->alloc(0,1); newConnI->alloc(1,1); newConnI->setIJ(0,0,0);
+  MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> 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();
index dae92e8fecd16fcf7fd45ce55a0262ca78c363ba..6c16f16957dd7fff68704e1dd5488ea062b6751c 100644 (file)
@@ -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
index e7359c4d92e519b5f7866464e2ea56723db9d322..3e28a515c6c2d929f5878b6a4fab49d84a99503b 100644 (file)
@@ -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)
       {
index aabcd6a1bf7f2a3ca3cddc33a0ad510f42b84318..b86a95d2febd6b0c0478670389c104ff004cf748 100644 (file)
@@ -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<PySliceObject *>(slic);
+        if(PySlice_GetIndices(sly,std::numeric_limits<int>::max(),&strt,&stp,&step)!=0)
+          throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !");
+        if(strt==std::numeric_limits<int>::max() || stp==std::numeric_limits<int>::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)
       {