MEDCouplingMultiFields.cxx
MEDCouplingDefinitionTime.cxx
MEDCouplingFieldOverTime.cxx
- MEDCouplingAHOGMesh.cxx
+ MEDCouplingCartesianAMRMesh.cxx
)
SET(medcouplingremapper_SOURCES
+++ /dev/null
-// 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 <limits>
-#include <sstream>
-
-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<int,int> >& 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<int,int> >& 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<int,int>);
- return ret;
-}
-
-std::vector<const BigMemoryObject *> MEDCouplingAHOGPatch::getDirectChildren() const
-{
- std::vector<const BigMemoryObject *> 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<MEDCouplingAHOGPatch> >::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<MEDCouplingAHOGPatch> >::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<MEDCouplingAHOGPatch> >::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<int,int> >& bottomLeftTopRight, int factor)
-{
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingIMesh> mesh(static_cast<MEDCouplingIMesh *>(_mesh->buildStructuredSubPart(bottomLeftTopRight)));
- mesh->refineWithFactor(factor);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingAHOGMesh> zeMesh(new MEDCouplingAHOGMesh(this,mesh));
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingAHOGPatch> 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<MEDCouplingUMesh> part(_mesh->buildUnstructured());
- std::vector<bool> bs(_mesh->getNumberOfCells(),false);
- std::vector<int> cgs(_mesh->getCellGridStructure());
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> > msSafe(_patches.size()+1);
- std::size_t ii(0);
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingAHOGPatch> >::const_iterator it=_patches.begin();it!=_patches.end();it++,ii++)
- {
- MEDCouplingStructuredMesh::SwitchOnIdsFrom(cgs,(*it)->getBLTRRange(),bs);
- msSafe[ii+1]=(*it)->getMesh()->buildUnstructured();
- }
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> eltsOff(DataArrayInt::BuildListOfSwitchedOff(bs));
- msSafe[0]=static_cast<MEDCouplingUMesh *>(part->buildPartOfMySelf(eltsOff->begin(),eltsOff->end(),false));
- std::vector< const MEDCouplingUMesh * > ms(msSafe.size());
- for(std::size_t i=0;i<msSafe.size();i++)
- ms[i]=msSafe[i];
- return MEDCouplingUMesh::MergeUMeshes(ms);
-}
-
-MEDCouplingAHOGMesh::MEDCouplingAHOGMesh(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
- const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop):_father(0)
-{
- _mesh=MEDCouplingIMesh::New(meshName,spaceDim,nodeStrctStart,nodeStrctStop,originStart,originStop,dxyzStart,dxyzStop);
-}
-
-MEDCouplingAHOGMesh::MEDCouplingAHOGMesh(MEDCouplingAHOGMesh *father, MEDCouplingIMesh *mesh):_father(father)
-{
- if(!_father)
- throw INTERP_KERNEL::Exception("MEDCouplingAHOGMesh(MEDCouplingIMesh *mesh) constructor : empty father !");
- if(!mesh)
- throw INTERP_KERNEL::Exception("MEDCouplingAHOGMesh(MEDCouplingIMesh *mesh) constructor : The input mesh is null !");
- mesh->checkCoherency();
- _mesh=mesh; _mesh->incrRef();
-}
-
-std::size_t MEDCouplingAHOGMesh::getHeapMemorySizeWithoutChildren() const
-{
- return sizeof(MEDCouplingAHOGMesh);
-}
-
-std::vector<const BigMemoryObject *> MEDCouplingAHOGMesh::getDirectChildren() const
-{
- std::vector<const BigMemoryObject *> ret;
- if((const MEDCouplingIMesh *)_mesh)
- ret.push_back((const MEDCouplingIMesh *)_mesh);
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingAHOGPatch> >::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);
-}
+++ /dev/null
-// 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
-
-#ifndef __MEDCOUPLINGAHOGMESH_HXX__
-#define __MEDCOUPLINGAHOGMESH_HXX__
-
-#include "MEDCoupling.hxx"
-#include "MEDCouplingTimeLabel.hxx"
-#include "MEDCouplingRefCountObject.hxx"
-#include "MEDCouplingAutoRefCountObjectPtr.hxx"
-
-#include "InterpKernelException.hxx"
-
-namespace ParaMEDMEM
-{
- class MEDCouplingIMesh;
- class MEDCouplingUMesh;
- class MEDCouplingAHOGMesh;
-
- /// @cond INTERNAL
- class MEDCouplingAHOGPatch : public RefCountObject
- {
- public:
- MEDCouplingAHOGPatch(MEDCouplingAHOGMesh *mesh, const std::vector< std::pair<int,int> >& bottomLeftTopRight);
- // direct forward to _mesh
- MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithOverlap() const;
- MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithoutOverlap() const;
- MEDCOUPLING_EXPORT int getMaxNumberOfLevelsRelativeToThis() const;
- MEDCOUPLING_EXPORT void addPatch(const std::vector< std::pair<int,int> >& bottomLeftTopRight, int factor);
- // end of direct forward to _mesh
- MEDCOUPLING_EXPORT int getNumberOfOverlapedCellsForFather() const;
- // basic set/get
- MEDCOUPLING_EXPORT const std::vector< std::pair<int,int> >& getBLTRRange() const { return _bl_tr; }
- MEDCOUPLING_EXPORT const MEDCouplingAHOGMesh *getMesh() const { return _mesh; }
- private:
- std::size_t getHeapMemorySizeWithoutChildren() const;
- std::vector<const BigMemoryObject *> getDirectChildren() const;
- private:
- //! bottom left/top right cell range relative to \a _father
- std::vector< std::pair<int,int> > _bl_tr;
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingAHOGMesh> _mesh;
- };
- /// @endcond
-
- /*!
- * This class is the base class dedicated to AMR using Adaptative Hierarchical Overlapped image Grid.
- * 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
- {
- public:
- MEDCOUPLING_EXPORT static 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);
- MEDCOUPLING_EXPORT int getSpaceDimension() const;
- MEDCOUPLING_EXPORT int getMaxNumberOfLevelsRelativeToThis() const;
- MEDCOUPLING_EXPORT int getNumberOfCellsAtCurrentLevel() const;
- MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithOverlap() const;
- MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithoutOverlap() const;
- //
- MEDCOUPLING_EXPORT const MEDCouplingAHOGMesh *getFather() const;
- MEDCOUPLING_EXPORT const MEDCouplingAHOGMesh *getGodFather() const;
- MEDCOUPLING_EXPORT void addPatch(const std::vector< std::pair<int,int> >& bottomLeftTopRight, int factor);
- MEDCOUPLING_EXPORT int getNumberOfPatches() const;
- MEDCOUPLING_EXPORT const MEDCouplingAHOGPatch *getPatch(int patchId) const;
- //
- MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const;
- private:
- MEDCouplingAHOGMesh(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);
- protected:
- MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
- MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
- MEDCOUPLING_EXPORT void updateTime() const;
- private:
- MEDCouplingAHOGMesh *_father;
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingIMesh> _mesh;
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingAHOGPatch> > _patches;
- };
-}
-
-#endif
-
checkCoherency1(eps);
}
-void MEDCouplingCMesh::getSplitCellValues(int *res) const
-{
- int meshDim(getMeshDimension());
- for(int l=0;l<meshDim;l++)
- {
- int val=1;
- for(int p=0;p<meshDim-l-1;p++)
- val*=getCoordsAt(p)->getNbOfElems()-1;
- res[meshDim-l-1]=val;
- }
-}
-
-void MEDCouplingCMesh::getSplitNodeValues(int *res) const
-{
- int spaceDim(getSpaceDimension());
- for(int l=0;l<spaceDim;l++)
- {
- int val=1;
- for(int p=0;p<spaceDim-l-1;p++)
- val*=getCoordsAt(p)->getNbOfElems();
- res[spaceDim-l-1]=val;
- }
-}
-
void MEDCouplingCMesh::getNodeGridStructure(int *res) const
{
std::vector<int> ret(getNodeGridStructure());
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<int> getNodeGridStructure() const;
MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair<int,int> >& cellPart) const;
--- /dev/null
+// 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 <limits>
+#include <sstream>
+
+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<int,int> >& 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<int,int> >& 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<int,int>);
+ return ret;
+}
+
+std::vector<const BigMemoryObject *> MEDCouplingCartesianAMRPatch::getDirectChildren() const
+{
+ std::vector<const BigMemoryObject *> 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<MEDCouplingCartesianAMRPatch> >::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<MEDCouplingCartesianAMRPatch> >::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<MEDCouplingCartesianAMRPatch> >::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<int,int> >& bottomLeftTopRight, int factor)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingIMesh> mesh(static_cast<MEDCouplingIMesh *>(_mesh->buildStructuredSubPart(bottomLeftTopRight)));
+ mesh->refineWithFactor(factor);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRMesh> zeMesh(new MEDCouplingCartesianAMRMesh(this,mesh));
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRPatch> 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<MEDCouplingCartesianAMRPatch> > patches(sz-1);
+ for(int i=0;i<sz;i++)
+ if(i!=patchId)
+ patches[j++]=_patches[i];
+ (const_cast<MEDCouplingCartesianAMRMesh *>(_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<MEDCouplingUMesh> part(_mesh->buildUnstructured());
+ std::vector<bool> bs(_mesh->getNumberOfCells(),false);
+ std::vector<int> cgs(_mesh->getCellGridStructure());
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> > msSafe(_patches.size()+1);
+ std::size_t ii(0);
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRPatch> >::const_iterator it=_patches.begin();it!=_patches.end();it++,ii++)
+ {
+ MEDCouplingStructuredMesh::SwitchOnIdsFrom(cgs,(*it)->getBLTRRange(),bs);
+ msSafe[ii+1]=(*it)->getMesh()->buildUnstructured();
+ }
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> eltsOff(DataArrayInt::BuildListOfSwitchedOff(bs));
+ msSafe[0]=static_cast<MEDCouplingUMesh *>(part->buildPartOfMySelf(eltsOff->begin(),eltsOff->end(),false));
+ std::vector< const MEDCouplingUMesh * > ms(msSafe.size());
+ for(std::size_t i=0;i<msSafe.size();i++)
+ ms[i]=msSafe[i];
+ return MEDCouplingUMesh::MergeUMeshes(ms);
+}
+
+MEDCouplingCartesianAMRMesh::MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
+ const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop):_father(0)
+{
+ _mesh=MEDCouplingIMesh::New(meshName,spaceDim,nodeStrctStart,nodeStrctStop,originStart,originStop,dxyzStart,dxyzStop);
+}
+
+MEDCouplingCartesianAMRMesh::MEDCouplingCartesianAMRMesh(MEDCouplingCartesianAMRMesh *father, MEDCouplingIMesh *mesh):_father(father)
+{
+ if(!_father)
+ throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMesh(MEDCouplingIMesh *mesh) constructor : empty father !");
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMesh(MEDCouplingIMesh *mesh) constructor : The input mesh is null !");
+ mesh->checkCoherency();
+ _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<const BigMemoryObject *> MEDCouplingCartesianAMRMesh::getDirectChildren() const
+{
+ std::vector<const BigMemoryObject *> ret;
+ if((const MEDCouplingIMesh *)_mesh)
+ ret.push_back((const MEDCouplingIMesh *)_mesh);
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRPatch> >::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<MEDCouplingCartesianAMRPatch> >::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);
+ }
+}
--- /dev/null
+// 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
+
+#ifndef __MEDCOUPLINGCARTESIANAMRMESH_HXX__
+#define __MEDCOUPLINGCARTESIANAMRMESH_HXX__
+
+#include "MEDCoupling.hxx"
+#include "MEDCouplingTimeLabel.hxx"
+#include "MEDCouplingRefCountObject.hxx"
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+
+#include "InterpKernelException.hxx"
+
+namespace ParaMEDMEM
+{
+ class MEDCouplingIMesh;
+ class MEDCouplingUMesh;
+ class MEDCouplingCartesianAMRMesh;
+
+ /// @cond INTERNAL
+ class MEDCouplingCartesianAMRPatch : public RefCountObject
+ {
+ public:
+ MEDCouplingCartesianAMRPatch(MEDCouplingCartesianAMRMesh *mesh, const std::vector< std::pair<int,int> >& bottomLeftTopRight);
+ // direct forward to _mesh
+ MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithOverlap() const;
+ MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithoutOverlap() const;
+ MEDCOUPLING_EXPORT int getMaxNumberOfLevelsRelativeToThis() const;
+ MEDCOUPLING_EXPORT void addPatch(const std::vector< std::pair<int,int> >& bottomLeftTopRight, int factor);
+ // end of direct forward to _mesh
+ MEDCOUPLING_EXPORT int getNumberOfOverlapedCellsForFather() const;
+ // basic set/get
+ MEDCOUPLING_EXPORT const std::vector< std::pair<int,int> >& getBLTRRange() const { return _bl_tr; }
+ MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMesh *getMesh() const { return _mesh; }
+ private:
+ std::size_t getHeapMemorySizeWithoutChildren() const;
+ std::vector<const BigMemoryObject *> getDirectChildren() const;
+ private:
+ //! bottom left/top right cell range relative to \a _father
+ std::vector< std::pair<int,int> > _bl_tr;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRMesh> _mesh;
+ };
+ /// @endcond
+
+ /*!
+ * This class is the base class dedicated to AMR using Adaptative Hierarchical Overlapped image Grid.
+ * 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 MEDCouplingCartesianAMRMesh : public RefCountObject, public TimeLabel
+ {
+ public:
+ MEDCOUPLING_EXPORT static MEDCouplingCartesianAMRMesh *New(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
+ const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
+ MEDCOUPLING_EXPORT int getSpaceDimension() const;
+ MEDCOUPLING_EXPORT int getMaxNumberOfLevelsRelativeToThis() const;
+ MEDCOUPLING_EXPORT int getNumberOfCellsAtCurrentLevel() const;
+ MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithOverlap() const;
+ MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithoutOverlap() 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<int,int> >& bottomLeftTopRight, int factor);
+ MEDCOUPLING_EXPORT void removePatch(int patchId);
+ MEDCOUPLING_EXPORT int getNumberOfPatches() const;
+ MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRPatch *getPatch(int patchId) const;
+ //
+ MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const;
+ private:
+ MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
+ const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
+ MEDCouplingCartesianAMRMesh(MEDCouplingCartesianAMRMesh *father, MEDCouplingIMesh *mesh);
+ void checkPatchId(int patchId) const;
+ protected:
+ MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
+ MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
+ MEDCOUPLING_EXPORT void updateTime() const;
+ private:
+ MEDCouplingCartesianAMRMesh *_father;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingIMesh> _mesh;
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRPatch> > _patches;
+ };
+}
+
+#endif
+
return MEDCouplingStructuredMesh::getNumberOfNodes();
}
-void MEDCouplingCurveLinearMesh::getSplitCellValues(int *res) const
-{
- int meshDim=getMeshDimension();
- for(int l=0;l<meshDim;l++)
- {
- int val=1;
- for(int p=0;p<meshDim-l-1;p++)
- val*=_structure[p]-1;
- res[meshDim-l-1]=val;
- }
-}
-
-void MEDCouplingCurveLinearMesh::getSplitNodeValues(int *res) const
-{
- int meshDim=getMeshDimension();
- for(int l=0;l<meshDim;l++)
- {
- int val=1;
- for(int p=0;p<meshDim-l-1;p++)
- val*=_structure[p];
- res[meshDim-l-1]=val;
- }
-}
-
void MEDCouplingCurveLinearMesh::getNodeGridStructure(int *res) const
{
std::copy(_structure.begin(),_structure.end(),res);
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;
//serialisation-unserialization
MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
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<int>& coarseSt, const DataArrayDouble *fineDA, const std::vector< std::pair<int,int> >& 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<DataArrayInt> 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<int> dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
+ for(int it=0;it<dims[1];it++)
+ {
+ for(int i=0;i<fact;i++)
+ {
+ for(int j=0;j<dims[0];j++,inPtr+=fact)
+ {
+ double *loc(outPtr+idsPtr[kk+j]*nbCompo);
+ std::transform(inPtr,inPtr+fact,loc,loc,std::plus<double>());
+ }
+ }
+ kk+=it;
+ }
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : only dimensions 2 supported !");
+ }
+}
+
void MEDCouplingIMesh::setSpaceDimension(int spaceDim)
{
if(spaceDim==_space_dim)
checkCoherency1(eps);
}
-void MEDCouplingIMesh::getSplitCellValues(int *res) const
-{
- int meshDim(getMeshDimension());
- for(int l=0;l<meshDim;l++)
- {
- int val=1;
- for(int p=0;p<meshDim-l-1;p++)
- val*=_structure[p]-1;
- res[meshDim-l-1]=val;
- }
-}
-
-void MEDCouplingIMesh::getSplitNodeValues(int *res) const
-{
- int spaceDim(getSpaceDimension());
- for(int l=0;l<spaceDim;l++)
- {
- int val=1;
- for(int p=0;p<spaceDim-l-1;p++)
- val*=_structure[p];
- res[spaceDim-l-1]=val;
- }
-}
-
void MEDCouplingIMesh::getNodeGridStructure(int *res) const
{
checkSpaceDimension();
throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CheckSpaceDimension : input spaceDim must be in [0,1,2,3] !");
}
+int MEDCouplingIMesh::FindIntRoot(int val, int order)
+{
+ if(order==0)
+ return 1;
+ if(val<0)
+ throw INTERP_KERNEL::Exception("MEDCouplingIMesh::FindIntRoot : input val is < 0 ! Not possible to compute a root !");
+ if(order==1)
+ return val;
+ if(order!=2 && order!=3)
+ throw INTERP_KERNEL::Exception("MEDCouplingIMesh::FindIntRoot : the order available are 0,1,2 or 3 !");
+ double valf((double)val);
+ if(order==2)
+ {
+ double retf(sqrt(valf));
+ int ret((int)retf);
+ if(ret*ret!=val)
+ throw INTERP_KERNEL::Exception("MEDCouplingIMesh::FindIntRoot : the input val is not a perfect square root !");
+ return ret;
+ }
+ else//order==3
+ {
+ double retf(std::pow(val,0.3333333333333333));
+ int ret((int)round(retf));
+ if(ret*ret*ret!=val)
+ throw INTERP_KERNEL::Exception("MEDCouplingIMesh::FindIntRoot : the input val is not a perfect cublic root !");
+ return ret;
+ }
+}
MEDCOUPLING_EXPORT double getMeasureOfAnyCell() const;
MEDCOUPLING_EXPORT MEDCouplingCMesh *convertToCartesian() const;
MEDCOUPLING_EXPORT void refineWithFactor(int factor);
+ MEDCOUPLING_EXPORT static void CondenseFineToCoarse(DataArrayDouble *coarseDA, const std::vector<int>& coarseSt, const DataArrayDouble *fineDA, const std::vector< std::pair<int,int> >& fineLocInCoarse);
//
MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const;
MEDCOUPLING_EXPORT MEDCouplingIMesh *clone(bool recDeepCpy) const;
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<int> getNodeGridStructure() const;
MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair<int,int> >& cellPart) const;
std::vector<std::string> buildInfoOnComponents() const;
void checkSpaceDimension() const;
static void CheckSpaceDimension(int spaceDim);
+ static int FindIntRoot(int val, int order);
private:
int _space_dim;
double _origin[3];
return spd1;
}
+void MEDCouplingStructuredMesh::getSplitCellValues(int *res) const
+{
+ std::vector<int> strct(getCellGridStructure());
+ std::vector<int> ret(MEDCouplingStructuredMesh::GetSplitVectFromStruct(strct));
+ std::copy(ret.begin(),ret.end(),res);
+}
+
+void MEDCouplingStructuredMesh::getSplitNodeValues(int *res) const
+{
+ std::vector<int> strct(getNodeGridStructure());
+ std::vector<int> 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.
*/
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<int> MEDCouplingStructuredMesh::GetSplitVectFromStruct(const std::vector<int>& strct)
+{
+ int spaceDim((int)strct.size());
+ std::vector<int> res(spaceDim);
+ for(int l=0;l<spaceDim;l++)
+ {
+ int val=1;
+ for(int p=0;p<spaceDim-l-1;p++)
+ val*=strct[p];
+ res[spaceDim-l-1]=val;
+ }
+ return res;
+}
+
/*!
* This method states if given part ids [ \a startIds, \a stopIds) and a structure \a st returns if it can be considered as a structured dataset.
* If true is returned \a partCompactFormat will contain the information to build the corresponding part.
}
}
+std::vector<int> MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(const std::vector< std::pair<int,int> >& partCompactFormat)
+{
+ std::vector<int> ret(partCompactFormat.size());
+ for(std::size_t i=0;i<partCompactFormat.size();i++)
+ ret[i]=partCompactFormat[i].second-partCompactFormat[i].first;
+ return ret;
+}
+
/*!
* This method is close to BuildExplicitIdsFrom except that instead of returning a DataArrayInt instance containing explicit ids it
* enable elems in the vector of booleans (for performance reasons). As it is method for performance, this method is \b not
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<int> dims(st.size());
- for(std::size_t i=0;i<st.size();i++)
- dims[i]=partCompactFormat[i].second-partCompactFormat[i].first;
+ std::vector<int> dims(GetDimensionsFromCompactFrmt(partCompactFormat));
switch(st.size())
{
case 3:
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<int> getNodeGridStructure() const = 0;
MEDCOUPLING_EXPORT std::vector<int> getCellGridStructure() const;
MEDCOUPLING_EXPORT virtual MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair<int,int> >& cellPart) const = 0;
+ MEDCOUPLING_EXPORT static std::vector<int> GetSplitVectFromStruct(const std::vector<int>& strct);
MEDCOUPLING_EXPORT static bool IsPartStructured(const int *startIds, const int *stopIds, const std::vector<int>& st, std::vector< std::pair<int,int> >& partCompactFormat);
+ MEDCOUPLING_EXPORT static std::vector<int> GetDimensionsFromCompactFrmt(const std::vector< std::pair<int,int> >& partCompactFormat);
MEDCOUPLING_EXPORT static void SwitchOnIdsFrom(const std::vector<int>& st, const std::vector< std::pair<int,int> >& partCompactFormat, std::vector<bool>& vectToSwitchOn);
MEDCOUPLING_EXPORT static DataArrayInt *BuildExplicitIdsFrom(const std::vector<int>& st, const std::vector< std::pair<int,int> >& partCompactFormat);
MEDCOUPLING_EXPORT static DataArrayInt *Build1GTNodalConnectivity(const int *nodeStBg, const int *nodeStEnd);
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
#include "MEDCouplingFieldOverTime.hxx"
#include "MEDCouplingDefinitionTime.hxx"
#include "MEDCouplingFieldDiscretization.hxx"
-#include "MEDCouplingAHOGMesh.hxx"
+#include "MEDCouplingCartesianAMRMesh.hxx"
#include "MEDCouplingTypemaps.i"
#include "InterpKernelAutoPtr.hxx"
%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();"
%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;
static INTERP_KERNEL::NormalizedCellType GetGeoTypeGivenMeshDimension(int meshDim) throw(INTERP_KERNEL::Exception);
MEDCoupling1SGTUMesh *build1SGTSubLevelMesh() const throw(INTERP_KERNEL::Exception);
static int DeduceNumberOfGivenStructure(const std::vector<int>& st) throw(INTERP_KERNEL::Exception);
+ static std::vector<int> GetSplitVectFromStruct(const std::vector<int>& strct) throw(INTERP_KERNEL::Exception);
%extend
{
virtual MEDCouplingStructuredMesh *buildStructuredSubPart(PyObject *cellPart) const throw(INTERP_KERNEL::Exception)
return MEDCouplingStructuredMesh::Build1GTNodalConnectivityOfSubLevelMesh(tmp,tmp+szArr);
}
+ static std::vector<int> GetDimensionsFromCompactFrmt(PyObject *partCompactFormat) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair<int,int> > inp;
+ convertPyToVectorPairInt(partCompactFormat,inp);
+ return MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(inp);
+ }
+
static PyObject *IsPartStructured(PyObject *li, PyObject *st) throw(INTERP_KERNEL::Exception)
{
int szArr,sw,iTypppArr;
self->setDXYZ(originPtr,originPtr+nbTuples);
}
+ static void CondenseFineToCoarse(DataArrayDouble *coarseDA, const std::vector<int>& coarseSt, const DataArrayDouble *fineDA, PyObject *fineLocInCoarse) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair<int,int> > inp;
+ convertPyToVectorPairInt(fineLocInCoarse,inp);
+ MEDCouplingIMesh::CondenseFineToCoarse(coarseDA,coarseSt,fineDA,inp);
+ }
+
std::string __str__() const throw(INTERP_KERNEL::Exception)
{
return self->simpleRepr();
}
};
- class MEDCouplingAHOGPatch : public RefCountObject
+ class MEDCouplingCartesianAMRMesh;
+
+ class MEDCouplingCartesianAMRPatch : public RefCountObject
{
public:
int getNumberOfCellsRecursiveWithOverlap() const throw(INTERP_KERNEL::Exception);
return convertFromVectorPairInt(ret);
}
- const MEDCouplingAHOGMesh *getMesh() const throw(INTERP_KERNEL::Exception)
+ MEDCouplingCartesianAMRMesh *getMesh() const throw(INTERP_KERNEL::Exception)
{
- MEDCouplingAHOGMesh *ret(const_cast<MEDCouplingAHOGMesh *>(self->getMesh()));
+ MEDCouplingCartesianAMRMesh *ret(const_cast<MEDCouplingCartesianAMRMesh *>(self->getMesh()));
if(ret)
ret->incrRef();
return ret;
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;
PyErr_SetString(PyExc_StopIteration,oss.str().c_str());
return 0;
}
- MEDCouplingAHOGPatch *ret(const_cast<MEDCouplingAHOGPatch *>(mesh->getPatch(patchId)));
+ MEDCouplingCartesianAMRPatch *ret(const_cast<MEDCouplingCartesianAMRPatch *>(mesh->getPatch(patchId)));
if(ret)
ret->incrRef();
return ret;
}
+ void __delitem__(int patchId) throw(INTERP_KERNEL::Exception)
+ {
+ MEDCouplingCartesianAMRMesh *mesh(const_cast<MEDCouplingCartesianAMRMesh *>(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:
//
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;
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)
self->addPatch(inp,factor);
}
- MEDCouplingAHOGMesh *getFather() const throw(INTERP_KERNEL::Exception)
+ MEDCouplingCartesianAMRMesh *getFather() const throw(INTERP_KERNEL::Exception)
{
- MEDCouplingAHOGMesh *ret(const_cast<MEDCouplingAHOGMesh *>(self->getFather()));
+ MEDCouplingCartesianAMRMesh *ret(const_cast<MEDCouplingCartesianAMRMesh *>(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<MEDCouplingAHOGMesh *>(self->getGodFather()));
+ MEDCouplingCartesianAMRMesh *ret(const_cast<MEDCouplingCartesianAMRMesh *>(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<MEDCouplingAHOGPatch *>(self->getPatch(patchId)));
+ MEDCouplingCartesianAMRPatch *ret(const_cast<MEDCouplingCartesianAMRPatch *>(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())
{
PyErr_SetString(PyExc_StopIteration,oss.str().c_str());
return 0;
}
- MEDCouplingAHOGPatch *ret(const_cast<MEDCouplingAHOGPatch *>(self->getPatch(patchId)));
+ MEDCouplingCartesianAMRPatch *ret(const_cast<MEDCouplingCartesianAMRPatch *>(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();