1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay
21 #ifndef __MEDCOUPLINGCARTESIANAMRMESH_HXX__
22 #define __MEDCOUPLINGCARTESIANAMRMESH_HXX__
24 #include "MEDCoupling.hxx"
25 #include "MEDCouplingTimeLabel.hxx"
26 #include "MEDCouplingRefCountObject.hxx"
27 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
29 #include "InterpKernelException.hxx"
33 class MEDCouplingIMesh;
34 class MEDCouplingUMesh;
35 class MEDCouplingCartesianAMRMesh;
38 class MEDCouplingCartesianAMRPatch : public RefCountObject
41 MEDCouplingCartesianAMRPatch(MEDCouplingCartesianAMRMesh *mesh, const std::vector< std::pair<int,int> >& bottomLeftTopRight);
42 // direct forward to _mesh
43 MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithOverlap() const;
44 MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithoutOverlap() const;
45 MEDCOUPLING_EXPORT int getMaxNumberOfLevelsRelativeToThis() const;
46 MEDCOUPLING_EXPORT void addPatch(const std::vector< std::pair<int,int> >& bottomLeftTopRight, int factor);
47 // end of direct forward to _mesh
48 MEDCOUPLING_EXPORT int getNumberOfOverlapedCellsForFather() const;
50 MEDCOUPLING_EXPORT const std::vector< std::pair<int,int> >& getBLTRRange() const { return _bl_tr; }
51 MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMesh *getMesh() const { return _mesh; }
53 std::size_t getHeapMemorySizeWithoutChildren() const;
54 std::vector<const BigMemoryObject *> getDirectChildren() const;
56 //! bottom left/top right cell range relative to \a _father
57 std::vector< std::pair<int,int> > _bl_tr;
58 MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRMesh> _mesh;
63 * This class is the base class dedicated to AMR using Adaptative Hierarchical Overlapped image Grid.
64 * This class does \b NOT inherit from MEDCouplingMesh because this class overlaps image grid structured meshes to perform adaptative mesh refinement.
65 * But this class aggregates MEDCouplingMesh instances !
67 class MEDCouplingCartesianAMRMesh : public RefCountObject, public TimeLabel
70 MEDCOUPLING_EXPORT static MEDCouplingCartesianAMRMesh *New(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
71 const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
72 MEDCOUPLING_EXPORT int getSpaceDimension() const;
73 MEDCOUPLING_EXPORT int getMaxNumberOfLevelsRelativeToThis() const;
74 MEDCOUPLING_EXPORT int getNumberOfCellsAtCurrentLevel() const;
75 MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithOverlap() const;
76 MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithoutOverlap() const;
78 MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMesh *getFather() const;
79 MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMesh *getGodFather() const;
80 MEDCOUPLING_EXPORT void detachFromFather();
81 MEDCOUPLING_EXPORT void addPatch(const std::vector< std::pair<int,int> >& bottomLeftTopRight, int factor);
82 MEDCOUPLING_EXPORT void removePatch(int patchId);
83 MEDCOUPLING_EXPORT int getNumberOfPatches() const;
84 MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRPatch *getPatch(int patchId) const;
86 MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const;
88 MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
89 const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
90 MEDCouplingCartesianAMRMesh(MEDCouplingCartesianAMRMesh *father, MEDCouplingIMesh *mesh);
91 void checkPatchId(int patchId) const;
93 MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
94 MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
95 MEDCOUPLING_EXPORT void updateTime() const;
97 MEDCouplingCartesianAMRMesh *_father;
98 MEDCouplingAutoRefCountObjectPtr<MEDCouplingIMesh> _mesh;
99 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRPatch> > _patches;