From 3c71ee12693701a7e63e2668d26e2632afe812fa Mon Sep 17 00:00:00 2001 From: geay Date: Fri, 16 May 2014 17:59:19 +0200 Subject: [PATCH] Checks the condensation of IMesh from fine to coarse. --- .../MEDCouplingCartesianAMRMesh.cxx | 4 +-- .../MEDCouplingCartesianAMRMesh.hxx | 4 +-- src/MEDCoupling/MEDCouplingIMesh.cxx | 25 +++++++++++-------- src/MEDCoupling_Swig/MEDCouplingBasicsTest.py | 8 ++++++ 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx index 08f1d1f59..bf06a977e 100644 --- a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx @@ -89,7 +89,7 @@ std::vector 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); } diff --git a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx index 46cee80fc..3815681b6 100644 --- a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx +++ b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx @@ -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: diff --git a/src/MEDCoupling/MEDCouplingIMesh.cxx b/src/MEDCoupling/MEDCouplingIMesh.cxx index 16dc17763..0f64ac2c6 100644 --- a/src/MEDCoupling/MEDCouplingIMesh.cxx +++ b/src/MEDCoupling/MEDCouplingIMesh.cxx @@ -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 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 dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); - for(int it=0;it()); + double *loc(outPtr+(kk+i)*nbCompo); + for(int ifact=0;ifact()); + else + std::copy(inPtr,inPtr+nbCompo,loc); + } } } - kk+=it; + kk+=coarseSt[0]; } break; } diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index aa6ee06da..25fe05512 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -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 -- 2.39.2