]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
Generalization of unstructured grid supported by the remapper.
authorageay <ageay>
Wed, 7 Aug 2013 07:20:25 +0000 (07:20 +0000)
committerageay <ageay>
Wed, 7 Aug 2013 07:20:25 +0000 (07:20 +0000)
src/MEDCoupling/MEDCoupling1GTUMesh.cxx
src/MEDCoupling/MEDCoupling1GTUMesh.hxx
src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.hxx
src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx
src/MEDCoupling/MEDCouplingPointSet.hxx
src/MEDCoupling/MEDCouplingRemapper.cxx
src/MEDCoupling/MEDCouplingUMeshDesc.cxx
src/MEDCoupling/MEDCouplingUMeshDesc.hxx
src/MEDCoupling_Swig/MEDCouplingCommon.i

index d80bf9374287fa388401739d1c603e4b3f0b222a..d65031154d9ff77b47f49f2c060c6da62d5210a2 100644 (file)
@@ -679,6 +679,11 @@ int MEDCoupling1SGTUMesh::getNumberOfCells() const
   return nbOfTuples/nbOfNodesPerCell;
 }
 
+int MEDCoupling1SGTUMesh::getNumberOfNodesInCell(int cellId) const throw(INTERP_KERNEL::Exception)
+{
+  return getNumberOfNodesPerCell();
+}
+
 int MEDCoupling1SGTUMesh::getNumberOfNodesPerCell() const throw(INTERP_KERNEL::Exception)
 {
   checkNonDynamicGeoType();
@@ -2053,7 +2058,7 @@ DataArrayInt *MEDCoupling1DGTUMesh::computeEffectiveNbOfNodesPerCell() const thr
 
 void MEDCoupling1DGTUMesh::getNodeIdsOfCell(int cellId, std::vector<int>& conn) const
 {
-  int nbOfCells=getNumberOfCells();//performs checks
+  int nbOfCells(getNumberOfCells());//performs checks
   if(cellId>=0 && cellId<nbOfCells)
     {
       int strt=_conn_indx->getIJ(cellId,0),stp=_conn_indx->getIJ(cellId+1,0);
@@ -2065,7 +2070,19 @@ void MEDCoupling1DGTUMesh::getNodeIdsOfCell(int cellId, std::vector<int>& conn)
     }
   else
     {
-      std::ostringstream oss; oss << "MEDCoupling1SGTUMesh::getNodeIdsOfCell : request for cellId #" << cellId << " must be in [0," << nbOfCells << ") !";
+      std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::getNodeIdsOfCell : request for cellId #" << cellId << " must be in [0," << nbOfCells << ") !";
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
+}
+
+int MEDCoupling1DGTUMesh::getNumberOfNodesInCell(int cellId) const throw(INTERP_KERNEL::Exception)
+{
+  int nbOfCells(getNumberOfCells());//performs checks
+  if(cellId>=0 && cellId<nbOfCells)
+    return _conn_indx->getIJ(cellId+1,0)-_conn_indx->getIJ(cellId,0);
+  else
+    {
+      std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::getNumberOfNodesInCell : request for cellId #" << cellId << " must be in [0," << nbOfCells << ") !";
       throw INTERP_KERNEL::Exception(oss.str().c_str());
     }
 }
index a11f3b7700dfbae66d5f0b758717770e50c0d21c..690a2c37e8c26b1edb6e0188aaeb1e7faa5335d3 100644 (file)
@@ -125,6 +125,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT DataArrayInt *getNodeIdsInUse(int& nbrOfNodesInUse) const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void renumberNodesInConn(const int *newNodeNumbersO2N);
     MEDCOUPLING_EXPORT void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, DataArrayInt *&cellIdsKeptArr) const;
+    MEDCOUPLING_EXPORT int getNumberOfNodesInCell(int cellId) const throw(INTERP_KERNEL::Exception);
     // overload of MEDCoupling1GTUMesh
     MEDCOUPLING_EXPORT void checkCoherencyOfConnectivity() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void allocateCells(int nbOfCells=0) throw(INTERP_KERNEL::Exception);
@@ -198,6 +199,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT DataArrayInt *getNodeIdsInUse(int& nbrOfNodesInUse) const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void renumberNodesInConn(const int *newNodeNumbersO2N);
     MEDCOUPLING_EXPORT void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, DataArrayInt *&cellIdsKeptArr) const;
+    MEDCOUPLING_EXPORT int getNumberOfNodesInCell(int cellId) const throw(INTERP_KERNEL::Exception);
     // overload of MEDCoupling1GTUMesh
     MEDCOUPLING_EXPORT void checkCoherencyOfConnectivity() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void allocateCells(int nbOfCells=0) throw(INTERP_KERNEL::Exception);
index 8e8ffb622b482c281b16671aaed500794feed834..7dfd3126cd61c1a787a54d8d92c101093dd5179a 100644 (file)
@@ -25,7 +25,7 @@
 
 namespace ParaMEDMEM
 {
-  class MEDCouplingUMesh;
+  class MEDCouplingPointSet;
 }
 
 template<int SPACEDIM,int MESHDIM>
@@ -37,7 +37,7 @@ public:
   typedef int MyConnType;
   static const INTERP_KERNEL::NumberingPolicy My_numPol=INTERP_KERNEL::ALL_C_MODE;
 public:
-  MEDCouplingNormalizedUnstructuredMesh(const ParaMEDMEM::MEDCouplingUMesh *mesh);
+  MEDCouplingNormalizedUnstructuredMesh(const ParaMEDMEM::MEDCouplingPointSet *mesh);
   void getBoundingBox(double *boundingBox) const;
   INTERP_KERNEL::NormalizedCellType getTypeOfElement(int eltId) const;
   int getNumberOfNodesOfElement(int eltId) const;
@@ -51,7 +51,7 @@ public:
 private:
   void prepare();
 private:
-  const ParaMEDMEM::MEDCouplingUMesh *_mesh;
+  const ParaMEDMEM::MEDCouplingPointSet *_mesh;
   int *_conn_for_interp;
   int *_conn_index_for_interp;
 };
index 95d74e589ad0f580ce83a3f18b3e5e69f4a4854b..eb9d2325de5582a81f0b444a80d15d03b6904e75 100644 (file)
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 // Author : Anthony Geay (CEA/DEN)
+
 #ifndef __MEDCOUPLINGNORMALIZEDUNSTRUCTUREDMESH_TXX__
 #define __MEDCOUPLINGNORMALIZEDUNSTRUCTUREDMESH_TXX__
 
 #include "MEDCouplingNormalizedUnstructuredMesh.hxx"
 
 #include "MEDCouplingUMesh.hxx"
+#include "MEDCoupling1GTUMesh.hxx"
 #include "MEDCouplingMemArray.hxx"
 
 #include <limits>
 
 template<int SPACEDIM,int MESHDIM>
-MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::MEDCouplingNormalizedUnstructuredMesh(const ParaMEDMEM::MEDCouplingUMesh *mesh):_mesh(mesh)
+MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::MEDCouplingNormalizedUnstructuredMesh(const ParaMEDMEM::MEDCouplingPointSet *mesh):_mesh(mesh)
 {
   if(_mesh)
     _mesh->incrRef();
@@ -122,24 +124,53 @@ MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::~MEDCouplingNormalizedU
 template<int SPACEDIM,int MESHDIM>
 void MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::prepare()
 {
-  int nbOfCell=_mesh->getNumberOfCells();
-  int initialConnSize=_mesh->getNodalConnectivity()->getNbOfElems();
-  _conn_for_interp=new int[initialConnSize-nbOfCell];
-  _conn_index_for_interp=new int[nbOfCell+1];
-  _conn_index_for_interp[0]=0;
-  const int *work_conn=_mesh->getNodalConnectivity()->getConstPointer()+1;
-  const int *work_conn_index=_mesh->getNodalConnectivityIndex()->getConstPointer();
-  int *work_conn_for_interp=_conn_for_interp;
-  int *work_conn_index_for_interp=_conn_index_for_interp;
-  for(int i=0;i<nbOfCell;i++)
+  const ParaMEDMEM::MEDCouplingUMesh *m1(dynamic_cast<const ParaMEDMEM::MEDCouplingUMesh *>(_mesh));
+  if(m1)
+    {
+      int nbOfCell=m1->getNumberOfCells();
+      int initialConnSize=m1->getNodalConnectivity()->getNbOfElems();
+      _conn_for_interp=new int[initialConnSize-nbOfCell];
+      _conn_index_for_interp=new int[nbOfCell+1];
+      _conn_index_for_interp[0]=0;
+      const int *work_conn=m1->getNodalConnectivity()->getConstPointer()+1;
+      const int *work_conn_index=m1->getNodalConnectivityIndex()->getConstPointer();
+      int *work_conn_for_interp=_conn_for_interp;
+      int *work_conn_index_for_interp=_conn_index_for_interp;
+      for(int i=0;i<nbOfCell;i++)
+        {
+          int nbOfValsToCopy=work_conn_index[1]-work_conn_index[0]-1;
+          work_conn_for_interp=std::copy(work_conn,work_conn+nbOfValsToCopy,work_conn_for_interp);
+          work_conn_index_for_interp[1]=work_conn_index_for_interp[0]+nbOfValsToCopy;
+          work_conn_index++;
+          work_conn+=nbOfValsToCopy+1;
+          work_conn_index_for_interp++;
+        }
+      return ;
+    }
+  const ParaMEDMEM::MEDCoupling1DGTUMesh *m2(dynamic_cast<const ParaMEDMEM::MEDCoupling1DGTUMesh *>(_mesh));
+  if(m2)
+    {
+      int nbOfCell(m2->getNumberOfCells());
+      _conn_index_for_interp=new int[nbOfCell+1];
+      const int *conni(m2->getNodalConnectivityIndex()->begin());
+      std::copy(conni,conni+nbOfCell+1,_conn_index_for_interp);
+      _conn_for_interp=new int[m2->getNodalConnectivity()->getNumberOfTuples()];
+      std::copy(m2->getNodalConnectivity()->begin(),m2->getNodalConnectivity()->end(),_conn_for_interp);
+      return ;
+    }
+  const ParaMEDMEM::MEDCoupling1SGTUMesh *m3(dynamic_cast<const ParaMEDMEM::MEDCoupling1SGTUMesh *>(_mesh));
+  if(m3)
     {
-      int nbOfValsToCopy=work_conn_index[1]-work_conn_index[0]-1;
-      work_conn_for_interp=std::copy(work_conn,work_conn+nbOfValsToCopy,work_conn_for_interp);
-      work_conn_index_for_interp[1]=work_conn_index_for_interp[0]+nbOfValsToCopy;
-      work_conn_index++;
-      work_conn+=nbOfValsToCopy+1;
-      work_conn_index_for_interp++;
+      int nbOfCell(m3->getNumberOfCells()),nbNodesPerCell(m3->getNumberOfNodesPerCell());
+      _conn_index_for_interp=new int[nbOfCell+1]; _conn_index_for_interp[0]=0;
+      int *work(_conn_index_for_interp);
+      for(int i=0;i<nbOfCell;i++,work++)
+        work[1]=work[0]+nbNodesPerCell;
+      _conn_for_interp=new int[m3->getNodalConnectivity()->getNumberOfTuples()];
+      std::copy(m3->getNodalConnectivity()->begin(),m3->getNodalConnectivity()->end(),_conn_for_interp);
+      return ;
     }
+  throw INTERP_KERNEL::Exception("MEDCouplingNormalizedUnstructuredMesh::prepare : Unrecognized unstructured mesh ! Type must be in MEDCouplingUMesh, MEDCoupling1DGTUMesh, MEDCoupling1SGTUMesh !");
 }
 
 #endif
index b6f5ada5083f2dd41ed73e92d86fe70bb4824791..dae6c4925deadcea33f0773441ec56efaa4e9771 100644 (file)
@@ -116,6 +116,7 @@ namespace ParaMEDMEM
     virtual MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *start, const int *end, bool fullyIn) const = 0;
     virtual DataArrayInt *findBoundaryNodes() const = 0;
     virtual MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const = 0;
+    virtual int getNumberOfNodesInCell(int cellId) const = 0;
     virtual DataArrayInt *getNodeIdsInUse(int& nbrOfNodesInUse) const throw(INTERP_KERNEL::Exception) = 0;
     virtual void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, DataArrayInt *&cellIdsKeptArr) const = 0;
     virtual void renumberNodesInConn(const int *newNodeNumbersO2N) = 0;
index 2843f883107a5ac08cc6226fc4e1eddbb940ff59..2879ada37d4d0f4972567f9e67b67f03c259bdc7 100644 (file)
@@ -82,10 +82,22 @@ int MEDCouplingRemapper::prepareInterpKernelOnly() throw(INTERP_KERNEL::Exceptio
   int meshInterpType=((int)_src_ft->getMesh()->getType()*16)+(int)_target_ft->getMesh()->getType();
   switch(meshInterpType)
     {
+    case 90:
+    case 91:
+    case 165:
+    case 181:
+    case 170:
+    case 171:
+    case 186:
+    case 187:
     case 85://Unstructured-Unstructured
       return prepareInterpKernelOnlyUU();
+    case 167:
+    case 183:
     case 87://Unstructured-Cartesian
       return prepareInterpKernelOnlyUC();
+    case 122:
+    case 123:
     case 117://Cartesian-Unstructured
       return prepareInterpKernelOnlyCU();
     case 119://Cartesian-Cartesian
@@ -289,8 +301,8 @@ void MEDCouplingRemapper::setInterpolationMatrixPolicy(int newInterpMatPol) thro
 
 int MEDCouplingRemapper::prepareInterpKernelOnlyUU() throw(INTERP_KERNEL::Exception)
 {
-  const MEDCouplingUMesh *src_mesh=static_cast<const MEDCouplingUMesh *>(_src_ft->getMesh());
-  const MEDCouplingUMesh *target_mesh=static_cast<const MEDCouplingUMesh *>(_target_ft->getMesh());
+  const MEDCouplingPointSet *src_mesh=static_cast<const MEDCouplingPointSet *>(_src_ft->getMesh());
+  const MEDCouplingPointSet *target_mesh=static_cast<const MEDCouplingPointSet *>(_target_ft->getMesh());
   std::string srcMeth,trgMeth;
   std::string method=checkAndGiveInterpolationMethodStr(srcMeth,trgMeth);
   const int srcMeshDim=src_mesh->getMeshDimension();
index 6f5a9ec2aba651ed46fb6dce4196a4ae75a0187c..4301475f6feff33c36a91f949850d5b1a8aa0936 100644 (file)
@@ -560,3 +560,8 @@ void MEDCouplingUMeshDesc::reprQuickOverview(std::ostream& stream) const throw(I
 {
   stream << "MEDCouplingUMeshDesc C++ instance at " << this << ". Name : \"" << getName() << "\".";
 }
+
+int MEDCouplingUMeshDesc::getNumberOfNodesInCell(int cellId) const throw(INTERP_KERNEL::Exception)
+{
+  throw INTERP_KERNEL::Exception("MEDCouplingUMeshDesc::getNumberOfNodesInCell : not implemented yet !");
+}
index e26b63d4465f77ed33bb8249f95668574ea4424e..71e5e0f7d320046aced68cd3ee72507334473f84 100644 (file)
@@ -57,6 +57,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT DataArrayInt *computeEffectiveNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
     MEDCOUPLING_EXPORT void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
+    MEDCOUPLING_EXPORT int getNumberOfNodesInCell(int cellId) const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT std::string simpleRepr() const;
     MEDCOUPLING_EXPORT std::string advancedRepr() const;
     MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return UNSTRUCTURED_DESC; }
index e39390b981be96c4878d9f9664dd6a5154c1dad6..6f8a20de7e5c1b3ebf4d4932d590732dbadc5b46 100644 (file)
@@ -1150,6 +1150,7 @@ namespace ParaMEDMEM
       virtual void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception);
       static DataArrayDouble *MergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) throw(INTERP_KERNEL::Exception);
       static MEDCouplingPointSet *BuildInstanceFromMeshType(MEDCouplingMeshType type) throw(INTERP_KERNEL::Exception);
+      virtual int getNumberOfNodesInCell(int cellId) const throw(INTERP_KERNEL::Exception);
       virtual MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const throw(INTERP_KERNEL::Exception);
       virtual DataArrayInt *getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps) throw(INTERP_KERNEL::Exception);
       virtual DataArrayInt *zipCoordsTraducer() throw(INTERP_KERNEL::Exception);
@@ -1733,7 +1734,6 @@ namespace ParaMEDMEM
     void setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes=true) throw(INTERP_KERNEL::Exception);
     INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const throw(INTERP_KERNEL::Exception);
     void setPartOfMySelf2(int start, int end, int step, const MEDCouplingUMesh& otherOnSameCoordsThanThis) throw(INTERP_KERNEL::Exception);
-    int getNumberOfNodesInCell(int cellId) const throw(INTERP_KERNEL::Exception);
     int getMeshLength() const throw(INTERP_KERNEL::Exception);
     void computeTypes() throw(INTERP_KERNEL::Exception);
     std::string reprConnectivityOfThis() const throw(INTERP_KERNEL::Exception);