X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingRemapper.cxx;h=808a25e03b01bd5f11e8f6fb10d8e48210df8634;hb=e7835cba1eb17f50ef4e130c2cb8d0f54bc25083;hp=a8c8dae00f8f1bc2185533ea2b5cec8df3eddf11;hpb=79386ac5c73f8365c428b8ef595c4ef004959667;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingRemapper.cxx b/src/MEDCoupling/MEDCouplingRemapper.cxx index a8c8dae00..808a25e03 100644 --- a/src/MEDCoupling/MEDCouplingRemapper.cxx +++ b/src/MEDCoupling/MEDCouplingRemapper.cxx @@ -35,6 +35,8 @@ #include "Interpolation3DSurf.hxx" #include "Interpolation2D1D.txx" #include "Interpolation2D3D.txx" +#include "Interpolation3D1D.txx" +#include "Interpolation1D0D.txx" #include "InterpolationCU.txx" #include "InterpolationCC.txx" @@ -310,14 +312,14 @@ bool MEDCouplingRemapper::setOptionString(const std::string& key, const std::str } /*! - * This method returns the interpolation matrix policy. This policy specifies which interpolation matrix method to keep or prefered. + * This method returns the interpolation matrix policy. This policy specifies which interpolation matrix method to keep or preferred. * If interpolation matrix policy is : * - * - set to IK_ONLY_PREFERED (0) (the default) : the INTERP_KERNEL only method is prefered. That is to say, if it is possible to treat the case + * - set to IK_ONLY_PREFERED (0) (the default) : the INTERP_KERNEL only method is preferred. That is to say, if it is possible to treat the case * regarding spatial discretization of source and target with INTERP_KERNEL only method, INTERP_KERNEL only method will be performed. * If not, the \b not only INTERP_KERNEL method will be attempt. * - * - set to NOT_IK_ONLY_PREFERED (1) : the \b NOT only INTERP_KERNEL method is prefered. That is to say, if it is possible to treat the case + * - set to NOT_IK_ONLY_PREFERED (1) : the \b NOT only INTERP_KERNEL method is preferred. That is to say, if it is possible to treat the case * regarding spatial discretization of source and target with \b NOT only INTERP_KERNEL method, \b NOT only INTERP_KERNEL method, will be performed. * If not, the INTERP_KERNEL only method will be attempt. * @@ -339,11 +341,11 @@ int MEDCouplingRemapper::getInterpolationMatrixPolicy() const * * If interpolation matrix policy is : * - * - set to IK_ONLY_PREFERED (0) (the default) : the INTERP_KERNEL only method is prefered. That is to say, if it is possible to treat the case + * - set to IK_ONLY_PREFERED (0) (the default) : the INTERP_KERNEL only method is preferred. That is to say, if it is possible to treat the case * regarding spatial discretization of source and target with INTERP_KERNEL only method, INTERP_KERNEL only method will be performed. * If not, the \b not only INTERP_KERNEL method will be attempt. * - * - set to NOT_IK_ONLY_PREFERED (1) : the \b NOT only INTERP_KERNEL method is prefered. That is to say, if it is possible to treat the case + * - set to NOT_IK_ONLY_PREFERED (1) : the \b NOT only INTERP_KERNEL method is preferred. That is to say, if it is possible to treat the case * regarding spatial discretization of source and target with \b NOT only INTERP_KERNEL method, \b NOT only INTERP_KERNEL method, will be performed. * If not, the INTERP_KERNEL only method will be attempt. * @@ -436,7 +438,16 @@ int MEDCouplingRemapper::prepareInterpKernelOnlyUU() throw INTERP_KERNEL::Exception("Invalid interpolation requested between 3D and 1D ! Select PointLocator as intersection type !"); MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh); MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh); - INTERP_KERNEL::Interpolation3D interpolation(*this); + INTERP_KERNEL::Interpolation3D1D interpolation(*this); + nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method); + } + else if(srcMeshDim==1 && trgMeshDim==0 && srcSpaceDim==3) + { + if(getIntersectionType()!=INTERP_KERNEL::PointLocator) + throw INTERP_KERNEL::Exception("Invalid interpolation requested between 1D and 0D into 3D space ! Select PointLocator as intersection type !"); + MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh); + MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh); + INTERP_KERNEL::Interpolation1D0D interpolation(*this); nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method); } else if(srcMeshDim==1 && trgMeshDim==3 && srcSpaceDim==3) @@ -445,7 +456,7 @@ int MEDCouplingRemapper::prepareInterpKernelOnlyUU() throw INTERP_KERNEL::Exception("Invalid interpolation requested between 3D and 1D ! Select PointLocator as intersection type !"); MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh); MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh); - INTERP_KERNEL::Interpolation3D interpolation(*this); + INTERP_KERNEL::Interpolation3D1D interpolation(*this); std::vector > matrixTmp; std::string revMethod(BuildMethodFrom(trgMeth,srcMeth)); nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,revMethod); @@ -506,7 +517,7 @@ int MEDCouplingRemapper::prepareInterpKernelOnlyUU() INTERP_KERNEL::Interpolation2D1D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces(); if(!duplicateFaces.empty()) { - std::ostringstream oss; oss << "An unexpected situation happend ! For the following 1D Cells are part of edges shared by 2D cells :\n"; + std::ostringstream oss; oss << "An unexpected situation happened ! For the following 1D Cells are part of edges shared by 2D cells :\n"; for(std::map >::const_iterator it=duplicateFaces.begin();it!=duplicateFaces.end();it++) { oss << "1D Cell #" << (*it).first << " is part of common edge of following 2D cells ids : "; @@ -525,7 +536,7 @@ int MEDCouplingRemapper::prepareInterpKernelOnlyUU() INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces(); if(!duplicateFaces.empty()) { - std::ostringstream oss; oss << "An unexpected situation happend ! For the following 2D Cells are part of edges shared by 3D cells :\n"; + std::ostringstream oss; oss << "An unexpected situation happened ! For the following 2D Cells are part of edges shared by 3D cells :\n"; for(std::map >::const_iterator it=duplicateFaces.begin();it!=duplicateFaces.end();it++) { oss << "2D Cell #" << (*it).first << " is part of common face of following 3D cells ids : "; @@ -536,23 +547,33 @@ int MEDCouplingRemapper::prepareInterpKernelOnlyUU() } else if(srcMeshDim==3 && trgMeshDim==2 && srcSpaceDim==3) { - MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh); - MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh); - INTERP_KERNEL::Interpolation2D3D interpolation(*this); - std::vector > matrixTmp; - 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::Interpolation2D3D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces(); - if(!duplicateFaces.empty()) + if(getIntersectionType()==INTERP_KERNEL::PointLocator) { - std::ostringstream oss; oss << "An unexpected situation happend ! For the following 2D Cells are part of edges shared by 3D cells :\n"; - for(std::map >::const_iterator it=duplicateFaces.begin();it!=duplicateFaces.end();it++) + MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh); + MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh); + INTERP_KERNEL::Interpolation3D interpolation(*this); + nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method); + } + else + { + MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh); + MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh); + INTERP_KERNEL::Interpolation2D3D interpolation(*this); + std::vector > matrixTmp; + 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::Interpolation2D3D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces(); + if(!duplicateFaces.empty()) { - oss << "2D Cell #" << (*it).first << " is part of common face of following 3D cells ids : "; - std::copy((*it).second.begin(),(*it).second.end(),std::ostream_iterator(oss," ")); - oss << std::endl; + std::ostringstream oss; oss << "An unexpected situation happened ! For the following 2D Cells are part of edges shared by 3D cells :\n"; + for(std::map >::const_iterator it=duplicateFaces.begin();it!=duplicateFaces.end();it++) + { + oss << "2D Cell #" << (*it).first << " is part of common face of following 3D cells ids : "; + std::copy((*it).second.begin(),(*it).second.end(),std::ostream_iterator(oss," ")); + oss << std::endl; + } } } } @@ -620,9 +641,11 @@ int MEDCouplingRemapper::prepareInterpKernelOnlyEE() const MEDCouplingMappedExtrudedMesh *target_mesh=static_cast(_target_ft->getMesh()); if(methC!="P0P0") throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareInterpKernelOnlyEE : Only P0P0 method implemented for Extruded/Extruded meshes !"); - MEDCouplingNormalizedUnstructuredMesh<3,2> source_mesh_wrapper(src_mesh->getMesh2D()); - MEDCouplingNormalizedUnstructuredMesh<3,2> target_mesh_wrapper(target_mesh->getMesh2D()); - INTERP_KERNEL::Interpolation3DSurf interpolation2D(*this); + MCAuto src2D(src_mesh->getMesh2D()->clone(false)); src2D->changeSpaceDimension(2,0.); + MCAuto trg2D(target_mesh->getMesh2D()->clone(false)); trg2D->changeSpaceDimension(2,0.); + MEDCouplingNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(src2D); + MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(trg2D); + INTERP_KERNEL::Interpolation2D interpolation2D(*this); std::vector > matrix2D; int nbCols2D=interpolation2D.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,matrix2D,methC); MEDCouplingUMesh *s1D,*t1D; @@ -632,6 +655,8 @@ int MEDCouplingRemapper::prepareInterpKernelOnlyEE() MEDCouplingNormalizedUnstructuredMesh<1,1> t1DWrapper(t1D); std::vector > matrix1D; INTERP_KERNEL::Interpolation1D interpolation1D(*this); + if(interpolation1D.getIntersectionType()==INTERP_KERNEL::Geometric2D)// For intersection type of 1D, Geometric2D do not deal with it ! -> make interpolation1D not inherite from this + interpolation1D.setIntersectionType(INTERP_KERNEL::Triangulation);// int nbCols1D=interpolation1D.interpolateMeshes(s1DWrapper,t1DWrapper,matrix1D,methC); s1D->decrRef(); t1D->decrRef(); @@ -936,7 +961,7 @@ void MEDCouplingRemapper::checkPrepare() const /*! * This method builds a code considering already set field discretization int \a this : \a _src_ft and \a _target_ft. - * This method returns 3 informations (2 in ouput parameters and 1 in return). + * This method returns 3 information (2 in output parameters and 1 in return). * * \param [out] srcMeth the string code of the discretization of source field template * \param [out] trgMeth the string code of the discretization of target field template