From: geay Date: Thu, 5 Jun 2014 09:33:18 +0000 (+0200) Subject: First test of synchronization of patches each other. X-Git-Tag: V7_5_0a1~37^2~19 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1422ee86c422b7dda83f8ff17b3a6368963f6b47;p=modules%2Fmed.git First test of synchronization of patches each other. --- diff --git a/src/MEDCoupling/MEDCouplingAMRAttribute.cxx b/src/MEDCoupling/MEDCouplingAMRAttribute.cxx index a91750d89..e5701be79 100644 --- a/src/MEDCoupling/MEDCouplingAMRAttribute.cxx +++ b/src/MEDCoupling/MEDCouplingAMRAttribute.cxx @@ -673,32 +673,29 @@ void MEDCouplingAMRAttribute::synchronizeCoarseToFine() } /*! - * This method performs coarse to fine spread only in the ghost zone. + * This method synchronizes the ghost zone of all patches (excepted the god father one). + * This method operates in 4 steps. Larger is the number of steps more accurate is the information in the ghost zone. + * + * - firstly coarse to fine with no interactions between brother patches. + * - secondly connected brother patches in a same master patch are updated. + * - thirdly connected nephew patches are updated each other. + * - forthly nth generation cousin patches are updated each other. + * * This method makes the hypothesis that \a this has been allocated before using MEDCouplingAMRAttribute::alloc method. * So if \a _ghost_lev == 0 this method has no effect. */ -void MEDCouplingAMRAttribute::synchronizeCoarseToFineOnlyInGhostZone() +void MEDCouplingAMRAttribute::synchronizeAllGhostZones() { if(_levs.empty()) - throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::synchronizeCoarseToFineOnlyInGhostZone : not any levels in this !"); + throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::synchronizeFineEachOther : not any levels in this !"); + // 1st - synchronize from coarse to the finest all the patches (excepted the god father one) std::size_t sz(_levs.size()); - // for(std::size_t i=1;isynchronizeFineEachOther(_ghost_lev,_neighbors[i]); } - // 2nd - mixed level + // 3rd - mixed level for(std::vector< std::pair >::const_iterator it=_mixed_lev_neighbors.begin();it!=_mixed_lev_neighbors.end();it++) { const DataArrayDoubleCollection *firstDAC(&findCollectionAttachedTo((*it).first->getMesh())),*secondDAC(&findCollectionAttachedTo((*it).second->getMesh())); DataArrayDoubleCollection::SynchronizeGhostZoneOfOneUsingTwo(_ghost_lev,(*it).first,firstDAC,(*it).second,secondDAC); } - // 3td - same level but with far ancestor. + // 4th - same level but with far ancestor. for(std::size_t i=1;i ancestorsOfThis; - const MEDCouplingCartesianAMRMeshGen *work(getMesh()),*work2(0); - ancestorsOfThis.push_back(work); - while(work) - { - work=work->getFather(); - if(work) - ancestorsOfThis.push_back(work); - } - // - work=other->getMesh(); - bool found(false); - std::size_t levThis(0),levOther(0); - while(work && !found) - { - work2=work; - work=work->getFather(); - if(work) - { - levOther++; - std::vector::iterator it(std::find(ancestorsOfThis.begin(),ancestorsOfThis.end(),work)); - if(it!=ancestorsOfThis.end()) - { - levThis=std::distance(ancestorsOfThis.begin(),it); - found=true; - } - } - } - if(!found) - throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRPatch::isInMyNeighborhoodDiffLev : no common ancestor found !"); - if(levThis<=levOther) - throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRPatch::isInMyNeighborhoodDiffLev : this method is not called correctly !"); - // - const MEDCouplingCartesianAMRMeshGen *comAncestor(ancestorsOfThis[levThis]); - int idThis(comAncestor->getPatchIdFromChildMesh(ancestorsOfThis[levThis-1])),idOther(comAncestor->getPatchIdFromChildMesh(work2)); - const MEDCouplingCartesianAMRPatch *thisp(comAncestor->getPatch(idThis)),*otherp(comAncestor->getPatch(idOther)); - std::vector offset(ComputeOffsetFromTwoToOne(comAncestor,levOther,thisp,otherp)); - std::vector< std::pair > thispp(thisp->getBLTRRange()),otherpp(MEDCouplingStructuredMesh::TranslateCompactFrmt(otherp->getBLTRRange(),offset)); - // - std::size_t nbOfTurn(levThis-levOther); - for(std::size_t i=0;i > tmp0; - MEDCouplingStructuredMesh::ChangeReferenceFromGlobalOfCompactFrmt(thispp,otherpp,tmp0,false); - otherpp=tmp0; - const MEDCouplingCartesianAMRMeshGen *curAncestor(ancestorsOfThis[levThis-i]); - ApplyFactorsOnCompactFrmt(otherpp,curAncestor->getFactors()); - curAncestor=ancestorsOfThis[levThis-1-i]; - int tmpId(curAncestor->getPatchIdFromChildMesh(ancestorsOfThis[levThis-2-i])); - thispp=curAncestor->getPatch(tmpId)->getBLTRRange(); - } + std::vector< std::pair > thispp,otherpp; + std::vector factors; + ComputeZonesOfTwoRelativeToOneDiffLev(ghostLev,this,other,thispp,otherpp,factors); return IsInMyNeighborhood(ghostLev,thispp,otherpp); } +std::vector MEDCouplingCartesianAMRPatch::computeCellGridSt() const +{ + const MEDCouplingCartesianAMRMeshGen *m(getMesh()); + if(!m) + throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRPatch::computeCellGridSt : no mesh held by this !"); + const MEDCouplingCartesianAMRMeshGen *father(m->getFather()); + if(!father) + throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRPatch::computeCellGridSt : no father help by underlying mesh !"); + const std::vector< std::pair >& bltr(getBLTRRange()); + const std::vector& factors(father->getFactors()); + std::vector ret(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(bltr)); + std::transform(ret.begin(),ret.end(),factors.begin(),ret.begin(),std::multiplies()); + return ret; +} + bool MEDCouplingCartesianAMRPatch::IsInMyNeighborhood(int ghostLev, const std::vector< std::pair >& p1, const std::vector< std::pair >& p2) { std::size_t thispsize(p1.size()); @@ -325,32 +292,6 @@ void MEDCouplingCartesianAMRPatch::UpdateNeighborsOfOneWithTwo(int ghostLev, con UpdateNeighborsOfOneWithTwoInternal(ghostLev,factors,p1BLTR,p2BLTR,dataOnP1,dataOnP2); } -void MEDCouplingCartesianAMRPatch::UpdateNeighborsOfOneWithTwoInternal(int ghostLev, const std::vector& factors, const std::vector< std::pair >&p1 ,const std::vector< std::pair >&p2, DataArrayDouble *dataOnP1, const DataArrayDouble *dataOnP2) -{//p1=[(1,4),(2,4)] p2=[(4,5),(3,4)] - int dim((int)factors.size()); - std::vector dimsCoarse(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(p1));//[3,2] - std::transform(dimsCoarse.begin(),dimsCoarse.end(),factors.begin(),dimsCoarse.begin(),std::multiplies());//[12,8] - std::transform(dimsCoarse.begin(),dimsCoarse.end(),dimsCoarse.begin(),std::bind2nd(std::plus(),2*ghostLev));//[14,10] - std::vector< std::pair > rangeCoarse(MEDCouplingStructuredMesh::GetCompactFrmtFromDimensions(dimsCoarse));//[(0,14),(0,10)] - std::vector fakeFactors(dim,1); - // - std::vector< std::pair > tmp0,tmp1,tmp2; - MEDCouplingStructuredMesh::ChangeReferenceFromGlobalOfCompactFrmt(p1,p2,tmp0,false);//tmp0=[(3,4),(1,2)] - ApplyFactorsOnCompactFrmt(tmp0,factors);//tmp0=[(12,16),(4,8)] - ApplyGhostOnCompactFrmt(tmp0,ghostLev);//tmp0=[(13,17),(5,9)] - std::vector< std::pair > interstRange(MEDCouplingStructuredMesh::IntersectRanges(tmp0,rangeCoarse));//interstRange=[(13,14),(5,9)] - MEDCouplingStructuredMesh::ChangeReferenceFromGlobalOfCompactFrmt(p2,p1,tmp1,false);//tmp1=[(-3,0),(-1,1)] - ApplyFactorsOnCompactFrmt(tmp1,factors);//tmp1=[(-12,-4),(-4,0)] - MEDCouplingStructuredMesh::ChangeReferenceToGlobalOfCompactFrmt(tmp1,interstRange,tmp2,false);//tmp2=[(1,2),(1,5)] - // - std::vector< std::pair > dimsFine(p2); - ApplyFactorsOnCompactFrmt(dimsFine,factors); - ApplyAllGhostOnCompactFrmt(dimsFine,ghostLev); - // - MEDCouplingAutoRefCountObjectPtr ghostVals(MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(dimsFine),dataOnP2,tmp2)); - MEDCouplingIMesh::CondenseFineToCoarse(dimsCoarse,ghostVals,interstRange,fakeFactors,dataOnP1); -} - /*! * Idem than UpdateNeighborsOfOneWithTwo, except that here \a p1 and \a p2 are not sharing the same direct father. * @@ -367,8 +308,88 @@ void MEDCouplingCartesianAMRPatch::UpdateNeighborsOfOneWithTwoExt(int ghostLev, UpdateNeighborsOfOneWithTwoInternal(ghostLev,p1->getMesh()->getFather()->getFactors(),p1BLTR,p2BLTR,dataOnP1,dataOnP2); } +/*! + * \a p1 is expected to be more refined than \a p2. \a p1 and \a p2 have to share a common ancestor. Compared to UpdateNeighborsOfOneWithTwoExt here \a p1 and \a p2 are \b not at the same level ! + */ void MEDCouplingCartesianAMRPatch::UpdateNeighborsOfOneWithTwoMixedLev(int ghostLev, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2, DataArrayDouble *dataOnP1, const DataArrayDouble *dataOnP2) { + std::vector< std::pair > p1pp,p2pp; + std::vector factors; + ComputeZonesOfTwoRelativeToOneDiffLev(ghostLev,p1,p2,p1pp,p2pp,factors); + // + std::vector dimsP2NotRefined(p2->computeCellGridSt()); + std::vector dimsP2Refined(dimsP2NotRefined); + std::transform(dimsP2NotRefined.begin(),dimsP2NotRefined.end(),factors.begin(),dimsP2Refined.begin(),std::multiplies()); + std::vector< std::pair > p2RefinedAbs(MEDCouplingStructuredMesh::GetCompactFrmtFromDimensions(dimsP2NotRefined)); + std::vector dimsP2RefinedGhost(dimsP2Refined.size()); + std::transform(dimsP2Refined.begin(),dimsP2Refined.end(),dimsP2RefinedGhost.begin(),std::bind2nd(std::plus(),2*ghostLev)); + MEDCouplingAutoRefCountObjectPtr fineP2(DataArrayDouble::New()); fineP2->alloc(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(dimsP2RefinedGhost),dataOnP2->getNumberOfComponents()); + MEDCouplingIMesh::SpreadCoarseToFineGhost(dataOnP2,dimsP2NotRefined,fineP2,p2RefinedAbs,factors,ghostLev); + // + UpdateNeighborsOfOneWithTwoInternal(ghostLev,p1->getMesh()->getFather()->getFactors(),p1pp,p2pp,dataOnP1,fineP2); +} + +/*! + * \a p1 is expected to be more refined than \a p2. \a p1 and \a p2 have to share a common ancestor. Compared to UpdateNeighborsOfOneWithTwoExt here \a p1 and \a p2 are \b not at the same level ! + * This method has 3 outputs. 2 two first are the resp the position of \a p1 and \a p2 relative to \a p1. And \a factToApplyOn2 is the coeff of refinement to be applied on \a p2 to be virtualy + * on the same level as \a p1. + */ +void MEDCouplingCartesianAMRPatch::ComputeZonesOfTwoRelativeToOneDiffLev(int ghostLev, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2, std::vector< std::pair >& p1Zone, std::vector< std::pair >& p2Zone, std::vector& factToApplyOn2) +{ + std::vector ancestorsOfThis; + const MEDCouplingCartesianAMRMeshGen *work(p1->getMesh()),*work2(0); + ancestorsOfThis.push_back(work); + while(work) + { + work=work->getFather(); + if(work) + ancestorsOfThis.push_back(work); + } + // + work=p2->getMesh(); + bool found(false); + std::size_t levThis(0),levOther(0); + while(work && !found) + { + work2=work; + work=work->getFather(); + if(work) + { + levOther++; + std::vector::iterator it(std::find(ancestorsOfThis.begin(),ancestorsOfThis.end(),work)); + if(it!=ancestorsOfThis.end()) + { + levThis=std::distance(ancestorsOfThis.begin(),it); + found=true; + } + } + } + if(!found) + throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRPatch::ComputeZonesOfTwoRelativeToOneDiffLev : no common ancestor found !"); + if(levThis<=levOther) + throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRPatch::ComputeZonesOfTwoRelativeToOneDiffLev : this method is not called correctly !"); + // + const MEDCouplingCartesianAMRMeshGen *comAncestor(ancestorsOfThis[levThis]); + int idThis(comAncestor->getPatchIdFromChildMesh(ancestorsOfThis[levThis-1])),idOther(comAncestor->getPatchIdFromChildMesh(work2)); + const MEDCouplingCartesianAMRPatch *thisp(comAncestor->getPatch(idThis)),*otherp(comAncestor->getPatch(idOther)); + std::vector offset(ComputeOffsetFromTwoToOne(comAncestor,levOther,thisp,otherp)); + p1Zone=thisp->getBLTRRange(); p2Zone=MEDCouplingStructuredMesh::TranslateCompactFrmt(otherp->getBLTRRange(),offset); + factToApplyOn2.resize(p1Zone.size()); std::fill(factToApplyOn2.begin(),factToApplyOn2.end(),1); + // + std::size_t nbOfTurn(levThis-levOther); + for(std::size_t i=0;i > tmp0; + MEDCouplingStructuredMesh::ChangeReferenceFromGlobalOfCompactFrmt(p1Zone,p2Zone,tmp0,false); + p2Zone=tmp0; + const MEDCouplingCartesianAMRMeshGen *curAncestor(ancestorsOfThis[levThis-i]); + ApplyFactorsOnCompactFrmt(p2Zone,curAncestor->getFactors()); + curAncestor=ancestorsOfThis[levThis-1-i]; + const std::vector& factors(curAncestor->getFactors()); + std::transform(factToApplyOn2.begin(),factToApplyOn2.end(),factors.begin(),factToApplyOn2.begin(),std::multiplies()); + int tmpId(curAncestor->getPatchIdFromChildMesh(ancestorsOfThis[levThis-2-i])); + p1Zone=curAncestor->getPatch(tmpId)->getBLTRRange(); + } } std::size_t MEDCouplingCartesianAMRPatch::getHeapMemorySizeWithoutChildren() const @@ -429,6 +450,32 @@ std::vector MEDCouplingCartesianAMRPatch::ComputeOffsetFromTwoToOne(const M return ret; } +void MEDCouplingCartesianAMRPatch::UpdateNeighborsOfOneWithTwoInternal(int ghostLev, const std::vector& factors, const std::vector< std::pair >&p1 ,const std::vector< std::pair >&p2, DataArrayDouble *dataOnP1, const DataArrayDouble *dataOnP2) +{//p1=[(1,4),(2,4)] p2=[(4,5),(3,4)] + int dim((int)factors.size()); + std::vector dimsCoarse(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(p1));//[3,2] + std::transform(dimsCoarse.begin(),dimsCoarse.end(),factors.begin(),dimsCoarse.begin(),std::multiplies());//[12,8] + std::transform(dimsCoarse.begin(),dimsCoarse.end(),dimsCoarse.begin(),std::bind2nd(std::plus(),2*ghostLev));//[14,10] + std::vector< std::pair > rangeCoarse(MEDCouplingStructuredMesh::GetCompactFrmtFromDimensions(dimsCoarse));//[(0,14),(0,10)] + std::vector fakeFactors(dim,1); + // + std::vector< std::pair > tmp0,tmp1,tmp2; + MEDCouplingStructuredMesh::ChangeReferenceFromGlobalOfCompactFrmt(p1,p2,tmp0,false);//tmp0=[(3,4),(1,2)] + ApplyFactorsOnCompactFrmt(tmp0,factors);//tmp0=[(12,16),(4,8)] + ApplyGhostOnCompactFrmt(tmp0,ghostLev);//tmp0=[(13,17),(5,9)] + std::vector< std::pair > interstRange(MEDCouplingStructuredMesh::IntersectRanges(tmp0,rangeCoarse));//interstRange=[(13,14),(5,9)] + MEDCouplingStructuredMesh::ChangeReferenceFromGlobalOfCompactFrmt(p2,p1,tmp1,false);//tmp1=[(-3,0),(-1,1)] + ApplyFactorsOnCompactFrmt(tmp1,factors);//tmp1=[(-12,-4),(-4,0)] + MEDCouplingStructuredMesh::ChangeReferenceToGlobalOfCompactFrmt(tmp1,interstRange,tmp2,false);//tmp2=[(1,2),(1,5)] + // + std::vector< std::pair > dimsFine(p2); + ApplyFactorsOnCompactFrmt(dimsFine,factors); + ApplyAllGhostOnCompactFrmt(dimsFine,ghostLev); + // + MEDCouplingAutoRefCountObjectPtr ghostVals(MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(dimsFine),dataOnP2,tmp2)); + MEDCouplingIMesh::CondenseFineToCoarse(dimsCoarse,ghostVals,interstRange,fakeFactors,dataOnP1); +} + /*! * \param [in,out] partBeforeFact - the part of a image mesh in compact format that will be put in refined reference. * \param [in] factors - the factors per axis. diff --git a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx index 2064445e4..7d87906c6 100644 --- a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx +++ b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx @@ -79,18 +79,21 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT bool isInMyNeighborhoodDiffLev(const MEDCouplingCartesianAMRPatch *other, int ghostLev) const; // basic set/get MEDCOUPLING_EXPORT const std::vector< std::pair >& getBLTRRange() const { return _bl_tr; } + MEDCOUPLING_EXPORT std::vector computeCellGridSt() const; MEDCOUPLING_EXPORT static bool IsInMyNeighborhood(int ghostLev, const std::vector< std::pair >& p1, const std::vector< std::pair >& p2); // static std::vector< std::vector< std::pair > > FindNeighborsOfSubPatchesOfSameLev(int ghostLev, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2); static void FindNeighborsOfSubPatchesOf(int ghostLev, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2, std::vector< std::pair >& ret); static void UpdateNeighborsOfOneWithTwo(int ghostLev, const std::vector& factors, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2, DataArrayDouble *dataOnP1, const DataArrayDouble *dataOnP2); - static void UpdateNeighborsOfOneWithTwoInternal(int ghostLev, const std::vector& factors, const std::vector< std::pair >&p1 ,const std::vector< std::pair >&p2, DataArrayDouble *dataOnP1, const DataArrayDouble *dataOnP2); static void UpdateNeighborsOfOneWithTwoExt(int ghostLev, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2, DataArrayDouble *dataOnP1, const DataArrayDouble *dataOnP2); static void UpdateNeighborsOfOneWithTwoMixedLev(int ghostLev, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2, DataArrayDouble *dataOnP1, const DataArrayDouble *dataOnP2); + private: + static void ComputeZonesOfTwoRelativeToOneDiffLev(int ghostLev, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2, std::vector< std::pair >& p1Zone, std::vector< std::pair >& p2Zone, std::vector& factToApplyOn2); private: std::size_t getHeapMemorySizeWithoutChildren() const; static const MEDCouplingCartesianAMRMeshGen *FindCommonAncestor(const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2, int& lev); static std::vector ComputeOffsetFromTwoToOne(const MEDCouplingCartesianAMRMeshGen *comAncestor, int lev, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2); + static void UpdateNeighborsOfOneWithTwoInternal(int ghostLev, const std::vector& factors, const std::vector< std::pair >&p1 ,const std::vector< std::pair >&p2, DataArrayDouble *dataOnP1, const DataArrayDouble *dataOnP2); public: static void ApplyFactorsOnCompactFrmt(std::vector< std::pair >& partBeforeFact, const std::vector& factors); static void ApplyGhostOnCompactFrmt(std::vector< std::pair >& partBeforeFact, int ghostSize); @@ -117,8 +120,7 @@ namespace ParaMEDMEM public: MEDCOUPLING_EXPORT virtual void synchronizeFineToCoarse() = 0; MEDCOUPLING_EXPORT virtual void synchronizeCoarseToFine() = 0; - MEDCOUPLING_EXPORT virtual void synchronizeCoarseToFineOnlyInGhostZone() = 0; - MEDCOUPLING_EXPORT virtual void synchronizeFineEachOtherInGhostZone() = 0; + MEDCOUPLING_EXPORT virtual void synchronizeAllGhostZones() = 0; MEDCOUPLING_EXPORT virtual void alloc() = 0; MEDCOUPLING_EXPORT virtual void dealloc() = 0; protected: diff --git a/src/MEDCoupling/MEDCouplingIMesh.cxx b/src/MEDCoupling/MEDCouplingIMesh.cxx index 4b7d62815..3821d60db 100644 --- a/src/MEDCoupling/MEDCouplingIMesh.cxx +++ b/src/MEDCoupling/MEDCouplingIMesh.cxx @@ -593,7 +593,7 @@ void MEDCouplingIMesh::SpreadCoarseToFine(const DataArrayDouble *coarseDA, const * \param [in] facts The refinement coefficient per axis. * \param [in] ghostSize - The size of the ghost zone. The ghost zone is expected to be the same for all axis and both for coarse and fine meshes. * - * \sa CondenseFineToCoarse,SpreadCoarseToFineGhostZone + * \sa CondenseFineToCoarse, SpreadCoarseToFineGhostZone */ void MEDCouplingIMesh::SpreadCoarseToFineGhost(const DataArrayDouble *coarseDA, const std::vector& coarseSt, DataArrayDouble *fineDA, const std::vector< std::pair >& fineLocInCoarse, const std::vector& facts, int ghostSize) { diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 6ca0ec39e..ba123bf6c 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -15244,6 +15244,72 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(lCpy[0].isEqual(da0Exp2,1e-12)) pass + def testSwig2AMR8(self): + """This test checks 'basic' operations for ghost update.""" + ghostSz=1 + amr=MEDCouplingCartesianAMRMesh("",2,[6,7],[0,0],[1,1]) + amr.addPatch([(1,4),(2,4)],[4,4]) + amr.addPatch([(4,5),(3,5)],[4,4]) + amr.addPatch([(0,1),(4,6)],[4,4]) + amr[0].addPatch([(10,12),(5,8)],[2,2]) + amr[1].addPatch([(0,1),(0,5)],[2,2]) + amr[2].addPatch([(3,4),(0,3)],[2,2]) + assert(3==amr.getMaxNumberOfLevelsRelativeToThis()) + att=MEDCouplingAMRAttribute(amr,[("Field",["X"])],ghostSz) + att.alloc() + d=att.getFieldOn(amr,"Field") + assert(56==d.getNumberOfTuples()) + assert(1==d.getNumberOfComponents()) + d.iota() ; d+=0.1 + d0=att.getFieldOn(amr[0].getMesh(),"Field") + assert(140==d0.getNumberOfTuples()) + assert(1==d0.getNumberOfComponents()) + d0.iota() ; d0+=0.2 + d1=att.getFieldOn(amr[1].getMesh(),"Field") + assert(60==d1.getNumberOfTuples()) + assert(1==d1.getNumberOfComponents()) + d1.iota() ; d1+=0.3 + d2=att.getFieldOn(amr[2].getMesh(),"Field") + assert(60==d2.getNumberOfTuples()) + assert(1==d2.getNumberOfComponents()) + d2.iota() ; d2+=0.4 + d00=att.getFieldOn(amr[0][0].getMesh(),"Field") + assert(48==d00.getNumberOfTuples()) + assert(1==d00.getNumberOfComponents()) + d00.iota() ; d00+=0.5 + d10=att.getFieldOn(amr[1][0].getMesh(),"Field") + assert(48==d10.getNumberOfTuples()) + assert(1==d10.getNumberOfComponents()) + d10.iota() ; d10+=0.6 + d20=att.getFieldOn(amr[2][0].getMesh(),"Field") + assert(32==d20.getNumberOfTuples()) + assert(1==d20.getNumberOfComponents()) + d20.iota() ; d20+=0.7 + f=att.buildCellFieldOnRecurseWithoutOverlapWithoutGhost(amr,"Field") + arrExp=DataArrayDouble([8.1,9.1,10.1,11.1,12.1,15.1,16.1,17.1,18.1,19.1,22.1,26.1,29.1,37.1,38.1,39.1,44.1,45.1,46.1,47.1,15.2,16.2,17.2,18.2,19.2,20.2,21.2,22.2,23.2,24.2,25.2,26.2,29.2,30.2,31.2,32.2,33.2,34.2,35.2,36.2,37.2,38.2,39.2,40.2,43.2,44.2,45.2,46.2,47.2,48.2,49.2,50.2,51.2,52.2,53.2,54.2,57.2,58.2,59.2,60.2,61.2,62.2,63.2,64.2,65.2,66.2,67.2,68.2,71.2,72.2,73.2,74.2,75.2,76.2,77.2,78.2,79.2,80.2,81.2,82.2,85.2,86.2,87.2,88.2,89.2,90.2,91.2,92.2,93.2,94.2,99.2,100.2,101.2,102.2,103.2,104.2,105.2,106.2,107.2,108.2,113.2,114.2,115.2,116.2,117.2,118.2,119.2,120.2,121.2,122.2,7.5,8.5,9.5,10.5,13.5,14.5,15.5,16.5,19.5,20.5,21.5,22.5,25.5,26.5,27.5,28.5,31.5,32.5,33.5,34.5,37.5,38.5,39.5,40.5,8.3,9.3,10.3,14.3,15.3,16.3,20.3,21.3,22.3,26.3,27.3,28.3,32.3,33.3,34.3,37.3,38.3,39.3,40.3,43.3,44.3,45.3,46.3,49.3,50.3,51.3,52.3,5.6,6.6,9.6,10.6,13.6,14.6,17.6,18.6,21.6,22.6,25.6,26.6,29.6,30.6,33.6,34.6,37.6,38.6,41.6,42.6,7.4,8.4,9.4,13.4,14.4,15.4,19.4,20.4,21.4,25.4,26.4,27.4,28.4,31.4,32.4,33.4,34.4,37.4,38.4,39.4,40.4,43.4,44.4,45.4,46.4,49.4,50.4,51.4,52.4,5.7,6.7,9.7,10.7,13.7,14.7,17.7,18.7,21.7,22.7,25.7,26.7]) + arrExp.setName("Field") ; arrExp.setInfoOnComponents(["X"]) + assert(f.getArray().isEqual(arrExp,1e-12)) + m=MEDCoupling1SGTUMesh(f.getMesh()) + assert(m.getNodalConnectivity().isEqual(DataArrayInt([1,0,6,7,2,1,7,8,3,2,8,9,4,3,9,10,5,4,10,11,7,6,12,13,8,7,13,14,9,8,14,15,10,9,15,16,11,10,16,17,13,12,18,19,17,16,20,21,19,18,22,23,24,23,27,28,25,24,28,29,26,25,29,30,28,27,32,33,29,28,33,34,30,29,34,35,31,30,35,36,38,37,50,51,39,38,51,52,40,39,52,53,41,40,53,54,42,41,54,55,43,42,55,56,44,43,56,57,45,44,57,58,46,45,58,59,47,46,59,60,48,47,60,61,49,48,61,62,51,50,63,64,52,51,64,65,53,52,65,66,54,53,66,67,55,54,67,68,56,55,68,69,57,56,69,70,58,57,70,71,59,58,71,72,60,59,72,73,61,60,73,74,62,61,74,75,64,63,76,77,65,64,77,78,66,65,78,79,67,66,79,80,68,67,80,81,69,68,81,82,70,69,82,83,71,70,83,84,72,71,84,85,73,72,85,86,74,73,86,87,75,74,87,88,77,76,89,90,78,77,90,91,79,78,91,92,80,79,92,93,81,80,93,94,82,81,94,95,83,82,95,96,84,83,96,97,85,84,97,98,86,85,98,99,87,86,99,100,88,87,100,101,90,89,102,103,91,90,103,104,92,91,104,105,93,92,105,106,94,93,106,107,95,94,107,108,96,95,108,109,97,96,109,110,98,97,110,111,99,98,111,112,100,99,112,113,101,100,113,114,103,102,115,116,104,103,116,117,105,104,117,118,106,105,118,119,107,106,119,120,108,107,120,121,109,108,121,122,110,109,122,123,111,110,123,124,112,111,124,125,116,115,126,127,117,116,127,128,118,117,128,129,119,118,129,130,120,119,130,131,121,120,131,132,122,121,132,133,123,122,133,134,124,123,134,135,125,124,135,136,127,126,137,138,128,127,138,139,129,128,139,140,130,129,140,141,131,130,141,142,132,131,142,143,133,132,143,144,134,133,144,145,135,134,145,146,136,135,146,147,149,148,153,154,150,149,154,155,151,150,155,156,152,151,156,157,154,153,158,159,155,154,159,160,156,155,160,161,157,156,161,162,159,158,163,164,160,159,164,165,161,160,165,166,162,161,166,167,164,163,168,169,165,164,169,170,166,165,170,171,167,166,171,172,169,168,173,174,170,169,174,175,171,170,175,176,172,171,176,177,174,173,178,179,175,174,179,180,176,175,180,181,177,176,181,182,184,183,187,188,185,184,188,189,186,185,189,190,188,187,191,192,189,188,192,193,190,189,193,194,192,191,195,196,193,192,196,197,194,193,197,198,196,195,199,200,197,196,200,201,198,197,201,202,200,199,204,205,201,200,205,206,202,201,206,207,204,203,208,209,205,204,209,210,206,205,210,211,207,206,211,212,209,208,213,214,210,209,214,215,211,210,215,216,212,211,216,217,214,213,218,219,215,214,219,220,216,215,220,221,217,216,221,222,224,223,226,227,225,224,227,228,227,226,229,230,228,227,230,231,230,229,232,233,231,230,233,234,233,232,235,236,234,233,236,237,236,235,238,239,237,236,239,240,239,238,241,242,240,239,242,243,242,241,244,245,243,242,245,246,245,244,247,248,246,245,248,249,248,247,250,251,249,248,251,252,251,250,253,254,252,251,254,255,257,256,260,261,258,257,261,262,259,258,262,263,261,260,264,265,262,261,265,266,263,262,266,267,265,264,268,269,266,265,269,270,267,266,270,271,269,268,273,274,270,269,274,275,271,270,275,276,272,271,276,277,274,273,278,279,275,274,279,280,276,275,280,281,277,276,281,282,279,278,283,284,280,279,284,285,281,280,285,286,282,281,286,287,284,283,288,289,285,284,289,290,286,285,290,291,287,286,291,292,289,288,293,294,290,289,294,295,291,290,295,296,292,291,296,297,299,298,301,302,300,299,302,303,302,301,304,305,303,302,305,306,305,304,307,308,306,305,308,309,308,307,310,311,309,308,311,312,311,310,313,314,312,311,314,315,314,313,316,317,315,314,317,318]))) + assert(m.getCoords().isEqualWithoutConsideringStr(DataArrayDouble([0.,0.,1.,0.,2.,0.,3.,0.,4.,0.,5.,0.,0.,1.,1.,1.,2.,1.,3.,1.,4.,1.,5.,1.,0.,2.,1.,2.,2.,2.,3.,2.,4.,2.,5.,2.,0.,3.,1.,3.,4.,3.,5.,3.,0.,4.,1.,4.,2.,4.,3.,4.,4.,4.,1.,5.,2.,5.,3.,5.,4.,5.,5.,5.,1.,6.,2.,6.,3.,6.,4.,6.,5.,6.,1.,2.,1.25,2.,1.5,2.,1.75,2.,2.,2.,2.25,2.,2.5,2.,2.75,2.,3.,2.,3.25,2.,3.5,2.,3.75,2.,4.,2.,1.,2.25,1.25,2.25,1.5,2.25,1.75,2.25,2.,2.25,2.25,2.25,2.5,2.25,2.75,2.25,3.,2.25,3.25,2.25,3.5,2.25,3.75,2.25,4.,2.25,1.,2.5,1.25,2.5,1.5,2.5,1.75,2.5,2.,2.5,2.25,2.5,2.5,2.5,2.75,2.5,3.,2.5,3.25,2.5,3.5,2.5,3.75,2.5,4.,2.5,1.,2.75,1.25,2.75,1.5,2.75,1.75,2.75,2.,2.75,2.25,2.75,2.5,2.75,2.75,2.75,3.,2.75,3.25,2.75,3.5,2.75,3.75,2.75,4.,2.75,1.,3.,1.25,3.,1.5,3.,1.75,3.,2.,3.,2.25,3.,2.5,3.,2.75,3.,3.,3.,3.25,3.,3.5,3.,3.75,3.,4.,3.,1.,3.25,1.25,3.25,1.5,3.25,1.75,3.25,2.,3.25,2.25,3.25,2.5,3.25,2.75,3.25,3.,3.25,3.25,3.25,3.5,3.25,3.75,3.25,4.,3.25,1.,3.5,1.25,3.5,1.5,3.5,1.75,3.5,2.,3.5,2.25,3.5,2.5,3.5,2.75,3.5,3.,3.5,3.25,3.5,3.5,3.5,1.,3.75,1.25,3.75,1.5,3.75,1.75,3.75,2.,3.75,2.25,3.75,2.5,3.75,2.75,3.75,3.,3.75,3.25,3.75,3.5,3.75,1.,4.,1.25,4.,1.5,4.,1.75,4.,2.,4.,2.25,4.,2.5,4.,2.75,4.,3.,4.,3.25,4.,3.5,4.,3.5,3.25,3.625,3.25,3.75,3.25,3.875,3.25,4.,3.25,3.5,3.375,3.625,3.375,3.75,3.375,3.875,3.375,4.,3.375,3.5,3.5,3.625,3.5,3.75,3.5,3.875,3.5,4.,3.5,3.5,3.625,3.625,3.625,3.75,3.625,3.875,3.625,4.,3.625,3.5,3.75,3.625,3.75,3.75,3.75,3.875,3.75,4.,3.75,3.5,3.875,3.625,3.875,3.75,3.875,3.875,3.875,4.,3.875,3.5,4.,3.625,4.,3.75,4.,3.875,4.,4.,4.,4.25,3.,4.5,3.,4.75,3.,5.,3.,4.25,3.25,4.5,3.25,4.75,3.25,5.,3.25,4.25,3.5,4.5,3.5,4.75,3.5,5.,3.5,4.25,3.75,4.5,3.75,4.75,3.75,5.,3.75,4.25,4.,4.5,4.,4.75,4.,5.,4.,4.,4.25,4.25,4.25,4.5,4.25,4.75,4.25,5.,4.25,4.,4.5,4.25,4.5,4.5,4.5,4.75,4.5,5.,4.5,4.,4.75,4.25,4.75,4.5,4.75,4.75,4.75,5.,4.75,4.,5.,4.25,5.,4.5,5.,4.75,5.,5.,5.,4.,3.,4.125,3.,4.25,3.,4.,3.125,4.125,3.125,4.25,3.125,4.,3.25,4.125,3.25,4.25,3.25,4.,3.375,4.125,3.375,4.25,3.375,4.,3.5,4.125,3.5,4.25,3.5,4.,3.625,4.125,3.625,4.25,3.625,4.,3.75,4.125,3.75,4.25,3.75,4.,3.875,4.125,3.875,4.25,3.875,4.,4.,4.125,4.,4.25,4.,4.,4.125,4.125,4.125,4.25,4.125,4.,4.25,4.125,4.25,4.25,4.25,0.,4.,0.25,4.,0.5,4.,0.75,4.,0.,4.25,0.25,4.25,0.5,4.25,0.75,4.25,0.,4.5,0.25,4.5,0.5,4.5,0.75,4.5,0.,4.75,0.25,4.75,0.5,4.75,0.75,4.75,1.,4.75,0.,5.,0.25,5.,0.5,5.,0.75,5.,1.,5.,0.,5.25,0.25,5.25,0.5,5.25,0.75,5.25,1.,5.25,0.,5.5,0.25,5.5,0.5,5.5,0.75,5.5,1.,5.5,0.,5.75,0.25,5.75,0.5,5.75,0.75,5.75,1.,5.75,0.,6.,0.25,6.,0.5,6.,0.75,6.,1.,6.,0.75,4.,0.875,4.,1.,4.,0.75,4.125,0.875,4.125,1.,4.125,0.75,4.25,0.875,4.25,1.,4.25,0.75,4.375,0.875,4.375,1.,4.375,0.75,4.5,0.875,4.5,1.,4.5,0.75,4.625,0.875,4.625,1.,4.625,0.75,4.75,0.875,4.75,1.,4.75],319,2),1e-12)) + # the test is here ! To be called after iteration with no remesh + att.synchronizeAllGhostZones() + f=att.buildCellFieldOnWithGhost(amr,"Field") + f0=att.buildCellFieldOnWithGhost(amr[0].getMesh(),"Field") + f1=att.buildCellFieldOnWithGhost(amr[1].getMesh(),"Field") + f2=att.buildCellFieldOnWithGhost(amr[2].getMesh(),"Field") + f00=att.buildCellFieldOnWithGhost(amr[0][0].getMesh(),"Field") + f10=att.buildCellFieldOnWithGhost(amr[1][0].getMesh(),"Field") + f20=att.buildCellFieldOnWithGhost(amr[2][0].getMesh(),"Field") + assert(f.getArray().isEqualWithoutConsideringStr(DataArrayDouble([0.1,1.1,2.1,3.1,4.1,5.1,6.1,7.1,8.1,9.1,10.1,11.1,12.1,13.1,14.1,15.1,16.1,17.1,18.1,19.1,20.1,21.1,22.1,23.1,24.1,25.1,26.1,27.1,28.1,29.1,30.1,31.1,32.1,33.1,34.1,35.1,36.1,37.1,38.1,39.1,40.1,41.1,42.1,43.1,44.1,45.1,46.1,47.1,48.1,49.1,50.1,51.1,52.1,53.1,54.1,55.1]),1e-12)) + assert(f0.getArray().isEqualWithoutConsideringStr(DataArrayDouble([15.1,16.1,16.1,16.1,16.1,17.1,17.1,17.1,17.1,18.1,18.1,18.1,18.1,19.1,22.1,15.2,16.2,17.2,18.2,19.2,20.2,21.2,22.2,23.2,24.2,25.2,26.2,26.1,22.1,29.2,30.2,31.2,32.2,33.2,34.2,35.2,36.2,37.2,38.2,39.2,40.2,26.1,22.1,43.2,44.2,45.2,46.2,47.2,48.2,49.2,50.2,51.2,52.2,53.2,54.2,26.1,22.1,57.2,58.2,59.2,60.2,61.2,62.2,63.2,64.2,65.2,66.2,67.2,68.2,26.1,29.1,71.2,72.2,73.2,74.2,75.2,76.2,77.2,78.2,79.2,80.2,81.2,82.2,7.3,29.1,85.2,86.2,87.2,88.2,89.2,90.2,91.2,92.2,93.2,94.2,95.2,96.2,13.3,29.1,99.2,100.2,101.2,102.2,103.2,104.2,105.2,106.2,107.2,108.2,109.2,110.2,19.3,29.1,113.2,114.2,115.2,116.2,117.2,118.2,119.2,120.2,121.2,122.2,123.2,124.2,25.3,10.4,37.1,37.1,37.1,37.1,38.1,38.1,38.1,38.1,39.1,39.1,39.1,39.1,31.3]),1e-12)) + assert(f1.getArray().isEqualWithoutConsideringStr(DataArrayDouble([68.2,26.1,26.1,26.1,26.1,27.1,82.2,7.3,8.3,9.3,10.3,34.1,96.2,13.3,14.3,15.3,16.3,34.1,110.2,19.3,20.3,21.3,22.3,34.1,124.2,25.3,26.3,27.3,28.3,34.1,39.1,31.3,32.3,33.3,34.3,41.1,39.1,37.3,38.3,39.3,40.3,41.1,39.1,43.3,44.3,45.3,46.3,41.1,39.1,49.3,50.3,51.3,52.3,41.1,46.1,47.1,47.1,47.1,47.1,48.1]),1e-12)) + assert(f2.getArray().isEqualWithoutConsideringStr(DataArrayDouble([28.1,29.1,29.1,29.1,29.1,113.2,35.1,7.4,8.4,9.4,10.4,37.1,35.1,13.4,14.4,15.4,16.4,37.1,35.1,19.4,20.4,21.4,22.4,37.1,35.1,25.4,26.4,27.4,28.4,37.1,42.1,31.4,32.4,33.4,34.4,44.1,42.1,37.4,38.4,39.4,40.4,44.1,42.1,43.4,44.4,45.4,46.4,44.1,42.1,49.4,50.4,51.4,52.4,44.1,49.1,50.1,50.1,50.1,50.1,51.1]),1e-12)) + assert(f00.getArray().isEqualWithoutConsideringStr(DataArrayDouble([80.2,81.2,81.2,82.2,82.2,9.6,94.2,7.5,8.5,9.5,10.5,13.6,94.2,13.5,14.5,15.5,16.5,17.6,108.2,19.5,20.5,21.5,22.5,21.6,108.2,25.5,26.5,27.5,28.5,25.6,122.2,31.5,32.5,33.5,34.5,29.6,122.2,37.5,38.5,39.5,40.5,33.6,39.1,39.1,39.1,39.1,39.1,37.6]),1e-12)) + assert(f10.getArray().isEqualWithoutConsideringStr(DataArrayDouble([68.2,26.1,26.1,26.1,82.2,5.6,6.6,8.3,82.2,9.6,10.6,8.3,10.5,13.6,14.6,14.3,16.5,17.6,18.6,14.3,22.5,21.6,22.6,20.3,28.5,25.6,26.6,20.3,34.5,29.6,30.6,26.3,40.5,33.6,34.6,26.3,39.1,37.6,38.6,32.3,39.1,41.6,42.6,32.3,39.1,37.3,37.3,38.3]),1e-12)) + assert(f20.getArray().isEqualWithoutConsideringStr(DataArrayDouble([29.1,29.1,29.1,113.2,9.4,5.7,6.7,37.1,9.4,9.7,10.7,37.1,15.4,13.7,14.7,37.1,15.4,17.7,18.7,37.1,21.4,21.7,22.7,37.1,21.4,25.7,26.7,37.1,27.4,28.4,28.4,37.1]),1e-12)) + pass + def setUp(self): pass pass diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 910bd6b8e..2be7cfb94 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -4825,6 +4825,7 @@ namespace ParaMEDMEM public: int getNumberOfOverlapedCellsForFather() const throw(INTERP_KERNEL::Exception); bool isInMyNeighborhood(const MEDCouplingCartesianAMRPatch *other, int ghostLev) const throw(INTERP_KERNEL::Exception); + std::vector computeCellGridSt() const throw(INTERP_KERNEL::Exception); %extend { PyObject *getBLTRRange() const throw(INTERP_KERNEL::Exception) @@ -4885,8 +4886,7 @@ namespace ParaMEDMEM public: virtual void synchronizeFineToCoarse() throw(INTERP_KERNEL::Exception); virtual void synchronizeCoarseToFine() throw(INTERP_KERNEL::Exception); - virtual void synchronizeCoarseToFineOnlyInGhostZone() throw(INTERP_KERNEL::Exception); - virtual void synchronizeFineEachOtherInGhostZone() throw(INTERP_KERNEL::Exception); + virtual void synchronizeAllGhostZones() throw(INTERP_KERNEL::Exception); virtual void alloc() throw(INTERP_KERNEL::Exception); virtual void dealloc() throw(INTERP_KERNEL::Exception); };