]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Checks the condensation of IMesh from fine to coarse.
authorgeay <anthony.geay@cea.fr>
Fri, 16 May 2014 15:59:19 +0000 (17:59 +0200)
committergeay <anthony.geay@cea.fr>
Fri, 16 May 2014 15:59:19 +0000 (17:59 +0200)
src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx
src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx
src/MEDCoupling/MEDCouplingIMesh.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index 08f1d1f59e4837fe82152148294eeca662013921..bf06a977ecd7c113e4c83167566b785c8a665c2c 100644 (file)
@@ -89,7 +89,7 @@ std::vector<const BigMemoryObject *> MEDCouplingCartesianAMRPatch::getDirectChil
 
 
 MEDCouplingCartesianAMRMesh *MEDCouplingCartesianAMRMesh::New(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
-                                              const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop)
+                                                              const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop)
 {
   return new MEDCouplingCartesianAMRMesh(meshName,spaceDim,nodeStrctStart,nodeStrctStop,originStart,originStop,dxyzStart,dxyzStop);
 }
@@ -210,7 +210,7 @@ MEDCouplingUMesh *MEDCouplingCartesianAMRMesh::buildUnstructured() const
 }
 
 MEDCouplingCartesianAMRMesh::MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
-                                         const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop):_father(0)
+                                                         const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop):_father(0)
 {
   _mesh=MEDCouplingIMesh::New(meshName,spaceDim,nodeStrctStart,nodeStrctStop,originStart,originStop,dxyzStart,dxyzStop);
 }
index 46cee80fc78492df082a62c8f1a206b630c6a269..3815681b6db7c6ddb437b8a5d8fae0f9db55d2c5 100644 (file)
@@ -68,7 +68,7 @@ namespace ParaMEDMEM
   {
   public:
     MEDCOUPLING_EXPORT static MEDCouplingCartesianAMRMesh *New(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
-                                                       const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
+                                                               const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
     MEDCOUPLING_EXPORT int getSpaceDimension() const;
     MEDCOUPLING_EXPORT int getMaxNumberOfLevelsRelativeToThis() const;
     MEDCOUPLING_EXPORT int getNumberOfCellsAtCurrentLevel() const;
@@ -86,7 +86,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const;
   private:
     MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
-                        const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
+                                const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
     MEDCouplingCartesianAMRMesh(MEDCouplingCartesianAMRMesh *father, MEDCouplingIMesh *mesh);
     void checkPatchId(int patchId) const;
   protected:
index 16dc17763bc9d3ad709b6ed5f1783e1e12e23b00..0f64ac2c6c29e7dbc2163162fcf4a0b032d4134f 100644 (file)
@@ -222,34 +222,37 @@ void MEDCouplingIMesh::CondenseFineToCoarse(DataArrayDouble *coarseDA, const std
       throw INTERP_KERNEL::Exception(oss.str().c_str());
     }
   int nbTuplesFine(fineDA->getNumberOfTuples());
-  if(nbTuplesFine%nbOfTuplesInCoarseExp!=0)
+  if(nbTuplesFine%nbOfTuplesInFineExp!=0)
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : Invalid nb of tuples in fine DataArray regarding its structure !");
   int factN(nbTuplesFine/nbOfTuplesInFineExp);
   int fact(FindIntRoot(factN,meshDim));
   // to improve use jump-iterator. Factorizes with SwitchOnIdsFrom BuildExplicitIdsFrom
-  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids(BuildExplicitIdsFrom(coarseSt,fineLocInCoarse));
-  const int *idsPtr(ids->begin());
   double *outPtr(coarseDA->getPointer());
   const double *inPtr(fineDA->begin());
-  coarseDA->setPartOfValuesSimple3(0.,ids->begin(),ids->end(),0,nbCompo,1);
   //
   switch(meshDim)
   {
     case 2:
       {
-        int kk(0);
         std::vector<int> dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
-        for(int it=0;it<dims[1];it++)
+        int kk(fineLocInCoarse[0].first+coarseSt[0]*fineLocInCoarse[1].first);
+        for(int j=0;j<dims[1];j++)
           {
-            for(int i=0;i<fact;i++)
+            for(int jfact=0;jfact<fact;jfact++)
               {
-                for(int j=0;j<dims[0];j++,inPtr+=fact)
+                for(int i=0;i<dims[0];i++)
                   {
-                    double *loc(outPtr+idsPtr[kk+j]*nbCompo);
-                    std::transform(inPtr,inPtr+fact,loc,loc,std::plus<double>());
+                    double *loc(outPtr+(kk+i)*nbCompo);
+                    for(int ifact=0;ifact<fact;ifact++,inPtr+=nbCompo)
+                      {
+                        if(jfact!=0 || ifact!=0)
+                          std::transform(inPtr,inPtr+nbCompo,loc,loc,std::plus<double>());
+                        else
+                          std::copy(inPtr,inPtr+nbCompo,loc);
+                      }
                   }
               }
-            kk+=it;
+            kk+=coarseSt[0];
           }
         break;
       }
index aa6ee06da602277f4b5cf451ef585fb475fb68df..25fe05512bc237adae02255148f5c3630ebe24c3 100644 (file)
@@ -15076,6 +15076,14 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         self.assertTrue(m2.getData().isEqual(DataArrayDouble([29,37,37,62]),1e-12))
         pass
 
+    def testAMR2(self):
+        """ Test condensation of fine IMesh instance into a coarse one, with a factor. See testRemapperAMR1 in MEDCouplingRemapperTest.py file to see how the expected value is obtained."""
+        coarse=DataArrayDouble(35) ; coarse.iota(0) #X=5,Y=7
+        fine=DataArrayDouble(3*2*4*4) ; fine.iota(0) #X=3,Y=2 refined by 4
+        MEDCouplingIMesh.CondenseFineToCoarse(coarse,[5,7],fine,[(1,4),(2,4)])
+        self.assertTrue(coarse.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,312,376,440,14,15,1080,1144,1208,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34]),1e-12))
+        pass
+
     def setUp(self):
         pass
     pass