Salome HOME
scotch6.0.4 needs pthread... Quick and dirty solution to be improved
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingGaussLocalization.cxx
index c1919217cdb75bd1c3d7f1dce05feea63c82d198..e5a5a413c001768ce071bbc6d8253b671f8561c1 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "MEDCouplingGaussLocalization.hxx"
 #include "InterpKernelGaussCoords.hxx"
+#include "MEDCoupling1GTUMesh.hxx"
 #include "MEDCouplingUMesh.hxx"
 #include "CellModel.hxx"
 
@@ -217,21 +218,41 @@ MCAuto<DataArrayDouble> MEDCouplingGaussLocalization::localizePtsInRefCooForEach
   //
   int nbPts(ptsInRefCoo->getNumberOfTuples());
   INTERP_KERNEL::NormalizedCellType typ(getType());
-  int dim(INTERP_KERNEL::CellModel::GetCellModel(typ).getDimension());
+  int dim(INTERP_KERNEL::CellModel::GetCellModel(typ).getDimension()),outDim(mesh->getSpaceDimension());
   MCAuto<DataArrayDouble> ret(DataArrayDouble::New());
-  ret->alloc(nbPts*nbCells,dim);
+  ret->alloc(nbPts*nbCells,outDim);
   double *retPtr(ret->getPointer());
-  if(dim!=ptsInRefCoo->getNumberOfComponents())
+  if(dim!=(int)ptsInRefCoo->getNumberOfComponents())
     throw INTERP_KERNEL::Exception("MEDCouplingGaussLocalization::localizePtsInRefCooForEachCell : number of components of input coo is not equal to dim of element !");
   const std::vector<double>& wg(getWeights());
   INTERP_KERNEL::GaussCoords calculator;
   calculator.addGaussInfo(typ,dim, ptsInRefCoo->begin(),nbPts,&_ref_coord[0],getNumberOfPtsInRefCell());
   //
-  for(int i=0;i<nbCells;i++,retPtr+=nbPts*dim)
-    calculator.calculateCoords(getType(),coords,dim,conn+connI[i]+1,retPtr);
+  for(int 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()!=(int)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<DataArrayInt> conn(DataArrayInt::New());
+  conn->alloc(cm.getNumberOfNodes(),1);
+  conn->iota();
+  ret->setNodalConnectivity(conn);
+  return MCAuto<MEDCouplingUMesh>(ret->buildUnstructured());
+}
+
 /*!
  * This method sets the comp_th component of ptIdInCell_th point coordinate of reference element of type this->_type.
  * @throw if not 0<=ptIdInCell<nbOfNodePerCell or if not 0<=comp<dim