From: ageay Date: Mon, 16 Apr 2012 13:12:53 +0000 (+0000) Subject: imp umesh with mdim=1 getValueOnMulti X-Git-Tag: TRIPOLI_323~66 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5f380c671af0b3ec3332151dcacef35ae8c4348a;p=tools%2Fmedcoupling.git imp umesh with mdim=1 getValueOnMulti --- diff --git a/src/INTERP_KERNEL/InterpolationUtils.hxx b/src/INTERP_KERNEL/InterpolationUtils.hxx index f2486f37b..af7fdfcc9 100644 --- a/src/INTERP_KERNEL/InterpolationUtils.hxx +++ b/src/INTERP_KERNEL/InterpolationUtils.hxx @@ -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 diff --git a/src/INTERP_KERNEL/PointLocatorAlgos.txx b/src/INTERP_KERNEL/PointLocatorAlgos.txx index 7467c3021..d30ea1540 100644 --- a/src/INTERP_KERNEL/PointLocatorAlgos.txx +++ b/src/INTERP_KERNEL/PointLocatorAlgos.txx @@ -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::ind2C(conn_elem[0]))]; + double p2=coords[(OTT::ind2C(conn_elem[1]))]; + double delta=fabs(p1-p2)+eps; + double val=*ptToTest-std::min(p1,p2); + return val>-eps && valgetConstPointer(); + 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] !"); } /*! diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 3dc61d058..d803173fa 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -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