const MEDCouplingPointSet *src_mesh=static_cast<const MEDCouplingPointSet *>(_src_ft->getMesh());
const MEDCouplingPointSet *target_mesh=static_cast<const MEDCouplingPointSet *>(_target_ft->getMesh());
std::string srcMeth,trgMeth;
- std::string method=checkAndGiveInterpolationMethodStr(srcMeth,trgMeth);
+ std::string method(checkAndGiveInterpolationMethodStr(srcMeth,trgMeth));
const int srcMeshDim=src_mesh->getMeshDimension();
int srcSpaceDim=-1;
if(srcMeshDim!=-1)
MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation3D interpolation(*this);
std::vector<std::map<int,double> > matrixTmp;
- nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method);
+ std::string revMethod(BuildMethodFrom(trgMeth,srcMeth));
+ nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,revMethod);
ReverseMatrix(matrixTmp,nbCols,_matrix);
nbCols=matrixTmp.size();
}
MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation2D1D interpolation(*this);
std::vector<std::map<int,double> > matrixTmp;
- nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method);
+ std::string revMethod(BuildMethodFrom(trgMeth,srcMeth));
+ nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,revMethod);
ReverseMatrix(matrixTmp,nbCols,_matrix);
nbCols=matrixTmp.size();
INTERP_KERNEL::Interpolation2D1D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces();
MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation2D interpolation(*this);
std::vector<std::map<int,double> > matrixTmp;
- nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method);
+ std::string revMethod(BuildMethodFrom(trgMeth,srcMeth));
+ nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,revMethod);
ReverseMatrix(matrixTmp,nbCols,_matrix);
nbCols=matrixTmp.size();
}
MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation3D2D interpolation(*this);
std::vector<std::map<int,double> > matrixTmp;
- nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method);
+ std::string revMethod(BuildMethodFrom(trgMeth,srcMeth));
+ nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,revMethod);
ReverseMatrix(matrixTmp,nbCols,_matrix);
nbCols=matrixTmp.size();
INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces();
throw INTERP_KERNEL::Exception("MEDCouplingRemapper::checkAndGiveInterpolationMethodStr : it appears that no all field templates have their mesh set !");
srcMeth=_src_ft->getDiscretization()->getRepr();
trgMeth=_target_ft->getDiscretization()->getRepr();
- std::string method(srcMeth); method+=trgMeth;
+ return BuildMethodFrom(srcMeth,trgMeth);
+}
+
+std::string MEDCouplingRemapper::BuildMethodFrom(const std::string& meth1, const std::string& meth2)
+{
+ std::string method(meth1); method+=meth2;
return method;
}
self.assertTrue(cellIdsOfSkin.isEqual(DataArrayInt([1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,19,20,21,23])))
self.assertTrue(cellIdsOfNonConformCells.isEqual(DataArrayInt([0,4,18,22])))
pass
+
+ def test3D1DOnP1P0_1(self):
+ """ This test focused on P1P0 interpolation with a source with meshDim=1 spaceDim=3 and a target with meshDim=3.
+ This test has revealed a bug in remapper. A reverse matrix is computed so a reverse method should be given in input.
+ """
+ target=MEDCouplingCMesh()
+ arrX=DataArrayDouble([0,1]) ; arrY=DataArrayDouble([0,1]) ; arrZ=DataArrayDouble(11) ; arrZ.iota()
+ target.setCoords(arrX,arrY,arrZ)
+ target=target.buildUnstructured() ; target.setName("TargetSecondaire")
+ #
+ sourceCoo=DataArrayDouble([(0.5,0.5,0.1),(0.5,0.5,1.2),(0.5,0.5,1.6),(0.5,0.5,1.8),(0.5,0.5,2.43),(0.5,0.5,2.55),(0.5,0.5,4.1),(0.5,0.5,4.4),(0.5,0.5,4.9),(0.5,0.5,5.1),(0.5,0.5,7.6),(0.5,0.5,7.7),(0.5,0.5,8.2),(0.5,0.5,8.4),(0.5,0.5,8.6),(0.5,0.5,8.8),(0.5,0.5,9.2),(0.5,0.5,9.6),(0.5,0.5,11.5)])
+ source=MEDCoupling1SGTUMesh("SourcePrimaire",NORM_SEG2)
+ source.setCoords(sourceCoo)
+ source.allocateCells()
+ for i in xrange(len(sourceCoo)-1):
+ source.insertNextCell([i,i+1])
+ pass
+ source=source.buildUnstructured()
+ fsource=MEDCouplingFieldDouble(ON_NODES) ; fsource.setName("field")
+ fsource.setMesh(source)
+ arr=DataArrayDouble(len(sourceCoo)) ; arr.iota(0.7) ; arr*=arr
+ fsource.setArray(arr)
+ fsource.setNature(ConservativeVolumic)
+ #
+ rem=MEDCouplingRemapper()
+ rem.setIntersectionType(PointLocator)
+ rem.prepare(source,target,"P1P0")
+ f2Test=rem.transferField(fsource,-27)
+ self.assertEqual(f2Test.getName(),fsource.getName())
+ self.assertEqual(f2Test.getMesh().getHiddenCppPointer(),target.getHiddenCppPointer())
+ expArr=DataArrayDouble([0.49,7.956666666666667,27.29,-27,59.95666666666667,94.09,-27,125.69,202.89,296.09])
+ self.assertTrue(f2Test.getArray().isEqual(expArr,1e-12))
+ f2Test=rem.reverseTransferField(f2Test,-36)
+ self.assertEqual(f2Test.getName(),fsource.getName())
+ self.assertEqual(f2Test.getMesh().getHiddenCppPointer(),source.getHiddenCppPointer())
+ expArr2=DataArrayDouble([0.49,7.956666666666667,7.956666666666667,7.956666666666667,27.29,27.29,59.95666666666667,59.95666666666667,59.95666666666667,94.09,125.69,125.69,202.89,202.89,202.89,202.89,296.09,296.09,-36.])
+ self.assertTrue(f2Test.getArray().isEqual(expArr2,1e-12))
+ pass
def build2DSourceMesh_1(self):
sourceCoords=[-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7]