X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingAMRAttribute.cxx;h=4267ae29fb970c199bd7a431c1c8de90c6d717f1;hb=b7e277ad50223814bc479c5bd64cf12abe8fc959;hp=d78f2a58d2dabf60374e72256e420ac661986b07;hpb=412b987b938a931abd14764009e5b591d1a4fcc5;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingAMRAttribute.cxx b/src/MEDCoupling/MEDCouplingAMRAttribute.cxx index d78f2a58d..4267ae29f 100644 --- a/src/MEDCoupling/MEDCouplingAMRAttribute.cxx +++ b/src/MEDCoupling/MEDCouplingAMRAttribute.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -24,15 +24,17 @@ #include "MEDCouplingIMesh.hxx" #include +#include -using namespace ParaMEDMEM; +using namespace MEDCoupling; +/// @cond INTERNAL DataArrayDoubleCollection *DataArrayDoubleCollection::New(const std::vector< std::pair >& fieldNames) { return new DataArrayDoubleCollection(fieldNames); } -DataArrayDoubleCollection *DataArrayDoubleCollection::deepCpy() const +DataArrayDoubleCollection *DataArrayDoubleCollection::deepCopy() const { return new DataArrayDoubleCollection(*this); } @@ -62,7 +64,7 @@ void DataArrayDoubleCollection::copyFrom(const DataArrayDoubleCollection& other) const DataArrayDouble *otherArr(other._arrs[i].first); if(!thisArr || !otherArr) throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::copyFrom : empty DataArray !"); - thisArr->cpyFrom(*otherArr); + thisArr->deepCopyFrom(*otherArr); } } @@ -130,7 +132,7 @@ std::vector DataArrayDoubleCollection::retrieveFields() const const DataArrayDouble *DataArrayDoubleCollection::getFieldWithName(const std::string& name) const { std::vector vec; - for(std::vector< std::pair< MEDCouplingAutoRefCountObjectPtr, NatureOfField > >::const_iterator it=_arrs.begin();it!=_arrs.end();it++) + for(std::vector< std::pair< MCAuto, NatureOfField > >::const_iterator it=_arrs.begin();it!=_arrs.end();it++) { const DataArrayDouble *obj((*it).first); if(obj) @@ -149,7 +151,7 @@ const DataArrayDouble *DataArrayDoubleCollection::getFieldWithName(const std::st DataArrayDouble *DataArrayDoubleCollection::getFieldWithName(const std::string& name) { std::vector vec; - for(std::vector< std::pair< MEDCouplingAutoRefCountObjectPtr, NatureOfField > >::iterator it=_arrs.begin();it!=_arrs.end();it++) + for(std::vector< std::pair< MCAuto, NatureOfField > >::iterator it=_arrs.begin();it!=_arrs.end();it++) { DataArrayDouble *obj((*it).first); if(obj) @@ -304,7 +306,7 @@ DataArrayDoubleCollection::DataArrayDoubleCollection(const std::vector< std::pai _arrs[i].first->alloc(0,info.second); _arrs[i].first->setName(info.first); names[i]=info.second; - _arrs[i].second=ConservativeVolumic; + _arrs[i].second=IntensiveMaximum; } CheckDiscriminantNames(names); } @@ -317,32 +319,28 @@ DataArrayDoubleCollection::DataArrayDoubleCollection(const DataArrayDoubleCollec _arrs[i].second=other._arrs[i].second; const DataArrayDouble *da(other._arrs[i].first); if(da) - _arrs[i].first=da->deepCpy(); + _arrs[i].first=da->deepCopy(); } } std::size_t DataArrayDoubleCollection::getHeapMemorySizeWithoutChildren() const { std::size_t ret(sizeof(DataArrayDoubleCollection)); - ret+=_arrs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr); + ret+=_arrs.capacity()*sizeof(MCAuto); return ret; } -std::vector DataArrayDoubleCollection::getDirectChildren() const +std::vector DataArrayDoubleCollection::getDirectChildrenWithNull() const { std::vector ret; - for(std::vector< std::pair< MEDCouplingAutoRefCountObjectPtr, NatureOfField > >::const_iterator it=_arrs.begin();it!=_arrs.end();it++) - { - const DataArrayDouble *pt((*it).first); - if(pt) - ret.push_back(pt); - } + for(std::vector< std::pair< MCAuto, NatureOfField > >::const_iterator it=_arrs.begin();it!=_arrs.end();it++) + ret.push_back((const DataArrayDouble *)(*it).first); return ret; } void DataArrayDoubleCollection::updateTime() const { - for(std::vector< std::pair< MEDCouplingAutoRefCountObjectPtr, NatureOfField > >::const_iterator it=_arrs.begin();it!=_arrs.end();it++) + for(std::vector< std::pair< MCAuto, NatureOfField > >::const_iterator it=_arrs.begin();it!=_arrs.end();it++) { const DataArrayDouble *pt((*it).first); if(pt) @@ -360,7 +358,7 @@ void DataArrayDoubleCollection::CheckDiscriminantNames(const std::vector > >::iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) + for(std::vector< std::pair > >::iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) { int nbTuples((*it).first->getNumberOfCellsAtCurrentLevelGhost(ghostLev)); DataArrayDoubleCollection *dadc((*it).second); @@ -402,7 +400,7 @@ void MEDCouplingGridCollection::alloc(int ghostLev) void MEDCouplingGridCollection::dealloc() { - for(std::vector< std::pair > >::iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) + for(std::vector< std::pair > >::iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) { DataArrayDoubleCollection *dadc((*it).second); if(dadc) @@ -414,13 +412,13 @@ void MEDCouplingGridCollection::dealloc() void MEDCouplingGridCollection::spillInfoOnComponents(const std::vector< std::vector >& compNames) { - for(std::vector< std::pair > >::iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) + for(std::vector< std::pair > >::iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) (*it).second->spillInfoOnComponents(compNames); } void MEDCouplingGridCollection::spillNatures(const std::vector& nfs) { - for(std::vector< std::pair > >::iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) + for(std::vector< std::pair > >::iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) (*it).second->spillNatures(nfs); } @@ -447,7 +445,7 @@ std::vector MEDCouplingGridCollection::getNatures() const bool MEDCouplingGridCollection::presenceOf(const MEDCouplingCartesianAMRMeshGen *m, int& pos) const { int ret(0); - for(std::vector< std::pair > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++,ret++) + for(std::vector< std::pair > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++,ret++) { if((*it).first==m) { @@ -479,13 +477,13 @@ DataArrayDoubleCollection& MEDCouplingGridCollection::getFieldsAt(int pos) */ void MEDCouplingGridCollection::copyOverlappedZoneFrom(int ghostLev, const MEDCouplingGridCollection& other) { - for(std::vector< std::pair > >::iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) + for(std::vector< std::pair > >::iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) { std::vector deltaThis,deltaOther; std::vector< std::pair > rgThis((*it).first->positionRelativeToGodFather(deltaThis)); std::vector thisSt((*it).first->getImageMesh()->getCellGridStructure()); std::transform(thisSt.begin(),thisSt.end(),thisSt.begin(),std::bind2nd(std::plus(),2*ghostLev)); - for(std::vector< std::pair > >::const_iterator it2=other._map_of_dadc.begin();it2!=other._map_of_dadc.end();it2++) + for(std::vector< std::pair > >::const_iterator it2=other._map_of_dadc.begin();it2!=other._map_of_dadc.end();it2++) { std::vector< std::pair > rgOther((*it2).first->positionRelativeToGodFather(deltaOther)); if(MEDCouplingStructuredMesh::AreRangesIntersect(rgThis,rgOther)) @@ -503,7 +501,7 @@ void MEDCouplingGridCollection::copyOverlappedZoneFrom(int ghostLev, const MEDCo { const DataArrayDouble *otherArr((*it2).second->at(i)); DataArrayDouble *thisArr((*it).second->at(i)); - MEDCouplingAutoRefCountObjectPtr partOfOther(MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom(otherSt,otherArr,pOther)); + MCAuto partOfOther(MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom(otherSt,otherArr,pOther)); MEDCouplingStructuredMesh::AssignPartOfFieldOfDoubleUsing(thisSt,thisArr,pThis,partOfOther); } } @@ -515,14 +513,14 @@ void MEDCouplingGridCollection::SynchronizeFineToCoarse(int ghostLev, const MEDC { if(!fine || !coarse) throw INTERP_KERNEL::Exception("MEDCouplingGridCollection::SynchronizeFineToCoarse : one or more input pointer is NULL !"); - const std::vector< std::pair > >& mf(fine->_map_of_dadc); - const std::vector< std::pair > >& mc(coarse->_map_of_dadc); - for(std::vector< std::pair > >::const_iterator it=mf.begin();it!=mf.end();it++) + const std::vector< std::pair > >& mf(fine->_map_of_dadc); + const std::vector< std::pair > >& mc(coarse->_map_of_dadc); + for(std::vector< std::pair > >::const_iterator it=mf.begin();it!=mf.end();it++) { const MEDCouplingCartesianAMRMeshGen *fineMesh((*it).first); const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh(fineMesh->getFather()); bool found(false); - for(std::vector< std::pair > >::const_iterator it0=mc.begin();it0!=mc.end() && !found;it0++) + for(std::vector< std::pair > >::const_iterator it0=mc.begin();it0!=mc.end() && !found;it0++) { if((*it0).first==fatherOfFineMesh) { @@ -542,14 +540,14 @@ void MEDCouplingGridCollection::SynchronizeCoarseToFine(int ghostLev, const MEDC { if(!fine || !coarse) throw INTERP_KERNEL::Exception("MEDCouplingGridCollection::SynchronizeCoarseToFine : one or more input pointer is NULL !"); - const std::vector< std::pair > >& mf(fine->_map_of_dadc); - const std::vector< std::pair > >& mc(coarse->_map_of_dadc); - for(std::vector< std::pair > >::const_iterator it=mf.begin();it!=mf.end();it++) + const std::vector< std::pair > >& mf(fine->_map_of_dadc); + const std::vector< std::pair > >& mc(coarse->_map_of_dadc); + for(std::vector< std::pair > >::const_iterator it=mf.begin();it!=mf.end();it++) { const MEDCouplingCartesianAMRMeshGen *fineMesh((*it).first); const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh(fineMesh->getFather()); bool found(false); - for(std::vector< std::pair > >::const_iterator it0=mc.begin();it0!=mc.end() && !found;it0++) + for(std::vector< std::pair > >::const_iterator it0=mc.begin();it0!=mc.end() && !found;it0++) { if((*it0).first==fatherOfFineMesh) { @@ -612,7 +610,7 @@ std::vector< std::pair > ret; std::map > m; - for(std::vector< std::pair > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) + for(std::vector< std::pair > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) { const MEDCouplingCartesianAMRMeshGen *fineMesh((*it).first); const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh(fineMesh->getFather()); @@ -641,14 +639,14 @@ void MEDCouplingGridCollection::SynchronizeCoarseToFineOnlyInGhostZone(int ghost { if(!fine || !coarse) throw INTERP_KERNEL::Exception("MEDCouplingGridCollection::SynchronizeCoarseToFineOnlyInGhostZone : one or more input pointer is NULL !"); - const std::vector< std::pair > >& mf(fine->_map_of_dadc); - const std::vector< std::pair > >& mc(coarse->_map_of_dadc); - for(std::vector< std::pair > >::const_iterator it=mf.begin();it!=mf.end();it++) + const std::vector< std::pair > >& mf(fine->_map_of_dadc); + const std::vector< std::pair > >& mc(coarse->_map_of_dadc); + for(std::vector< std::pair > >::const_iterator it=mf.begin();it!=mf.end();it++) { const MEDCouplingCartesianAMRMeshGen *fineMesh((*it).first); const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh(fineMesh->getFather()); bool found(false); - for(std::vector< std::pair > >::const_iterator it0=mc.begin();it0!=mc.end() && !found;it0++) + for(std::vector< std::pair > >::const_iterator it0=mc.begin();it0!=mc.end() && !found;it0++) { if((*it0).first==fatherOfFineMesh) { @@ -666,7 +664,7 @@ void MEDCouplingGridCollection::SynchronizeCoarseToFineOnlyInGhostZone(int ghost void MEDCouplingGridCollection::fillIfInTheProgenyOf(const std::string& fieldName, const MEDCouplingCartesianAMRMeshGen *head, std::vector& recurseArrs) const { - for(std::vector< std::pair > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) + for(std::vector< std::pair > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) { const MEDCouplingCartesianAMRMeshGen *a((*it).first); if(head==a || head->isObjectInTheProgeny(a)) @@ -698,32 +696,28 @@ MEDCouplingGridCollection::MEDCouplingGridCollection(const MEDCouplingGridCollec _map_of_dadc[i].first=newGf->getMeshAtPosition(pos); const DataArrayDoubleCollection *dac(other._map_of_dadc[i].second); if(dac) - _map_of_dadc[i].second=dac->deepCpy(); + _map_of_dadc[i].second=dac->deepCopy(); } } std::size_t MEDCouplingGridCollection::getHeapMemorySizeWithoutChildren() const { std::size_t ret(sizeof(MEDCouplingGridCollection)); - ret+=_map_of_dadc.capacity()*sizeof(std::pair >); + ret+=_map_of_dadc.capacity()*sizeof(std::pair >); return ret; } -std::vector MEDCouplingGridCollection::getDirectChildren() const +std::vector MEDCouplingGridCollection::getDirectChildrenWithNull() const { std::vector ret; - for(std::vector< std::pair > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) - { - const DataArrayDoubleCollection *col((*it).second); - if(col) - ret.push_back(col); - } + for(std::vector< std::pair > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) + ret.push_back((const DataArrayDoubleCollection *)(*it).second); return ret; } void MEDCouplingGridCollection::updateTime() const { - for(std::vector< std::pair > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) + for(std::vector< std::pair > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) { const MEDCouplingCartesianAMRMeshGen *a((*it).first); if(a) @@ -734,6 +728,8 @@ void MEDCouplingGridCollection::updateTime() const } } +/// @endcond + MEDCouplingCartesianAMRMesh *MEDCouplingDataForGodFather::getMyGodFather() { return _gf; @@ -775,7 +771,7 @@ MEDCouplingDataForGodFather::MEDCouplingDataForGodFather(const MEDCouplingDataFo { const MEDCouplingCartesianAMRMesh *gf(other._gf); if(gf) - _gf=gf->deepCpy(0); + _gf=gf->deepCopy(0); _tlc.keepTrackOfNewTL(_gf); } } @@ -799,7 +795,7 @@ MEDCouplingAMRAttribute *MEDCouplingAMRAttribute::New(MEDCouplingCartesianAMRMes fieldNames2[i].second=(int)fieldNames[i].second.size(); compNames[i]=fieldNames[i].second; } - MEDCouplingAutoRefCountObjectPtr ret(New(gf,fieldNames2,ghostLev)); + MCAuto ret(New(gf,fieldNames2,ghostLev)); ret->spillInfoOnComponents(compNames); return ret.retn(); } @@ -813,7 +809,7 @@ MEDCouplingAMRAttribute *MEDCouplingAMRAttribute::New(MEDCouplingCartesianAMRMes void MEDCouplingAMRAttribute::spillInfoOnComponents(const std::vector< std::vector >& compNames) { _tlc.checkConst(); - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_levs.begin();it!=_levs.end();it++) + for(std::vector< MCAuto >::iterator it=_levs.begin();it!=_levs.end();it++) (*it)->spillInfoOnComponents(compNames); } @@ -824,11 +820,11 @@ void MEDCouplingAMRAttribute::spillInfoOnComponents(const std::vector< std::vect void MEDCouplingAMRAttribute::spillNatures(const std::vector& nfs) { _tlc.checkConst(); - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_levs.begin();it!=_levs.end();it++) + for(std::vector< MCAuto >::iterator it=_levs.begin();it!=_levs.end();it++) (*it)->spillNatures(nfs); } -MEDCouplingAMRAttribute *MEDCouplingAMRAttribute::deepCpy() const +MEDCouplingAMRAttribute *MEDCouplingAMRAttribute::deepCopy() const { return new MEDCouplingAMRAttribute(*this,true); } @@ -857,7 +853,7 @@ int MEDCouplingAMRAttribute::getNumberOfLevels() const */ std::vector MEDCouplingAMRAttribute::retrieveFieldsOn(MEDCouplingCartesianAMRMeshGen *mesh) const { - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_levs.begin();it!=_levs.end();it++) + for(std::vector< MCAuto >::const_iterator it=_levs.begin();it!=_levs.end();it++) { int tmp(-1); if((*it)->presenceOf(mesh,tmp)) @@ -874,7 +870,7 @@ std::vector MEDCouplingAMRAttribute::retrieveFieldsOn(MEDCoup */ const DataArrayDouble *MEDCouplingAMRAttribute::getFieldOn(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const { - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_levs.begin();it!=_levs.end();it++) + for(std::vector< MCAuto >::const_iterator it=_levs.begin();it!=_levs.end();it++) { int tmp(-1); if((*it)->presenceOf(mesh,tmp)) @@ -888,7 +884,7 @@ const DataArrayDouble *MEDCouplingAMRAttribute::getFieldOn(MEDCouplingCartesianA DataArrayDouble *MEDCouplingAMRAttribute::getFieldOn(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) { - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_levs.begin();it!=_levs.end();it++) + for(std::vector< MCAuto >::iterator it=_levs.begin();it!=_levs.end();it++) { int tmp(-1); if((*it)->presenceOf(mesh,tmp)) @@ -910,7 +906,7 @@ MEDCouplingFieldDouble *MEDCouplingAMRAttribute::buildCellFieldOnRecurseWithoutO { std::vector recurseArrs; std::size_t lev(0); - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_levs.begin();it!=_levs.end();it++,lev++) + for(std::vector< MCAuto >::const_iterator it=_levs.begin();it!=_levs.end();it++,lev++) { int tmp(-1); if((*it)->presenceOf(mesh,tmp)) @@ -940,7 +936,7 @@ MEDCouplingFieldDouble *MEDCouplingAMRAttribute::buildCellFieldOnRecurseWithoutO MEDCouplingFieldDouble *MEDCouplingAMRAttribute::buildCellFieldOnWithGhost(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const { const DataArrayDouble *arr(0); - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_levs.begin();it!=_levs.end();it++) + for(std::vector< MCAuto >::const_iterator it=_levs.begin();it!=_levs.end();it++) { int tmp(-1); if((*it)->presenceOf(mesh,tmp)) @@ -951,8 +947,8 @@ MEDCouplingFieldDouble *MEDCouplingAMRAttribute::buildCellFieldOnWithGhost(MEDCo } if(!arr) throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::buildCellFieldOnWithGhost : the mesh specified is not in the progeny of this !"); - MEDCouplingAutoRefCountObjectPtr im(mesh->getImageMesh()->buildWithGhost(_ghost_lev)); - MEDCouplingAutoRefCountObjectPtr ret(MEDCouplingFieldDouble::New(ON_CELLS)); + MCAuto im(mesh->getImageMesh()->buildWithGhost(_ghost_lev)); + MCAuto ret(MEDCouplingFieldDouble::New(ON_CELLS)); ret->setMesh(im); ret->setArray(const_cast(arr)); ret->setName(arr->getName()); @@ -969,9 +965,8 @@ MEDCouplingFieldDouble *MEDCouplingAMRAttribute::buildCellFieldOnWithGhost(MEDCo */ MEDCouplingFieldDouble *MEDCouplingAMRAttribute::buildCellFieldOnWithoutGhost(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const { - //tony const DataArrayDouble *arr(0); - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_levs.begin();it!=_levs.end();it++) + for(std::vector< MCAuto >::const_iterator it=_levs.begin();it!=_levs.end();it++) { int tmp(-1); if((*it)->presenceOf(mesh,tmp)) @@ -983,9 +978,9 @@ MEDCouplingFieldDouble *MEDCouplingAMRAttribute::buildCellFieldOnWithoutGhost(ME if(!arr) throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::buildCellFieldOnWithoutGhost : the mesh specified is not in the progeny of this !"); // - MEDCouplingAutoRefCountObjectPtr im(mesh->getImageMesh()->buildWithGhost(_ghost_lev)); + MCAuto im(mesh->getImageMesh()->buildWithGhost(_ghost_lev)); std::vector cgs(mesh->getImageMesh()->getCellGridStructure()),cgsWG(im->getCellGridStructure()); - MEDCouplingAutoRefCountObjectPtr arr2(DataArrayDouble::New()); + MCAuto arr2(DataArrayDouble::New()); arr2->alloc(mesh->getImageMesh()->getNumberOfCells(),arr->getNumberOfComponents()); std::vector< std::pair > cgs2(MEDCouplingStructuredMesh::GetCompactFrmtFromDimensions(cgs)); MEDCouplingStructuredMesh::ApplyGhostOnCompactFrmt(cgs2,_ghost_lev); @@ -993,19 +988,129 @@ MEDCouplingFieldDouble *MEDCouplingAMRAttribute::buildCellFieldOnWithoutGhost(ME MEDCouplingIMesh::SpreadCoarseToFine(arr,cgsWG,arr2,cgs2,fakeFactors); arr2->copyStringInfoFrom(*arr); // - MEDCouplingAutoRefCountObjectPtr ret(MEDCouplingFieldDouble::New(ON_CELLS)); + MCAuto ret(MEDCouplingFieldDouble::New(ON_CELLS)); ret->setMesh(mesh->getImageMesh()); ret->setArray(arr2); ret->setName(arr->getName()); return ret.retn(); } -/*! - * This method is useful just after a remesh after a time step computation to project values in \a this to the new - * mesh \a targetGF. - * - * This method performs a projection from \a this to a target AMR mesh \a targetGF. - * This method performs the projection by trying to transfer the finest information to \a targetGF. + +std::string MEDCouplingAMRAttribute::writeVTHB(const std::string& fileName) const +{ + static const char EXT[]=".vthb"; + std::string baseName,extName,zeFileName; + MEDCouplingMesh::SplitExtension(fileName,baseName,extName); + if(extName==EXT) + zeFileName=fileName; + else + { zeFileName=baseName; zeFileName+=EXT; } + // + std::ofstream ofs(fileName.c_str()); + ofs << "\n"; + const MEDCouplingCartesianAMRMesh *gf(getMyGodFather()); + ofs << " getImageMesh()); + std::vector orig(gfm->getOrigin()); + std::vector spacing(gfm->getDXYZ()); + int dim((int)orig.size()); + std::copy(orig.begin(),orig.end(),std::ostream_iterator(ofs," ")); ofs << "\" grid_description=\""; + for(int i=0;i\n"; + // + int maxLev(gf->getMaxNumberOfLevelsRelativeToThis()),kk(0); + for(int i=0;i patches(gf->retrieveGridsAt(i)); + std::size_t sz(patches.size()); + std::vector< MCAuto > patchesSafe(sz); + for(std::size_t j=0;j(ofs," ")); + ofs << "\">\n"; + if(i!=maxLev-1) + { + std::vector factors(patches[0]->getMesh()->getFactors()); + for(int k=0;k::const_iterator it=patches.begin();it!=patches.end();it++,jj++,kk++) + { + ofs << " (*it)); + const MEDCouplingCartesianAMRMeshGen *mesh((*it)->getMesh()); + if(patchCast) + { + const std::vector< std::pair >& bltr(patchCast->getBLTRRangeRelativeToGF()); + for(int pp=0;ppgetMesh()->getImageMesh()); + std::vector cgs(im->getCellGridStructure()); + for(int pp=0;pppresenceOf((*it)->getMesh(),tmp)) + { + const DataArrayDoubleCollection& ddc(_levs[i]->getFieldsAt(tmp)); + std::vector arrs(ddc.retrieveFields()); + std::size_t nbFields(arrs.size()); + std::vector< MCAuto > arrsSafe(nbFields),arrs2Safe(nbFields); + std::vector< const MEDCouplingFieldDouble *> fields(nbFields); + std::vector< MCAuto > fieldsSafe(nbFields); + for(std::size_t pp=0;pp im(mesh->getImageMesh()->buildWithGhost(_ghost_lev)); + std::vector cgs(mesh->getImageMesh()->getCellGridStructure()),cgsWG(im->getCellGridStructure()); + arrs2Safe[pp]=DataArrayDouble::New(); + arrs2Safe[pp]->alloc(mesh->getImageMesh()->getNumberOfCells(),arrs[pp]->getNumberOfComponents()); + std::vector< std::pair > cgs2(MEDCouplingStructuredMesh::GetCompactFrmtFromDimensions(cgs)); + MEDCouplingStructuredMesh::ApplyGhostOnCompactFrmt(cgs2,_ghost_lev); + std::vector fakeFactors(mesh->getImageMesh()->getSpaceDimension(),1); + MEDCouplingIMesh::SpreadCoarseToFine(arrs[pp],cgsWG,arrs2Safe[pp],cgs2,fakeFactors); + arrs2Safe[pp]->copyStringInfoFrom(*arrs[pp]); + // + fieldsSafe[pp]=MEDCouplingFieldDouble::New(ON_CELLS); fields[pp]=fieldsSafe[pp]; + fieldsSafe[pp]->setMesh(mesh->getImageMesh()); + fieldsSafe[pp]->setArray(arrs2Safe[pp]); + fieldsSafe[pp]->setName(arrs[pp]->getName()); + } + std::ostringstream vtiFileName; vtiFileName << baseName << "_" << kk << ".vti"; + MEDCouplingFieldDouble::WriteVTK(vtiFileName.str(),fields,true); + // + ofs << vtiFileName.str() << "\">\n"; + ofs << " \n \n"; + } + } + ofs << " \n"; + } + // + ofs << " \n"; + ofs << "\n"; + return zeFileName; +} + + /*! + * This method is useful just after a remesh after a time step computation to project values in \a this to the new + * mesh \a targetGF. + * + * This method performs a projection from \a this to a target AMR mesh \a targetGF. + * This method performs the projection by trying to transfer the finest information to \a targetGF. * \b WARNING this method does not update the ghost zone, if any. * The level0 of \a this god father must have the same structure than those of \a targetGF. * @@ -1022,7 +1127,7 @@ MEDCouplingAMRAttribute *MEDCouplingAMRAttribute::projectTo(MEDCouplingCartesian if(!lev0) throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::projectTo : lev0 is NULL !"); std::vector< std::pair < std::string, std::vector > > fieldNames(lev0->getInfoOnComponents()); - MEDCouplingAutoRefCountObjectPtr ret(MEDCouplingAMRAttribute::New(targetGF,fieldNames,_ghost_lev)); + MCAuto ret(MEDCouplingAMRAttribute::New(targetGF,fieldNames,_ghost_lev)); ret->spillNatures(lev0->getNatures()); ret->alloc(); int nbLevs(getNumberOfLevels()); @@ -1247,7 +1352,7 @@ void MEDCouplingAMRAttribute::synchronizeAllGhostZonesAtASpecifiedLevelUsingOnly void MEDCouplingAMRAttribute::alloc() { _tlc.resetState(); - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_levs.begin();it!=_levs.end();it++) + for(std::vector< MCAuto >::iterator it=_levs.begin();it!=_levs.end();it++) { MEDCouplingGridCollection *elt(*it); if(elt) @@ -1264,7 +1369,7 @@ void MEDCouplingAMRAttribute::alloc() void MEDCouplingAMRAttribute::dealloc() { _tlc.checkConst(); - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_levs.begin();it!=_levs.end();it++) + for(std::vector< MCAuto >::iterator it=_levs.begin();it!=_levs.end();it++) { MEDCouplingGridCollection *elt(*it); if(elt) @@ -1283,19 +1388,15 @@ bool MEDCouplingAMRAttribute::changeGodFather(MEDCouplingCartesianAMRMesh *gf) std::size_t MEDCouplingAMRAttribute::getHeapMemorySizeWithoutChildren() const { std::size_t ret(sizeof(MEDCouplingAMRAttribute)); - ret+=_levs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr); + ret+=_levs.capacity()*sizeof(MCAuto); return ret; } -std::vector MEDCouplingAMRAttribute::getDirectChildren() const +std::vector MEDCouplingAMRAttribute::getDirectChildrenWithNull() const { std::vector ret; - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_levs.begin();it!=_levs.end();it++) - { - const MEDCouplingGridCollection *elt(*it); - if(elt) - ret.push_back(elt); - } + for(std::vector< MCAuto >::const_iterator it=_levs.begin();it!=_levs.end();it++) + ret.push_back((const MEDCouplingGridCollection *)*it); return ret; } @@ -1312,7 +1413,7 @@ MEDCouplingAMRAttribute::MEDCouplingAMRAttribute(MEDCouplingCartesianAMRMesh *gf { std::vector patches(gf->retrieveGridsAt(i)); std::size_t sz(patches.size()); - std::vector< MEDCouplingAutoRefCountObjectPtr > patchesSafe(patches.size()); + std::vector< MCAuto > patchesSafe(patches.size()); for(std::size_t j=0;j ms(sz); @@ -1359,7 +1460,7 @@ MEDCouplingAMRAttribute::MEDCouplingAMRAttribute(const MEDCouplingAMRAttribute& const MEDCouplingGridCollection *elt(other._levs[i]); if(elt) { - _levs[i]=other._levs[i]->deepCpy(_gf,other._gf); + _levs[i]=other._levs[i]->deepCopy(_gf,other._gf); } } //_cross_lev_neighbors(other._cross_lev_neighbors) @@ -1405,7 +1506,7 @@ MEDCouplingAMRAttribute::MEDCouplingAMRAttribute(const MEDCouplingAMRAttribute& const DataArrayDoubleCollection& MEDCouplingAMRAttribute::findCollectionAttachedTo(const MEDCouplingCartesianAMRMeshGen *m) const { - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_levs.begin();it!=_levs.end();it++) + for(std::vector< MCAuto >::const_iterator it=_levs.begin();it!=_levs.end();it++) { const MEDCouplingGridCollection *elt(*it); if(elt)