+ // updates cross levels neighbors
+ _neighbors.resize(_levs.size());
+ _cross_lev_neighbors.resize(_levs.size());
+ if(_levs.empty())
+ throw INTERP_KERNEL::Exception("constructor of MEDCouplingAMRAttribute : not any levels in this !");
+ std::size_t sz(_levs.size());
+ for(std::size_t i=1;i<sz;i++)
+ {
+ const MEDCouplingGridCollection *fine(_levs[i]);
+ if(!fine)
+ throw INTERP_KERNEL::Exception("constructor of MEDCouplingAMRAttribute : presence of a NULL element !");
+ _neighbors[i]=fine->findNeighbors(_ghost_lev);
+ if(i!=sz-1)
+ {
+ for(std::vector< std::pair<const MEDCouplingCartesianAMRPatch *,const MEDCouplingCartesianAMRPatch *> >::const_iterator it=_neighbors[i].begin();it!=_neighbors[i].end();it++)
+ {
+ MEDCouplingCartesianAMRPatch::FindNeighborsOfSubPatchesOf(_ghost_lev,(*it).first,(*it).second,_mixed_lev_neighbors);
+ std::vector< std::vector < std::pair<const MEDCouplingCartesianAMRPatch *,const MEDCouplingCartesianAMRPatch *> > > neighs2(MEDCouplingCartesianAMRPatch::FindNeighborsOfSubPatchesOfSameLev(_ghost_lev,(*it).first,(*it).second));
+ std::size_t fullLev(i+neighs2.size());
+ if(fullLev>=sz)
+ throw INTERP_KERNEL::Exception("constructor of MEDCouplingAMRAttribute : internal error ! something is wrong in computation of cross level neighbors !");
+ std::size_t ii(i+1);
+ for(std::vector< std::vector< std::pair<const MEDCouplingCartesianAMRPatch *,const MEDCouplingCartesianAMRPatch *> > >::const_iterator it0=neighs2.begin();it0!=neighs2.end();it0++,ii++)
+ _cross_lev_neighbors[ii].insert(_cross_lev_neighbors[ii].end(),(*it0).begin(),(*it0).end());
+ }
+ }
+ }
+}
+
+MEDCouplingAMRAttribute::MEDCouplingAMRAttribute(const MEDCouplingAMRAttribute& other, bool deepCpyGF):MEDCouplingDataForGodFather(other,deepCpyGF),_ghost_lev(other._ghost_lev),_levs(other._levs.size()),_neighbors(other._neighbors),_mixed_lev_neighbors(other._mixed_lev_neighbors),_cross_lev_neighbors(other._cross_lev_neighbors)
+{
+ std::size_t sz(other._levs.size());
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const MEDCouplingGridCollection *elt(other._levs[i]);
+ if(elt)
+ {
+ _levs[i]=other._levs[i]->deepCopy(_gf,other._gf);
+ }
+ }
+ //_cross_lev_neighbors(other._cross_lev_neighbors)
+ sz=other._neighbors.size();
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const std::vector< std::pair<const MEDCouplingCartesianAMRPatch *,const MEDCouplingCartesianAMRPatch *> >& neigh2(other._neighbors[i]);
+ std::size_t sz2(neigh2.size());
+ std::vector< std::pair<const MEDCouplingCartesianAMRPatch *,const MEDCouplingCartesianAMRPatch *> >& neigh3(_neighbors[i]);
+ for(std::size_t j=0;j<sz2;j++)
+ {
+ const MEDCouplingCartesianAMRPatch *p1(neigh2[j].first),*p2(neigh2[j].second);
+ std::vector<mcIdType> pp1(p1->getMesh()->getPositionRelativeTo(other._gf)),pp2(p2->getMesh()->getPositionRelativeTo(other._gf));
+ neigh3[j].first=_gf->getPatchAtPosition(pp1);
+ neigh3[j].second=_gf->getPatchAtPosition(pp2);
+ }
+ }
+ //
+ sz=other._mixed_lev_neighbors.size();
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const MEDCouplingCartesianAMRPatch *p1(other._mixed_lev_neighbors[i].first),*p2(other._mixed_lev_neighbors[i].second);
+ std::vector<mcIdType> pp1(p1->getMesh()->getPositionRelativeTo(other._gf)),pp2(p2->getMesh()->getPositionRelativeTo(other._gf));
+ _mixed_lev_neighbors[i].first=_gf->getPatchAtPosition(pp1);
+ _mixed_lev_neighbors[i].second=_gf->getPatchAtPosition(pp2);
+ }
+ //
+ sz=other._cross_lev_neighbors.size();
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const std::vector< std::pair<const MEDCouplingCartesianAMRPatch *,const MEDCouplingCartesianAMRPatch *> >& neigh2(other._cross_lev_neighbors[i]);
+ std::size_t sz2(neigh2.size());
+ std::vector< std::pair<const MEDCouplingCartesianAMRPatch *,const MEDCouplingCartesianAMRPatch *> >& neigh3(_cross_lev_neighbors[i]);
+ for(std::size_t j=0;j<sz2;j++)
+ {
+ const MEDCouplingCartesianAMRPatch *p1(neigh2[j].first),*p2(neigh2[j].second);
+ std::vector<mcIdType> pp1(p1->getMesh()->getPositionRelativeTo(other._gf)),pp2(p2->getMesh()->getPositionRelativeTo(other._gf));
+ neigh3[j].first=_gf->getPatchAtPosition(pp1);
+ neigh3[j].second=_gf->getPatchAtPosition(pp2);
+ }
+ }
+}
+
+const DataArrayDoubleCollection& MEDCouplingAMRAttribute::findCollectionAttachedTo(const MEDCouplingCartesianAMRMeshGen *m) const
+{
+ for(std::vector< MCAuto<MEDCouplingGridCollection> >::const_iterator it=_levs.begin();it!=_levs.end();it++)
+ {
+ const MEDCouplingGridCollection *elt(*it);
+ if(elt)
+ {
+ mcIdType tmp(-1);
+ if(elt->presenceOf(m,tmp))
+ {
+ return elt->getFieldsAt(tmp);
+ }
+ }
+ }
+ throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::findCollectionAttachedTo : unable to find such part of mesh in this !");
+}
+
+void MEDCouplingAMRAttribute::synchronizeFineToCoarseByOneLevel(mcIdType level)
+{
+ mcIdType nbl(getNumberOfLevels());
+ if(level<=0 || level>=nbl)
+ throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::synchronizeFineToCoarseByOneLevel : the input level must be in ]0,nb_of_levels[ !");
+ const MEDCouplingGridCollection *fine(_levs[level]),*coarse(_levs[level-1]);
+ MEDCouplingGridCollection::SynchronizeFineToCoarse(_ghost_lev,fine,coarse);
+}
+
+void MEDCouplingAMRAttribute::synchronizeCoarseToFineByOneLevel(mcIdType level)
+{
+ mcIdType nbl(getNumberOfLevels());
+ if(level<0 || level>=nbl-1)
+ throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::synchronizeFineToCoarseByOneLevel : the input level must be in [0,nb_of_levels[ !");
+ const MEDCouplingGridCollection *fine(_levs[level+1]),*coarse(_levs[level]);
+ MEDCouplingGridCollection::SynchronizeCoarseToFine(_ghost_lev,coarse,fine);