Salome HOME
Modification of the getHeapMemorySize computation.
[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 MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization : public RefCountObject, public TimeLabel
44   {
45   public:
46     static MEDCouplingFieldDiscretization *New(TypeOfField type);
47     double getPrecision() const { return _precision; }
48     void setPrecision(double val) { _precision=val; }
49     void updateTime() const;
50     std::size_t getHeapMemorySizeWithoutChildren() const;
51     std::vector<RefCountObject *> getDirectChildren() const;
52     static TypeOfField GetTypeOfFieldFromStringRepr(const char *repr) throw(INTERP_KERNEL::Exception);
53     virtual TypeOfField getEnum() const = 0;
54     virtual bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
55     virtual bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const = 0;
56     virtual bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const;
57     virtual MEDCouplingFieldDiscretization *deepCpy() const;
58     virtual MEDCouplingFieldDiscretization *clone() const = 0;
59     virtual MEDCouplingFieldDiscretization *clonePart(const int *startCellIds, const int *endCellIds) const;
60     virtual MEDCouplingFieldDiscretization *clonePartRange(int beginCellIds, int endCellIds, int stepCellIds) const;
61     virtual std::string getStringRepr() const = 0;
62     virtual const char *getRepr() const = 0;
63     virtual int getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception) = 0;
64     virtual int getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception) = 0;
65     virtual int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const = 0;
66     virtual DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const = 0;
67     virtual void normL1(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception);
68     virtual void normL2(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception);
69     virtual void integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs, double *res) const throw(INTERP_KERNEL::Exception);
70     virtual DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const = 0;
71     virtual void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *tupleIdsBg, const int *tupleIdsEnd,
72                                                     DataArrayInt *&cellRestriction, DataArrayInt *&trueTupleRestriction) const throw(INTERP_KERNEL::Exception) = 0;
73     virtual void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception) = 0;
74     virtual void renumberCells(const int *old2NewBg, bool check=true) throw(INTERP_KERNEL::Exception);
75     virtual void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArray *>& arrays,
76                                        const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) = 0;
77     virtual double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception);
78     virtual void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const throw(INTERP_KERNEL::Exception) = 0;
79     virtual MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const = 0;
80     virtual void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const = 0;
81     virtual void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const = 0;
82     virtual DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const = 0;
83     virtual DataArrayInt *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const int *startCellIds, const int *endCellIds) const = 0;
84     virtual MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const = 0;
85     virtual MEDCouplingMesh *buildSubMeshDataRange(const MEDCouplingMesh *mesh, int beginCellIds, int endCellIds, int stepCellIds, int& beginOut, int& endOut, int& stepOut, DataArrayInt *&di) const;
86     virtual void renumberValuesOnNodes(double epsOnVals, const int *old2New, int newNbOfNodes, DataArrayDouble *arr) const = 0;
87     virtual void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, int newSz, DataArrayDouble *arr) const = 0;
88     virtual void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const = 0;
89     virtual void getSerializationIntArray(DataArrayInt *& arr) const;
90     virtual void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
91     virtual void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
92     virtual void finishUnserialization(const std::vector<double>& tinyInfo);
93     virtual void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *& arr);
94     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     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     virtual void clearGaussLocalizations() throw(INTERP_KERNEL::Exception);
99     virtual MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception);
100     virtual int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception);
101     virtual int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception);
102     virtual int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
103     virtual std::set<int> getGaussLocalizationIdsOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
104     virtual void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const throw(INTERP_KERNEL::Exception);
105     virtual const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception);
106     virtual void reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception) = 0;
107     virtual ~MEDCouplingFieldDiscretization();
108   protected:
109     MEDCouplingFieldDiscretization();
110     static void RenumberEntitiesFromO2NArr(double epsOnVals, const int *old2NewPtr, int newNbOfEntity, DataArrayDouble *arr, const char *msg);
111     static void RenumberEntitiesFromN2OArr(const int *new2OldPtr, int new2OldSz, DataArrayDouble *arr, const char *msg);
112   protected:
113     double _precision;
114     static const double DFLT_PRECISION;
115   };
116
117   class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationP0 : public MEDCouplingFieldDiscretization
118   {
119   public:
120     TypeOfField getEnum() const;
121     MEDCouplingFieldDiscretization *clone() const;
122     std::string getStringRepr() const;
123     const char *getRepr() const;
124     bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
125     int getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
126     int getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception);
127     int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
128     DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
129     void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArray *>& arrays,
130                                const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
131     DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
132     void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
133     void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *tupleIdsBg, const int *tupleIdsEnd,
134                                             DataArrayInt *&cellRestriction, DataArrayInt *&trueTupleRestriction) const throw(INTERP_KERNEL::Exception);
135     void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const throw(INTERP_KERNEL::Exception);
136     MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
137     void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
138     void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
139     DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
140     void renumberValuesOnNodes(double epsOnVals, const int *old2New, int newNbOfNodes, DataArrayDouble *arr) const;
141     void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, int newSz, DataArrayDouble *arr) const;
142     void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
143     MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
144     MEDCouplingMesh *buildSubMeshDataRange(const MEDCouplingMesh *mesh, int beginCellIds, int endCellIds, int stepCellIds, int& beginOut, int& endOut, int& stepOut, DataArrayInt *&di) const;
145     DataArrayInt *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const int *startCellIds, const int *endCellIds) const;
146     void reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
147   public:
148     static const char REPR[];
149     static const TypeOfField TYPE;
150   };
151
152   class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationOnNodes : public MEDCouplingFieldDiscretization
153   {
154   public:
155     int getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception);
156     int getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
157     int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
158     DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
159     void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArray *>& arrays,
160                                const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
161     DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
162     void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *tupleIdsBg, const int *tupleIdsEnd,
163                                             DataArrayInt *&cellRestriction, DataArrayInt *&trueTupleRestriction) const throw(INTERP_KERNEL::Exception);
164     void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const throw(INTERP_KERNEL::Exception);
165     MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
166     MEDCouplingMesh *buildSubMeshDataRange(const MEDCouplingMesh *mesh, int beginCellIds, int endCellIds, int stepCellIds, int& beginOut, int& endOut, int& stepOut, DataArrayInt *&di) const;
167     DataArrayInt *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const int *startCellIds, const int *endCellIds) const;
168     void renumberValuesOnNodes(double epsOnVals, const int *old2New, int newNbOfNodes, DataArrayDouble *arr) const;
169     void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, int newSz, DataArrayDouble *arr) const;
170     void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
171   public:
172     void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
173   };
174
175   class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationP1 : public MEDCouplingFieldDiscretizationOnNodes
176   {
177   public:
178     TypeOfField getEnum() const;
179     MEDCouplingFieldDiscretization *clone() const;
180     std::string getStringRepr() const;
181     const char *getRepr() const;
182     void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
183     bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
184     MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
185     void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
186     DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
187     void reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
188   public:
189     static const char REPR[];
190     static const TypeOfField TYPE;
191   protected:
192     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 MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationPerCell : public MEDCouplingFieldDiscretization
200   {
201   public:
202     const DataArrayInt *getArrayOfDiscIds() const;
203     void setArrayOfDiscIds(const DataArrayInt *adids) throw(INTERP_KERNEL::Exception);
204     void checkNoOrphanCells() const throw(INTERP_KERNEL::Exception);
205     std::vector<DataArrayInt *> splitIntoSingleGaussDicrPerCellType(std::vector< int >& locIds) const throw(INTERP_KERNEL::Exception);
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<RefCountObject *> getDirectChildren() const;
214     void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const throw(INTERP_KERNEL::Exception);
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) throw(INTERP_KERNEL::Exception);
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 MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationGauss : public MEDCouplingFieldDiscretizationPerCell
226   {
227   public:
228     MEDCouplingFieldDiscretizationGauss();
229     TypeOfField getEnum() const;
230     bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
231     bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const;
232     MEDCouplingFieldDiscretization *clone() const;
233     MEDCouplingFieldDiscretization *clonePart(const int *startCellIds, const int *endCellIds) const;
234     MEDCouplingFieldDiscretization *clonePartRange(int beginCellIds, int endCellIds, int stepCellIds) const;
235     std::string getStringRepr() const;
236     const char *getRepr() const;
237     std::size_t getHeapMemorySizeWithoutChildren() const;
238     int getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
239     int getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception);
240     int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
241     DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
242     void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArray *>& arrays,
243                                const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
244     DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
245     void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *tupleIdsBg, const int *tupleIdsEnd,
246                                             DataArrayInt *&cellRestriction, DataArrayInt *&trueTupleRestriction) const throw(INTERP_KERNEL::Exception);
247     void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
248     void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
249     void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
250     void finishUnserialization(const std::vector<double>& tinyInfo);
251     void getSerializationIntArray(DataArrayInt *& arr) const;
252     void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *& arr);
253     double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception);
254     void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const throw(INTERP_KERNEL::Exception);
255     MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
256     void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
257     void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
258     DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
259     MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
260     MEDCouplingMesh *buildSubMeshDataRange(const MEDCouplingMesh *mesh, int beginCellIds, int endCellIds, int stepCellIds, int& beginOut, int& endOut, int& stepOut, DataArrayInt *&di) const;
261     DataArrayInt *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const int *startCellIds, const int *endCellIds) const;
262     void renumberValuesOnNodes(double epsOnVals, const int *old2New, int newNbOfNodes, DataArrayDouble *arr) const;
263     void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, int newSz, DataArrayDouble *arr) const;
264     void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
265     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     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     void clearGaussLocalizations() throw(INTERP_KERNEL::Exception);
270     void setGaussLocalization(int locId, const MEDCouplingGaussLocalization& loc) throw(INTERP_KERNEL::Exception);
271     void resizeLocalizationVector(int newSz) throw(INTERP_KERNEL::Exception);
272     MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception);
273     int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception);
274     int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception);
275     int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
276     std::set<int> getGaussLocalizationIdsOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
277     void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const throw(INTERP_KERNEL::Exception);
278     const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception);
279     DataArrayInt *buildNbOfGaussPointPerCellField() const throw(INTERP_KERNEL::Exception);
280     void reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
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 throw(INTERP_KERNEL::Exception);
286     void checkLocalizationId(int locId) const throw(INTERP_KERNEL::Exception);
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 MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationGaussNE : public MEDCouplingFieldDiscretization
298   {
299   public:
300     MEDCouplingFieldDiscretizationGaussNE();
301     TypeOfField getEnum() const;
302     MEDCouplingFieldDiscretization *clone() const;
303     std::string getStringRepr() const;
304     const char *getRepr() const;
305     bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
306     int getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
307     int getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception);
308     int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
309     DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
310     void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArray *>& arrays,
311                                const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
312     DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
313     void integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs, double *res) const throw(INTERP_KERNEL::Exception);
314     void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *tupleIdsBg, const int *tupleIdsEnd,
315                                             DataArrayInt *&cellRestriction, DataArrayInt *&trueTupleRestriction) const throw(INTERP_KERNEL::Exception);
316     void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
317     double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception);
318     void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const throw(INTERP_KERNEL::Exception);
319     MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
320     void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
321     void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
322     DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
323     MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
324     MEDCouplingMesh *buildSubMeshDataRange(const MEDCouplingMesh *mesh, int beginCellIds, int endCellIds, int stepCellIds, int& beginOut, int& endOut, int& stepOut, DataArrayInt *&di) const;
325     DataArrayInt *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const int *startCellIds, const int *endCellIds) const;
326     void renumberValuesOnNodes(double epsOnVals, const int *old2New, int newNbOfNodes, DataArrayDouble *arr) const;
327     void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, int newSz, DataArrayDouble *arr) const;
328     void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
329     void reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
330     static const double *GetWeightArrayFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType, std::size_t& lgth) throw(INTERP_KERNEL::Exception);
331     static const double *GetRefCoordsFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType, std::size_t& lgth) throw(INTERP_KERNEL::Exception);
332   protected:
333     MEDCouplingFieldDiscretizationGaussNE(const MEDCouplingFieldDiscretizationGaussNE& other);
334   public:
335     static const char REPR[];
336     static const TypeOfField TYPE;
337     static const double FGP_SEG2[2];
338     static const double FGP_SEG3[3];
339     static const double FGP_SEG4[4];
340     static const double FGP_TRI3[3];
341     static const double FGP_TRI6[6];
342     static const double FGP_TRI7[7];
343     static const double FGP_QUAD4[4];
344     //static const double FGP_QUAD8[8];
345     static const double FGP_QUAD9[9];
346     static const double FGP_TETRA4[4];
347     //static const double FGP_TETRA10[10];
348     static const double FGP_PENTA6[6];
349     //static const double FGP_PENTA15[15];
350     static const double FGP_HEXA8[8];
351     static const double FGP_HEXA27[27];
352     static const double FGP_PYRA5[5];
353     //static const double FGP_PYRA13[13];
354     static const double REF_SEG2[2];
355     static const double REF_SEG3[3];
356     static const double REF_SEG4[4];
357     static const double REF_TRI3[6];
358     static const double REF_TRI6[12];
359     static const double REF_TRI7[14];
360     static const double REF_QUAD4[8];
361     static const double REF_QUAD8[16];
362     static const double REF_QUAD9[18];
363     static const double REF_TETRA4[12];
364     static const double REF_TETRA10[30];
365     static const double REF_PENTA6[18];
366     static const double REF_PENTA15[45];
367     static const double REF_HEXA8[24];
368     static const double REF_HEXA20[60];
369     static const double REF_HEXA27[81];
370     static const double REF_PYRA5[15];
371     static const double REF_PYRA13[39];
372   };
373
374   class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationKriging : public MEDCouplingFieldDiscretizationOnNodes
375   {
376   public:
377     TypeOfField getEnum() const;
378     const char *getRepr() const;
379     MEDCouplingFieldDiscretization *clone() const;
380     std::string getStringRepr() const;
381     void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
382     bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
383     MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
384     void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
385     DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
386     void reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
387   public://specific part
388     DataArrayDouble *computeEvaluationMatrixOnGivenPts(const MEDCouplingMesh *mesh, const double *loc, int nbOfTargetPoints, int& nbCols) const;
389     DataArrayDouble *computeInverseMatrix(const MEDCouplingMesh *mesh, int& isDrift, int& matSz) const;
390     DataArrayDouble *computeVectorOfCoefficients(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, int& isDrift) const;
391   protected:
392     void operateOnDenseMatrix(int spaceDimension, int nbOfElems, double *matrixPtr) const;
393     DataArrayDouble *performDrift(const DataArrayDouble *matr, const DataArrayDouble *arr, int& delta) const;
394   public:
395     static const char REPR[];
396     static const TypeOfField TYPE;
397   };
398 }
399
400 #endif