Salome HOME
599747830498abbe8ac2e0fcc9a9c84adcb99244
[modules/med.git] / src / MEDCoupling / MEDCouplingFieldDiscretization.hxx
1 // Copyright (C) 2007-2013  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.
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_MEDCOUPLINGFIELDDISCRETIZATION_HXX__
22 #define __PARAMEDMEM_MEDCOUPLINGFIELDDISCRETIZATION_HXX__
23
24 #include "MEDCoupling.hxx"
25 #include "MEDCouplingRefCountObject.hxx"
26 #include "InterpKernelException.hxx"
27 #include "MEDCouplingTimeLabel.hxx"
28 #include "MEDCouplingNatureOfField.hxx"
29 #include "MEDCouplingGaussLocalization.hxx"
30 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
31
32 #include <set>
33 #include <vector>
34
35 namespace ParaMEDMEM
36 {
37   class DataArray;
38   class DataArrayInt;
39   class MEDCouplingMesh;
40   class DataArrayDouble;
41   class MEDCouplingFieldDouble;
42
43   class MEDCouplingFieldDiscretization : public RefCountObject, public TimeLabel
44   {
45   public:
46     MEDCOUPLING_EXPORT static MEDCouplingFieldDiscretization *New(TypeOfField type);
47     MEDCOUPLING_EXPORT double getPrecision() const { return _precision; }
48     MEDCOUPLING_EXPORT void setPrecision(double val) { _precision=val; }
49     MEDCOUPLING_EXPORT void updateTime() const;
50     MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
51     MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
52     MEDCOUPLING_EXPORT static TypeOfField GetTypeOfFieldFromStringRepr(const std::string& repr);
53     MEDCOUPLING_EXPORT virtual TypeOfField getEnum() const = 0;
54     MEDCOUPLING_EXPORT virtual bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
55     MEDCOUPLING_EXPORT virtual bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const = 0;
56     MEDCOUPLING_EXPORT virtual bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const;
57     MEDCOUPLING_EXPORT virtual MEDCouplingFieldDiscretization *deepCpy() const;
58     MEDCOUPLING_EXPORT virtual MEDCouplingFieldDiscretization *clone() const = 0;
59     MEDCOUPLING_EXPORT virtual MEDCouplingFieldDiscretization *clonePart(const int *startCellIds, const int *endCellIds) const;
60     MEDCOUPLING_EXPORT virtual MEDCouplingFieldDiscretization *clonePartRange(int beginCellIds, int endCellIds, int stepCellIds) const;
61     MEDCOUPLING_EXPORT virtual std::string getStringRepr() const = 0;
62     MEDCOUPLING_EXPORT virtual const char *getRepr() const = 0;
63     MEDCOUPLING_EXPORT virtual int getNumberOfTuplesExpectedRegardingCode(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const = 0;
64     MEDCOUPLING_EXPORT virtual int getNumberOfTuples(const MEDCouplingMesh *mesh) const = 0;
65     MEDCOUPLING_EXPORT virtual int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const = 0;
66     MEDCOUPLING_EXPORT virtual DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const = 0;
67     MEDCOUPLING_EXPORT virtual void normL1(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const;
68     MEDCOUPLING_EXPORT virtual void normL2(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const;
69     MEDCOUPLING_EXPORT virtual void integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs, double *res) const;
70     MEDCOUPLING_EXPORT virtual DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const = 0;
71     MEDCOUPLING_EXPORT virtual void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *tupleIdsBg, const int *tupleIdsEnd,
72                                                                        DataArrayInt *&cellRestriction, DataArrayInt *&trueTupleRestriction) const throw(INTERP_KERNEL::Exception) = 0;
73     MEDCOUPLING_EXPORT virtual void checkCompatibilityWithNature(NatureOfField nat) const = 0;
74     MEDCOUPLING_EXPORT virtual void renumberCells(const int *old2NewBg, bool check=true);
75     MEDCOUPLING_EXPORT virtual void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArray *>& arrays,
76                                                           const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) = 0;
77     MEDCOUPLING_EXPORT virtual double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const;
78     MEDCOUPLING_EXPORT virtual void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const = 0;
79     MEDCOUPLING_EXPORT virtual MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const = 0;
80     MEDCOUPLING_EXPORT virtual void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const = 0;
81     MEDCOUPLING_EXPORT virtual void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const = 0;
82     MEDCOUPLING_EXPORT virtual DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const = 0;
83     MEDCOUPLING_EXPORT virtual DataArrayInt *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const int *startCellIds, const int *endCellIds) const = 0;
84     MEDCOUPLING_EXPORT virtual MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const = 0;
85     MEDCOUPLING_EXPORT virtual MEDCouplingMesh *buildSubMeshDataRange(const MEDCouplingMesh *mesh, int beginCellIds, int endCellIds, int stepCellIds, int& beginOut, int& endOut, int& stepOut, DataArrayInt *&di) const;
86     MEDCOUPLING_EXPORT virtual void renumberValuesOnNodes(double epsOnVals, const int *old2New, int newNbOfNodes, DataArrayDouble *arr) const = 0;
87     MEDCOUPLING_EXPORT virtual void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, int newSz, DataArrayDouble *arr) const = 0;
88     MEDCOUPLING_EXPORT virtual void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const = 0;
89     MEDCOUPLING_EXPORT virtual void getSerializationIntArray(DataArrayInt *& arr) const;
90     MEDCOUPLING_EXPORT virtual void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
91     MEDCOUPLING_EXPORT virtual void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
92     MEDCOUPLING_EXPORT virtual void finishUnserialization(const std::vector<double>& tinyInfo);
93     MEDCOUPLING_EXPORT virtual void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *& arr);
94     MEDCOUPLING_EXPORT virtual void setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
95                                                                const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
96     MEDCOUPLING_EXPORT virtual void setGaussLocalizationOnCells(const MEDCouplingMesh *m, const int *begin, const int *end, const std::vector<double>& refCoo,
97                                                                 const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
98     MEDCOUPLING_EXPORT virtual void clearGaussLocalizations();
99     MEDCOUPLING_EXPORT virtual MEDCouplingGaussLocalization& getGaussLocalization(int locId);
100     MEDCOUPLING_EXPORT virtual int getNbOfGaussLocalization() const;
101     MEDCOUPLING_EXPORT virtual int getGaussLocalizationIdOfOneCell(int cellId) const;
102     MEDCOUPLING_EXPORT virtual int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const;
103     MEDCOUPLING_EXPORT virtual std::set<int> getGaussLocalizationIdsOfOneType(INTERP_KERNEL::NormalizedCellType type) const;
104     MEDCOUPLING_EXPORT virtual void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const;
105     MEDCOUPLING_EXPORT virtual const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const;
106     MEDCOUPLING_EXPORT virtual void reprQuickOverview(std::ostream& stream) const = 0;
107     MEDCOUPLING_EXPORT virtual ~MEDCouplingFieldDiscretization();
108   protected:
109     MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization();
110     MEDCOUPLING_EXPORT static void RenumberEntitiesFromO2NArr(double epsOnVals, const int *old2NewPtr, int newNbOfEntity, DataArrayDouble *arr, const std::string& msg);
111     MEDCOUPLING_EXPORT static void RenumberEntitiesFromN2OArr(const int *new2OldPtr, int new2OldSz, DataArrayDouble *arr, const std::string& msg);
112   protected:
113     double _precision;
114     static const double DFLT_PRECISION;
115   };
116
117   class MEDCouplingFieldDiscretizationP0 : public MEDCouplingFieldDiscretization
118   {
119   public:
120     MEDCOUPLING_EXPORT TypeOfField getEnum() const;
121     MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization *clone() const;
122     MEDCOUPLING_EXPORT std::string getStringRepr() const;
123     MEDCOUPLING_EXPORT const char *getRepr() const;
124     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
125     MEDCOUPLING_EXPORT int getNumberOfTuplesExpectedRegardingCode(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const;
126     MEDCOUPLING_EXPORT int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
127     MEDCOUPLING_EXPORT int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
128     MEDCOUPLING_EXPORT DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
129     MEDCOUPLING_EXPORT void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArray *>& arrays,
130                                                   const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
131     MEDCOUPLING_EXPORT DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
132     MEDCOUPLING_EXPORT void checkCompatibilityWithNature(NatureOfField nat) const;
133     MEDCOUPLING_EXPORT void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *tupleIdsBg, const int *tupleIdsEnd,
134                                                                DataArrayInt *&cellRestriction, DataArrayInt *&trueTupleRestriction) const throw(INTERP_KERNEL::Exception);
135     MEDCOUPLING_EXPORT void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const;
136     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
137     MEDCOUPLING_EXPORT void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
138     MEDCOUPLING_EXPORT void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
139     MEDCOUPLING_EXPORT DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
140     MEDCOUPLING_EXPORT void renumberValuesOnNodes(double epsOnVals, const int *old2New, int newNbOfNodes, DataArrayDouble *arr) const;
141     MEDCOUPLING_EXPORT void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, int newSz, DataArrayDouble *arr) const;
142     MEDCOUPLING_EXPORT void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
143     MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
144     MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshDataRange(const MEDCouplingMesh *mesh, int beginCellIds, int endCellIds, int stepCellIds, int& beginOut, int& endOut, int& stepOut, DataArrayInt *&di) const;
145     MEDCOUPLING_EXPORT DataArrayInt *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const int *startCellIds, const int *endCellIds) const;
146     MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
147   public:
148     static const char REPR[];
149     static const TypeOfField TYPE;
150   };
151
152   class MEDCouplingFieldDiscretizationOnNodes : public MEDCouplingFieldDiscretization
153   {
154   public:
155     MEDCOUPLING_EXPORT int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
156     MEDCOUPLING_EXPORT int getNumberOfTuplesExpectedRegardingCode(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const;
157     MEDCOUPLING_EXPORT int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
158     MEDCOUPLING_EXPORT DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
159     MEDCOUPLING_EXPORT void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArray *>& arrays,
160                                                   const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
161     MEDCOUPLING_EXPORT DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
162     MEDCOUPLING_EXPORT void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *tupleIdsBg, const int *tupleIdsEnd,
163                                                                DataArrayInt *&cellRestriction, DataArrayInt *&trueTupleRestriction) const throw(INTERP_KERNEL::Exception);
164     MEDCOUPLING_EXPORT void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const;
165     MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
166     MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshDataRange(const MEDCouplingMesh *mesh, int beginCellIds, int endCellIds, int stepCellIds, int& beginOut, int& endOut, int& stepOut, DataArrayInt *&di) const;
167     MEDCOUPLING_EXPORT DataArrayInt *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const int *startCellIds, const int *endCellIds) const;
168     MEDCOUPLING_EXPORT void renumberValuesOnNodes(double epsOnVals, const int *old2New, int newNbOfNodes, DataArrayDouble *arr) const;
169     MEDCOUPLING_EXPORT void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, int newSz, DataArrayDouble *arr) const;
170     MEDCOUPLING_EXPORT void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
171   public:
172     MEDCOUPLING_EXPORT void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
173   };
174
175   class MEDCouplingFieldDiscretizationP1 : public MEDCouplingFieldDiscretizationOnNodes
176   {
177   public:
178     MEDCOUPLING_EXPORT TypeOfField getEnum() const;
179     MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization *clone() const;
180     MEDCOUPLING_EXPORT std::string getStringRepr() const;
181     MEDCOUPLING_EXPORT const char *getRepr() const;
182     MEDCOUPLING_EXPORT void checkCompatibilityWithNature(NatureOfField nat) const;
183     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
184     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
185     MEDCOUPLING_EXPORT void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
186     MEDCOUPLING_EXPORT DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
187     MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
188   public:
189     static const char REPR[];
190     static const TypeOfField TYPE;
191   protected:
192     MEDCOUPLING_EXPORT void getValueInCell(const MEDCouplingMesh *mesh, int cellId, const DataArrayDouble *arr, const double *loc, double *res) const;
193   };
194
195   /*!
196    * This class abstracts MEDCouplingFieldDiscretization that needs an information on each cell to perform their job.
197    * All classes that inherits from this are more linked to mesh.
198    */
199   class MEDCouplingFieldDiscretizationPerCell : public MEDCouplingFieldDiscretization
200   {
201   public:
202     MEDCOUPLING_EXPORT const DataArrayInt *getArrayOfDiscIds() const;
203     MEDCOUPLING_EXPORT void setArrayOfDiscIds(const DataArrayInt *adids);
204     MEDCOUPLING_EXPORT void checkNoOrphanCells() const;
205     MEDCOUPLING_EXPORT std::vector<DataArrayInt *> splitIntoSingleGaussDicrPerCellType(std::vector< int >& locIds) const;
206   protected:
207     MEDCouplingFieldDiscretizationPerCell();
208     MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other, const int *startCellIds, const int *endCellIds);
209     MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other, int beginCellIds, int endCellIds, int stepCellIds);
210     ~MEDCouplingFieldDiscretizationPerCell();
211     void updateTime() const;
212     std::size_t getHeapMemorySizeWithoutChildren() const;
213     std::vector<const BigMemoryObject *> getDirectChildren() const;
214     void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const;
215     bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
216     bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const;
217     void renumberCells(const int *old2NewBg, bool check);
218   protected:
219     void buildDiscrPerCellIfNecessary(const MEDCouplingMesh *mesh);
220   protected:
221     DataArrayInt *_discr_per_cell;
222     static const int DFT_INVALID_LOCID_VALUE;
223   };
224
225   class MEDCouplingFieldDiscretizationGauss : public MEDCouplingFieldDiscretizationPerCell
226   {
227   public:
228     MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationGauss();
229     MEDCOUPLING_EXPORT TypeOfField getEnum() const;
230     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
231     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const;
232     MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization *clone() const;
233     MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization *clonePart(const int *startCellIds, const int *endCellIds) const;
234     MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization *clonePartRange(int beginCellIds, int endCellIds, int stepCellIds) const;
235     MEDCOUPLING_EXPORT std::string getStringRepr() const;
236     MEDCOUPLING_EXPORT const char *getRepr() const;
237     MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
238     MEDCOUPLING_EXPORT int getNumberOfTuplesExpectedRegardingCode(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const;
239     MEDCOUPLING_EXPORT int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
240     MEDCOUPLING_EXPORT int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
241     MEDCOUPLING_EXPORT DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
242     MEDCOUPLING_EXPORT void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArray *>& arrays,
243                                                   const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
244     MEDCOUPLING_EXPORT DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
245     MEDCOUPLING_EXPORT void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *tupleIdsBg, const int *tupleIdsEnd,
246                                                                DataArrayInt *&cellRestriction, DataArrayInt *&trueTupleRestriction) const throw(INTERP_KERNEL::Exception);
247     MEDCOUPLING_EXPORT void checkCompatibilityWithNature(NatureOfField nat) const;
248     MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
249     MEDCOUPLING_EXPORT void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
250     MEDCOUPLING_EXPORT void finishUnserialization(const std::vector<double>& tinyInfo);
251     MEDCOUPLING_EXPORT void getSerializationIntArray(DataArrayInt *& arr) const;
252     MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *& arr);
253     MEDCOUPLING_EXPORT double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const;
254     MEDCOUPLING_EXPORT void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const;
255     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
256     MEDCOUPLING_EXPORT void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
257     MEDCOUPLING_EXPORT void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
258     MEDCOUPLING_EXPORT DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
259     MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
260     MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshDataRange(const MEDCouplingMesh *mesh, int beginCellIds, int endCellIds, int stepCellIds, int& beginOut, int& endOut, int& stepOut, DataArrayInt *&di) const;
261     MEDCOUPLING_EXPORT DataArrayInt *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const int *startCellIds, const int *endCellIds) const;
262     MEDCOUPLING_EXPORT void renumberValuesOnNodes(double epsOnVals, const int *old2New, int newNbOfNodes, DataArrayDouble *arr) const;
263     MEDCOUPLING_EXPORT void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, int newSz, DataArrayDouble *arr) const;
264     MEDCOUPLING_EXPORT void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
265     MEDCOUPLING_EXPORT void setGaussLocalizationOnType(const MEDCouplingMesh *mesh, INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
266                                                        const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
267     MEDCOUPLING_EXPORT void setGaussLocalizationOnCells(const MEDCouplingMesh *mesh, const int *begin, const int *end, const std::vector<double>& refCoo,
268                                                         const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
269     MEDCOUPLING_EXPORT void clearGaussLocalizations();
270     MEDCOUPLING_EXPORT void setGaussLocalization(int locId, const MEDCouplingGaussLocalization& loc);
271     MEDCOUPLING_EXPORT void resizeLocalizationVector(int newSz);
272     MEDCOUPLING_EXPORT MEDCouplingGaussLocalization& getGaussLocalization(int locId);
273     MEDCOUPLING_EXPORT int getNbOfGaussLocalization() const;
274     MEDCOUPLING_EXPORT int getGaussLocalizationIdOfOneCell(int cellId) const;
275     MEDCOUPLING_EXPORT int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const;
276     MEDCOUPLING_EXPORT std::set<int> getGaussLocalizationIdsOfOneType(INTERP_KERNEL::NormalizedCellType type) const;
277     MEDCOUPLING_EXPORT void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const;
278     MEDCOUPLING_EXPORT const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const;
279     MEDCOUPLING_EXPORT DataArrayInt *buildNbOfGaussPointPerCellField() const;
280     MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
281   protected:
282     MEDCouplingFieldDiscretizationGauss(const MEDCouplingFieldDiscretizationGauss& other, const int *startCellIds=0, const int *endCellIds=0);
283     MEDCouplingFieldDiscretizationGauss(const MEDCouplingFieldDiscretizationGauss& other, int beginCellIds, int endCellIds, int stepCellIds);
284     void zipGaussLocalizations();
285     int getOffsetOfCell(int cellId) const;
286     void checkLocalizationId(int locId) const;
287   public:
288     static const char REPR[];
289     static const TypeOfField TYPE;
290   private:
291     std::vector<MEDCouplingGaussLocalization> _loc;
292   };
293
294   /*!
295    * Gauss with points of values located on nodes of element. This is a specialization of MEDCouplingFieldDiscretizationGauss.
296    */
297   class MEDCouplingFieldDiscretizationGaussNE : public MEDCouplingFieldDiscretization
298   {
299   public:
300     MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationGaussNE();
301     MEDCOUPLING_EXPORT TypeOfField getEnum() const;
302     MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization *clone() const;
303     MEDCOUPLING_EXPORT std::string getStringRepr() const;
304     MEDCOUPLING_EXPORT const char *getRepr() const;
305     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
306     MEDCOUPLING_EXPORT int getNumberOfTuplesExpectedRegardingCode(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const;
307     MEDCOUPLING_EXPORT int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
308     MEDCOUPLING_EXPORT int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
309     MEDCOUPLING_EXPORT DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
310     MEDCOUPLING_EXPORT void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArray *>& arrays,
311                                                   const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
312     MEDCOUPLING_EXPORT DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
313     MEDCOUPLING_EXPORT void integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs, double *res) const;
314     MEDCOUPLING_EXPORT void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *tupleIdsBg, const int *tupleIdsEnd,
315                                                                DataArrayInt *&cellRestriction, DataArrayInt *&trueTupleRestriction) const throw(INTERP_KERNEL::Exception);
316     MEDCOUPLING_EXPORT void checkCompatibilityWithNature(NatureOfField nat) const;
317     MEDCOUPLING_EXPORT double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const;
318     MEDCOUPLING_EXPORT void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const;
319     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
320     MEDCOUPLING_EXPORT void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
321     MEDCOUPLING_EXPORT void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
322     MEDCOUPLING_EXPORT DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
323     MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
324     MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshDataRange(const MEDCouplingMesh *mesh, int beginCellIds, int endCellIds, int stepCellIds, int& beginOut, int& endOut, int& stepOut, DataArrayInt *&di) const;
325     MEDCOUPLING_EXPORT DataArrayInt *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const int *startCellIds, const int *endCellIds) const;
326     MEDCOUPLING_EXPORT void renumberValuesOnNodes(double epsOnVals, const int *old2New, int newNbOfNodes, DataArrayDouble *arr) const;
327     MEDCOUPLING_EXPORT void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, int newSz, DataArrayDouble *arr) const;
328     MEDCOUPLING_EXPORT void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
329     MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
330     MEDCOUPLING_EXPORT static const double *GetWeightArrayFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType, std::size_t& lgth);
331     MEDCOUPLING_EXPORT static const double *GetRefCoordsFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType, std::size_t& lgth);
332     MEDCOUPLING_EXPORT static const double *GetLocsFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType, std::size_t& lgth);
333   protected:
334     MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationGaussNE(const MEDCouplingFieldDiscretizationGaussNE& other);
335   public:
336     static const char REPR[];
337     static const TypeOfField TYPE;
338     static const double FGP_SEG2[2];
339     static const double FGP_SEG3[3];
340     static const double FGP_SEG4[4];
341     static const double FGP_TRI3[3];
342     static const double FGP_TRI6[6];
343     static const double FGP_TRI7[7];
344     static const double FGP_QUAD4[4];
345     static const double FGP_QUAD8[8];
346     static const double FGP_QUAD9[9];
347     static const double FGP_TETRA4[4];
348     //static const double FGP_TETRA10[10];
349     static const double FGP_PENTA6[6];
350     //static const double FGP_PENTA15[15];
351     static const double FGP_HEXA8[8];
352     static const double FGP_HEXA27[27];
353     static const double FGP_PYRA5[5];
354     //static const double FGP_PYRA13[13];
355     static const double REF_SEG2[2];
356     static const double REF_SEG3[3];
357     static const double REF_SEG4[4];
358     static const double REF_TRI3[6];
359     static const double REF_TRI6[12];
360     static const double REF_TRI7[14];
361     static const double REF_QUAD4[8];
362     static const double REF_QUAD8[16];
363     static const double REF_QUAD9[18];
364     static const double REF_TETRA4[12];
365     static const double REF_TETRA10[30];
366     static const double REF_PENTA6[18];
367     static const double REF_PENTA15[45];
368     static const double REF_HEXA8[24];
369     static const double REF_HEXA20[60];
370     static const double REF_HEXA27[81];
371     static const double REF_PYRA5[15];
372     static const double REF_PYRA13[39];
373     static const double LOC_SEG2[2];
374     static const double LOC_SEG3[3];
375     static const double LOC_SEG4[4];
376     static const double LOC_TRI3[6];
377     static const double LOC_TRI6[12];
378     static const double LOC_TRI7[14];
379     static const double LOC_QUAD4[8];
380     static const double LOC_QUAD8[16];
381     static const double LOC_QUAD9[18];
382     static const double LOC_TETRA4[12];
383     //static const double LOC_TETRA10[30];
384     static const double LOC_PENTA6[18];
385     //static const double LOC_PENTA15[45];
386     static const double LOC_HEXA8[24];
387     static const double LOC_HEXA27[81];
388     static const double LOC_PYRA5[15];
389     //static const double LOC_PYRA13[39];
390   };
391
392   class MEDCouplingFieldDiscretizationKriging : public MEDCouplingFieldDiscretizationOnNodes
393   {
394   public:
395     MEDCOUPLING_EXPORT TypeOfField getEnum() const;
396     MEDCOUPLING_EXPORT const char *getRepr() const;
397     MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization *clone() const;
398     MEDCOUPLING_EXPORT std::string getStringRepr() const;
399     MEDCOUPLING_EXPORT void checkCompatibilityWithNature(NatureOfField nat) const;
400     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
401     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
402     MEDCOUPLING_EXPORT void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
403     MEDCOUPLING_EXPORT DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
404     MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
405   public://specific part
406     MEDCOUPLING_EXPORT DataArrayDouble *computeEvaluationMatrixOnGivenPts(const MEDCouplingMesh *mesh, const double *loc, int nbOfTargetPoints, int& nbCols) const;
407     MEDCOUPLING_EXPORT DataArrayDouble *computeInverseMatrix(const MEDCouplingMesh *mesh, int& isDrift, int& matSz) const;
408     MEDCOUPLING_EXPORT DataArrayDouble *computeVectorOfCoefficients(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, int& isDrift) const;
409   protected:
410     void operateOnDenseMatrix(int spaceDimension, int nbOfElems, double *matrixPtr) const;
411     DataArrayDouble *performDrift(const DataArrayDouble *matr, const DataArrayDouble *arr, int& delta) const;
412   public:
413     static const char REPR[];
414     static const TypeOfField TYPE;
415   };
416 }
417
418 #endif