return ( x0 < x1 ) ? ( x1 - x0 ) : 0.;
}
+ template<class MyMeshType>
+ class DummyMyMeshType1D
+ {
+ public:
+ static const int MY_SPACEDIM=1;
+ static const int MY_MESHDIM=8;
+ typedef mcIdType MyConnType;
+ static const INTERP_KERNEL::NumberingPolicy My_numPol=MyMeshType::My_numPol;
+ // begin
+ // useless, but for windows compilation ...
+ const double *getCoordinatesPtr() const { return nullptr; }
+ const MyConnType *getConnectivityPtr() const { return nullptr; }
+ const MyConnType *getConnectivityIndexPtr() const { return nullptr; }
+ INTERP_KERNEL::NormalizedCellType getTypeOfElement(MyConnType) const { return (INTERP_KERNEL::NormalizedCellType)0; }
+ // end
+ };
+
/*!
* This method determines if a target point ( \a coordsT ) is in source seg2 contained in \a coordsS. To do so _precision attribute is used.
* If target point is in, \a xs0, \a xs1 and \a xt are set to 1D referential for a further barycentric computation.
if(!projectionThis(coordsT,coordsS,xs0,xs1,xt))
return false;
constexpr ConnType TAB[2]={0,1};
- return PointLocatorAlgos<MyMeshType>::isElementContainsPoint(coordsT,NORM_SEG2,coordsS,TAB,2,this->_precision);
+ const double coordsS_1D[2]={xs0,xs1};
+ const double *coordsT_1D(&xt);
+ return PointLocatorAlgos<DummyMyMeshType1D<MyMeshType>>::isElementContainsPoint(coordsT_1D,NORM_SEG2,coordsS_1D,TAB,2,this->_precision);
}
/*!
rem.setIntersectionType(PointLocator)
self.assertEqual(rem.prepare(mS.buildUnstructured(),mT.buildUnstructured(),"P1P1"),1)
m=rem.getCrudeCSRMatrix()
- print(rem.getCrudeMatrix())
rowSum=m.sum(axis=1)
m=diags(array(1/rowSum.transpose()),[0])*m
# expected matrix
rem.setIntersectionType(PointLocator)
self.assertEqual(rem.prepare(mS,mT,"P1P1"),1)
m=rem.getCrudeCSRMatrix()
- print(rem.getCrudeMatrix())
rowSum=m.sum(axis=1)
m=diags(array(1/rowSum.transpose()),[0])*m
diff=abs(m-mExp0)
ref=float(m.getMeasureField(True).getArray())
self.assertTrue(abs(res-ref)/ref<1e-12)
pass
-
+
def test3D0DPointLocator(self):
"""
For pointlocator fans, Remapper support following intersection
src.insertNextCell(NORM_SEG2,[0,2])
src.insertNextCell(NORM_SEG2,[2,3])
src.insertNextCell(NORM_SEG2,[3,1])
- trg = MEDCouplingUMesh.Build0DMeshFromCoords( DataArrayDouble([0.4,2.3-1e-13,4.,7.]) )
+ for eps in [0,1e-13,-1e-13]:
+ trg = MEDCouplingUMesh.Build0DMeshFromCoords( DataArrayDouble([0.4,2.3+eps,4.,7.]) )
+ rem=MEDCouplingRemapper()
+ rem.setIntersectionType(PointLocator)
+ rem.prepare(src,trg,"P1P1")
+ rem.nullifiedTinyCoeffInCrudeMatrixAbs(1e-12)
+ self.checkMatrix(rem.getCrudeMatrix(),[{}, {2: 2.0}, {2: 0.4516129032258065, 3: 0.5483870967741935}, {1: 0.7272727272727273, 3: 0.27272727272727265}],src.getNumberOfNodes(),1e-12)
+ # P1P1 - 5 - descending order of coords in source mesh
+ src = MEDCouplingUMesh("src",1)
+ src.allocateCells()
+ src.setCoords( DataArrayDouble([3.,1.]) )
+ src.insertNextCell(NORM_SEG2,[0,1])
+ trg = MEDCouplingUMesh.Build0DMeshFromCoords( DataArrayDouble([2.3]) )
rem=MEDCouplingRemapper()
rem.setIntersectionType(PointLocator)
rem.prepare(src,trg,"P1P1")
- rem.nullifiedTinyCoeffInCrudeMatrixAbs(1e-12)
- self.checkMatrix(rem.getCrudeMatrix(),[{}, {2: 2.0}, {2: 0.4516129032258065, 3: 0.5483870967741935}, {1: 0.7272727272727273, 3: 0.27272727272727265}],src.getNumberOfNodes(),1e-12)
+ self.checkMatrix(rem.getCrudeMatrix(),[{0:0.65,1:0.35}],src.getNumberOfNodes(),1e-12)
pass
def checkMatrix(self,mat1,mat2,nbCols,eps):