Salome HOME
Spread and condense on cell fields on images meshes with ghost management in 1D and 2D.
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingIMesh.hxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #ifndef __PARAMEDMEM_MEDCOUPLINGIMESH_HXX__
22 #define __PARAMEDMEM_MEDCOUPLINGIMESH_HXX__
23
24 #include "MEDCoupling.hxx"
25 #include "MEDCouplingStructuredMesh.hxx"
26
27 namespace ParaMEDMEM
28 {
29   class MEDCouplingCMesh;
30
31   class MEDCouplingIMesh : public MEDCouplingStructuredMesh
32   {
33   public:
34     MEDCOUPLING_EXPORT static MEDCouplingIMesh *New();
35     MEDCOUPLING_EXPORT static MEDCouplingIMesh *New(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
36                                                     const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
37     //
38     MEDCOUPLING_EXPORT void setSpaceDimension(int spaceDim);
39     MEDCOUPLING_EXPORT void setNodeStruct(const int *nodeStrctStart, const int *nodeStrctStop);
40     MEDCOUPLING_EXPORT std::vector<int> getNodeStruct() const;
41     MEDCOUPLING_EXPORT void setOrigin(const double *originStart, const double *originStop);
42     MEDCOUPLING_EXPORT std::vector<double> getOrigin() const;
43     MEDCOUPLING_EXPORT void setDXYZ(const double *dxyzStart, const double *dxyzStop);
44     MEDCOUPLING_EXPORT std::vector<double> getDXYZ() const;
45     MEDCOUPLING_EXPORT void setAxisUnit(const std::string& unitName);
46     MEDCOUPLING_EXPORT std::string getAxisUnit() const;
47     MEDCOUPLING_EXPORT double getMeasureOfAnyCell() const;
48     MEDCOUPLING_EXPORT MEDCouplingCMesh *convertToCartesian() const;
49     MEDCOUPLING_EXPORT void refineWithFactor(const std::vector<int>& factors);
50     MEDCOUPLING_EXPORT MEDCouplingIMesh *asSingleCell() const;
51     MEDCOUPLING_EXPORT static void CondenseFineToCoarse(const std::vector<int>& coarseSt, const DataArrayDouble *fineDA, const std::vector< std::pair<int,int> >& fineLocInCoarse, const std::vector<int>& facts, DataArrayDouble *coarseDA);
52     MEDCOUPLING_EXPORT static void CondenseFineToCoarseGhost(const std::vector<int>& coarseSt, const DataArrayDouble *fineDA, const std::vector< std::pair<int,int> >& fineLocInCoarse, const std::vector<int>& facts, DataArrayDouble *coarseDA, int ghostSize);
53     MEDCOUPLING_EXPORT static void SpreadCoarseToFine(const DataArrayDouble *coarseDA, const std::vector<int>& coarseSt, DataArrayDouble *fineDA, const std::vector< std::pair<int,int> >& fineLocInCoarse, const std::vector<int>& facts);
54     MEDCOUPLING_EXPORT static void SpreadCoarseToFineGhost(const DataArrayDouble *coarseDA, const std::vector<int>& coarseSt, DataArrayDouble *fineDA, const std::vector< std::pair<int,int> >& fineLocInCoarse, const std::vector<int>& facts, int ghostSize);
55     //
56     MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const;
57     MEDCOUPLING_EXPORT MEDCouplingIMesh *clone(bool recDeepCpy) const;
58     MEDCOUPLING_EXPORT MEDCouplingIMesh *buildWithGhost(int ghostLev) const;
59     MEDCOUPLING_EXPORT void updateTime() const;
60     MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
61     MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
62     MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return IMAGE_GRID; }
63     MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingMesh *other);
64     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const;
65     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
66     MEDCOUPLING_EXPORT void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
67                                                  DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const;
68     MEDCOUPLING_EXPORT void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
69                                                             DataArrayInt *&cellCor) const;
70     MEDCOUPLING_EXPORT void checkCoherency() const;
71     MEDCOUPLING_EXPORT void checkCoherency1(double eps=1e-12) const;
72     MEDCOUPLING_EXPORT void checkCoherency2(double eps=1e-12) const;
73     MEDCOUPLING_EXPORT int getSpaceDimension() const;
74     MEDCOUPLING_EXPORT void getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const;
75     MEDCOUPLING_EXPORT std::string simpleRepr() const;
76     MEDCOUPLING_EXPORT std::string advancedRepr() const;
77     // tools
78     MEDCOUPLING_EXPORT void getBoundingBox(double *bbox) const;
79     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
80     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const;
81     MEDCOUPLING_EXPORT int getCellContainingPoint(const double *pos, double eps) const;
82     MEDCOUPLING_EXPORT void rotate(const double *center, const double *vector, double angle);
83     MEDCOUPLING_EXPORT void translate(const double *vector);
84     MEDCOUPLING_EXPORT void scale(const double *point, double factor);
85     MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const;
86     MEDCOUPLING_EXPORT DataArrayDouble *getCoordinatesAndOwner() const;
87     MEDCOUPLING_EXPORT DataArrayDouble *getBarycenterAndOwner() const;
88     MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const;
89     MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check=true);
90     //some useful methods
91     MEDCOUPLING_EXPORT void getNodeGridStructure(int *res) const;
92     MEDCOUPLING_EXPORT std::vector<int> getNodeGridStructure() const;
93     MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair<int,int> >& cellPart) const;
94     //serialisation-unserialization
95     MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
96     MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
97     MEDCOUPLING_EXPORT void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
98     MEDCOUPLING_EXPORT void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
99                                             const std::vector<std::string>& littleStrings);
100     MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
101   private:
102     MEDCouplingIMesh();
103     MEDCouplingIMesh(const MEDCouplingIMesh& other, bool deepCpy);
104     ~MEDCouplingIMesh();
105     void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const;
106     std::string getVTKDataSetType() const;
107     bool isEqualWithoutConsideringStrInternal(const MEDCouplingMesh *other, double prec, std::string& reason) const;
108     std::vector<std::string> buildInfoOnComponents() const;
109     void checkSpaceDimension() const;
110     static void CheckSpaceDimension(int spaceDim);
111     static int FindIntRoot(int val, int order);
112   private:
113     int _space_dim;
114     double _origin[3];
115     double _dxyz[3];
116     int _structure[3];
117     std::string _axis_unit;
118   };
119 }
120
121 #endif