Salome HOME
Fix computation height of isocel triangle with base equal zero : NaN
[tools/medcoupling.git] / src / MEDCoupling_Swig / MEDCouplingCommon.i
index b6d35cfe6820a0c71fb0ff392bc1363d70fea865..1fca14d4b4fcfadffd5abb6d42fa0d2abee28fef 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2020  CEA/DEN, EDF R&D
+// Copyright (C) 2017-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -47,6 +47,7 @@
 #include "MEDCouplingFieldOverTime.hxx"
 #include "MEDCouplingDefinitionTime.hxx"
 #include "MEDCouplingFieldDiscretization.hxx"
+#include "MEDCouplingFieldDiscretizationOnNodesFE.hxx"
 #include "MEDCouplingCartesianAMRMesh.hxx"
 #include "MEDCouplingAMRAttribute.hxx"
 #include "MEDCouplingMatrix.hxx"
@@ -72,7 +73,7 @@ using namespace INTERP_KERNEL;
 typedef int mcIdType;
 typedef DataArrayInt32 DataArrayIdType;
 %template(ivec) std::vector<int>;
-%template(i64vec) std::vector<long>;
+%template(i64vec) std::vector<int64_t>;
 #else
 //typedef std::int64_t mcIdType;
 typedef DataArrayInt64 DataArrayIdType;
@@ -85,7 +86,11 @@ typedef long int mcIdType;
 #endif
 %template(i32vec) std::vector<int>;
 #endif
-
+#ifdef WIN32
+typedef long long mcPyPtrType;
+#else
+typedef long mcPyPtrType;
+#endif
 
 ////////////////////
 %typemap(out) MEDCoupling::MEDCouplingMesh*
@@ -213,6 +218,7 @@ typedef long int mcIdType;
 %feature("autodoc", "1");
 %feature("docstring");
 
+%newobject MEDCoupling::MEDCouplingFieldDiscretizationOnNodesFE::getCooInRefElement;
 %newobject MEDCoupling::MEDCouplingField::buildMeasureField;
 %newobject MEDCoupling::MEDCouplingField::getLocalizationOfDiscr;
 %newobject MEDCoupling::MEDCouplingField::computeTupleIdsToSelectFromCellIds;
@@ -309,6 +315,7 @@ typedef long int mcIdType;
 %newobject MEDCoupling::MEDCouplingMesh::buildPartRange;
 %newobject MEDCoupling::MEDCouplingMesh::giveCellsWithType;
 %newobject MEDCoupling::MEDCouplingMesh::getCoordinatesAndOwner;
+%newobject MEDCoupling::MEDCouplingMesh::computeMeshCenterOfMass;
 %newobject MEDCoupling::MEDCouplingMesh::computeCellCenterOfMass;
 %newobject MEDCoupling::MEDCouplingMesh::computeIsoBarycenterOfNodesPerCell;
 %newobject MEDCoupling::MEDCouplingMesh::buildOrthogonalField;
@@ -364,6 +371,7 @@ typedef long int mcIdType;
 %newobject MEDCoupling::MEDCouplingUMesh::getRenumArrForMEDFileFrmt;
 %newobject MEDCoupling::MEDCouplingUMesh::convertCellArrayPerGeoType;
 %newobject MEDCoupling::MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec;
+%newobject MEDCoupling::MEDCouplingUMesh::findNodesToDuplicate;
 %newobject MEDCoupling::MEDCouplingUMesh::buildDirectionVectorField;
 %newobject MEDCoupling::MEDCouplingUMesh::convertLinearCellsToQuadratic;
 %newobject MEDCoupling::MEDCouplingUMesh::getEdgeRatioField;
@@ -405,6 +413,7 @@ typedef long int mcIdType;
 %newobject MEDCoupling::MEDCoupling1SGTUMesh::buildSetInstanceFromThis;
 %newobject MEDCoupling::MEDCoupling1SGTUMesh::computeDualMesh;
 %newobject MEDCoupling::MEDCoupling1SGTUMesh::explodeEachHexa8To6Quad4;
+%newobject MEDCoupling::MEDCoupling1SGTUMesh::computeTriangleHeight;
 %newobject MEDCoupling::MEDCoupling1SGTUMesh::sortHexa8EachOther;
 %newobject MEDCoupling::MEDCoupling1SGTUMesh::Merge1SGTUMeshes;
 %newobject MEDCoupling::MEDCoupling1SGTUMesh::Merge1SGTUMeshesOnSameCoords;
@@ -472,6 +481,9 @@ typedef long int mcIdType;
 %newobject MEDCoupling::DenseMatrix::__mul__;
 %newobject MEDCoupling::MEDCouplingGaussLocalization::localizePtsInRefCooForEachCell;
 %newobject MEDCoupling::MEDCouplingGaussLocalization::buildRefCell;
+%newobject MEDCoupling::MEDCouplingGaussLocalization::getShapeFunctionValues;
+%newobject MEDCoupling::MEDCouplingGaussLocalization::getDerivativeOfShapeFunctionValues;
+%newobject MEDCoupling::MEDCouplingGaussLocalization::GetDefaultReferenceCoordinatesOf;
 %newobject MEDCoupling::MEDCouplingSkyLineArray::BuildFromPolyhedronConn;
 %newobject MEDCoupling::MEDCouplingSkyLineArray::getSuperIndexArray;
 %newobject MEDCoupling::MEDCouplingSkyLineArray::getIndexArray;
@@ -497,6 +509,7 @@ typedef long int mcIdType;
 %feature("unref") MEDCouplingFieldDiscretizationGauss "$this->decrRef();"
 %feature("unref") MEDCouplingFieldDiscretizationGaussNE "$this->decrRef();"
 %feature("unref") MEDCouplingFieldDiscretizationKriging "$this->decrRef();"
+%feature("unref") MEDCouplingFieldDiscretizationOnNodesFE "$this->decrRef();"
 %feature("unref") MEDCouplingFieldDouble "$this->decrRef();"
 %feature("unref") MEDCouplingFieldFloat "$this->decrRef();"
 %feature("unref") MEDCouplingFieldInt32 "$this->decrRef();"
@@ -630,7 +643,8 @@ namespace MEDCoupling
       ON_NODES = 1,
       ON_GAUSS_PT = 2,
       ON_GAUSS_NE = 3,
-      ON_NODES_KR = 4
+      ON_NODES_KR = 4,
+      ON_NODES_FE = 5
     } TypeOfField;
 
   typedef enum
@@ -666,6 +680,14 @@ namespace MEDCoupling
       std::ostringstream oss; oss << "C++ Pointer address is : " << self;
       return oss.str();
     }
+
+    // Hack to allow retrieving of underlying C++ pointer whatever the situation
+    // This allows for example to mix different types of Python binding (SWIG and PyBind for example)
+    long long getHiddenCppPointerAsLongLong() const
+    {
+      return (long long) self;
+    }
+
   }
 
   %extend MEDCouplingGaussLocalization
@@ -750,6 +772,12 @@ namespace MEDCoupling
          {
            return self->simpleRepr();
          }
+         
+          DataArrayDouble *computeMeshCenterOfMass() const
+          {
+            MCAuto<DataArrayDouble> ret(self->computeMeshCenterOfMass());
+            return ret.retn();
+          }
 
          PyObject *getTime()
          {
@@ -1269,7 +1297,7 @@ namespace MEDCoupling
     const std::vector<double>& getGaussCoords() const;
     double getGaussCoord(int gaussPtIdInCell, int comp) const;
     const std::vector<double>& getWeights() const;
-    double getWeight(int gaussPtIdInCell, double newVal) const;
+    double getWeight(int gaussPtIdInCell) const;
     void setRefCoord(int ptIdInCell, int comp, double newVal);
     void setGaussCoord(int gaussPtIdInCell, int comp, double newVal);
     void setWeight(int gaussPtIdInCell, double newVal);
@@ -1292,6 +1320,24 @@ namespace MEDCoupling
         MCAuto<MEDCouplingUMesh> ret(self->buildRefCell());
         return ret.retn();
       }
+      
+      DataArrayDouble *getShapeFunctionValues() const
+      {
+        MCAuto<DataArrayDouble> ret(self->getShapeFunctionValues());
+        return ret.retn();
+      }
+      
+      DataArrayDouble *getDerivativeOfShapeFunctionValues() const
+      {
+        MCAuto<DataArrayDouble> ret(self->getDerivativeOfShapeFunctionValues());
+        return ret.retn();
+      }
+
+      static DataArrayDouble *GetDefaultReferenceCoordinatesOf(INTERP_KERNEL::NormalizedCellType type)
+      {
+        MCAuto<DataArrayDouble> ret(MEDCouplingGaussLocalization::GetDefaultReferenceCoordinatesOf(type));
+        return ret.retn();
+      }
     }
   };
 
@@ -2048,6 +2094,7 @@ namespace MEDCoupling
     static MEDCouplingUMesh *New();
     static MEDCouplingUMesh *New(const char *meshName, int meshDim);
     void checkConsistencyLight() const;
+    void checkGeomConsistency(double eps=1e-12) const;
     void setMeshDimension(int meshDim);
     void allocateCells(int nbOfCells=0);
     void finishInsertingCells();
@@ -2109,6 +2156,7 @@ namespace MEDCoupling
     DataArrayDouble *getBoundingBoxForBBTree2DQuadratic(double arcDetEps=1e-12) const;
     DataArrayDouble *getBoundingBoxForBBTree1DQuadratic(double arcDetEps=1e-12) const;
     void changeOrientationOfCells();
+    void orientCorrectly2DCells(const MEDCouplingUMesh *refFaces);
     DataArrayDouble *computeCellCenterOfMassWithPrecision(double eps);
     int split2DCells(const DataArrayIdType *desc, const DataArrayIdType *descI, const DataArrayIdType *subNodesInSeg, const DataArrayIdType *subNodesInSegI, const DataArrayIdType *midOpt=0, const DataArrayIdType *midOptI=0);
     static MEDCouplingUMesh *Build0DMeshFromCoords(DataArrayDouble *da);
@@ -2444,14 +2492,19 @@ namespace MEDCoupling
         return ret;
       }
 
-      PyObject *findNodesToDuplicate(const MEDCouplingUMesh& otherDimM1OnSameCoords) const
+      DataArrayIdType *findNodesToDuplicate(const MEDCouplingUMesh& otherDimM1OnSameCoords) const
       {
-        DataArrayIdType *tmp0=0,*tmp1=0,*tmp2=0;
-        self->findNodesToDuplicate(otherDimM1OnSameCoords,tmp0,tmp1,tmp2);
-        PyObject *ret=PyTuple_New(3);
+        DataArrayIdType *ret=self->findNodesToDuplicate(otherDimM1OnSameCoords);
+        return ret;
+      }
+
+      PyObject *findCellsToRenumber(const MEDCouplingUMesh& otherDimM1OnSameCoords, const DataArrayIdType *dupNodes) const
+      {
+        DataArrayIdType *tmp0=0,*tmp1=0;
+        self->findCellsToRenumber(otherDimM1OnSameCoords,dupNodes->begin(), dupNodes->end(), tmp0,tmp1);
+        PyObject *ret=PyTuple_New(2);
         PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(tmp0),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
         PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp1),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
-        PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(tmp2),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
         return ret;
       }
 
@@ -2689,6 +2742,19 @@ namespace MEDCoupling
         return ret;
       }
 
+      PyObject *explodeMeshTo(int targetDeltaLevel) const
+      {
+        MCAuto<DataArrayIdType> desc,descIndx,revDesc,revDescIndx;
+        MCAuto<MEDCouplingUMesh> m=self->explodeMeshTo(targetDeltaLevel,desc,descIndx,revDesc,revDescIndx);
+        PyObject *ret=PyTuple_New(5);
+        PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(m.retn()),SWIGTYPE_p_MEDCoupling__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
+        PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(desc.retn()),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
+        PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(descIndx.retn()),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
+        PyTuple_SetItem(ret,3,SWIG_NewPointerObj(SWIG_as_voidptr(revDesc.retn()),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
+        PyTuple_SetItem(ret,4,SWIG_NewPointerObj(SWIG_as_voidptr(revDescIndx.retn()),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
+        return ret;
+      }
+
       PyObject *explodeIntoEdges() const
       {
         MCAuto<DataArrayIdType> desc,descIndex,revDesc,revDescIndx;
@@ -3002,6 +3068,7 @@ namespace MEDCoupling
     void convertExtrudedPolyhedra();
     bool unPolyze();
     void simplifyPolyhedra(double eps);
+    void colinearizeEdges(double eps);
     MEDCouplingUMesh *buildSpreadZonesWithPoly() const;
     MEDCouplingUMesh *buildExtrudedMesh(const MEDCouplingUMesh *mesh1D, int policy);
   };
@@ -3160,6 +3227,12 @@ namespace MEDCoupling
         return ret;
       }
 
+      DataArrayDouble *MEDCoupling1SGTUMesh::computeTriangleHeight() const
+      {
+        MCAuto<DataArrayDouble> ret = self->computeTriangleHeight();
+        return ret.retn();
+      }
+
       static MEDCoupling1SGTUMesh *Merge1SGTUMeshes(PyObject *li)
       {
         std::vector<const MEDCoupling::MEDCoupling1SGTUMesh *> tmp;