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 "BoxSplittingOptions.hxx"
30 #include "InterpKernelException.hxx"
34 class MEDCouplingIMesh;
35 class MEDCouplingUMesh;
37 class DataArrayDouble;
38 class MEDCoupling1SGTUMesh;
39 class MEDCouplingCartesianAMRMesh;
42 class MEDCouplingCartesianAMRPatch : public RefCountObject
45 MEDCouplingCartesianAMRPatch(MEDCouplingCartesianAMRMesh *mesh, const std::vector< std::pair<int,int> >& bottomLeftTopRight);
46 // direct forward to _mesh
47 MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithOverlap() const;
48 MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithoutOverlap() const;
49 MEDCOUPLING_EXPORT int getMaxNumberOfLevelsRelativeToThis() const;
50 MEDCOUPLING_EXPORT void addPatch(const std::vector< std::pair<int,int> >& bottomLeftTopRight, const std::vector<int>& factors);
51 // end of direct forward to _mesh
52 MEDCOUPLING_EXPORT int getNumberOfOverlapedCellsForFather() const;
54 MEDCOUPLING_EXPORT const std::vector< std::pair<int,int> >& getBLTRRange() const { return _bl_tr; }
55 MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMesh *getMesh() const { return _mesh; }
57 std::size_t getHeapMemorySizeWithoutChildren() const;
58 std::vector<const BigMemoryObject *> getDirectChildren() const;
60 //! bottom left/top right cell range relative to \a _father
61 std::vector< std::pair<int,int> > _bl_tr;
62 MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRMesh> _mesh;
67 * This class is the base class dedicated to AMR using Adaptative Hierarchical Overlapped image Grid.
68 * This class does \b NOT inherit from MEDCouplingMesh because this class overlaps image grid structured meshes to perform adaptative mesh refinement.
69 * But this class aggregates MEDCouplingMesh instances !
71 class MEDCouplingCartesianAMRMesh : public RefCountObject, public TimeLabel
74 MEDCOUPLING_EXPORT static MEDCouplingCartesianAMRMesh *New(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
75 const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
76 MEDCOUPLING_EXPORT int getSpaceDimension() const;
77 MEDCOUPLING_EXPORT const std::vector<int>& getFactors() const { return _factors; }
78 MEDCOUPLING_EXPORT void setFactors(const std::vector<int>& newFactors);
79 MEDCOUPLING_EXPORT int getMaxNumberOfLevelsRelativeToThis() const;
80 MEDCOUPLING_EXPORT int getNumberOfCellsAtCurrentLevel() const;
81 MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithOverlap() const;
82 MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithoutOverlap() const;
83 MEDCOUPLING_EXPORT const MEDCouplingIMesh *getImageMesh() const { return _mesh; }
85 MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMesh *getFather() const;
86 MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMesh *getGodFather() const;
87 MEDCOUPLING_EXPORT void detachFromFather();
88 MEDCOUPLING_EXPORT void addPatch(const std::vector< std::pair<int,int> >& bottomLeftTopRight, const std::vector<int>& factors);
89 MEDCOUPLING_EXPORT void createPatchesFromCriterion(const INTERP_KERNEL::BoxSplittingOptions& bso, const std::vector<bool>& criterion, const std::vector<int>& factors);
90 MEDCOUPLING_EXPORT void createPatchesFromCriterion(const INTERP_KERNEL::BoxSplittingOptions& bso, const DataArrayByte *criterion, const std::vector<int>& factors);
91 MEDCOUPLING_EXPORT void removeAllPatches();
92 MEDCOUPLING_EXPORT void removePatch(int patchId);
93 MEDCOUPLING_EXPORT int getNumberOfPatches() const;
94 MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRPatch *getPatch(int patchId) const;
95 MEDCOUPLING_EXPORT DataArrayDouble *createCellFieldOnPatch(int patchId, const DataArrayDouble *cellFieldOnThis) const;
96 MEDCOUPLING_EXPORT void fillCellFieldOnPatch(int patchId, const DataArrayDouble *cellFieldOnThis, DataArrayDouble *cellFieldOnPatch) const;
97 MEDCOUPLING_EXPORT void fillCellFieldComingFromPatch(int patchId, const DataArrayDouble *cellFieldOnPatch, DataArrayDouble *cellFieldOnThis) const;
99 MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const;
100 MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh *buildMeshFromPatchEnvelop() const;
102 MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
103 const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
104 MEDCouplingCartesianAMRMesh(MEDCouplingCartesianAMRMesh *father, MEDCouplingIMesh *mesh);
105 void checkPatchId(int patchId) const;
106 void checkFactorsAndIfNotSetAssign(const std::vector<int>& factors);
108 MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
109 MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
110 MEDCOUPLING_EXPORT void updateTime() const;
112 MEDCouplingCartesianAMRMesh *_father;
113 MEDCouplingAutoRefCountObjectPtr<MEDCouplingIMesh> _mesh;
114 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRPatch> > _patches;
115 std::vector<int> _factors;