From 773a19557f33364e5b59658b77f8c533f499eeeb Mon Sep 17 00:00:00 2001 From: geay Date: Wed, 30 Apr 2014 16:09:31 +0200 Subject: [PATCH] AMR 2 --- src/MEDCoupling/CMakeLists.txt | 2 +- src/MEDCoupling/MEDCouplingAHOGMesh.cxx | 237 --------------- src/MEDCoupling/MEDCouplingCMesh.cxx | 24 -- src/MEDCoupling/MEDCouplingCMesh.hxx | 2 - .../MEDCouplingCartesianAMRMesh.cxx | 269 ++++++++++++++++++ ...sh.hxx => MEDCouplingCartesianAMRMesh.hxx} | 35 +-- .../MEDCouplingCurveLinearMesh.cxx | 24 -- .../MEDCouplingCurveLinearMesh.hxx | 2 - src/MEDCoupling/MEDCouplingIMesh.cxx | 114 ++++++-- src/MEDCoupling/MEDCouplingIMesh.hxx | 4 +- src/MEDCoupling/MEDCouplingStructuredMesh.cxx | 44 ++- src/MEDCoupling/MEDCouplingStructuredMesh.hxx | 6 +- src/MEDCoupling_Swig/MEDCouplingBasicsTest.py | 43 +++ src/MEDCoupling_Swig/MEDCouplingCommon.i | 102 ++++--- 14 files changed, 536 insertions(+), 372 deletions(-) delete mode 100644 src/MEDCoupling/MEDCouplingAHOGMesh.cxx create mode 100644 src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx rename src/MEDCoupling/{MEDCouplingAHOGMesh.hxx => MEDCouplingCartesianAMRMesh.hxx} (71%) diff --git a/src/MEDCoupling/CMakeLists.txt b/src/MEDCoupling/CMakeLists.txt index bbd0d8ea0..6ac3fbd86 100644 --- a/src/MEDCoupling/CMakeLists.txt +++ b/src/MEDCoupling/CMakeLists.txt @@ -55,7 +55,7 @@ SET(medcoupling_SOURCES MEDCouplingMultiFields.cxx MEDCouplingDefinitionTime.cxx MEDCouplingFieldOverTime.cxx - MEDCouplingAHOGMesh.cxx + MEDCouplingCartesianAMRMesh.cxx ) SET(medcouplingremapper_SOURCES diff --git a/src/MEDCoupling/MEDCouplingAHOGMesh.cxx b/src/MEDCoupling/MEDCouplingAHOGMesh.cxx deleted file mode 100644 index 82e9bd83c..000000000 --- a/src/MEDCoupling/MEDCouplingAHOGMesh.cxx +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright (C) 2007-2014 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 -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// Author : Anthony Geay - -#include "MEDCouplingAHOGMesh.hxx" -#include "MEDCouplingIMesh.hxx" -#include "MEDCouplingUMesh.hxx" - -#include -#include - -using namespace ParaMEDMEM; - -/// @cond INTERNAL - -/*! - * \param [in] mesh not null pointer of refined mesh replacing the cell range of \a father defined by the bottom left and top right just after. - * \param [in] bottomLeftTopRight a vector equal to the space dimension of \a mesh that specifies for each dimension, the included cell start of the range for the first element of the pair, - * a the end cell (\b excluded) of the range for the second element of the pair. - */ -MEDCouplingAHOGPatch::MEDCouplingAHOGPatch(MEDCouplingAHOGMesh *mesh, const std::vector< std::pair >& bottomLeftTopRight) -{ - if(!mesh) - throw INTERP_KERNEL::Exception("EDCouplingAHOGPatch constructor : input mesh is NULL !"); - _mesh=mesh; _mesh->incrRef(); - int dim((int)bottomLeftTopRight.size()); - if(dim!=_mesh->getSpaceDimension()) - throw INTERP_KERNEL::Exception("MEDCouplingAHOGPatch constructor : space dimension of father and input bottomLeft/topRight size mismatches !"); - _bl_tr=bottomLeftTopRight; -} - -int MEDCouplingAHOGPatch::getNumberOfCellsRecursiveWithOverlap() const -{ - return _mesh->getNumberOfCellsRecursiveWithOverlap(); -} - -int MEDCouplingAHOGPatch::getNumberOfCellsRecursiveWithoutOverlap() const -{ - return _mesh->getNumberOfCellsRecursiveWithoutOverlap(); -} - -int MEDCouplingAHOGPatch::getMaxNumberOfLevelsRelativeToThis() const -{ - return _mesh->getMaxNumberOfLevelsRelativeToThis(); -} - -void MEDCouplingAHOGPatch::addPatch(const std::vector< std::pair >& bottomLeftTopRight, int factor) -{ - return _mesh->addPatch(bottomLeftTopRight,factor); -} - -int MEDCouplingAHOGPatch::getNumberOfOverlapedCellsForFather() const -{ - return MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(_bl_tr); -} - -std::size_t MEDCouplingAHOGPatch::getHeapMemorySizeWithoutChildren() const -{ - std::size_t ret(sizeof(MEDCouplingAHOGPatch)); - ret+=_bl_tr.capacity()*sizeof(std::pair); - return ret; -} - -std::vector MEDCouplingAHOGPatch::getDirectChildren() const -{ - std::vector ret; - if((const MEDCouplingAHOGMesh *)_mesh) - ret.push_back((const MEDCouplingAHOGMesh *)_mesh); - return ret; -} - -/// @endcond - - -MEDCouplingAHOGMesh *MEDCouplingAHOGMesh::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) -{ - return new MEDCouplingAHOGMesh(meshName,spaceDim,nodeStrctStart,nodeStrctStop,originStart,originStop,dxyzStart,dxyzStop); -} - -int MEDCouplingAHOGMesh::getSpaceDimension() const -{ - return _mesh->getSpaceDimension(); -} - -int MEDCouplingAHOGMesh::getMaxNumberOfLevelsRelativeToThis() const -{ - int ret(1); - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_patches.begin();it!=_patches.end();it++) - ret=std::max(ret,(*it)->getMaxNumberOfLevelsRelativeToThis()+1); - return ret; -} - -int MEDCouplingAHOGMesh::getNumberOfCellsAtCurrentLevel() const -{ - return _mesh->getNumberOfCells(); -} - -int MEDCouplingAHOGMesh::getNumberOfCellsRecursiveWithOverlap() const -{ - int ret(_mesh->getNumberOfCells()); - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_patches.begin();it!=_patches.end();it++) - { - ret+=(*it)->getNumberOfCellsRecursiveWithOverlap(); - } - return ret; -} - -int MEDCouplingAHOGMesh::getNumberOfCellsRecursiveWithoutOverlap() const -{ - int ret(_mesh->getNumberOfCells()); - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_patches.begin();it!=_patches.end();it++) - { - ret-=(*it)->getNumberOfOverlapedCellsForFather(); - ret+=(*it)->getNumberOfCellsRecursiveWithoutOverlap(); - } - return ret; -} - -const MEDCouplingAHOGMesh *MEDCouplingAHOGMesh::getFather() const -{ - return _father; -} - -const MEDCouplingAHOGMesh *MEDCouplingAHOGMesh::getGodFather() const -{ - if(_father==0) - return this; - else - return _father->getGodFather(); -} - -/*! - * \param [in] bottomLeftTopRight a vector equal to the space dimension of \a mesh that specifies for each dimension, the included cell start of the range for the first element of the pair, - * a the end cell (\b excluded) of the range for the second element of the pair. - * \param [in] factor The != 0 factor of refinement. - */ -void MEDCouplingAHOGMesh::addPatch(const std::vector< std::pair >& bottomLeftTopRight, int factor) -{ - MEDCouplingAutoRefCountObjectPtr mesh(static_cast(_mesh->buildStructuredSubPart(bottomLeftTopRight))); - mesh->refineWithFactor(factor); - MEDCouplingAutoRefCountObjectPtr zeMesh(new MEDCouplingAHOGMesh(this,mesh)); - MEDCouplingAutoRefCountObjectPtr elt(new MEDCouplingAHOGPatch(zeMesh,bottomLeftTopRight)); - _patches.push_back(elt); -} - -int MEDCouplingAHOGMesh::getNumberOfPatches() const -{ - return (int)_patches.size(); -} - -const MEDCouplingAHOGPatch *MEDCouplingAHOGMesh::getPatch(int patchId) const -{ - int sz(getNumberOfPatches()); - if(patchId<0 || patchId>=sz) - { - std::ostringstream oss; oss << "MEDCouplingAHOGMesh::getPatch : invalid patchId (" << patchId << ") ! Must be in [0," << sz << ") !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - return _patches[patchId]; -} - -MEDCouplingUMesh *MEDCouplingAHOGMesh::buildUnstructured() const -{ - MEDCouplingAutoRefCountObjectPtr part(_mesh->buildUnstructured()); - std::vector bs(_mesh->getNumberOfCells(),false); - std::vector cgs(_mesh->getCellGridStructure()); - std::vector< MEDCouplingAutoRefCountObjectPtr > msSafe(_patches.size()+1); - std::size_t ii(0); - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_patches.begin();it!=_patches.end();it++,ii++) - { - MEDCouplingStructuredMesh::SwitchOnIdsFrom(cgs,(*it)->getBLTRRange(),bs); - msSafe[ii+1]=(*it)->getMesh()->buildUnstructured(); - } - MEDCouplingAutoRefCountObjectPtr eltsOff(DataArrayInt::BuildListOfSwitchedOff(bs)); - msSafe[0]=static_cast(part->buildPartOfMySelf(eltsOff->begin(),eltsOff->end(),false)); - std::vector< const MEDCouplingUMesh * > ms(msSafe.size()); - for(std::size_t i=0;icheckCoherency(); - _mesh=mesh; _mesh->incrRef(); -} - -std::size_t MEDCouplingAHOGMesh::getHeapMemorySizeWithoutChildren() const -{ - return sizeof(MEDCouplingAHOGMesh); -} - -std::vector MEDCouplingAHOGMesh::getDirectChildren() const -{ - std::vector ret; - if((const MEDCouplingIMesh *)_mesh) - ret.push_back((const MEDCouplingIMesh *)_mesh); - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_patches.begin();it!=_patches.end();it++) - { - if((const MEDCouplingAHOGPatch*)*it) - ret.push_back((const MEDCouplingAHOGPatch*)*it); - } - return ret; -} - -void MEDCouplingAHOGMesh::updateTime() const -{ - if((const MEDCouplingIMesh *)_mesh) - updateTimeWith(*_mesh); -} diff --git a/src/MEDCoupling/MEDCouplingCMesh.cxx b/src/MEDCoupling/MEDCouplingCMesh.cxx index 3eeadc142..65ee343c1 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCMesh.cxx @@ -274,30 +274,6 @@ void MEDCouplingCMesh::checkCoherency2(double eps) const checkCoherency1(eps); } -void MEDCouplingCMesh::getSplitCellValues(int *res) const -{ - int meshDim(getMeshDimension()); - for(int l=0;lgetNbOfElems()-1; - res[meshDim-l-1]=val; - } -} - -void MEDCouplingCMesh::getSplitNodeValues(int *res) const -{ - int spaceDim(getSpaceDimension()); - for(int l=0;lgetNbOfElems(); - res[spaceDim-l-1]=val; - } -} - void MEDCouplingCMesh::getNodeGridStructure(int *res) const { std::vector ret(getNodeGridStructure()); diff --git a/src/MEDCoupling/MEDCouplingCMesh.hxx b/src/MEDCoupling/MEDCouplingCMesh.hxx index 92909bea3..e19f6a099 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.hxx +++ b/src/MEDCoupling/MEDCouplingCMesh.hxx @@ -71,8 +71,6 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const; MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check=true); //some useful methods - MEDCOUPLING_EXPORT void getSplitCellValues(int *res) const; - MEDCOUPLING_EXPORT void getSplitNodeValues(int *res) const; MEDCOUPLING_EXPORT void getNodeGridStructure(int *res) const; MEDCOUPLING_EXPORT std::vector getNodeGridStructure() const; MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair >& cellPart) const; diff --git a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx new file mode 100644 index 000000000..08f1d1f59 --- /dev/null +++ b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx @@ -0,0 +1,269 @@ +// Copyright (C) 2007-2014 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 +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay + +#include "MEDCouplingCartesianAMRMesh.hxx" +#include "MEDCouplingIMesh.hxx" +#include "MEDCouplingUMesh.hxx" + +#include +#include + +using namespace ParaMEDMEM; + +/// @cond INTERNAL + +/*! + * \param [in] mesh not null pointer of refined mesh replacing the cell range of \a father defined by the bottom left and top right just after. + * \param [in] bottomLeftTopRight a vector equal to the space dimension of \a mesh that specifies for each dimension, the included cell start of the range for the first element of the pair, + * a the end cell (\b excluded) of the range for the second element of the pair. + */ +MEDCouplingCartesianAMRPatch::MEDCouplingCartesianAMRPatch(MEDCouplingCartesianAMRMesh *mesh, const std::vector< std::pair >& bottomLeftTopRight) +{ + if(!mesh) + throw INTERP_KERNEL::Exception("EDCouplingCartesianAMRPatch constructor : input mesh is NULL !"); + _mesh=mesh; _mesh->incrRef(); + int dim((int)bottomLeftTopRight.size()); + if(dim!=_mesh->getSpaceDimension()) + throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRPatch constructor : space dimension of father and input bottomLeft/topRight size mismatches !"); + _bl_tr=bottomLeftTopRight; +} + +int MEDCouplingCartesianAMRPatch::getNumberOfCellsRecursiveWithOverlap() const +{ + return _mesh->getNumberOfCellsRecursiveWithOverlap(); +} + +int MEDCouplingCartesianAMRPatch::getNumberOfCellsRecursiveWithoutOverlap() const +{ + return _mesh->getNumberOfCellsRecursiveWithoutOverlap(); +} + +int MEDCouplingCartesianAMRPatch::getMaxNumberOfLevelsRelativeToThis() const +{ + return _mesh->getMaxNumberOfLevelsRelativeToThis(); +} + +void MEDCouplingCartesianAMRPatch::addPatch(const std::vector< std::pair >& bottomLeftTopRight, int factor) +{ + return _mesh->addPatch(bottomLeftTopRight,factor); +} + +int MEDCouplingCartesianAMRPatch::getNumberOfOverlapedCellsForFather() const +{ + return MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(_bl_tr); +} + +std::size_t MEDCouplingCartesianAMRPatch::getHeapMemorySizeWithoutChildren() const +{ + std::size_t ret(sizeof(MEDCouplingCartesianAMRPatch)); + ret+=_bl_tr.capacity()*sizeof(std::pair); + return ret; +} + +std::vector MEDCouplingCartesianAMRPatch::getDirectChildren() const +{ + std::vector ret; + if((const MEDCouplingCartesianAMRMesh *)_mesh) + ret.push_back((const MEDCouplingCartesianAMRMesh *)_mesh); + return ret; +} + +/// @endcond + + +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) +{ + return new MEDCouplingCartesianAMRMesh(meshName,spaceDim,nodeStrctStart,nodeStrctStop,originStart,originStop,dxyzStart,dxyzStop); +} + +int MEDCouplingCartesianAMRMesh::getSpaceDimension() const +{ + return _mesh->getSpaceDimension(); +} + +int MEDCouplingCartesianAMRMesh::getMaxNumberOfLevelsRelativeToThis() const +{ + int ret(1); + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_patches.begin();it!=_patches.end();it++) + ret=std::max(ret,(*it)->getMaxNumberOfLevelsRelativeToThis()+1); + return ret; +} + +int MEDCouplingCartesianAMRMesh::getNumberOfCellsAtCurrentLevel() const +{ + return _mesh->getNumberOfCells(); +} + +int MEDCouplingCartesianAMRMesh::getNumberOfCellsRecursiveWithOverlap() const +{ + int ret(_mesh->getNumberOfCells()); + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_patches.begin();it!=_patches.end();it++) + { + ret+=(*it)->getNumberOfCellsRecursiveWithOverlap(); + } + return ret; +} + +int MEDCouplingCartesianAMRMesh::getNumberOfCellsRecursiveWithoutOverlap() const +{ + int ret(_mesh->getNumberOfCells()); + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_patches.begin();it!=_patches.end();it++) + { + ret-=(*it)->getNumberOfOverlapedCellsForFather(); + ret+=(*it)->getNumberOfCellsRecursiveWithoutOverlap(); + } + return ret; +} + +const MEDCouplingCartesianAMRMesh *MEDCouplingCartesianAMRMesh::getFather() const +{ + return _father; +} + +const MEDCouplingCartesianAMRMesh *MEDCouplingCartesianAMRMesh::getGodFather() const +{ + if(_father==0) + return this; + else + return _father->getGodFather(); +} + +void MEDCouplingCartesianAMRMesh::detachFromFather() +{ + _father=0; +} + +/*! + * \param [in] bottomLeftTopRight a vector equal to the space dimension of \a mesh that specifies for each dimension, the included cell start of the range for the first element of the pair, + * a the end cell (\b excluded) of the range for the second element of the pair. + * \param [in] factor The != 0 factor of refinement. + */ +void MEDCouplingCartesianAMRMesh::addPatch(const std::vector< std::pair >& bottomLeftTopRight, int factor) +{ + MEDCouplingAutoRefCountObjectPtr mesh(static_cast(_mesh->buildStructuredSubPart(bottomLeftTopRight))); + mesh->refineWithFactor(factor); + MEDCouplingAutoRefCountObjectPtr zeMesh(new MEDCouplingCartesianAMRMesh(this,mesh)); + MEDCouplingAutoRefCountObjectPtr elt(new MEDCouplingCartesianAMRPatch(zeMesh,bottomLeftTopRight)); + _patches.push_back(elt); +} + +void MEDCouplingCartesianAMRMesh::removePatch(int patchId) +{ + checkPatchId(patchId); + int sz((int)_patches.size()),j(0); + std::vector< MEDCouplingAutoRefCountObjectPtr > patches(sz-1); + for(int i=0;i(_patches[patchId]->getMesh()))->detachFromFather(); + _patches=patches; + declareAsNew(); +} + +int MEDCouplingCartesianAMRMesh::getNumberOfPatches() const +{ + return (int)_patches.size(); +} + +const MEDCouplingCartesianAMRPatch *MEDCouplingCartesianAMRMesh::getPatch(int patchId) const +{ + checkPatchId(patchId); + return _patches[patchId]; +} + +MEDCouplingUMesh *MEDCouplingCartesianAMRMesh::buildUnstructured() const +{ + MEDCouplingAutoRefCountObjectPtr part(_mesh->buildUnstructured()); + std::vector bs(_mesh->getNumberOfCells(),false); + std::vector cgs(_mesh->getCellGridStructure()); + std::vector< MEDCouplingAutoRefCountObjectPtr > msSafe(_patches.size()+1); + std::size_t ii(0); + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_patches.begin();it!=_patches.end();it++,ii++) + { + MEDCouplingStructuredMesh::SwitchOnIdsFrom(cgs,(*it)->getBLTRRange(),bs); + msSafe[ii+1]=(*it)->getMesh()->buildUnstructured(); + } + MEDCouplingAutoRefCountObjectPtr eltsOff(DataArrayInt::BuildListOfSwitchedOff(bs)); + msSafe[0]=static_cast(part->buildPartOfMySelf(eltsOff->begin(),eltsOff->end(),false)); + std::vector< const MEDCouplingUMesh * > ms(msSafe.size()); + for(std::size_t i=0;icheckCoherency(); + _mesh=mesh; _mesh->incrRef(); +} + +void MEDCouplingCartesianAMRMesh::checkPatchId(int patchId) const +{ + int sz(getNumberOfPatches()); + if(patchId<0 || patchId>=sz) + { + std::ostringstream oss; oss << "MEDCouplingCartesianAMRMesh::checkPatchId : invalid patchId (" << patchId << ") ! Must be in [0," << sz << ") !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } +} + +std::size_t MEDCouplingCartesianAMRMesh::getHeapMemorySizeWithoutChildren() const +{ + return sizeof(MEDCouplingCartesianAMRMesh); +} + +std::vector MEDCouplingCartesianAMRMesh::getDirectChildren() const +{ + std::vector ret; + if((const MEDCouplingIMesh *)_mesh) + ret.push_back((const MEDCouplingIMesh *)_mesh); + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_patches.begin();it!=_patches.end();it++) + { + if((const MEDCouplingCartesianAMRPatch*)*it) + ret.push_back((const MEDCouplingCartesianAMRPatch*)*it); + } + return ret; +} + +void MEDCouplingCartesianAMRMesh::updateTime() const +{ + if((const MEDCouplingIMesh *)_mesh) + updateTimeWith(*_mesh); + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_patches.begin();it!=_patches.end();it++) + { + const MEDCouplingCartesianAMRPatch *elt(*it); + if(!elt) + continue; + const MEDCouplingCartesianAMRMesh *mesh(elt->getMesh()); + if(mesh) + updateTimeWith(*mesh); + } +} diff --git a/src/MEDCoupling/MEDCouplingAHOGMesh.hxx b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx similarity index 71% rename from src/MEDCoupling/MEDCouplingAHOGMesh.hxx rename to src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx index b2e755457..46cee80fc 100644 --- a/src/MEDCoupling/MEDCouplingAHOGMesh.hxx +++ b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx @@ -18,8 +18,8 @@ // // Author : Anthony Geay -#ifndef __MEDCOUPLINGAHOGMESH_HXX__ -#define __MEDCOUPLINGAHOGMESH_HXX__ +#ifndef __MEDCOUPLINGCARTESIANAMRMESH_HXX__ +#define __MEDCOUPLINGCARTESIANAMRMESH_HXX__ #include "MEDCoupling.hxx" #include "MEDCouplingTimeLabel.hxx" @@ -32,13 +32,13 @@ namespace ParaMEDMEM { class MEDCouplingIMesh; class MEDCouplingUMesh; - class MEDCouplingAHOGMesh; + class MEDCouplingCartesianAMRMesh; /// @cond INTERNAL - class MEDCouplingAHOGPatch : public RefCountObject + class MEDCouplingCartesianAMRPatch : public RefCountObject { public: - MEDCouplingAHOGPatch(MEDCouplingAHOGMesh *mesh, const std::vector< std::pair >& bottomLeftTopRight); + MEDCouplingCartesianAMRPatch(MEDCouplingCartesianAMRMesh *mesh, const std::vector< std::pair >& bottomLeftTopRight); // direct forward to _mesh MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithOverlap() const; MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithoutOverlap() const; @@ -48,14 +48,14 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT int getNumberOfOverlapedCellsForFather() const; // basic set/get MEDCOUPLING_EXPORT const std::vector< std::pair >& getBLTRRange() const { return _bl_tr; } - MEDCOUPLING_EXPORT const MEDCouplingAHOGMesh *getMesh() const { return _mesh; } + MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMesh *getMesh() const { return _mesh; } private: std::size_t getHeapMemorySizeWithoutChildren() const; std::vector getDirectChildren() const; private: //! bottom left/top right cell range relative to \a _father std::vector< std::pair > _bl_tr; - MEDCouplingAutoRefCountObjectPtr _mesh; + MEDCouplingAutoRefCountObjectPtr _mesh; }; /// @endcond @@ -64,10 +64,10 @@ namespace ParaMEDMEM * This class does \b NOT inherit from MEDCouplingMesh because this class overlaps image grid structured meshes to perform adaptative mesh refinement. * But this class aggregates MEDCouplingMesh instances ! */ - class MEDCouplingAHOGMesh : public RefCountObject, public TimeLabel + class MEDCouplingCartesianAMRMesh : public RefCountObject, public TimeLabel { public: - MEDCOUPLING_EXPORT static MEDCouplingAHOGMesh *New(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop, + 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); MEDCOUPLING_EXPORT int getSpaceDimension() const; MEDCOUPLING_EXPORT int getMaxNumberOfLevelsRelativeToThis() const; @@ -75,25 +75,28 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithOverlap() const; MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithoutOverlap() const; // - MEDCOUPLING_EXPORT const MEDCouplingAHOGMesh *getFather() const; - MEDCOUPLING_EXPORT const MEDCouplingAHOGMesh *getGodFather() const; + MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMesh *getFather() const; + MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMesh *getGodFather() const; + MEDCOUPLING_EXPORT void detachFromFather(); MEDCOUPLING_EXPORT void addPatch(const std::vector< std::pair >& bottomLeftTopRight, int factor); + MEDCOUPLING_EXPORT void removePatch(int patchId); MEDCOUPLING_EXPORT int getNumberOfPatches() const; - MEDCOUPLING_EXPORT const MEDCouplingAHOGPatch *getPatch(int patchId) const; + MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRPatch *getPatch(int patchId) const; // MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const; private: - MEDCouplingAHOGMesh(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop, + 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); - MEDCouplingAHOGMesh(MEDCouplingAHOGMesh *father, MEDCouplingIMesh *mesh); + MEDCouplingCartesianAMRMesh(MEDCouplingCartesianAMRMesh *father, MEDCouplingIMesh *mesh); + void checkPatchId(int patchId) const; protected: MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; MEDCOUPLING_EXPORT std::vector getDirectChildren() const; MEDCOUPLING_EXPORT void updateTime() const; private: - MEDCouplingAHOGMesh *_father; + MEDCouplingCartesianAMRMesh *_father; MEDCouplingAutoRefCountObjectPtr _mesh; - std::vector< MEDCouplingAutoRefCountObjectPtr > _patches; + std::vector< MEDCouplingAutoRefCountObjectPtr > _patches; }; } diff --git a/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx b/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx index 6745edac4..a5158def8 100644 --- a/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx @@ -223,30 +223,6 @@ int MEDCouplingCurveLinearMesh::getNumberOfNodes() const return MEDCouplingStructuredMesh::getNumberOfNodes(); } -void MEDCouplingCurveLinearMesh::getSplitCellValues(int *res) const -{ - int meshDim=getMeshDimension(); - for(int l=0;l& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const; diff --git a/src/MEDCoupling/MEDCouplingIMesh.cxx b/src/MEDCoupling/MEDCouplingIMesh.cxx index dc2cf8793..05e587535 100644 --- a/src/MEDCoupling/MEDCouplingIMesh.cxx +++ b/src/MEDCoupling/MEDCouplingIMesh.cxx @@ -196,6 +196,68 @@ void MEDCouplingIMesh::refineWithFactor(int factor) declareAsNew(); } +/*! + * This static method is useful to condense field on cells of a MEDCouplingIMesh instance coming from a refinement ( MEDCouplingIMesh::refineWithFactor for example) + * to a coarse MEDCouplingIMesh instance. So this method can be seen as a specialization in P0P0 conservative interpolation non overlaping from fine image mesh + * to a coarse image mesh. Only tuples ( deduced from \a fineLocInCoarse ) of \a coarseDA will be modified. Other tuples of \a coarseDA will be let unchanged. + * + * \param [in,out] coarseDA The DataArrayDouble corresponding to the a cell field of a coarse mesh whose cell structure is defined by \a coarseSt. + * \param [in] coarseSt The cell structure of coarse mesh. + * \param [in] fineDA The DataArray containing the cell field on uniformly refined mesh + * \param [in] fineLocInCoarse The cell localization of refined mesh into the coarse one. + */ +void MEDCouplingIMesh::CondenseFineToCoarse(DataArrayDouble *coarseDA, const std::vector& coarseSt, const DataArrayDouble *fineDA, const std::vector< std::pair >& fineLocInCoarse) +{ + if(!coarseDA || !coarseDA->isAllocated() || !fineDA || !fineDA->isAllocated()) + throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : the parameters 1 or 3 are NULL or not allocated !"); + int meshDim((int)coarseSt.size()),nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseSt)),nbOfTuplesInFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(fineLocInCoarse)); + int nbCompo(fineDA->getNumberOfComponents()); + if(coarseDA->getNumberOfComponents()!=nbCompo) + throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : the number of components of fine DA and coarse one mismatches !"); + if(meshDim!=(int)fineLocInCoarse.size()) + throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : the size of fineLocInCoarse (4th param) must be equal to the sier of coarseSt (2nd param) !"); + if(coarseDA->getNumberOfTuples()!=nbOfTuplesInCoarseExp) + { + std::ostringstream oss; oss << "MEDCouplingIMesh::CondenseFineToCoarse : Expecting " << nbOfTuplesInCoarseExp << " having " << coarseDA->getNumberOfTuples() << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + int nbTuplesFine(fineDA->getNumberOfTuples()); + if(nbTuplesFine%nbOfTuplesInCoarseExp!=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()); + } + } + kk+=it; + } + break; + } + default: + throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : only dimensions 2 supported !"); + } +} + void MEDCouplingIMesh::setSpaceDimension(int spaceDim) { if(spaceDim==_space_dim) @@ -347,30 +409,6 @@ void MEDCouplingIMesh::checkCoherency2(double eps) const checkCoherency1(eps); } -void MEDCouplingIMesh::getSplitCellValues(int *res) const -{ - int meshDim(getMeshDimension()); - for(int l=0;l& coarseSt, const DataArrayDouble *fineDA, const std::vector< std::pair >& fineLocInCoarse); // MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const; MEDCOUPLING_EXPORT MEDCouplingIMesh *clone(bool recDeepCpy) const; @@ -82,8 +83,6 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const; MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check=true); //some useful methods - MEDCOUPLING_EXPORT void getSplitCellValues(int *res) const; - MEDCOUPLING_EXPORT void getSplitNodeValues(int *res) const; MEDCOUPLING_EXPORT void getNodeGridStructure(int *res) const; MEDCOUPLING_EXPORT std::vector getNodeGridStructure() const; MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair >& cellPart) const; @@ -104,6 +103,7 @@ namespace ParaMEDMEM std::vector buildInfoOnComponents() const; void checkSpaceDimension() const; static void CheckSpaceDimension(int spaceDim); + static int FindIntRoot(int val, int order); private: int _space_dim; double _origin[3]; diff --git a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx index d716be479..e737159ea 100644 --- a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx +++ b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx @@ -209,6 +209,20 @@ int MEDCouplingStructuredMesh::getSpaceDimensionOnNodeStruct() const return spd1; } +void MEDCouplingStructuredMesh::getSplitCellValues(int *res) const +{ + std::vector strct(getCellGridStructure()); + std::vector ret(MEDCouplingStructuredMesh::GetSplitVectFromStruct(strct)); + std::copy(ret.begin(),ret.end(),res); +} + +void MEDCouplingStructuredMesh::getSplitNodeValues(int *res) const +{ + std::vector strct(getNodeGridStructure()); + std::vector ret(MEDCouplingStructuredMesh::GetSplitVectFromStruct(strct)); + std::copy(ret.begin(),ret.end(),res); +} + /*! * This method returns the number of cells of unstructured sub level mesh, without building it. */ @@ -904,6 +918,24 @@ std::vector MEDCouplingStructuredMesh::getCellGridStructure() const return ret; } +/*! + * Given a struct \a strct it returns a split vector [1,strct[0],strct[0]*strct[1]...] + * This decomposition allows to quickly find i,j,k given a global id. + */ +std::vector MEDCouplingStructuredMesh::GetSplitVectFromStruct(const std::vector& strct) +{ + int spaceDim((int)strct.size()); + std::vector res(spaceDim); + for(int l=0;l MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(const std::vector< std::pair >& partCompactFormat) +{ + std::vector ret(partCompactFormat.size()); + for(std::size_t i=0;i& st, cons throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::SwitchOnIdsFrom : input arrays must have the same size !"); if((int)vectToSwitchOn.size()!=DeduceNumberOfGivenStructure(st)) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::SwitchOnIdsFrom : invalid size of input vector of boolean regarding the structure !"); - std::vector dims(st.size()); - for(std::size_t i=0;i dims(GetDimensionsFromCompactFrmt(partCompactFormat)); switch(st.size()) { case 3: diff --git a/src/MEDCoupling/MEDCouplingStructuredMesh.hxx b/src/MEDCoupling/MEDCouplingStructuredMesh.hxx index cb12e85af..3e2072e28 100644 --- a/src/MEDCoupling/MEDCouplingStructuredMesh.hxx +++ b/src/MEDCoupling/MEDCouplingStructuredMesh.hxx @@ -65,12 +65,14 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT int getNumberOfCellsOfSubLevelMesh() const; MEDCOUPLING_EXPORT int getSpaceDimensionOnNodeStruct() const; MEDCOUPLING_EXPORT virtual void getNodeGridStructure(int *res) const = 0; - MEDCOUPLING_EXPORT virtual void getSplitCellValues(int *res) const = 0; - MEDCOUPLING_EXPORT virtual void getSplitNodeValues(int *res) const = 0; + MEDCOUPLING_EXPORT virtual void getSplitCellValues(int *res) const; + MEDCOUPLING_EXPORT virtual void getSplitNodeValues(int *res) const; MEDCOUPLING_EXPORT virtual std::vector getNodeGridStructure() const = 0; MEDCOUPLING_EXPORT std::vector getCellGridStructure() const; MEDCOUPLING_EXPORT virtual MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair >& cellPart) const = 0; + MEDCOUPLING_EXPORT static std::vector GetSplitVectFromStruct(const std::vector& strct); MEDCOUPLING_EXPORT static bool IsPartStructured(const int *startIds, const int *stopIds, const std::vector& st, std::vector< std::pair >& partCompactFormat); + MEDCOUPLING_EXPORT static std::vector GetDimensionsFromCompactFrmt(const std::vector< std::pair >& partCompactFormat); MEDCOUPLING_EXPORT static void SwitchOnIdsFrom(const std::vector& st, const std::vector< std::pair >& partCompactFormat, std::vector& vectToSwitchOn); MEDCOUPLING_EXPORT static DataArrayInt *BuildExplicitIdsFrom(const std::vector& st, const std::vector< std::pair >& partCompactFormat); MEDCOUPLING_EXPORT static DataArrayInt *Build1GTNodalConnectivity(const int *nodeStBg, const int *nodeStEnd); diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 58eb47e11..9d834779b 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -14934,6 +14934,49 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(mu.getCoords().isEqual(coordsExp,1e-12)) self.assertTrue(mu.getNodalConnectivity().isEqual(DataArrayInt([1,0,3,4,2,1,4,5,4,3,6,7,5,4,7,8,7,6,9,10,8,7,10,11]))) pass + + def testSwig2AMR1(self): + self.assertEqual((1,3,12),MEDCouplingStructuredMesh.GetSplitVectFromStruct([3,4,5])) + self.assertEqual((3,2),MEDCouplingStructuredMesh.GetDimensionsFromCompactFrmt([(1,4),(2,4)])) + # + amr=MEDCouplingCartesianAMRMesh("",2,[3,3],[0,0],[1,1]) + self.assertEqual(4,amr.getNumberOfCellsAtCurrentLevel()) + self.assertEqual(4,amr.getNumberOfCellsRecursiveWithOverlap()) + self.assertEqual(4,amr.getNumberOfCellsRecursiveWithoutOverlap()) + self.assertEqual(0,amr.getNumberOfPatches()) + self.assertEqual(1,amr.getMaxNumberOfLevelsRelativeToThis()) + self.assertEqual(2,amr.getSpaceDimension()) + amr.addPatch([(1,2),(0,1)],4) + self.assertEqual(4,amr.getNumberOfCellsAtCurrentLevel()) + self.assertEqual(20,amr.getNumberOfCellsRecursiveWithOverlap()) + self.assertEqual(19,amr.getNumberOfCellsRecursiveWithoutOverlap()) + self.assertEqual(1,amr.getNumberOfPatches()) + self.assertEqual(2,amr.getMaxNumberOfLevelsRelativeToThis()) + self.assertEqual(2,amr.getSpaceDimension()) + amr[0].addPatch([(2,3),(1,3)],2) + self.assertEqual(amr[0].getBLTRRange(),[(1,2),(0,1)]) + self.assertEqual(4,amr.getNumberOfCellsAtCurrentLevel()) + self.assertEqual(28,amr.getNumberOfCellsRecursiveWithOverlap()) + self.assertEqual(25,amr.getNumberOfCellsRecursiveWithoutOverlap()) + self.assertEqual(1,amr.getNumberOfPatches()) + self.assertEqual(3,amr.getMaxNumberOfLevelsRelativeToThis()) + self.assertEqual(2,amr.getSpaceDimension()) + amr[0].addPatch([(0,2),(3,4)],3) + self.assertEqual(16,amr[0].getMesh().getNumberOfCellsAtCurrentLevel()) + self.assertEqual(46,amr.getNumberOfCellsRecursiveWithOverlap()) + self.assertEqual(41,amr.getNumberOfCellsRecursiveWithoutOverlap()) + self.assertEqual(2,amr[0].getMesh().getNumberOfPatches()) + self.assertEqual(3,amr.getMaxNumberOfLevelsRelativeToThis()) + self.assertEqual(2,amr.getSpaceDimension()) + del amr[0][1] + self.assertEqual(amr[0].getBLTRRange(),[(1,2),(0,1)]) + self.assertEqual(4,amr.getNumberOfCellsAtCurrentLevel()) + self.assertEqual(28,amr.getNumberOfCellsRecursiveWithOverlap()) + self.assertEqual(25,amr.getNumberOfCellsRecursiveWithoutOverlap()) + self.assertEqual(1,amr.getNumberOfPatches()) + self.assertEqual(3,amr.getMaxNumberOfLevelsRelativeToThis()) + self.assertEqual(2,amr.getSpaceDimension()) + pass def setUp(self): pass diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 8f0dfb8c9..92cd4bbd2 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -40,7 +40,7 @@ #include "MEDCouplingFieldOverTime.hxx" #include "MEDCouplingDefinitionTime.hxx" #include "MEDCouplingFieldDiscretization.hxx" -#include "MEDCouplingAHOGMesh.hxx" +#include "MEDCouplingCartesianAMRMesh.hxx" #include "MEDCouplingTypemaps.i" #include "InterpKernelAutoPtr.hxx" @@ -311,14 +311,14 @@ using namespace INTERP_KERNEL; %newobject ParaMEDMEM::MEDCouplingMultiFields::New; %newobject ParaMEDMEM::MEDCouplingMultiFields::deepCpy; %newobject ParaMEDMEM::MEDCouplingFieldOverTime::New; -%newobject ParaMEDMEM::MEDCouplingAHOGPatch::getMesh; -%newobject ParaMEDMEM::MEDCouplingAHOGPatch::__getitem__; -%newobject ParaMEDMEM::MEDCouplingAHOGMesh::New; -%newobject ParaMEDMEM::MEDCouplingAHOGMesh::buildUnstructured; -%newobject ParaMEDMEM::MEDCouplingAHOGMesh::getGodFather; -%newobject ParaMEDMEM::MEDCouplingAHOGMesh::getFather; -%newobject ParaMEDMEM::MEDCouplingAHOGMesh::getPatch; -%newobject ParaMEDMEM::MEDCouplingAHOGMesh::__getitem__; +%newobject ParaMEDMEM::MEDCouplingCartesianAMRPatch::getMesh; +%newobject ParaMEDMEM::MEDCouplingCartesianAMRPatch::__getitem__; +%newobject ParaMEDMEM::MEDCouplingCartesianAMRMesh::New; +%newobject ParaMEDMEM::MEDCouplingCartesianAMRMesh::buildUnstructured; +%newobject ParaMEDMEM::MEDCouplingCartesianAMRMesh::getGodFather; +%newobject ParaMEDMEM::MEDCouplingCartesianAMRMesh::getFather; +%newobject ParaMEDMEM::MEDCouplingCartesianAMRMesh::getPatch; +%newobject ParaMEDMEM::MEDCouplingCartesianAMRMesh::__getitem__; %feature("unref") MEDCouplingPointSet "$this->decrRef();" %feature("unref") MEDCouplingMesh "$this->decrRef();" @@ -340,8 +340,8 @@ using namespace INTERP_KERNEL; %feature("unref") MEDCouplingMultiFields "$this->decrRef();" %feature("unref") MEDCouplingFieldTemplate "$this->decrRef();" %feature("unref") MEDCouplingMultiFields "$this->decrRef();" -%feature("unref") MEDCouplingAHOGMesh "$this->decrRef();" -%feature("unref") MEDCouplingAHOGPatch "$this->decrRef();" +%feature("unref") MEDCouplingCartesianAMRMesh "$this->decrRef();" +%feature("unref") MEDCouplingCartesianAMRPatch "$this->decrRef();" %rename(assign) *::operator=; %ignore ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationIntInfo; @@ -2769,6 +2769,7 @@ namespace ParaMEDMEM static INTERP_KERNEL::NormalizedCellType GetGeoTypeGivenMeshDimension(int meshDim) throw(INTERP_KERNEL::Exception); MEDCoupling1SGTUMesh *build1SGTSubLevelMesh() const throw(INTERP_KERNEL::Exception); static int DeduceNumberOfGivenStructure(const std::vector& st) throw(INTERP_KERNEL::Exception); + static std::vector GetSplitVectFromStruct(const std::vector& strct) throw(INTERP_KERNEL::Exception); %extend { virtual MEDCouplingStructuredMesh *buildStructuredSubPart(PyObject *cellPart) const throw(INTERP_KERNEL::Exception) @@ -2831,6 +2832,13 @@ namespace ParaMEDMEM return MEDCouplingStructuredMesh::Build1GTNodalConnectivityOfSubLevelMesh(tmp,tmp+szArr); } + static std::vector GetDimensionsFromCompactFrmt(PyObject *partCompactFormat) throw(INTERP_KERNEL::Exception) + { + std::vector< std::pair > inp; + convertPyToVectorPairInt(partCompactFormat,inp); + return MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(inp); + } + static PyObject *IsPartStructured(PyObject *li, PyObject *st) throw(INTERP_KERNEL::Exception) { int szArr,sw,iTypppArr; @@ -3027,6 +3035,13 @@ namespace ParaMEDMEM self->setDXYZ(originPtr,originPtr+nbTuples); } + static void CondenseFineToCoarse(DataArrayDouble *coarseDA, const std::vector& coarseSt, const DataArrayDouble *fineDA, PyObject *fineLocInCoarse) throw(INTERP_KERNEL::Exception) + { + std::vector< std::pair > inp; + convertPyToVectorPairInt(fineLocInCoarse,inp); + MEDCouplingIMesh::CondenseFineToCoarse(coarseDA,coarseSt,fineDA,inp); + } + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); @@ -4562,7 +4577,9 @@ namespace ParaMEDMEM } }; - class MEDCouplingAHOGPatch : public RefCountObject + class MEDCouplingCartesianAMRMesh; + + class MEDCouplingCartesianAMRPatch : public RefCountObject { public: int getNumberOfCellsRecursiveWithOverlap() const throw(INTERP_KERNEL::Exception); @@ -4577,9 +4594,9 @@ namespace ParaMEDMEM return convertFromVectorPairInt(ret); } - const MEDCouplingAHOGMesh *getMesh() const throw(INTERP_KERNEL::Exception) + MEDCouplingCartesianAMRMesh *getMesh() const throw(INTERP_KERNEL::Exception) { - MEDCouplingAHOGMesh *ret(const_cast(self->getMesh())); + MEDCouplingCartesianAMRMesh *ret(const_cast(self->getMesh())); if(ret) ret->incrRef(); return ret; @@ -4592,11 +4609,11 @@ namespace ParaMEDMEM self->addPatch(inp,factor); } - MEDCouplingAHOGPatch *__getitem__(int patchId) const throw(INTERP_KERNEL::Exception) + MEDCouplingCartesianAMRPatch *__getitem__(int patchId) const throw(INTERP_KERNEL::Exception) { - const MEDCouplingAHOGMesh *mesh(self->getMesh()); + const MEDCouplingCartesianAMRMesh *mesh(self->getMesh()); if(!mesh) - throw INTERP_KERNEL::Exception("wrap MEDCouplingAHOGPatch.__getitem__ : no underlying mesh !"); + throw INTERP_KERNEL::Exception("wrap MEDCouplingCartesianAMRPatch.__getitem__ : no underlying mesh !"); if(patchId==mesh->getNumberOfPatches()) { std::ostringstream oss; @@ -4604,23 +4621,31 @@ namespace ParaMEDMEM PyErr_SetString(PyExc_StopIteration,oss.str().c_str()); return 0; } - MEDCouplingAHOGPatch *ret(const_cast(mesh->getPatch(patchId))); + MEDCouplingCartesianAMRPatch *ret(const_cast(mesh->getPatch(patchId))); if(ret) ret->incrRef(); return ret; } + void __delitem__(int patchId) throw(INTERP_KERNEL::Exception) + { + MEDCouplingCartesianAMRMesh *mesh(const_cast(self->getMesh())); + if(!mesh) + throw INTERP_KERNEL::Exception("wrap MEDCouplingCartesianAMRPatch.__delitem__ : no underlying mesh !"); + mesh->removePatch(patchId); + } + int __len__() const throw(INTERP_KERNEL::Exception) { - const MEDCouplingAHOGMesh *mesh(self->getMesh()); + const MEDCouplingCartesianAMRMesh *mesh(self->getMesh()); if(!mesh) - throw INTERP_KERNEL::Exception("wrap MEDCouplingAHOGPatch.__len__ : no underlying mesh !"); + throw INTERP_KERNEL::Exception("wrap MEDCouplingCartesianAMRPatch.__len__ : no underlying mesh !"); return mesh->getNumberOfPatches(); } } }; - class MEDCouplingAHOGMesh : public RefCountObject, public TimeLabel + class MEDCouplingCartesianAMRMesh : public RefCountObject, public TimeLabel { public: @@ -4632,12 +4657,14 @@ namespace ParaMEDMEM // int getNumberOfPatches() const throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception); + void removePatch(int patchId) throw(INTERP_KERNEL::Exception); + void detachFromFather() throw(INTERP_KERNEL::Exception); %extend { - static MEDCouplingAHOGMesh *New(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) throw(INTERP_KERNEL::Exception) + static MEDCouplingCartesianAMRMesh *New(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) throw(INTERP_KERNEL::Exception) { - static const char msg0[]="MEDCouplingAHOGMesh::New : error on 'origin' parameter !"; - static const char msg1[]="MEDCouplingAHOGMesh::New : error on 'dxyz' parameter !"; + static const char msg0[]="MEDCouplingCartesianAMRMesh::New : error on 'origin' parameter !"; + static const char msg1[]="MEDCouplingCartesianAMRMesh::New : error on 'dxyz' parameter !"; const int *nodeStrctPtr(0); const double *originPtr(0),*dxyzPtr(0); int sw,sz,val0; @@ -4650,12 +4677,12 @@ namespace ParaMEDMEM originPtr=convertObjToPossibleCpp5_SingleCompo(origin,sw,val,bb,msg0,false,sz1); dxyzPtr=convertObjToPossibleCpp5_SingleCompo(dxyz,sw,val2,bb2,msg1,false,sz2); // - return MEDCouplingAHOGMesh::New(meshName,spaceDim,nodeStrctPtr,nodeStrctPtr+sz,originPtr,originPtr+sz1,dxyzPtr,dxyzPtr+sz2); + return MEDCouplingCartesianAMRMesh::New(meshName,spaceDim,nodeStrctPtr,nodeStrctPtr+sz,originPtr,originPtr+sz1,dxyzPtr,dxyzPtr+sz2); } - MEDCouplingAHOGMesh(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) throw(INTERP_KERNEL::Exception) + MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) throw(INTERP_KERNEL::Exception) { - return ParaMEDMEM_MEDCouplingAHOGMesh_New(meshName,spaceDim,nodeStrct,origin,dxyz); + return ParaMEDMEM_MEDCouplingCartesianAMRMesh_New(meshName,spaceDim,nodeStrct,origin,dxyz); } void addPatch(PyObject *bottomLeftTopRight, int factor) throw(INTERP_KERNEL::Exception) @@ -4665,31 +4692,31 @@ namespace ParaMEDMEM self->addPatch(inp,factor); } - MEDCouplingAHOGMesh *getFather() const throw(INTERP_KERNEL::Exception) + MEDCouplingCartesianAMRMesh *getFather() const throw(INTERP_KERNEL::Exception) { - MEDCouplingAHOGMesh *ret(const_cast(self->getFather())); + MEDCouplingCartesianAMRMesh *ret(const_cast(self->getFather())); if(ret) ret->incrRef(); return ret; } - MEDCouplingAHOGMesh *getGodFather() const throw(INTERP_KERNEL::Exception) + MEDCouplingCartesianAMRMesh *getGodFather() const throw(INTERP_KERNEL::Exception) { - MEDCouplingAHOGMesh *ret(const_cast(self->getGodFather())); + MEDCouplingCartesianAMRMesh *ret(const_cast(self->getGodFather())); if(ret) ret->incrRef(); return ret; } - MEDCouplingAHOGPatch *getPatch(int patchId) const throw(INTERP_KERNEL::Exception) + MEDCouplingCartesianAMRPatch *getPatch(int patchId) const throw(INTERP_KERNEL::Exception) { - MEDCouplingAHOGPatch *ret(const_cast(self->getPatch(patchId))); + MEDCouplingCartesianAMRPatch *ret(const_cast(self->getPatch(patchId))); if(ret) ret->incrRef(); return ret; } - MEDCouplingAHOGPatch *__getitem__(int patchId) const throw(INTERP_KERNEL::Exception) + MEDCouplingCartesianAMRPatch *__getitem__(int patchId) const throw(INTERP_KERNEL::Exception) { if(patchId==self->getNumberOfPatches()) { @@ -4698,12 +4725,17 @@ namespace ParaMEDMEM PyErr_SetString(PyExc_StopIteration,oss.str().c_str()); return 0; } - MEDCouplingAHOGPatch *ret(const_cast(self->getPatch(patchId))); + MEDCouplingCartesianAMRPatch *ret(const_cast(self->getPatch(patchId))); if(ret) ret->incrRef(); return ret; } + void __delitem__(int patchId) throw(INTERP_KERNEL::Exception) + { + self->removePatch(patchId); + } + int __len__() const throw(INTERP_KERNEL::Exception) { return self->getNumberOfPatches(); -- 2.39.2