]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
*** empty log message ***
authorageay <ageay>
Thu, 24 Feb 2011 15:34:34 +0000 (15:34 +0000)
committerageay <ageay>
Thu, 24 Feb 2011 15:34:34 +0000 (15:34 +0000)
17 files changed:
src/MEDCoupling/MEDCouplingCMesh.cxx
src/MEDCoupling/MEDCouplingExtrudedMesh.cxx
src/MEDCoupling/MEDCouplingFieldDiscretization.cxx
src/MEDCoupling/MEDCouplingFieldDiscretization.hxx
src/MEDCoupling/MEDCouplingFieldDouble.cxx
src/MEDCoupling/MEDCouplingFieldDouble.hxx
src/MEDCoupling/MEDCouplingMemArray.cxx
src/MEDCoupling/MEDCouplingMesh.cxx
src/MEDCoupling/MEDCouplingMesh.hxx
src/MEDCoupling/MEDCouplingUMesh.cxx
src/MEDCoupling/MEDCouplingUMeshDesc.cxx
src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx
src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx
src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx
src/MEDCoupling_Swig/MEDCoupling.i
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py
src/MEDCoupling_Swig/MEDCouplingDataForTest.py

index 56462207078cd38e7da3b5f3bfee3e67347f6d20..a5dbae15b7c0e52e0aef972abd9faa0e41d7b50f 100644 (file)
@@ -370,7 +370,7 @@ std::string MEDCouplingCMesh::simpleRepr() const
   ret << "Description of mesh : \"" << getDescription() << "\"\n";
   int tmpp1,tmpp2;
   double tt=getTime(tmpp1,tmpp2);
-  ret << "Time attached to the mesh (unit) : " << tt << " (" << getTimeUnit() << ")\n";
+  ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n";
   ret << "Iteration : " << tmpp1  << " Order : " << tmpp2 << "\n";
   ret << "Mesh and SpaceDimension dimension : " << getSpaceDimension() << "\n\nArrays :\n________\n\n";
   if(_x_array)
index 0f0c418b244c389ff415923221c7ab070fb641e2..9918560186416c2882489909254e675402f6c72f 100644 (file)
@@ -260,7 +260,7 @@ std::string MEDCouplingExtrudedMesh::simpleRepr() const
   ret << "Description of mesh : \"" << getDescription() << "\"\n";
   int tmpp1,tmpp2;
   double tt=getTime(tmpp1,tmpp2);
-  ret << "Time attached to the mesh (unit) : " << tt << " (" << getTimeUnit() << ")\n";
+  ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n";
   ret << "Iteration : " << tmpp1  << " Order : " << tmpp2 << "\n";
   ret << "Cell id where 1D mesh has been deduced : " << _cell_2D_id << "\n";
   ret << "Number of cells : " << getNumberOfCells() << "(" << _mesh2D->getNumberOfCells() << "x" << _mesh1D->getNumberOfCells() << ")\n";
@@ -386,8 +386,7 @@ MEDCouplingFieldDouble *MEDCouplingExtrudedMesh::buildOrthogonalField() const
 
 int MEDCouplingExtrudedMesh::getCellContainingPoint(const double *pos, double eps) const
 {
-  //not implemented yet
-  return -1;
+  throw INTERP_KERNEL::Exception("MEDCouplingExtrudedMesh::getCellContainingPoint : not implemented yet !");
 }
 
 MEDCouplingExtrudedMesh::~MEDCouplingExtrudedMesh()
index 898b4d2b312ee217affb00e44a6c309eca729127..183dbb47165acbaed23eea0e043fbbc98d8eaed2 100644 (file)
@@ -409,6 +409,29 @@ void MEDCouplingFieldDiscretizationP0::getValueOnPos(const DataArrayDouble *arr,
   arr->getTuple(id,res);
 }
 
+DataArrayDouble *MEDCouplingFieldDiscretizationP0::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const
+{
+  std::vector<int> elts,eltsIndex;
+  mesh->getCellsContainingPoints(loc,nbOfPoints,_precision,elts,eltsIndex);
+  int spaceDim=mesh->getSpaceDimension();
+  int nbOfComponents=arr->getNumberOfComponents();
+  MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
+  ret->alloc(nbOfPoints,nbOfComponents);
+  double *ptToFill=ret->getPointer();
+  for(int i=0;i<nbOfPoints;i++,ptToFill+=nbOfComponents)
+    if(eltsIndex[i+1]-eltsIndex[i]>=1)
+      arr->getTuple(elts[eltsIndex[i]],ptToFill);
+    else
+      {
+        std::ostringstream oss; oss << "Point #" << i << " with coordinates : (";
+        std::copy(loc+i*spaceDim,loc+(i+1)*spaceDim,std::ostream_iterator<double>(oss,", "));
+        oss << ") detected outside mesh : unable to apply P0::getValueOnMulti ! ";
+        throw INTERP_KERNEL::Exception(oss.str().c_str());
+      }
+  ret->incrRef();
+  return ret;
+}
+
 /*!
  * Nothing to do. It's not a bug.
  */
@@ -516,9 +539,18 @@ void MEDCouplingFieldDiscretizationP1::getValueOn(const DataArrayDouble *arr, co
   INTERP_KERNEL::NormalizedCellType type=mesh->getTypeOfCell(id);
   if(type!=INTERP_KERNEL::NORM_SEG2 && type!=INTERP_KERNEL::NORM_TRI3 && type!=INTERP_KERNEL::NORM_TETRA4)
     throw INTERP_KERNEL::Exception("P1 getValueOn is not specified for not simplex cells !");
+  getValueInCell(mesh,id,arr,loc,res);
+}
+
+/*!
+ * This method localizes a point defined by 'loc' in a cell with id 'cellId' into mesh 'mesh'.
+ * The result is put into res expected to be of size at least arr->getNumberOfComponents()
+ */
+void MEDCouplingFieldDiscretizationP1::getValueInCell(const MEDCouplingMesh *mesh, int cellId, const DataArrayDouble *arr, const double *loc, double *res) const
+{
   std::vector<int> conn;
   std::vector<double> coo;
-  mesh->getNodeIdsOfCell(id,conn);
+  mesh->getNodeIdsOfCell(cellId,conn);
   for(std::vector<int>::const_iterator iter=conn.begin();iter!=conn.end();iter++)
     mesh->getCoordinatesOfNode(*iter,coo);
   int spaceDim=mesh->getSpaceDimension();
@@ -526,19 +558,17 @@ void MEDCouplingFieldDiscretizationP1::getValueOn(const DataArrayDouble *arr, co
   std::vector<const double *> vec(nbOfNodes);
   for(int i=0;i<nbOfNodes;i++)
     vec[i]=&coo[i*spaceDim];
-  double *tmp=new double[nbOfNodes];
+  INTERP_KERNEL::AutoPtr<double> tmp=new double[nbOfNodes];
   INTERP_KERNEL::barycentric_coords(vec,loc,tmp);
   int sz=arr->getNumberOfComponents();
-  double *tmp2=new double[sz];
+  INTERP_KERNEL::AutoPtr<double> tmp2=new double[sz];
   std::fill(res,res+sz,0.);
   for(int i=0;i<nbOfNodes;i++)
     {
-      arr->getTuple(conn[i],tmp2);
-      std::transform(tmp2,tmp2+sz,tmp2,std::bind2nd(std::multiplies<double>(),tmp[i]));
-      std::transform(res,res+sz,tmp2,res,std::plus<double>());
+      arr->getTuple(conn[i],(double *)tmp2);
+      std::transform((double *)tmp2,((double *)tmp2)+sz,(double *)tmp2,std::bind2nd(std::multiplies<double>(),tmp[i]));
+      std::transform(res,res+sz,(double *)tmp2,res,std::plus<double>());
     }
-  delete [] tmp;
-  delete [] tmp2;
 }
 
 void MEDCouplingFieldDiscretizationP1::getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const
@@ -550,6 +580,29 @@ void MEDCouplingFieldDiscretizationP1::getValueOnPos(const DataArrayDouble *arr,
   arr->getTuple(id,res);
 }
 
+DataArrayDouble *MEDCouplingFieldDiscretizationP1::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const
+{
+  std::vector<int> elts,eltsIndex;
+  mesh->getCellsContainingPoints(loc,nbOfPoints,_precision,elts,eltsIndex);
+  int spaceDim=mesh->getSpaceDimension();
+  int nbOfComponents=arr->getNumberOfComponents();
+  MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
+  ret->alloc(nbOfPoints,nbOfComponents);
+  double *ptToFill=ret->getPointer();
+  for(int i=0;i<nbOfPoints;i++)
+    if(eltsIndex[i+1]-eltsIndex[i]>=1)
+      getValueInCell(mesh,elts[eltsIndex[i]],arr,loc+i*spaceDim,ptToFill+i*nbOfComponents);
+    else
+      {
+        std::ostringstream oss; oss << "Point #" << i << " with coordinates : (";
+        std::copy(loc+i*spaceDim,loc+(i+1)*spaceDim,std::ostream_iterator<double>(oss,", "));
+        oss << ") detected outside mesh : unable to apply P1::getValueOnMulti ! ";
+        throw INTERP_KERNEL::Exception(oss.str().c_str());
+      }
+  ret->incrRef();
+  return ret;
+}
+
 void MEDCouplingFieldDiscretizationP1::renumberValuesOnNodes(double epsOnVals, const int *old2NewPtr, DataArrayDouble *arr) const
 {
   renumberEntitiesFromO2NArr(epsOnVals,old2NewPtr,arr,"Node");
@@ -948,6 +1001,11 @@ void MEDCouplingFieldDiscretizationGauss::getValueOnPos(const DataArrayDouble *a
   throw INTERP_KERNEL::Exception("getValueOnPos(i,j,k) : Not applyable for Gauss points !");
 }
 
+DataArrayDouble *MEDCouplingFieldDiscretizationGauss::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const
+{
+  throw INTERP_KERNEL::Exception("getValueOnMulti : Not implemented yet for gauss points !");
+}
+
 MEDCouplingMesh *MEDCouplingFieldDiscretizationGauss::buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const
 {
   throw INTERP_KERNEL::Exception("Not implemented yet !");
@@ -1345,6 +1403,11 @@ void MEDCouplingFieldDiscretizationGaussNE::getValueOnPos(const DataArrayDouble
   throw INTERP_KERNEL::Exception("getValueOnPos(i,j,k) : Not applyable for Gauss points !");
 }
 
+DataArrayDouble *MEDCouplingFieldDiscretizationGaussNE::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const
+{
+  throw INTERP_KERNEL::Exception("getValueOnMulti : Not implemented for Gauss NE !");
+}
+
 MEDCouplingMesh *MEDCouplingFieldDiscretizationGaussNE::buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const
 {
   throw INTERP_KERNEL::Exception("Not implemented yet !");
index 2f543fe96272bcbc36b62c01a97c6e4521025417..df6ba297ec8aba6e68f5c1d9e3075e3c545bb78b 100644 (file)
@@ -65,6 +65,7 @@ namespace ParaMEDMEM
     virtual MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const = 0;
     virtual void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const = 0;
     virtual void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const = 0;
+    virtual DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const = 0;
     virtual MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const = 0;
     virtual void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const = 0;
     virtual void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const = 0;
@@ -113,6 +114,7 @@ namespace ParaMEDMEM
     MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
     void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
     void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
+    DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
     void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
     void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
     void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
@@ -140,10 +142,13 @@ namespace ParaMEDMEM
     MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
     void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
     void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
+    DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
     MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
     void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
     void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
     void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
+  protected:
+    void getValueInCell(const MEDCouplingMesh *mesh, int cellId, const DataArrayDouble *arr, const double *loc, double *res) const;
   public:
     static const char REPR[];
     static const TypeOfField TYPE;
@@ -198,6 +203,7 @@ namespace ParaMEDMEM
     MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
     void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
     void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
+    DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
     MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
     void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
     void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
@@ -250,6 +256,7 @@ namespace ParaMEDMEM
     MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
     void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
     void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
+    DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
     MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
     void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
     void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
index 870c27c6cfed59a7827ed06eaa5d45f9f7468ec2..6ba066f220c64cadaca5af57eef1b6bb99bf3fcf 100644 (file)
@@ -734,6 +734,15 @@ void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double *res) con
   _type->getValueOn(arr,_mesh,spaceLoc,res);
 }
 
+/*!
+ * Returns a newly allocated array with 'nbOfPoints' tuples and nb of components equal to 'this->getNumberOfComponents()'.
+ */
+DataArrayDouble *MEDCouplingFieldDouble::getValueOnMulti(const double *spaceLoc, int nbOfPoints) const throw(INTERP_KERNEL::Exception)
+{
+  const DataArrayDouble *arr=_time_discr->getArray();
+  return _type->getValueOnMulti(arr,_mesh,spaceLoc,nbOfPoints);
+}
+
 /*!
  * Returns value of 'this' on time 'time' of point 'spaceLoc' using spatial discretization.
  * If 'time' is not covered by this->_time_discr an exception will be thrown.
index aa6987ccc1174b671d4aa15c6ff80f6a1b4f9583..177075c0312b109d7371041cc809a24f038ae05d 100644 (file)
@@ -102,6 +102,7 @@ namespace ParaMEDMEM
     void getValueOnPos(int i, int j, int k, double *res) const throw(INTERP_KERNEL::Exception);
     void getValueOn(const double *spaceLoc, double *res) const throw(INTERP_KERNEL::Exception);
     void getValueOn(const double *spaceLoc, double time, double *res) const throw(INTERP_KERNEL::Exception);
+    DataArrayDouble *getValueOnMulti(const double *spaceLoc, int nbOfPoints) const throw(INTERP_KERNEL::Exception);
     //! \b temporary
     void applyLin(double a, double b, int compoId);
     MEDCouplingFieldDouble &operator=(double value) throw(INTERP_KERNEL::Exception);
index bb57d0dea4fd7eed95c834153ec3854b3671f75c..80c2aa6a64747dc838f37eb1c75c729673f1a37e 100644 (file)
@@ -2732,6 +2732,7 @@ void DataArrayInt::computeOffsets() throw(INTERP_KERNEL::Exception)
       work[i]=work[i-1]+tmp;
       tmp=tmp2;
     }
+  declareAsNew();
 }
 
 /*!
index 711a6400c8089b787dac66869ef03628f1a10154..cdb0cfdf425d1f51510b4e686967b8fd91025b9f 100644 (file)
@@ -266,3 +266,29 @@ MEDCouplingMesh *MEDCouplingMesh::MergeMeshes(const MEDCouplingMesh *mesh1, cons
 {
   return mesh1->mergeMyselfWith(mesh2);
 }
+
+void MEDCouplingMesh::getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const
+{
+  int ret=getCellContainingPoint(pos,eps);
+  elts.push_back(ret);
+}
+
+void MEDCouplingMesh::getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, std::vector<int>& elts, std::vector<int>& eltsIndex) const
+{
+  eltsIndex.resize(nbOfPoints+1);
+  eltsIndex[0]=0;
+  elts.clear();
+  int spaceDim=getSpaceDimension();
+  const double *work=pos;
+  for(int i=0;i<nbOfPoints;i++,work+=spaceDim)
+    {
+      int ret=getCellContainingPoint(work,eps);
+      if(ret>=0)
+        {
+          elts.push_back(ret);
+          eltsIndex[i+1]=eltsIndex[i]+1;
+        }
+      else
+        eltsIndex[i+1]=eltsIndex[i];
+    }
+}
index 1ec2652a2ce06a26500c3116d6bab743bbf50763..6303f0fe57a3db720191ed4bf6ec3cd4c6795639 100644 (file)
@@ -88,6 +88,8 @@ namespace ParaMEDMEM
     virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const = 0;
     virtual MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const = 0;
     virtual int getCellContainingPoint(const double *pos, double eps) const = 0;
+    virtual void getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const;
+    virtual void getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, std::vector<int>& elts, std::vector<int>& eltsIndex) const;
     virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, FunctionToEvaluate func) const;
     virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, const char *func) const;
     virtual MEDCouplingFieldDouble *fillFromAnalytic2(TypeOfField t, int nbOfComp, const char *func) const;
index 1849ee8a460a303c61c49a10b1cd46b9111ae801..d3b4f7b19757ba934a1b405935f33cabcff68411 100644 (file)
@@ -1478,7 +1478,7 @@ std::string MEDCouplingUMesh::simpleRepr() const
   ret << "Description of mesh : \"" << getDescription() << "\"\n";
   int tmpp1,tmpp2;
   double tt=getTime(tmpp1,tmpp2);
-  ret << "Time attached to the mesh (unit) : " << tt << " (" << getTimeUnit() << ")\n";
+  ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n";
   ret << "Iteration : " << tmpp1  << " Order : " << tmpp2 << "\n";
   ret << "Mesh dimension : " << _mesh_dim << "\nSpace dimension : ";
   if(_coords!=0)
index f09efe65889913513d8f22abb30876df5dbc35a9..877b7e2c664c5893d932173f7c8278902135cb5d 100644 (file)
@@ -459,6 +459,5 @@ DataArrayDouble *MEDCouplingUMeshDesc::getBarycenterAndOwner() const
 
 int MEDCouplingUMeshDesc::getCellContainingPoint(const double *pos, double eps) const
 {
-  //not implemented yet.
-  return -1;
+  throw INTERP_KERNEL::Exception("MEDCouplingUMeshDesc::getCellContainingPoint : not implemented yet !");
 }
index dda08257a8e1be148836bd593d86022ce2832451..e37a6047afcfd51ca571e43747c44fe65ac03c21 100644 (file)
@@ -27,6 +27,7 @@
 
 namespace ParaMEDMEM
 {
+  class DataArrayDouble;
   class MEDCouplingUMesh;
   class MEDCouplingFieldDouble;
   class MEDCouplingMultiFields;
@@ -203,6 +204,11 @@ namespace ParaMEDMEM
     CPPUNIT_TEST( testFillFromAnalyticTwo1 );
     CPPUNIT_TEST( testFillFromAnalyticThree1 );
     CPPUNIT_TEST( testDAUnitVar1 );
+    CPPUNIT_TEST( testGaussCoordinates1 );
+    //CPPUNIT_TEST( testP2Localization1 ); not implemented yet
+    CPPUNIT_TEST( testGetValueOn2 );
+    CPPUNIT_TEST( testDAIGetIdsNotEqual1 );
+    CPPUNIT_TEST( testDAIComputeOffsets1 );
     //MEDCouplingBasicsTestInterp.cxx
     CPPUNIT_TEST( test2DInterpP0P0_1 );
     CPPUNIT_TEST( test2DInterpP0P0PL_1 );
@@ -432,6 +438,11 @@ namespace ParaMEDMEM
     void testFillFromAnalyticTwo1();
     void testFillFromAnalyticThree1();
     void testDAUnitVar1();
+    void testGaussCoordinates1();
+    void testP2Localization1();
+    void testGetValueOn2();
+    void testDAIGetIdsNotEqual1();
+    void testDAIComputeOffsets1();
     //MEDCouplingBasicsTestInterp.cxx
     void test2DInterpP0P0_1();
     void test2DInterpP0P0PL_1();
@@ -525,6 +536,11 @@ namespace ParaMEDMEM
     static MEDCouplingUMesh *build2DTargetMesh_3();
     static MEDCouplingUMesh *build3DTargetMesh_3();
     static MEDCouplingUMesh *build2DTargetMesh_4();
+    static MEDCouplingUMesh *build1DMultiTypes_1();
+    static MEDCouplingUMesh *build2DMultiTypes_1();
+    static MEDCouplingUMesh *build3DMultiTypes_1();
+    static MEDCouplingUMesh *buildHexa8Mesh_1();
+    static DataArrayDouble *buildCoordsForMultiTypes_1();
     static MEDCouplingMultiFields *buildMultiFields_1();
     static std::vector<MEDCouplingFieldDouble *> buildMultiFields_2();
     static double sumAll(const std::vector< std::map<int,double> >& matrix);
index a095d48463649ce4ef485a8a4aa849d3a2a2697a..5266686894c41bad106f4355ac39170d0bba7594 100644 (file)
@@ -982,6 +982,156 @@ std::vector<MEDCouplingFieldDouble *> MEDCouplingBasicsTest::buildMultiFields_2(
   return fs;
 }
 
+MEDCouplingUMesh *MEDCouplingBasicsTest::build1DMultiTypes_1()
+{
+  MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi1DMesh",1);
+  DataArrayDouble *coo=buildCoordsForMultiTypes_1();
+  const int conn[5]={0,2, 0,2,1};
+  mesh->allocateCells(2);
+  mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
+  mesh->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn+2);
+  mesh->finishInsertingCells();
+  mesh->setCoords(coo);
+  coo->decrRef();
+  return mesh;
+}
+
+MEDCouplingUMesh *MEDCouplingBasicsTest::build2DMultiTypes_1()
+{
+  MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi2DMesh",2);
+  DataArrayDouble *coo=buildCoordsForMultiTypes_1();
+  const int conn[21]={3,4,5, 3,4,5,6,7,8, 0,9,10,11, 0,9,10,11,12,13,14,15};
+  mesh->allocateCells(4);
+  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn);
+  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,conn+3);
+  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+9);
+  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,conn+13);
+  mesh->finishInsertingCells();
+  mesh->setCoords(coo);
+  coo->decrRef();
+  return mesh;
+}
+
+MEDCouplingUMesh *MEDCouplingBasicsTest::build3DMultiTypes_1()
+{
+  MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi3DMesh",3);
+  DataArrayDouble *coo=buildCoordsForMultiTypes_1();
+  const int conn[81]={0,16,17,18,
+                      0,16,17,18,19,20,21,22,23,24,
+                      0,11,10,9,25,
+                      0,11,10,9,25,15,14,13,12,26,27,28,29,
+                      0,30,31,32,33,34,
+                      0,30,31,32,33,34,35,36,37,38,39,40,41,42,43,
+                      0,9,10,11,44,45,46,47,
+                      0,9,10,11,44,45,46,47,12,13,14,15,48,49,50,51,52,53,54,55 };
+  mesh->allocateCells(8);
+  mesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn);
+  mesh->insertNextCell(INTERP_KERNEL::NORM_TETRA10,10,conn+4);
+  mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA5,5,conn+14);
+  mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA13,13,conn+19);
+  mesh->insertNextCell(INTERP_KERNEL::NORM_PENTA6,6,conn+32);
+  mesh->insertNextCell(INTERP_KERNEL::NORM_PENTA15,15,conn+38);
+  mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+53);
+  mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA20,20,conn+61);
+  mesh->finishInsertingCells();
+  mesh->setCoords(coo);
+  coo->decrRef();
+  return mesh;
+}
+
+DataArrayDouble *MEDCouplingBasicsTest::buildCoordsForMultiTypes_1()
+{
+  DataArrayDouble *coords=DataArrayDouble::New();
+  coords->alloc(56,3);
+  coords->setInfoOnComponent(0,"X (cm)");
+  coords->setInfoOnComponent(1,"Y (cm)");
+  coords->setInfoOnComponent(2,"Z (cm)");
+  const double data[168]={
+    0.0, 0.0, 0.0, //#0
+    0.5, 0.5, 0.5, //#1
+    1.0, 1.0, 1.0, //#2
+    1.0, 1.0, 0.0, //#3
+    2.0, 2.5, 0.0, //#4
+    6.0, 1.5, 0.0, //#5
+    1.0, 2.0, 0.0, //#6
+    4.5, 2.5, 0.0, //#7
+    4.0, 0.5, 0.0, //#8
+    0.0, 4.0, 0.0, //#9
+    4.0, 4.0, 0.0, //#10
+    4.0, 0.0, 0.0, //#11
+    0.0, 2.0, 0.0, //#12
+    2.0, 4.0, 0.0, //#13
+    4.0, 2.0, 0.0, //#14
+    2.0, 0.0, 0.0, //#15
+    0.0, 6.0, 0.0, //#16
+    3.0, 3.0, 0.0, //#17
+    1.3, 3.0, 3.0, //#18
+    0.0, 3.0, 0.0, //#19
+    1.5, 4.5, 0.0, //#20
+    1.5, 1.5, 0.0, //#21
+    0.65, 1.5, 1.5, //#22
+    0.65, 4.5, 1.5, //#23
+    2.15, 3.0, 1.5, //#24
+    2.0, 2.0, 2.0, //#25
+    3.0, 1.0, 1.0, //#26
+    3.0, 3.0, 1.0, //#27
+    1.0, 3.0, 1.0, //#28
+    1.0, 1.0, 1.0, //#29
+    0.0, 3.0, 0.0, //#30
+    2.0, 0.0, 0.0, //#31
+    0.0, 0.0, 6.0, //#32
+    0.0, 3.0, 6.0, //#33
+    3.0, 0.0, 6.0, //#34
+    0.0, 1.5, 0.0, //#35
+    1.5, 1.5, 0.0, //#36
+    1.5, 0.0, 0.0, //#37
+    0.0, 1.5, 6.0, //#38
+    1.5, 1.5, 6.0, //#39
+    1.5, 0.0, 6.0, //#40
+    0.0, 0.0, 3.0, //#41
+    0.0, 3.0, 3.0, //#42
+    3.0, 0.0, 3.0, //#43
+    0.0, 0.0, 4.0, //#44
+    0.0, 4.0, 4.0, //#45
+    4.0, 4.0, 4.0, //#46
+    4.0, 0.0, 4.0, //#47
+    0.0, 2.0, 4.0, //#48
+    2.0, 4.0, 4.0, //#49
+    4.0, 2.0, 4.0, //#50
+    2.0, 0.0, 4.0, //#51
+    0.0, 0.0, 2.0, //#52
+    0.0, 4.0, 2.0, //#53
+    4.0, 4.0, 2.0, //#54
+    4.0, 0.0, 2.0  //#55
+  };
+  std::copy(data,data+168,coords->getPointer());
+  return coords;
+}
+
+MEDCouplingUMesh *MEDCouplingBasicsTest::buildHexa8Mesh_1()
+{
+  MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Hexa8Only",3);
+  DataArrayDouble *coo=DataArrayDouble::New();
+  const double coords[81]={0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, 0.5, 1.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 1.0, 0.5, 0.5, 0.0, 1.0, 0.5, 0.5, 1.0, 0.5, 1.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.5, 0.5, 1.0, 1.0, 0.5, 1.0, 0.0, 1.0, 1.0, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0};
+  coo->alloc(27,3);
+  std::copy(coords,coords+81,coo->getPointer());
+  const int conn[64]={3,12,13,4,0,9,10,1,
+                      4,13,14,5,1,10,11,2,
+                      6,15,16,7,3,12,13,4,
+                      7,16,17,8,4,13,14,5,
+                      12,21,22,13,9,18,19,10,
+                      13,22,23,14,10,19,20,11,
+                      15,24,25,16,12,21,22,13,
+                      16,25,26,17,13,22,23,14};
+  mesh->allocateCells(8);
+  for(int i=0;i<8;i++)
+    mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+8*i);
+  mesh->finishInsertingCells();
+  mesh->setCoords(coo);
+  coo->decrRef();
+  return mesh;
+}
+
 double MEDCouplingBasicsTest::sumAll(const std::vector< std::map<int,double> >& matrix)
 {
   double ret=0.;
index e99faae89634d0f0067a292172ddb9216146a5db..4ac5866324121711800251d04459128b8cda3ca4 100644 (file)
@@ -259,6 +259,13 @@ void MEDCouplingBasicsTest::testMeshSetTime1()
   CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
   m2->setTime(3.14,6,7);
   CPPUNIT_ASSERT(m1->isEqual(m2,1e-12));
+  m1->setTimeUnit("ms");
+  CPPUNIT_ASSERT(std::string(m1->getTimeUnit())=="ms");
+  m1->setTimeUnit("us");
+  CPPUNIT_ASSERT(std::string(m1->getTimeUnit())=="us");
+  CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
+  m2->setTimeUnit("us");
+  CPPUNIT_ASSERT(m1->isEqual(m2,1e-12));
   m2->setTime(3.14,6,8);
   CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
   m2->setTime(3.14,7,7);
@@ -478,3 +485,247 @@ void MEDCouplingBasicsTest::testDAUnitVar1()
   da->decrRef();
 }
 
+void MEDCouplingBasicsTest::testGaussCoordinates1()
+{
+  //Testing 1D cell types
+  MEDCouplingUMesh *m1=build1DMultiTypes_1();
+  MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,ONE_TIME);
+  f->setMesh(m1);
+  std::vector<double> wg1(1); wg1[0]=0.3;
+  std::vector<double> gsCoo1(1); gsCoo1[0]=0.2;
+  std::vector<double> refCoo1(2); refCoo1[0]=-1.0; refCoo1[1]=1.0;
+  f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_SEG2,refCoo1,gsCoo1,wg1);
+  std::vector<double> wg2(wg1);
+  std::vector<double> gsCoo2(1); gsCoo2[0]=0.2;
+  std::vector<double> refCoo2(3); refCoo2[0]=-1.0; refCoo2[1]=1.0; refCoo2[2]=0.0;
+  f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_SEG3,refCoo2,gsCoo2,wg2);
+  //
+  DataArrayDouble *resToTest=f->getLocalizationOfDiscr();
+  CPPUNIT_ASSERT_EQUAL(3,resToTest->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(2,resToTest->getNumberOfTuples());
+  const double expected1[6]={0.6,0.6,0.6, 0.6,0.6,0.6};
+  for(int i=0;i<6;i++)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],resToTest->getIJ(0,i),1e-14);
+  resToTest->decrRef();
+  //
+  m1->decrRef();
+  f->decrRef();
+  //Testing 2D cell types
+  MEDCouplingUMesh *m2=build2DMultiTypes_1();
+  f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,ONE_TIME);
+  f->setMesh(m2);
+  std::vector<double> wg3(2); wg3[0]=0.3; wg3[1]=0.3;
+  const double tria3CooGauss[4]={ 0.1, 0.8, 0.2, 0.7 };
+  std::vector<double> gsCoo3(tria3CooGauss,tria3CooGauss+4);
+  const double tria3CooRef[6]={ 0.0, 0.0, 1.0 , 0.0, 0.0, 1.0 };
+  std::vector<double> refCoo3(tria3CooRef,tria3CooRef+6);
+  f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI3,refCoo3,gsCoo3,wg3);
+  std::vector<double> wg4(3); wg4[0]=0.3; wg4[1]=0.3; wg4[2]=0.3;
+  const double tria6CooGauss[6]={ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4 };
+  std::vector<double> gsCoo4(tria6CooGauss,tria6CooGauss+6);
+  const double tria6CooRef[12]={0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0, 0.5, 0.5, 0.0, 0.5};
+  std::vector<double> refCoo4(tria6CooRef,tria6CooRef+12);
+  f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI6,refCoo4,gsCoo4,wg4);
+  std::vector<double> wg5(4); wg5[0]=0.3; wg5[1]=0.3; wg5[2]=0.3; wg5[3]=0.3;
+  const double quad4CooGauss[8]={ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4, 0.15, 0.27 };
+  std::vector<double> gsCoo5(quad4CooGauss,quad4CooGauss+8);
+  const double quad4CooRef[8]={-1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0};
+  std::vector<double> refCoo5(quad4CooRef,quad4CooRef+8);
+  f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,refCoo5,gsCoo5,wg5);
+  std::vector<double> wg6(4); wg6[0]=0.3; wg6[1]=0.3; wg6[2]=0.3; wg6[3]=0.3;
+  const double quad8CooGauss[8]={ 0.34, 0.16, 0.21, 0.3, 0.23, 0.4, 0.14, 0.37 };
+  std::vector<double> gsCoo6(quad8CooGauss,quad8CooGauss+8);
+  const double quad8CooRef[16]={ -1.0, -1.0, 1.0, -1.0, 1.0,  1.0, -1.0,  1.0, 0.0, -1.0, 1.0,  0.0, 0.0,  1.0, -1.0,  0.0};
+  std::vector<double> refCoo6(quad8CooRef,quad8CooRef+16);
+  f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD8,refCoo6,gsCoo6,wg6);
+  //
+  resToTest=f->getLocalizationOfDiscr();
+  CPPUNIT_ASSERT_EQUAL(3,resToTest->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(13,resToTest->getNumberOfTuples());//2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8
+  const double expected2[39]={5.1,1.55,0.0, 4.7,1.65,0.0, //TRI3
+                              2.32,1.52,0.0, 1.6,1.32,0.0, 3.52,1.26,0.0,//TRI6
+                              2.6,1.6,0.0, 2.4,1.8,0.0, 2.4,1.2,0.0, 2.3,1.46,0.0,//QUAD4
+                              2.32,2.68,0.0, 2.6,2.42,0.0, 2.8,2.46,0.0, 2.74,2.28,0.0 };//QUAD8
+  for(int i=0;i<39;i++)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],resToTest->getIJ(0,i),1e-14);
+  resToTest->decrRef();
+  //
+  m2->decrRef();
+  f->decrRef();
+  //Testing 3D cell types
+  MEDCouplingUMesh *m3=build3DMultiTypes_1();
+  f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,ONE_TIME);
+  f->setMesh(m3);
+  //
+  std::vector<double> wg7(1); wg7[0]=0.3;
+  const double tetra4CooGauss[3]={0.34, 0.16, 0.21};
+  std::vector<double> gsCoo7(tetra4CooGauss,tetra4CooGauss+3);
+  const double tetra4CooRef[12]={0.0,1.0,0.0, 0.0,0.0,1.0, 0.0,0.0,0.0, 1.0,0.0,0.0};
+  std::vector<double> refCoo7(tetra4CooRef,tetra4CooRef+12);
+  f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TETRA4,refCoo7,gsCoo7,wg7);
+  std::vector<double> wg8(1); wg8[0]=0.3;
+  const double tetra10CooGauss[3]={0.2, 0.3, 0.1};
+  std::vector<double> gsCoo8(tetra10CooGauss,tetra10CooGauss+3);
+  const double tetra10CooRef[30]={0.0,1.0,0.0, 0.0,0.0,0.0, 0.0,0.0,1.0, 1.0,0.0,0.0, 0.0,0.5,0.0, 0.0,0.0,0.5, 0.0,0.5,0.5, 0.5,0.5,0.0, 0.5,0.0,0.0, 0.5,0.0,0.5};
+  std::vector<double> refCoo8(tetra10CooRef,tetra10CooRef+30);
+  f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TETRA10,refCoo8,gsCoo8,wg8);
+  std::vector<double> wg9(1); wg9[0]=0.3;
+  const double pyra5CooGauss[3]={0.2, 0.3, 0.1};
+  std::vector<double> gsCoo9(pyra5CooGauss,pyra5CooGauss+3);
+  const double pyra5CooRef[15]={1.0,0.0,0.0, 0.0,1.0,0.0, -1.0,0.0,0.0, 0.0,-1.0,0.0, 0.0,0.0,1.0};
+  std::vector<double> refCoo9(pyra5CooRef,pyra5CooRef+15);
+  f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PYRA5,refCoo9,gsCoo9,wg9);
+  std::vector<double> wg10(1); wg10[0]=0.3;
+  const double pyra13CooGauss[3]={0.1, 0.2, 0.7};
+  std::vector<double> gsCoo10(pyra13CooGauss,pyra13CooGauss+3);
+  const double pyra13CooRef[39]={1.0,0.0,0.0, 0.0,1.0,0.0,-1.0,0.0,0.0,0.0,-1.0,0.0,0.0,0.0,1.0,0.5,0.5,0.0,-0.5,0.5,0.0,-0.5,-0.5,0.0,0.5,-0.5,0.0,0.5,0.0,0.5,0.0,0.5,0.5,-0.5,0.0,0.5,0.0,-0.5,0.5};
+  std::vector<double> refCoo10(pyra13CooRef,pyra13CooRef+39);
+  f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PYRA13,refCoo10,gsCoo10,wg10);
+  std::vector<double> wg11(1); wg11[0]=0.3;
+  const double penta6CooGauss[3]={0.2, 0.3, 0.1};
+  std::vector<double> gsCoo11(penta6CooGauss,penta6CooGauss+3);
+  const double penta6CooRef[18]={-1.0,1.0,0.0,-1.0,-0.0,1.0,-1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0};
+  std::vector<double> refCoo11(penta6CooRef,penta6CooRef+18);
+  f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PENTA6,refCoo11,gsCoo11,wg11);
+  std::vector<double> wg12(1); wg12[0]=0.3;
+  const double penta15CooGauss[3]={0.2, 0.3,0.15};
+  std::vector<double> gsCoo12(penta15CooGauss,penta15CooGauss+3);
+  const double penta15CooRef[45]={-1.0,1.0,0.0,-1.0,0.0,1.0,-1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,-1.0,0.5,0.5,-1.0,0.0,0.5,-1.0,0.5,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.5,0.5,1.0,0.0, 0.5,1.0,0.5,0.0};
+  std::vector<double> refCoo12(penta15CooRef,penta15CooRef+45);
+  f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PENTA15,refCoo12,gsCoo12,wg12);
+  std::vector<double> wg13(1); wg13[0]=0.3;
+  const double hexa8CooGauss[3]={0.2,0.3,0.15};
+  std::vector<double> gsCoo13(hexa8CooGauss,hexa8CooGauss+3);
+  const double hexa8CooRef[24]={-1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,1.0};
+  std::vector<double> refCoo13(hexa8CooRef,hexa8CooRef+24);
+  f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_HEXA8,refCoo13,gsCoo13,wg13);
+  std::vector<double> wg14(1); wg14[0]=0.3;
+  const double hexa20CooGauss[3]={0.11,0.3,0.55};
+  std::vector<double> gsCoo14(hexa20CooGauss,hexa20CooGauss+3);
+  const double hexa20CooRef[60]={-1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,1.0,0.0,-1.0,-1.0,1.0,0.0,-1.0,0.0,1.0,-1.0,-1.0,0.0,-1.0,-1.0,-1.0,0.0,1.0,-1.0,0.0,1.0,1.0,0.0,-1.0,1.0,0.0,0.0,-1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,-1.0,0.0,1.0};
+  std::vector<double> refCoo14(hexa20CooRef,hexa20CooRef+60);
+  f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_HEXA20,refCoo14,gsCoo14,wg14);
+  //
+  resToTest=f->getLocalizationOfDiscr();
+  CPPUNIT_ASSERT_EQUAL(3,resToTest->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(8,resToTest->getNumberOfTuples());//2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8
+  const double expected3[24]={1.312,3.15,1.02, 0.56,3.3,0.6, 2.18,1.1,0.2, 1.18,1.54,0.98, 1.56,0.3,3.6, 1.613,0.801,4.374, 2.6,2.4,2.3, 2.31232,2.3933985,1.553255};
+  for(int i=0;i<24;i++)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],resToTest->getIJ(0,i),1e-14);
+  resToTest->decrRef();
+  //
+  m3->decrRef();
+  f->decrRef();
+}
+
+/*!
+ * Not activated test ! To be implemented ! WARNING Hexa8 should be replaced by Quad8...
+ */
+void MEDCouplingBasicsTest::testP2Localization1()
+{
+  MEDCouplingUMesh *m=buildHexa8Mesh_1();
+  MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME);
+  DataArrayDouble *da=DataArrayDouble::New();
+  const double vals1[27]={1.0,3.0,4.0,1.0,3.0,4.0,3.0,2.0,5.0,1.0,3.0,4.0,1.0,3.0,4.0,3.0,2.0,5.0,1.0,3.0,4.0,1.0,3.0,4.0,3.0,2.0,5.0};
+  da->alloc(27,1);
+  std::copy(vals1,vals1+27,da->getPointer());
+  f->setMesh(m);
+  f->setArray(da);
+  da->decrRef();
+  //
+  const double point1[3]={0.25,0.75,0.25};
+  //const double points1[6]={0.25,0.75,0.25,1.0,1.0,1.0};
+  double res1[3];
+  f->getValueOn(point1,res1);
+  //
+  f->decrRef();
+  m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testGetValueOn2()
+{
+  MEDCouplingUMesh *m=build2DTargetMesh_1();
+  MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
+  f->setMesh(m);
+  DataArrayDouble *arr=DataArrayDouble::New();
+  int nbOfCells=m->getNumberOfCells();
+  arr->alloc(nbOfCells,3);
+  f->setArray(arr);
+  arr->decrRef();
+  const double values1[15]={7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.};
+  std::copy(values1,values1+15,arr->getPointer());
+  const double loc[10]={-0.05,-0.05, 0.55,-0.25, 0.55,0.15, -0.05,0.45, 0.45,0.45};
+  f->checkCoherency();
+  DataArrayDouble *locs=f->getValueOnMulti(loc,5);
+  CPPUNIT_ASSERT_EQUAL(5,locs->getNumberOfTuples());
+  CPPUNIT_ASSERT_EQUAL(3,locs->getNumberOfComponents());
+  for(int j=0;j<15;j++)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(values1[j],locs->getIJ(0,j),1e-12);
+  locs->decrRef();
+  f->decrRef();
+  // Testing ON_NODES
+  f=MEDCouplingFieldDouble::New(ON_NODES,NO_TIME);
+  f->setMesh(m);
+  arr=DataArrayDouble::New();
+  int nbOfNodes=m->getNumberOfNodes();
+  arr->alloc(nbOfNodes,3);
+  f->setArray(arr);
+  arr->decrRef();
+  const double values2[27]={7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.,12.,112.,10012.,13.,113.,10013.,14.,114.,10014.,15.,115.,10015.};
+  std::copy(values2,values2+27,arr->getPointer());
+  const double loc2[8]={0.5432,-0.2432, 0.5478,0.1528, 0.5432,-0.2432, 0.5432,-0.2432};
+  const double expected2[12]={9.0272, 109.0272, 10009.0272, 11.4124,111.4124,10011.4124, 9.0272, 109.0272, 10009.0272, 9.0272, 109.0272, 10009.0272};
+  f->checkCoherency();
+  locs=f->getValueOnMulti(loc2,4);
+  CPPUNIT_ASSERT_EQUAL(4,locs->getNumberOfTuples());
+  CPPUNIT_ASSERT_EQUAL(3,locs->getNumberOfComponents());
+  for(int i=0;i<12;i++)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],locs->getIJ(0,i),1e-12);
+  f->decrRef();
+  locs->decrRef();
+  //
+  m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIGetIdsNotEqual1()
+{
+  DataArrayInt *d=DataArrayInt::New();
+  const int vals1[10]={2,3,5,6,8,5,5,6,1,-5};
+  d->alloc(10,1);
+  std::copy(vals1,vals1+10,d->getPointer());
+  DataArrayInt *d2=d->getIdsNotEqual(5);
+  CPPUNIT_ASSERT_EQUAL(7,d2->getNumberOfTuples());
+  CPPUNIT_ASSERT_EQUAL(1,d2->getNumberOfComponents());
+  const int expected1[7]={0,1,3,4,7,8,9};
+  for(int i=0;i<7;i++)
+    CPPUNIT_ASSERT_EQUAL(expected1[i],d2->getIJ(0,i));
+  d->rearrange(2);
+  CPPUNIT_ASSERT_THROW(d->getIdsNotEqual(5),INTERP_KERNEL::Exception);
+  const int vals2[3]={-4,5,6};
+  std::vector<int> vals3(vals2,vals2+3);
+  d->rearrange(1);
+  DataArrayInt *d3=d->getIdsNotEqualList(vals3);
+  CPPUNIT_ASSERT_EQUAL(5,d3->getNumberOfTuples());
+  CPPUNIT_ASSERT_EQUAL(1,d3->getNumberOfComponents());
+  const int expected2[5]={0,1,4,8,9};
+  for(int i=0;i<5;i++)
+    CPPUNIT_ASSERT_EQUAL(expected2[i],d3->getIJ(0,i));
+  d3->decrRef();
+  d->decrRef();
+  d2->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIComputeOffsets1()
+{
+  DataArrayInt *d=DataArrayInt::New();
+  const int vals1[6]={3,5,1,2,0,8};
+  const int expected1[6]={0,3,8,9,11,11};
+  d->alloc(6,1);
+  std::copy(vals1,vals1+6,d->getPointer());
+  d->computeOffsets();
+  CPPUNIT_ASSERT_EQUAL(6,d->getNumberOfTuples());
+  CPPUNIT_ASSERT_EQUAL(1,d->getNumberOfComponents());
+  for(int i=0;i<6;i++)
+    CPPUNIT_ASSERT_EQUAL(expected1[i],d->getIJ(0,i));
+  d->decrRef();
+}
index 18dfb6980483a76289e8a5e5969b7f3dd276922e..8b4e725da210dd9367f5cdf75889ab8296fcb4bf 100644 (file)
@@ -72,6 +72,7 @@ using namespace INTERP_KERNEL;
 %feature("docstring");
 
 %newobject ParaMEDMEM::MEDCouplingField::buildMeasureField;
+%newobject ParaMEDMEM::MEDCouplingField::getLocalizationOfDiscr;
 %newobject ParaMEDMEM::MEDCouplingFieldDouble::New;
 %newobject ParaMEDMEM::MEDCouplingFieldDouble::getArray;
 %newobject ParaMEDMEM::MEDCouplingFieldDouble::getEndArray;
@@ -109,6 +110,7 @@ using namespace INTERP_KERNEL;
 %newobject ParaMEDMEM::MEDCouplingFieldDouble::cloneWithMesh;
 %newobject ParaMEDMEM::MEDCouplingFieldDouble::deepCpy;
 %newobject ParaMEDMEM::MEDCouplingFieldDouble::buildNewTimeReprFromThis;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::getValueOnMulti;
 %newobject ParaMEDMEM::MEDCouplingFieldTemplate::New;
 %newobject ParaMEDMEM::DataArrayInt::New;
 %newobject ParaMEDMEM::DataArrayInt::convertToDblArr;
@@ -126,7 +128,9 @@ using namespace INTERP_KERNEL;
 %newobject ParaMEDMEM::DataArrayInt::invertArrayO2N2N2O;
 %newobject ParaMEDMEM::DataArrayInt::invertArrayN2O2O2N;
 %newobject ParaMEDMEM::DataArrayInt::getIdsEqual;
+%newobject ParaMEDMEM::DataArrayInt::getIdsNotEqual;
 %newobject ParaMEDMEM::DataArrayInt::getIdsEqualList;
+%newobject ParaMEDMEM::DataArrayInt::getIdsNotEqualList;
 %newobject ParaMEDMEM::DataArrayInt::Aggregate;
 %newobject ParaMEDMEM::DataArrayInt::Meld;
 %newobject ParaMEDMEM::DataArrayInt::BuildUnion;
@@ -345,6 +349,35 @@ namespace ParaMEDMEM
            delete [] pos;
            return ret;
          }
+
+         PyObject *getCellsContainingPoints(PyObject *p, int nbOfPoints, double eps) const throw(INTERP_KERNEL::Exception)
+         {
+           int sz;
+           INTERP_KERNEL::AutoPtr<double> pos=convertPyToNewDblArr2(p,&sz);
+           std::vector<int> elts,eltsIndex;
+           self->getCellsContainingPoints(pos,nbOfPoints,eps,elts,eltsIndex);
+           MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
+           MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d1=DataArrayInt::New();
+           d0->alloc(elts.size(),1);
+           d1->alloc(eltsIndex.size(),1);
+           std::copy(elts.begin(),elts.end(),d0->getPointer());
+           std::copy(eltsIndex.begin(),eltsIndex.end(),d1->getPointer());
+           PyObject *ret=PyTuple_New(2);
+           PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+           PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+           d0->incrRef();
+           d1->incrRef();
+           return ret;
+         }
+
+         PyObject *getCellsContainingPoint(PyObject *p, double eps) const throw(INTERP_KERNEL::Exception)
+         {
+           int sz;
+           INTERP_KERNEL::AutoPtr<double> pos=convertPyToNewDblArr2(p,&sz);
+           std::vector<int> elts;
+           self->getCellsContainingPoint(pos,eps,elts);
+           return convertIntArrToPyList2(elts);
+         }
          
          void renumberCells(PyObject *li, bool check) throw(INTERP_KERNEL::Exception)
          {
@@ -874,37 +907,6 @@ namespace ParaMEDMEM
         return ret;
       }
 
-      PyObject *getCellsContainingPoints(PyObject *p, int nbOfPoints, double eps) const throw(INTERP_KERNEL::Exception)
-      {
-        int sz;
-        double *pos=convertPyToNewDblArr2(p,&sz);
-        std::vector<int> elts,eltsIndex;
-        self->getCellsContainingPoints(pos,nbOfPoints,eps,elts,eltsIndex);
-        delete [] pos;
-        MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
-        MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d1=DataArrayInt::New();
-        d0->alloc(elts.size(),1);
-        d1->alloc(eltsIndex.size(),1);
-        std::copy(elts.begin(),elts.end(),d0->getPointer());
-        std::copy(eltsIndex.begin(),eltsIndex.end(),d1->getPointer());
-        PyObject *ret=PyTuple_New(2);
-        PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
-        PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
-        d0->incrRef();
-        d1->incrRef();
-        return ret;
-      }
-
-      PyObject *getCellsContainingPoint(PyObject *p, double eps) const throw(INTERP_KERNEL::Exception)
-      {
-        int sz;
-        double *pos=convertPyToNewDblArr2(p,&sz);
-        std::vector<int> elts;
-        self->getCellsContainingPoint(pos,eps,elts);
-        delete [] pos;
-        return convertIntArrToPyList2(elts);
-      }
-
       static PyObject *MergeUMeshesOnSameCoords(PyObject *ms) throw(INTERP_KERNEL::Exception)
       {
         std::vector<const ParaMEDMEM::MEDCouplingUMesh *> meshes;
@@ -1836,6 +1838,7 @@ namespace ParaMEDMEM
     TypeOfField getTypeOfField() const throw(INTERP_KERNEL::Exception);
     NatureOfField getNature() const throw(INTERP_KERNEL::Exception);
     virtual void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception);
+    DataArrayDouble *getLocalizationOfDiscr() const throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldDiscretization *getDiscretization() const throw(INTERP_KERNEL::Exception);
     int getNumberOfTuplesExpected() const throw(INTERP_KERNEL::Exception);
@@ -2037,6 +2040,39 @@ namespace ParaMEDMEM
         self->getValueOn(spaceLoc,res);
         return convertDblArrToPyList(res,sz);
       }
+
+      DataArrayDouble *getValueOnMulti(PyObject *li) const throw(INTERP_KERNEL::Exception)
+      {
+        void *da=0;
+        int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, 0 |  0 );
+        if (!SWIG_IsOK(res1))
+          {
+            int size;
+            INTERP_KERNEL::AutoPtr<double> tmp=convertPyToNewDblArr2(li,&size);
+            int spaceDim=self->getMesh()->getSpaceDimension();
+            int nbOfPoints=size/spaceDim;
+            if(size%spaceDim!=0)
+              {
+                throw INTERP_KERNEL::Exception("Invalid list length ! Must be a multiple of self.getMesh().getSpaceDimension() !");
+              }
+            return self->getValueOnMulti(tmp,nbOfPoints);
+          }
+        else
+          {
+            DataArrayDouble *da2=reinterpret_cast< DataArrayDouble * >(da);
+            if(!da2)
+              throw INTERP_KERNEL::Exception("Not null DataArrayDouble instance expected !");
+            da2->checkAllocated();
+            int size=da2->getNumberOfTuples();
+            int nbOfCompo=da2->getNumberOfComponents();
+            if(nbOfCompo!=self->getMesh()->getSpaceDimension())
+              {
+                throw INTERP_KERNEL::Exception("Invalid DataArrayDouble nb of components ! Expected same as self.getMesh().getSpaceDimension() !");
+              }
+            return self->getValueOnMulti(da2->getConstPointer(),size);
+          }
+      }
+
       PyObject *getValueOn(PyObject *sl, double time) const throw(INTERP_KERNEL::Exception)
       {
         int sz;
index efcb3364b780fdb67f754f2a1fc33d6555ad2b78..ee379906fcec267268b678f7bfbd2255b776d06a 100644 (file)
@@ -6154,6 +6154,13 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         self.assertTrue(not m1.isEqual(m2,1e-12));
         m2.setTime(3.14,6,7);
         self.assertTrue(m1.isEqual(m2,1e-12));
+        m1.setTimeUnit("ms");
+        self.assertTrue(m1.getTimeUnit()=="ms");
+        m1.setTimeUnit("us");
+        self.assertTrue(m1.getTimeUnit()=="us");
+        self.assertTrue(not m1.isEqual(m2,1e-12));
+        m2.setTimeUnit("us");
+        self.assertTrue(m1.isEqual(m2,1e-12));
         m2.setTime(3.14,6,8);
         self.assertTrue(not m1.isEqual(m2,1e-12));
         m2.setTime(3.14,7,7);
@@ -6347,6 +6354,209 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         self.assertTrue(vs[1]=="m^2/kJ");
         self.assertTrue(vs[2]=="MW/s");
         pass
+
+    def testGaussCoordinates1(self):
+        #Testing 1D cell types
+        m1=MEDCouplingDataForTest.build1DMultiTypes_1();
+        f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME);
+        f.setMesh(m1);
+        wg1=[0.3];
+        gsCoo1=[0.2];
+        refCoo1=[-1.0,1.0];
+        f.setGaussLocalizationOnType(NORM_SEG2,refCoo1,gsCoo1,wg1);
+        wg2=wg1;
+        gsCoo2=[0.2];
+        refCoo2=[-1.0,1.0,0.0];
+        f.setGaussLocalizationOnType(NORM_SEG3,refCoo2,gsCoo2,wg2);
+        #
+        resToTest=f.getLocalizationOfDiscr();
+        self.assertEqual(3,resToTest.getNumberOfComponents());
+        self.assertEqual(2,resToTest.getNumberOfTuples());
+        expected1=[0.6,0.6,0.6, 0.6,0.6,0.6]
+        for i in xrange(6):
+            self.assertAlmostEqual(expected1[i],resToTest.getIJ(0,i),14);
+            pass
+        #
+        #Testing 2D cell types
+        m2=MEDCouplingDataForTest.build2DMultiTypes_1();
+        f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME);
+        f.setMesh(m2);
+        wg3=[0.3,0.3];
+        tria3CooGauss=[ 0.1, 0.8, 0.2, 0.7 ]
+        gsCoo3=tria3CooGauss
+        tria3CooRef=[ 0.0, 0.0, 1.0 , 0.0, 0.0, 1.0 ]
+        refCoo3=tria3CooRef;
+        f.setGaussLocalizationOnType(NORM_TRI3,refCoo3,gsCoo3,wg3);
+        wg4=[0.3,0.3,0.3];
+        tria6CooGauss=[ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4 ]
+        gsCoo4=tria6CooGauss;
+        tria6CooRef=[0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0, 0.5, 0.5, 0.0, 0.5]
+        refCoo4=tria6CooRef;
+        f.setGaussLocalizationOnType(NORM_TRI6,refCoo4,gsCoo4,wg4);
+        wg5=[0.3,0.3,0.3,0.3];
+        quad4CooGauss=[ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4, 0.15, 0.27 ]
+        gsCoo5=quad4CooGauss;
+        quad4CooRef=[-1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0]
+        refCoo5=quad4CooRef;
+        f.setGaussLocalizationOnType(NORM_QUAD4,refCoo5,gsCoo5,wg5);
+        wg6=[0.3,0.3,0.3,0.3];
+        quad8CooGauss=[ 0.34, 0.16, 0.21, 0.3, 0.23, 0.4, 0.14, 0.37 ]
+        gsCoo6=quad8CooGauss;
+        quad8CooRef=[ -1.0, -1.0, 1.0, -1.0, 1.0,  1.0, -1.0,  1.0, 0.0, -1.0, 1.0,  0.0, 0.0,  1.0, -1.0,  0.0]
+        refCoo6=quad8CooRef;
+        f.setGaussLocalizationOnType(NORM_QUAD8,refCoo6,gsCoo6,wg6);
+        #
+        resToTest=f.getLocalizationOfDiscr();
+        self.assertEqual(3,resToTest.getNumberOfComponents());
+        self.assertEqual(13,resToTest.getNumberOfTuples());#2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8
+        expected2=[5.1,1.55,0.0, 4.7,1.65,0.0,
+                   2.32,1.52,0.0, 1.6,1.32,0.0, 3.52,1.26,0.0,#TRI6
+                   2.6,1.6,0.0, 2.4,1.8,0.0, 2.4,1.2,0.0, 2.3,1.46,0.0,#QUAD4
+                   2.32,2.68,0.0, 2.6,2.42,0.0, 2.8,2.46,0.0, 2.74,2.28,0.0 ];#QUAD8
+        for i in xrange(39):
+            self.assertAlmostEqual(expected2[i],resToTest.getIJ(0,i),14);
+            pass
+        #
+        #Testing 3D cell types
+        m3=MEDCouplingDataForTest.build3DMultiTypes_1();
+        f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME);
+        f.setMesh(m3);
+        #
+        wg7=[0.3];
+        tetra4CooGauss=[0.34, 0.16, 0.21]
+        gsCoo7=tetra4CooGauss;
+        tetra4CooRef=[0.0,1.0,0.0, 0.0,0.0,1.0, 0.0,0.0,0.0, 1.0,0.0,0.0]
+        refCoo7=tetra4CooRef;
+        f.setGaussLocalizationOnType(NORM_TETRA4,refCoo7,gsCoo7,wg7);
+        wg8=[0.3];
+        tetra10CooGauss=[0.2, 0.3, 0.1]
+        gsCoo8=tetra10CooGauss;
+        tetra10CooRef=[0.0,1.0,0.0, 0.0,0.0,0.0, 0.0,0.0,1.0, 1.0,0.0,0.0, 0.0,0.5,0.0, 0.0,0.0,0.5, 0.0,0.5,0.5, 0.5,0.5,0.0, 0.5,0.0,0.0, 0.5,0.0,0.5]
+        refCoo8=tetra10CooRef;
+        f.setGaussLocalizationOnType(NORM_TETRA10,refCoo8,gsCoo8,wg8);
+        wg9=[0.3];
+        pyra5CooGauss=[0.2, 0.3, 0.1]
+        gsCoo9=pyra5CooGauss;
+        pyra5CooRef=[1.0,0.0,0.0, 0.0,1.0,0.0, -1.0,0.0,0.0, 0.0,-1.0,0.0, 0.0,0.0,1.0]
+        refCoo9=pyra5CooRef;
+        f.setGaussLocalizationOnType(NORM_PYRA5,refCoo9,gsCoo9,wg9);
+        wg10=[0.3];
+        pyra13CooGauss=[0.1, 0.2, 0.7]
+        gsCoo10=pyra13CooGauss;
+        pyra13CooRef=[1.0,0.0,0.0, 0.0,1.0,0.0,-1.0,0.0,0.0,0.0,-1.0,0.0,0.0,0.0,1.0,0.5,0.5,0.0,-0.5,0.5,0.0,-0.5,-0.5,0.0,0.5,-0.5,0.0,0.5,0.0,0.5,0.0,0.5,0.5,-0.5,0.0,0.5,0.0,-0.5,0.5]
+        refCoo10=pyra13CooRef;
+        f.setGaussLocalizationOnType(NORM_PYRA13,refCoo10,gsCoo10,wg10);
+        wg11=[0.3];
+        penta6CooGauss=[0.2, 0.3, 0.1]
+        gsCoo11=penta6CooGauss;
+        penta6CooRef=[-1.0,1.0,0.0,-1.0,-0.0,1.0,-1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0]
+        refCoo11=penta6CooRef;
+        f.setGaussLocalizationOnType(NORM_PENTA6,refCoo11,gsCoo11,wg11);
+        wg12=[0.3];
+        penta15CooGauss=[0.2, 0.3,0.15]
+        gsCoo12=penta15CooGauss;
+        penta15CooRef=[-1.0,1.0,0.0,-1.0,0.0,1.0,-1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,-1.0,0.5,0.5,-1.0,0.0,0.5,-1.0,0.5,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.5,0.5,1.0,0.0, 0.5,1.0,0.5,0.0]
+        refCoo12=penta15CooRef;
+        f.setGaussLocalizationOnType(NORM_PENTA15,refCoo12,gsCoo12,wg12);
+        wg13=[0.3];
+        hexa8CooGauss=[0.2,0.3,0.15]
+        gsCoo13=hexa8CooGauss;
+        hexa8CooRef=[-1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,1.0]
+        refCoo13=hexa8CooRef;
+        f.setGaussLocalizationOnType(NORM_HEXA8,refCoo13,gsCoo13,wg13);
+        wg14=[0.3];
+        hexa20CooGauss=[0.11,0.3,0.55]
+        gsCoo14=hexa20CooGauss;
+        hexa20CooRef=[-1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,1.0,0.0,-1.0,-1.0,1.0,0.0,-1.0,0.0,1.0,-1.0,-1.0,0.0,-1.0,-1.0,-1.0,0.0,1.0,-1.0,0.0,1.0,1.0,0.0,-1.0,1.0,0.0,0.0,-1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,-1.0,0.0,1.0]
+        refCoo14=hexa20CooRef;
+        f.setGaussLocalizationOnType(NORM_HEXA20,refCoo14,gsCoo14,wg14);
+        #
+        resToTest=f.getLocalizationOfDiscr();
+        self.assertEqual(3,resToTest.getNumberOfComponents());
+        self.assertEqual(8,resToTest.getNumberOfTuples());#2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8
+        expected3=[1.312,3.15,1.02, 0.56,3.3,0.6, 2.18,1.1,0.2, 1.18,1.54,0.98, 1.56,0.3,3.6, 1.613,0.801,4.374, 2.6,2.4,2.3, 2.31232,2.3933985,1.553255]
+        for i in xrange(24):
+            self.assertAlmostEqual(expected3[i],resToTest.getIJ(0,i),14);
+            pass
+        #
+        pass
+
+    def testGetValueOn2(self):
+        m=MEDCouplingDataForTest.build2DTargetMesh_1();
+        f=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
+        f.setMesh(m);
+        arr=DataArrayDouble.New();
+        nbOfCells=m.getNumberOfCells();
+        f.setArray(arr);
+        values1=[7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.]
+        arr.setValues(values1,nbOfCells,3);
+        loc=[-0.05,-0.05, 0.55,-0.25, 0.55,0.15, -0.05,0.45, 0.45,0.45]
+        f.checkCoherency();
+        locs=f.getValueOnMulti(loc);
+        self.assertEqual(5,locs.getNumberOfTuples());
+        self.assertEqual(3,locs.getNumberOfComponents());
+        for j in xrange(15):
+            self.assertAlmostEqual(values1[j],locs.getIJ(0,j),12);
+            pass
+        # Testing ON_NODES
+        f=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME);
+        f.setMesh(m);
+        arr=DataArrayDouble.New();
+        nbOfNodes=m.getNumberOfNodes();
+        f.setArray(arr);
+        values2=[7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.,12.,112.,10012.,13.,113.,10013.,14.,114.,10014.,15.,115.,10015.]
+        arr.setValues(values2,nbOfNodes,3);
+        loc2=[0.5432,-0.2432, 0.5478,0.1528, 0.5432,-0.2432, 0.5432,-0.2432]
+        expected2=[9.0272, 109.0272, 10009.0272, 11.4124,111.4124,10011.4124, 9.0272, 109.0272, 10009.0272, 9.0272, 109.0272, 10009.0272]
+        f.checkCoherency();
+        loc3=DataArrayDouble.New()
+        loc3.setValues(loc2,4,2);
+        locs=f.getValueOnMulti(loc3);
+        self.assertEqual(4,locs.getNumberOfTuples());
+        self.assertEqual(3,locs.getNumberOfComponents());
+        for i in xrange(12):
+            self.assertAlmostEqual(expected2[i],locs.getIJ(0,i),12);
+            pass
+        #
+        pass
+
+    def testDAIGetIdsNotEqual1(self):
+        d=DataArrayInt.New();
+        vals1=[2,3,5,6,8,5,5,6,1,-5]
+        d.setValues(vals1,10,1);
+        d2=d.getIdsNotEqual(5);
+        self.assertEqual(7,d2.getNumberOfTuples());
+        self.assertEqual(1,d2.getNumberOfComponents());
+        expected1=[0,1,3,4,7,8,9]
+        for i in xrange(7):
+            self.assertEqual(expected1[i],d2.getIJ(0,i));
+            pass
+        d.rearrange(2);
+        self.assertRaises(InterpKernelException,d.getIdsNotEqual,5);
+        vals2=[-4,5,6]
+        vals3=vals2;
+        d.rearrange(1);
+        d3=d.getIdsNotEqualList(vals3);
+        self.assertEqual(5,d3.getNumberOfTuples());
+        self.assertEqual(1,d3.getNumberOfComponents());
+        expected2=[0,1,4,8,9]
+        for i in xrange(5):
+            self.assertEqual(expected2[i],d3.getIJ(0,i));
+            pass
+        pass
+
+    def testDAIComputeOffsets1(self):
+        d=DataArrayInt.New();
+        vals1=[3,5,1,2,0,8]
+        expected1=[0,3,8,9,11,11]
+        d.setValues(vals1,6,1);
+        d.computeOffsets();
+        self.assertEqual(6,d.getNumberOfTuples());
+        self.assertEqual(1,d.getNumberOfComponents());
+        for i in xrange(6):
+            self.assertEqual(expected1[i],d.getIJ(0,i));
+            pass
+        pass
     
     def setUp(self):
         pass
index 99299d48c7dfe17dec859f7a7407454ace53b4ba..9607373a96ab927a5a069feffb63a8ca3ce60bbb 100644 (file)
@@ -430,6 +430,84 @@ class MEDCouplingDataForTest:
         f4.setName("f4");
         return [f0,f1,f2,f3,f4]
 
+    def build1DMultiTypes_1(self):
+        mesh=MEDCouplingUMesh.New("Multi1DMesh",1);
+        coo=MEDCouplingDataForTest.buildCoordsForMultiTypes_1();
+        conn=[0,2, 0,2,1]
+        mesh.allocateCells(2);
+        mesh.insertNextCell(NORM_SEG2,2,conn[0:2])
+        mesh.insertNextCell(NORM_SEG3,3,conn[2:5])
+        mesh.finishInsertingCells();
+        mesh.setCoords(coo);
+        return mesh;
+
+    def build2DMultiTypes_1(self):
+        mesh=MEDCouplingUMesh.New("Multi2DMesh",2);
+        coo=MEDCouplingDataForTest.buildCoordsForMultiTypes_1();
+        conn=[3,4,5, 3,4,5,6,7,8, 0,9,10,11, 0,9,10,11,12,13,14,15]
+        mesh.allocateCells(4);
+        mesh.insertNextCell(NORM_TRI3,3,conn[0:3])
+        mesh.insertNextCell(NORM_TRI6,6,conn[3:9])
+        mesh.insertNextCell(NORM_QUAD4,4,conn[9:13])
+        mesh.insertNextCell(NORM_QUAD8,8,conn[13:21])
+        mesh.finishInsertingCells();
+        mesh.setCoords(coo);
+        return mesh;
+
+    def build3DMultiTypes_1(self):
+        mesh=MEDCouplingUMesh.New("Multi3DMesh",3);
+        coo=MEDCouplingDataForTest.buildCoordsForMultiTypes_1();
+        conn=[0,16,17,18,
+              0,16,17,18,19,20,21,22,23,24,
+              0,11,10,9,25,
+              0,11,10,9,25,15,14,13,12,26,27,28,29,
+              0,30,31,32,33,34,
+              0,30,31,32,33,34,35,36,37,38,39,40,41,42,43,
+              0,9,10,11,44,45,46,47,
+              0,9,10,11,44,45,46,47,12,13,14,15,48,49,50,51,52,53,54,55 ];
+        mesh.allocateCells(8);
+        mesh.insertNextCell(NORM_TETRA4,4,conn[0:4])
+        mesh.insertNextCell(NORM_TETRA10,10,conn[4:14])
+        mesh.insertNextCell(NORM_PYRA5,5,conn[14:19])
+        mesh.insertNextCell(NORM_PYRA13,13,conn[19:32])
+        mesh.insertNextCell(NORM_PENTA6,6,conn[32:38])
+        mesh.insertNextCell(NORM_PENTA15,15,conn[38:53])
+        mesh.insertNextCell(NORM_HEXA8,8,conn[53:61])
+        mesh.insertNextCell(NORM_HEXA20,20,conn[61:81])
+        mesh.finishInsertingCells();
+        mesh.setCoords(coo);
+        return mesh;
+
+    def buildCoordsForMultiTypes_1(self):
+        coords=DataArrayDouble.New();
+        data=[0.0,0.0,0.0, 0.5,0.5,0.5, 1.0,1.0,1.0, 1.0,1.0,0.0, 2.0,2.5,0.0, 6.0,1.5,0.0, 1.0,2.0,0.0, 4.5,2.5,0.0, 4.0,0.5,0.0, 0.0,4.0,0.0, 4.0,4.0,0.0, 4.0,0.0,0.0, 0.0,2.0,0.0, 2.0,4.0,0.0, 4.0,2.0,0.0, 2.0,0.0,0.0, 0.0,6.0,0.0, 3.0,3.0,0.0, 1.3,3.0,3.0, 0.0,3.0,0.0, 1.5,4.5,0.0, 1.5,1.5,0.0, 0.65,1.5,1.5, 0.65,4.5,1.5, 2.15,3.0,1.5, 2.0,2.0,2.0, 3.0,1.0,1.0, 3.0,3.0,1.0, 1.0,3.0,1.0, 1.0,1.0,1.0, 0.0,3.0,0.0, 2.0,0.0,0.0, 0.0,0.0,6.0, 0.0,3.0,6.0, 3.0,0.0,6.0, 0.0,1.5,0.0, 1.5,1.5,0.0, 1.5,0.0,0.0, 0.0,1.5,6.0, 1.5,1.5,6.0, 1.5,0.0,6.0, 0.0,0.0,3.0, 0.0,3.0,3.0, 3.0,0.0,3.0, 0.0,0.0,4.0, 0.0,4.0,4.0, 4.0,4.0,4.0, 4.0,0.0,4.0, 0.0,2.0,4.0, 2.0,4.0,4.0, 4.0,2.0,4.0, 2.0,0.0,4.0, 0.0,0.0,2.0, 0.0,4.0,2.0, 4.0,4.0,2.0, 4.0,0.0,2.0]
+        coords.setValues(data,56,3);
+        coords.setInfoOnComponent(0,"X (cm)");
+        coords.setInfoOnComponent(1,"Y (cm)");
+        coords.setInfoOnComponent(2,"Z (cm)");
+        return coords
+
+    def buildHexa8Mesh_1(self):
+        mesh=MEDCouplingUMesh.New("Hexa8Only",3);
+        coo=DataArrayDouble.New();
+        coords=[0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, 0.5, 1.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 1.0, 0.5, 0.5, 0.0, 1.0, 0.5, 0.5, 1.0, 0.5, 1.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.5, 0.5, 1.0, 1.0, 0.5, 1.0, 0.0, 1.0, 1.0, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0]
+        coo.setValues(coords,27,3);
+        conn=[3,12,13,4,0,9,10,1,
+              4,13,14,5,1,10,11,2,
+              6,15,16,7,3,12,13,4,
+              7,16,17,8,4,13,14,5,
+              12,21,22,13,9,18,19,10,
+              13,22,23,14,10,19,20,11,
+              15,24,25,16,12,21,22,13,
+              16,25,26,17,13,22,23,14];
+        mesh.allocateCells(8);
+        for i in xrange(8):
+            mesh.insertNextCell(NORM_HEXA8,8,conn[8*i:8*(i+1)])
+            pass
+        mesh.finishInsertingCells();
+        mesh.setCoords(coo);
+        return mesh;
+
     build2DTargetMesh_1=classmethod(build2DTargetMesh_1)
     build2DSourceMesh_1=classmethod(build2DSourceMesh_1)
     build3DTargetMesh_1=classmethod(build3DTargetMesh_1)
@@ -446,4 +524,9 @@ class MEDCouplingDataForTest:
     build2DTargetMesh_4=classmethod(build2DTargetMesh_4)
     buildMultiFields_1=classmethod(buildMultiFields_1)
     buildMultiFields_2=classmethod(buildMultiFields_2)
+    build1DMultiTypes_1=classmethod(build1DMultiTypes_1)
+    build2DMultiTypes_1=classmethod(build2DMultiTypes_1)
+    build3DMultiTypes_1=classmethod(build3DMultiTypes_1)
+    buildCoordsForMultiTypes_1=classmethod(buildCoordsForMultiTypes_1)
+    buildHexa8Mesh_1=classmethod(buildHexa8Mesh_1)
     pass