]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
imp umesh with mdim=1 getValueOnMulti
authorageay <ageay>
Mon, 16 Apr 2012 13:12:53 +0000 (13:12 +0000)
committerageay <ageay>
Mon, 16 Apr 2012 13:12:53 +0000 (13:12 +0000)
src/INTERP_KERNEL/InterpolationUtils.hxx
src/INTERP_KERNEL/PointLocatorAlgos.txx
src/MEDCoupling/MEDCouplingUMesh.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index f2486f37b858e2dd52e37cc8142d08c8b68dcde1..af7fdfcc93aad5cd681a39820d0be5e55e0f89e2 100644 (file)
@@ -422,6 +422,13 @@ namespace INTERP_KERNEL
     enum { _X, _Y, _Z };
     switch(n.size())
       {
+      case 2:
+        {// SEG 2
+          double delta=n[0][0]-n[1][0];
+          bc[0]=fabs((*p-n[1][0])/delta);
+          bc[1]=fabs((*p-n[0][0])/delta);
+          break;
+        }
       case 3:
         { // TRIA3
           // matrix 2x2
index 7467c302196d07209d32d0aa984891e454d9ef46..d30ea1540f155a46b3e32983f4f41aba4c06fcff 100644 (file)
@@ -188,6 +188,15 @@ namespace INTERP_KERNEL
         {
           return isElementContainsPointAlg3D(ptToTest,conn_elem,conn_elem_sz,coords,cmType,eps);
         }
+
+      if(SPACEDIM==1)
+        {
+          double p1=coords[(OTT<ConnType,numPol>::ind2C(conn_elem[0]))];
+          double p2=coords[(OTT<ConnType,numPol>::ind2C(conn_elem[1]))];
+          double delta=fabs(p1-p2)+eps;
+          double val=*ptToTest-std::min(p1,p2);
+          return val>-eps && val<delta;
+        }
       throw INTERP_KERNEL::Exception("Invalid spacedim detected ! Managed spaceDim are 2 and 3 !");
     }
         
index 4308867fa7b8178bf8b9f97e44f55601ef63e6fb..de605df872f1928086a9ac3d54c65f2ce67bb5fb 100644 (file)
@@ -2903,6 +2903,18 @@ void MEDCouplingUMesh::getCellsContainingPoints(const double *pos, int nbOfPoint
       else
         throw INTERP_KERNEL::Exception("For spaceDim==2 only meshDim==2 implemented for getelementscontainingpoints !");
     }
+  else if(spaceDim==1)
+    {
+      if(mDim==1)
+        {
+          const double *coords=_coords->getConstPointer();
+          getCellsContainingPointsAlg<1>(coords,pos,nbOfPoints,eps,elts,eltsIndex);
+        }
+      else
+        throw INTERP_KERNEL::Exception("For spaceDim==1 only meshDim==1 implemented for getelementscontainingpoints !");
+    }
+  else
+    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getCellsContainingPoints : not managed for mdim not in [1,2,3] !");
 }
 
 /*!
index 3dc61d05845b1d8c47878cd9b0bcb04b25bf4036..d803173fa2b2bbb57f00847660bbfc91aed5f3dc 100644 (file)
@@ -9210,6 +9210,34 @@ class MEDCouplingBasicsTest(unittest.TestCase):
             pass
         #
         pass
+
+    # test on 1D
+    def testGetValueOn3(self):
+        v=[0.,1.,1.5,2.]
+        v2=[0.7,1.25,0.,2.,1.5]
+        disp=[5.,50.,500.,6.,60.,600.,7.,70.,700.,8.,80.,800.]
+        m=MEDCouplingUMesh.New("myMesh",1)
+        nbNodes=len(v)
+        nbCells=nbNodes-1
+        m.allocateCells(nbCells)
+        coords=DataArrayDouble.New() ; coords.setValues(v,nbNodes,1)
+        m.setCoords(coords)
+        m.insertNextCell(NORM_SEG2,2,[0,1])
+        m.insertNextCell(NORM_SEG2,2,[2,1])
+        m.insertNextCell(NORM_SEG2,2,[2,3])
+        m.finishInsertingCells()
+        f=MEDCouplingFieldDouble.New(ON_NODES)
+        f.setMesh(m)
+        array=DataArrayDouble.New(); array.setValues(disp,m.getNumberOfNodes(),3)
+        f.setArray(array)
+        arr1=f.getValueOnMulti(v2)
+        self.assertEqual(5,arr1.getNumberOfTuples());
+        self.assertEqual(3,arr1.getNumberOfComponents());
+        expected1=[5.7,57.,570.,6.5,65.,650.,5.,50.,500.,8.,80.,800.,7.,70.,700.]
+        for i in xrange(15):
+            self.assertAlmostEqual(expected1[i],arr1.getIJ(0,i),14);
+            pass
+        pass
     
     def setUp(self):
         pass