From b9b36f3068648e31f01e59126e0a5de2dc910a39 Mon Sep 17 00:00:00 2001 From: ageay Date: Wed, 31 Oct 2012 10:44:28 +0000 Subject: [PATCH] CU,CU,CC available in remapper. --- src/INTERP_KERNEL/InterpolationCC.hxx | 2 +- src/INTERP_KERNEL/InterpolationCC.txx | 4 + src/MEDCoupling/MEDCouplingRemapper.cxx | 182 ++++++++++++++++++++++-- src/MEDCoupling/MEDCouplingRemapper.hxx | 9 +- 4 files changed, 184 insertions(+), 13 deletions(-) diff --git a/src/INTERP_KERNEL/InterpolationCC.hxx b/src/INTERP_KERNEL/InterpolationCC.hxx index 88bbc00a1..e3c409592 100644 --- a/src/INTERP_KERNEL/InterpolationCC.hxx +++ b/src/INTERP_KERNEL/InterpolationCC.hxx @@ -39,7 +39,7 @@ namespace INTERP_KERNEL // static const NumberingPolicy numPol=MyMeshType::My_numPol; public: InterpolationCC(); - //InterpolationCC(const InterpolationOptions& io); + InterpolationCC(const InterpolationOptions& io); template int interpolateMeshes(const MyMeshType& srcMesh, const MyMeshType& targetMesh, MatrixType& result, const char *method); diff --git a/src/INTERP_KERNEL/InterpolationCC.txx b/src/INTERP_KERNEL/InterpolationCC.txx index da4ec44f1..84a925986 100644 --- a/src/INTERP_KERNEL/InterpolationCC.txx +++ b/src/INTERP_KERNEL/InterpolationCC.txx @@ -40,6 +40,10 @@ namespace INTERP_KERNEL { } + InterpolationCC::InterpolationCC(const InterpolationOptions& io):Interpolation(io) + { + } + //================================================================================ /*! * \brief An 1D intersection result diff --git a/src/MEDCoupling/MEDCouplingRemapper.cxx b/src/MEDCoupling/MEDCouplingRemapper.cxx index 0ef48eec7..f81ea85c3 100644 --- a/src/MEDCoupling/MEDCouplingRemapper.cxx +++ b/src/MEDCoupling/MEDCouplingRemapper.cxx @@ -24,7 +24,9 @@ #include "MEDCouplingFieldTemplate.hxx" #include "MEDCouplingFieldDiscretization.hxx" #include "MEDCouplingExtrudedMesh.hxx" +#include "MEDCouplingCMesh.hxx" #include "MEDCouplingNormalizedUnstructuredMesh.txx" +#include "MEDCouplingNormalizedCartesianMesh.txx" #include "Interpolation1D.txx" #include "Interpolation2DCurve.hxx" @@ -33,6 +35,8 @@ #include "Interpolation3DSurf.hxx" #include "Interpolation2D1D.txx" #include "Interpolation3D2D.txx" +#include "InterpolationCU.txx" +#include "InterpolationCC.txx" using namespace ParaMEDMEM; @@ -55,6 +59,12 @@ int MEDCouplingRemapper::prepare(const MEDCouplingMesh *srcMesh, const MEDCoupli { case 85://Unstructured-Unstructured return prepareUU(method); + case 87://Unstructured-Cartesian + return prepareUC(method); + case 117://Cartesian-Unstructured + return prepareCU(method); + case 119://Cartesian-Cartesian + return prepareCC(method); case 136://Extruded-Extruded return prepareEE(method); default: @@ -232,7 +242,7 @@ int MEDCouplingRemapper::prepareUU(const char *method) throw(INTERP_KERNEL::Exce INTERP_KERNEL::Interpolation3D interpolation(*this); std::vector > matrixTmp; nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method); - reverseMatrix(matrixTmp,nbCols,_matrix); + ReverseMatrix(matrixTmp,nbCols,_matrix); nbCols=matrixTmp.size(); } else if(srcMeshDim==2 && trgMeshDim==1 && srcSpaceDim==2) @@ -251,7 +261,7 @@ int MEDCouplingRemapper::prepareUU(const char *method) throw(INTERP_KERNEL::Exce INTERP_KERNEL::Interpolation2D1D interpolation(*this); std::vector > matrixTmp; nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method); - reverseMatrix(matrixTmp,nbCols,_matrix); + ReverseMatrix(matrixTmp,nbCols,_matrix); nbCols=matrixTmp.size(); INTERP_KERNEL::Interpolation2D1D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces(); if(!duplicateFaces.empty()) @@ -275,7 +285,7 @@ int MEDCouplingRemapper::prepareUU(const char *method) throw(INTERP_KERNEL::Exce INTERP_KERNEL::Interpolation2D interpolation(*this); std::vector > matrixTmp; nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method); - reverseMatrix(matrixTmp,nbCols,_matrix); + ReverseMatrix(matrixTmp,nbCols,_matrix); nbCols=matrixTmp.size(); } else @@ -322,7 +332,7 @@ int MEDCouplingRemapper::prepareUU(const char *method) throw(INTERP_KERNEL::Exce INTERP_KERNEL::Interpolation3D2D interpolation(*this); std::vector > matrixTmp; nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method); - reverseMatrix(matrixTmp,nbCols,_matrix); + ReverseMatrix(matrixTmp,nbCols,_matrix); nbCols=matrixTmp.size(); INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces(); if(!duplicateFaces.empty()) @@ -426,6 +436,160 @@ int MEDCouplingRemapper::prepareEE(const char *method) throw(INTERP_KERNEL::Exce return 1; } +int MEDCouplingRemapper::prepareUC(const char *method) throw(INTERP_KERNEL::Exception) +{ + std::string methodCpp(method); + if(methodCpp!="P0P0") + throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareUC : only P0P0 interpolation supported for the moment !"); + MEDCouplingUMesh *src_mesh=static_cast(_src_mesh); + MEDCouplingCMesh *target_mesh=static_cast(_target_mesh); + const int srcMeshDim=src_mesh->getMeshDimension(); + const int srcSpceDim=src_mesh->getSpaceDimension(); + const int trgMeshDim=target_mesh->getMeshDimension(); + if(srcMeshDim!=srcSpceDim || srcMeshDim!=trgMeshDim) + throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareUC : space dim of src unstructured should be equal to mesh dim of src unstructured and should be equal also equal to trg cartesian dimension !"); + std::vector > res; + switch(srcMeshDim) + { + case 1: + { + MEDCouplingNormalizedCartesianMesh<1> targetWrapper(target_mesh); + MEDCouplingNormalizedUnstructuredMesh<1,1> sourceWrapper(src_mesh); + INTERP_KERNEL::InterpolationCU myInterpolator(*this); + myInterpolator.interpolateMeshes(targetWrapper,sourceWrapper,res,"P0P0"); + break; + } + case 2: + { + MEDCouplingNormalizedCartesianMesh<2> targetWrapper(target_mesh); + MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(src_mesh); + INTERP_KERNEL::InterpolationCU myInterpolator(*this); + myInterpolator.interpolateMeshes(targetWrapper,sourceWrapper,res,"P0P0"); + break; + } + case 3: + { + MEDCouplingNormalizedCartesianMesh<3> targetWrapper(target_mesh); + MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(src_mesh); + INTERP_KERNEL::InterpolationCU myInterpolator(*this); + myInterpolator.interpolateMeshes(targetWrapper,sourceWrapper,res,"P0P0"); + break; + } + default: + throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareUC : only dimension 1 2 or 3 supported !"); + } + ReverseMatrix(res,target_mesh->getNumberOfCells(),_matrix); + nullifiedTinyCoeffInCrudeMatrixAbs(0.); + // + _deno_multiply.clear(); + _deno_multiply.resize(_matrix.size()); + _deno_reverse_multiply.clear(); + _deno_reverse_multiply.resize(src_mesh->getNumberOfCells()); + declareAsNew(); + return 1; +} + +int MEDCouplingRemapper::prepareCU(const char *method) throw(INTERP_KERNEL::Exception) +{ + std::string methodCpp(method); + if(methodCpp!="P0P0") + throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareCU : only P0P0 interpolation supported for the moment !"); + MEDCouplingCMesh *src_mesh=static_cast(_src_mesh); + MEDCouplingUMesh *target_mesh=static_cast(_target_mesh); + const int srcMeshDim=src_mesh->getMeshDimension(); + const int trgMeshDim=target_mesh->getMeshDimension(); + const int trgSpceDim=target_mesh->getSpaceDimension(); + if(trgMeshDim!=trgSpceDim || trgMeshDim!=srcMeshDim) + throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareCU : space dim of target unstructured should be equal to mesh dim of target unstructured and should be equal also equal to source cartesian dimension !"); + switch(srcMeshDim) + { + case 1: + { + MEDCouplingNormalizedCartesianMesh<1> sourceWrapper(src_mesh); + MEDCouplingNormalizedUnstructuredMesh<1,1> targetWrapper(target_mesh); + INTERP_KERNEL::InterpolationCU myInterpolator(*this); + myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,_matrix,"P0P0"); + break; + } + case 2: + { + MEDCouplingNormalizedCartesianMesh<2> sourceWrapper(src_mesh); + MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(target_mesh); + INTERP_KERNEL::InterpolationCU myInterpolator(*this); + myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,_matrix,"P0P0"); + break; + } + case 3: + { + MEDCouplingNormalizedCartesianMesh<3> sourceWrapper(src_mesh); + MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(target_mesh); + INTERP_KERNEL::InterpolationCU myInterpolator(*this); + myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,_matrix,"P0P0"); + break; + } + default: + throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareCU : only dimension 1 2 or 3 supported !"); + } + nullifiedTinyCoeffInCrudeMatrixAbs(0.); + // + _deno_multiply.clear(); + _deno_multiply.resize(_matrix.size()); + _deno_reverse_multiply.clear(); + _deno_reverse_multiply.resize(src_mesh->getNumberOfCells()); + declareAsNew(); + return 1; +} + +int MEDCouplingRemapper::prepareCC(const char *method) throw(INTERP_KERNEL::Exception) +{ + std::string methodCpp(method); + if(methodCpp!="P0P0") + throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareCC : only P0P0 interpolation supported for the moment !"); + MEDCouplingCMesh *src_mesh=static_cast(_src_mesh); + MEDCouplingCMesh *target_mesh=static_cast(_target_mesh); + const int srcMeshDim=src_mesh->getMeshDimension(); + const int trgMeshDim=target_mesh->getMeshDimension(); + if(trgMeshDim!=srcMeshDim) + throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareCC : dim of target cartesian should be equal to dim of source cartesian dimension !"); + switch(srcMeshDim) + { + case 1: + { + MEDCouplingNormalizedCartesianMesh<1> sourceWrapper(src_mesh); + MEDCouplingNormalizedCartesianMesh<1> targetWrapper(target_mesh); + INTERP_KERNEL::InterpolationCC myInterpolator(*this); + myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,_matrix,"P0P0"); + break; + } + case 2: + { + MEDCouplingNormalizedCartesianMesh<2> sourceWrapper(src_mesh); + MEDCouplingNormalizedCartesianMesh<2> targetWrapper(target_mesh); + INTERP_KERNEL::InterpolationCC myInterpolator(*this); + myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,_matrix,"P0P0"); + break; + } + case 3: + { + MEDCouplingNormalizedCartesianMesh<2> sourceWrapper(src_mesh); + MEDCouplingNormalizedCartesianMesh<2> targetWrapper(target_mesh); + INTERP_KERNEL::InterpolationCC myInterpolator(*this); + myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,_matrix,"P0P0"); + break; + } + default: + throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareCC : only dimension 1 2 or 3 supported !"); + } + nullifiedTinyCoeffInCrudeMatrixAbs(0.); + // + _deno_multiply.clear(); + _deno_multiply.resize(_matrix.size()); + _deno_reverse_multiply.clear(); + _deno_reverse_multiply.resize(src_mesh->getNumberOfCells()); + declareAsNew(); + return 1; +} + void MEDCouplingRemapper::updateTime() const { } @@ -494,7 +658,7 @@ void MEDCouplingRemapper::computeDenoFromScratch(NatureOfField nat, const MEDCou { case ConservativeVolumic: { - computeRowSumAndColSum(_matrix,_deno_multiply,_deno_reverse_multiply); + ComputeRowSumAndColSum(_matrix,_deno_multiply,_deno_reverse_multiply); break; } case Integral: @@ -526,7 +690,7 @@ void MEDCouplingRemapper::computeDenoFromScratch(NatureOfField nat, const MEDCou } case IntegralGlobConstraint: { - computeColSumAndRowSum(_matrix,_deno_multiply,_deno_reverse_multiply); + ComputeColSumAndRowSum(_matrix,_deno_multiply,_deno_reverse_multiply); break; } case RevIntegral: @@ -607,7 +771,7 @@ void MEDCouplingRemapper::computeReverseProduct(const double *inputPointer, int std::fill(resPointer+idx*inputNbOfCompo,resPointer+(idx+1)*inputNbOfCompo,dftValue); } -void MEDCouplingRemapper::reverseMatrix(const std::vector >& matIn, int nbColsMatIn, std::vector >& matOut) +void MEDCouplingRemapper::ReverseMatrix(const std::vector >& matIn, int nbColsMatIn, std::vector >& matOut) { matOut.resize(nbColsMatIn); int id=0; @@ -616,7 +780,7 @@ void MEDCouplingRemapper::reverseMatrix(const std::vector > matOut[(*iter2).first][id]=(*iter2).second; } -void MEDCouplingRemapper::computeRowSumAndColSum(const std::vector >& matrixDeno, +void MEDCouplingRemapper::ComputeRowSumAndColSum(const std::vector >& matrixDeno, std::vector >& deno, std::vector >& denoReverse) { std::map values; @@ -640,7 +804,7 @@ void MEDCouplingRemapper::computeRowSumAndColSum(const std::vector >& matrixDeno, +void MEDCouplingRemapper::ComputeColSumAndRowSum(const std::vector >& matrixDeno, std::vector >& deno, std::vector >& denoReverse) { std::map values; diff --git a/src/MEDCoupling/MEDCouplingRemapper.hxx b/src/MEDCoupling/MEDCouplingRemapper.hxx index c2005df8e..41948c2fb 100644 --- a/src/MEDCoupling/MEDCouplingRemapper.hxx +++ b/src/MEDCoupling/MEDCouplingRemapper.hxx @@ -65,6 +65,9 @@ namespace ParaMEDMEM private: int prepareUU(const char *method) throw(INTERP_KERNEL::Exception); int prepareEE(const char *method) throw(INTERP_KERNEL::Exception); + int prepareUC(const char *method) throw(INTERP_KERNEL::Exception); + int prepareCU(const char *method) throw(INTERP_KERNEL::Exception); + int prepareCC(const char *method) throw(INTERP_KERNEL::Exception); void updateTime() const; void releaseData(bool matrixSuppression); void transferUnderground(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField, bool isDftVal, double dftValue) throw(INTERP_KERNEL::Exception); @@ -76,11 +79,11 @@ namespace ParaMEDMEM const std::vector< std::map >& m2D, const int *corrCellIdSrc, int nbOf2DCellsSrc, int nbOf1DCellsSrc, const int *corrCellIdTrg); - static void reverseMatrix(const std::vector >& matIn, int nbColsMatIn, + static void ReverseMatrix(const std::vector >& matIn, int nbColsMatIn, std::vector >& matOut); - static void computeRowSumAndColSum(const std::vector >& matrixDeno, + static void ComputeRowSumAndColSum(const std::vector >& matrixDeno, std::vector >& deno, std::vector >& denoReverse); - static void computeColSumAndRowSum(const std::vector >& matrixDeno, + static void ComputeColSumAndRowSum(const std::vector >& matrixDeno, std::vector >& deno, std::vector >& denoReverse); private: MEDCouplingMesh *_src_mesh; -- 2.39.2