+int MEDCouplingRemapper::prepareNotInterpKernelOnlyGaussGauss()
+{
+ if(getIntersectionType()!=INTERP_KERNEL::PointLocator)
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareNotInterpKernelOnlyGaussGauss : The intersection type is not supported ! Only PointLocator is supported for Gauss->Gauss interpolation ! Please invoke setIntersectionType(PointLocator) on the MEDCouplingRemapper instance !");
+ MCAuto<DataArrayDouble> trgLoc=_target_ft->getLocalizationOfDiscr();
+ const double *trgLocPtr=trgLoc->begin();
+ int trgSpaceDim=trgLoc->getNumberOfComponents();
+ MCAuto<DataArrayInt> srcOffsetArr=_src_ft->getDiscretization()->getOffsetArr(_src_ft->getMesh());
+ if(trgSpaceDim!=_src_ft->getMesh()->getSpaceDimension())
+ {
+ std::ostringstream oss; oss << "MEDCouplingRemapper::prepareNotInterpKernelOnlyGaussGauss : space dimensions mismatch between source and target !";
+ oss << " Target discretization localization has dimension " << trgSpaceDim << ", whereas the space dimension of source is equal to ";
+ oss << _src_ft->getMesh()->getSpaceDimension() << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ const int *srcOffsetArrPtr=srcOffsetArr->begin();
+ MCAuto<DataArrayDouble> srcLoc=_src_ft->getLocalizationOfDiscr();
+ const double *srcLocPtr=srcLoc->begin();
+ MCAuto<DataArrayInt> eltsArr,eltsIndexArr;
+ int trgNbOfGaussPts=trgLoc->getNumberOfTuples();
+ _matrix.resize(trgNbOfGaussPts);
+ _src_ft->getMesh()->getCellsContainingPointsLinearPartOnlyOnNonDynType(trgLoc->begin(),trgNbOfGaussPts,getPrecision(),eltsArr,eltsIndexArr);
+ const int *elts(eltsArr->begin()),*eltsIndex(eltsIndexArr->begin());
+ MCAuto<DataArrayInt> nbOfSrcCellsShTrgPts(eltsIndexArr->deltaShiftIndex());
+ MCAuto<DataArrayInt> ids0=nbOfSrcCellsShTrgPts->findIdsNotEqual(0);
+ for(const int *trgId=ids0->begin();trgId!=ids0->end();trgId++)
+ {
+ const double *ptTrg=trgLocPtr+trgSpaceDim*(*trgId);
+ int srcCellId=elts[eltsIndex[*trgId]];
+ double dist=std::numeric_limits<double>::max();
+ int srcEntry=-1;
+ for(int srcId=srcOffsetArrPtr[srcCellId];srcId<srcOffsetArrPtr[srcCellId+1];srcId++)
+ {
+ const double *ptSrc=srcLocPtr+trgSpaceDim*srcId;
+ double tmp=0.;
+ for(int i=0;i<trgSpaceDim;i++)
+ tmp+=(ptTrg[i]-ptSrc[i])*(ptTrg[i]-ptSrc[i]);
+ if(tmp<dist)
+ { dist=tmp; srcEntry=srcId; }
+ }
+ _matrix[*trgId][srcEntry]=1.;
+ }
+ if(ids0->getNumberOfTuples()!=trgNbOfGaussPts)
+ {
+ MCAuto<DataArrayInt> orphanTrgIds=nbOfSrcCellsShTrgPts->findIdsEqual(0);
+ MCAuto<DataArrayDouble> orphanTrg=trgLoc->selectByTupleId(orphanTrgIds->begin(),orphanTrgIds->end());
+ MCAuto<DataArrayInt> srcIdPerTrg=srcLoc->findClosestTupleId(orphanTrg);
+ const int *srcIdPerTrgPtr=srcIdPerTrg->begin();
+ for(const int *orphanTrgId=orphanTrgIds->begin();orphanTrgId!=orphanTrgIds->end();orphanTrgId++,srcIdPerTrgPtr++)
+ _matrix[*orphanTrgId][*srcIdPerTrgPtr]=2.;
+ }
+ _deno_multiply.clear();
+ _deno_multiply.resize(_matrix.size());
+ _deno_reverse_multiply.clear();
+ _deno_reverse_multiply.resize(srcLoc->getNumberOfTuples());
+ declareAsNew();
+ return 1;
+}
+
+/*!
+ * This method checks that the input interpolation \a method is managed by not INTERP_KERNEL only methods.
+ * If no an INTERP_KERNEL::Exception will be thrown. If yes, a magic number will be returned to switch in the MEDCouplingRemapper::prepareNotInterpKernelOnly method.
+ */
+int MEDCouplingRemapper::CheckInterpolationMethodManageableByNotOnlyInterpKernel(const std::string& method)
+{
+ if(method=="GAUSSGAUSS")
+ return 0;
+ std::ostringstream oss; oss << "MEDCouplingRemapper::CheckInterpolationMethodManageableByNotOnlyInterpKernel : ";
+ oss << "The method \"" << method << "\" is not manageable by not INTERP_KERNEL only method.";
+ oss << " Not only INTERP_KERNEL methods dealed are : GAUSSGAUSS !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
+/*!
+ * This method determines regarding \c _interp_matrix_pol attribute ( set by MEDCouplingRemapper::setInterpolationMatrixPolicy and by default equal
+ * to IK_ONLY_PREFERED, which method will be applied. If \c true is returned the INTERP_KERNEL only method should be applied to \c false the \b not
+ * only INTERP_KERNEL method should be applied.
+ */
+bool MEDCouplingRemapper::isInterpKernelOnlyOrNotOnly() const
+{
+ std::string srcm,trgm,method;
+ method=checkAndGiveInterpolationMethodStr(srcm,trgm);
+ switch(_interp_matrix_pol)
+ {
+ case IK_ONLY_PREFERED:
+ {
+ try
+ {
+ std::string tmp1,tmp2;
+ INTERP_KERNEL::Interpolation<INTERP_KERNEL::Interpolation3D>::CheckAndSplitInterpolationMethod(method,tmp1,tmp2);
+ return true;
+ }
+ catch(INTERP_KERNEL::Exception& /*e*/)
+ {
+ return false;
+ }
+ }
+ case NOT_IK_ONLY_PREFERED:
+ {
+ try
+ {
+ CheckInterpolationMethodManageableByNotOnlyInterpKernel(method);
+ return false;
+ }
+ catch(INTERP_KERNEL::Exception& /*e*/)
+ {
+ return true;
+ }
+ }
+ case IK_ONLY_FORCED:
+ return true;
+ case NOT_IK_ONLY_FORCED:
+ return false;
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::isInterpKernelOnlyOrNotOnly : internal error ! The interpolation matrix policy is not managed ! Try to change it using MEDCouplingRemapper::setInterpolationMatrixPolicy !");
+ }
+}
+