+/*!
+ * Given points in \a ptsInRefCoo in the reference coordinates of \a this (in _ref_coord attribute)
+ * this method computes their coordinates in real world for each cells in \a mesh.
+ * So the returned array will contain nbCells* \a ptsInRefCoo->getNumberOfTuples() tuples and the number of component
+ * will be equal to the dimension of \a this.
+ *
+ * This method ignores Gauss points in \a this and only those in \a ptsInRefCoo are considered here.
+ */
+MCAuto<DataArrayDouble> MEDCouplingGaussLocalization::localizePtsInRefCooForEachCell(const DataArrayDouble *ptsInRefCoo, const MEDCouplingUMesh *mesh) const
+{
+ if(!ptsInRefCoo || !mesh)
+ throw INTERP_KERNEL::Exception("MEDCouplingGaussLocalization::localizePtsInRefCooForEachCell : null pointer !");
+ ptsInRefCoo->checkAllocated();
+ mesh->checkConsistencyLight();
+ //
+ mcIdType nbCells=mesh->getNumberOfCells();
+ const double *coords(mesh->getCoords()->begin());
+ const mcIdType *connI(mesh->getNodalConnectivityIndex()->begin()),*conn(mesh->getNodalConnectivity()->begin());
+ //
+ mcIdType nbPts(ptsInRefCoo->getNumberOfTuples());
+ INTERP_KERNEL::NormalizedCellType typ(getType());
+ int dim(INTERP_KERNEL::CellModel::GetCellModel(typ).getDimension()),outDim(mesh->getSpaceDimension());
+ MCAuto<DataArrayDouble> ret(DataArrayDouble::New());
+ ret->alloc(nbPts*nbCells,outDim);
+ double *retPtr(ret->getPointer());
+ if(dim!=ToIdType(ptsInRefCoo->getNumberOfComponents()))
+ throw INTERP_KERNEL::Exception("MEDCouplingGaussLocalization::localizePtsInRefCooForEachCell : number of components of input coo is not equal to dim of element !");
+ INTERP_KERNEL::GaussCoords calculator;
+ calculator.addGaussInfo(typ,dim, ptsInRefCoo->begin(),nbPts,&_ref_coord[0],getNumberOfPtsInRefCell());
+ //
+ for(mcIdType i=0;i<nbCells;i++,retPtr+=nbPts*outDim)
+ calculator.calculateCoords(getType(),coords,outDim,conn+connI[i]+1,retPtr);
+ return ret;
+}
+
+/*!
+ * This method returns an unstructured mesh that represents the reference cell.
+ */
+MCAuto<MEDCouplingUMesh> MEDCouplingGaussLocalization::buildRefCell() const
+{
+ MCAuto<DataArrayDouble> coo(DataArrayDouble::New());
+ const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getType()));
+ if(getDimension()!=ToIdType(cm.getDimension()))
+ throw INTERP_KERNEL::Exception("BuildRefCell : dimension mistmatch !");
+ coo->alloc(cm.getNumberOfNodes(),getDimension());
+ std::copy(_ref_coord.begin(),_ref_coord.end(),coo->getPointer());
+ MCAuto<MEDCoupling1SGTUMesh> ret(MEDCoupling1SGTUMesh::New("",getType()));
+ ret->setCoords(coo);
+ MCAuto<DataArrayIdType> conn(DataArrayIdType::New());
+ conn->alloc(cm.getNumberOfNodes(),1);
+ conn->iota();
+ ret->setNodalConnectivity(conn);
+ return MCAuto<MEDCouplingUMesh>(ret->buildUnstructured());
+}
+
+/*!
+ * This method returns an array containing for each Gauss Points in \a this, function values relative to the points of the
+ * reference cell. Number of components of returned array is equal to the number of points of the reference cell.
+ */
+MCAuto<DataArrayDouble> MEDCouplingGaussLocalization::getShapeFunctionValues() const
+{
+ MCAuto<DataArrayDouble> ret(DataArrayDouble::New());
+ int nbGaussPt(getNumberOfGaussPt()),nbPtsRefCell(getNumberOfPtsInRefCell()),dim(getDimension());
+ ret->alloc(nbGaussPt,nbPtsRefCell);
+ double *retPtr(ret->getPointer());
+ for(int iGaussPt = 0 ; iGaussPt < nbGaussPt ; ++iGaussPt)
+ {
+ std::vector<double> curGaussPt(_gauss_coord.begin()+iGaussPt*dim,_gauss_coord.begin()+(iGaussPt+1)*dim);
+ INTERP_KERNEL::GaussInfo gi(_type,curGaussPt,1,_ref_coord,nbPtsRefCell);
+ gi.initLocalInfo();
+ const double *funcVal( gi.getFunctionValues(0) );
+ std::copy(funcVal,funcVal+nbPtsRefCell,retPtr);
+ retPtr += nbPtsRefCell;
+ }
+ return ret;
+}
+
+MCAuto<DataArrayDouble> MEDCouplingGaussLocalization::getDerivativeOfShapeFunctionValues() const
+{
+ MCAuto<DataArrayDouble> ret(DataArrayDouble::New());
+ int nbGaussPt(getNumberOfGaussPt()),nbPtsRefCell(getNumberOfPtsInRefCell()),dim(getDimension());
+ ret->alloc(nbGaussPt,nbPtsRefCell*dim);
+ double *retPtr(ret->getPointer());
+ for(int iGaussPt = 0 ; iGaussPt < nbGaussPt ; ++iGaussPt)
+ {
+ std::vector<double> curGaussPt(_gauss_coord.begin()+iGaussPt*dim,_gauss_coord.begin()+(iGaussPt+1)*dim);
+ INTERP_KERNEL::GaussInfo gi(_type,curGaussPt,1,_ref_coord,nbPtsRefCell);
+ gi.initLocalInfo();
+ const double *devOfFuncVal( gi.getDerivativeOfShapeFunctionAt(0) );
+ std::copy(devOfFuncVal,devOfFuncVal+nbPtsRefCell*dim,retPtr);
+ retPtr += nbPtsRefCell*dim;
+ }
+ return ret;
+}
+