Salome HOME
c43a706d10d20576928adfef2ecb8aac534f4a20
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingGaussLocalization.hxx
1 // Copyright (C) 2007-2020  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_MEDCOUPLINGGAUSSLOCALIZATION_HXX__
22 #define __PARAMEDMEM_MEDCOUPLINGGAUSSLOCALIZATION_HXX__
23
24 #include "MEDCoupling.hxx"
25 #include "NormalizedUnstructuredMesh.hxx"
26 #include "MEDCouplingMemArray.hxx"
27 #include "InterpKernelException.hxx"
28
29 #include <vector>
30
31 namespace MEDCoupling
32 {
33   class MEDCouplingMesh;
34   class MEDCouplingUMesh;
35
36   class MEDCouplingGaussLocalization
37   {
38   public:
39     MEDCOUPLING_EXPORT MEDCouplingGaussLocalization(INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
40                                                     const std::vector<double>& gsCoo, const std::vector<double>& w);
41     MEDCOUPLING_EXPORT MEDCouplingGaussLocalization(INTERP_KERNEL::NormalizedCellType typ);
42     MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getType() const { return _type; }
43     MEDCOUPLING_EXPORT void setType(INTERP_KERNEL::NormalizedCellType typ);
44     MEDCOUPLING_EXPORT int getNumberOfGaussPt() const { return (int)_weight.size(); }
45     MEDCOUPLING_EXPORT int getDimension() const;
46     MEDCOUPLING_EXPORT int getNumberOfPtsInRefCell() const;
47     MEDCOUPLING_EXPORT std::string getStringRepr() const;
48     MEDCOUPLING_EXPORT std::size_t getMemorySize() const;
49     MEDCOUPLING_EXPORT void checkConsistencyLight() const;
50     MEDCOUPLING_EXPORT bool isEqual(const MEDCouplingGaussLocalization& other, double eps) const;
51     MEDCOUPLING_EXPORT void pushTinySerializationIntInfo(std::vector<mcIdType>& tinyInfo) const;
52     MEDCOUPLING_EXPORT void pushTinySerializationDblInfo(std::vector<double>& tinyInfo) const;
53     MEDCOUPLING_EXPORT const double *fillWithValues(const double *vals);
54     //
55     MEDCOUPLING_EXPORT MCAuto<DataArrayDouble> localizePtsInRefCooForEachCell(const DataArrayDouble *ptsInRefCoo, const MEDCouplingUMesh *mesh) const;
56     MEDCOUPLING_EXPORT MCAuto<MEDCouplingUMesh> buildRefCell() const;
57     //
58     MEDCOUPLING_EXPORT const std::vector<double>& getRefCoords() const { return _ref_coord; }
59     MEDCOUPLING_EXPORT double getRefCoord(int ptIdInCell, int comp) const;
60     MEDCOUPLING_EXPORT const std::vector<double>& getGaussCoords() const { return _gauss_coord; }
61     MEDCOUPLING_EXPORT double getGaussCoord(int gaussPtIdInCell, int comp) const;
62     MEDCOUPLING_EXPORT const std::vector<double>& getWeights() const { return _weight; }
63     MEDCOUPLING_EXPORT double getWeight(int gaussPtIdInCell, double newVal) const;
64     MEDCOUPLING_EXPORT void setRefCoord(int ptIdInCell, int comp, double newVal);
65     MEDCOUPLING_EXPORT void setGaussCoord(int gaussPtIdInCell, int comp, double newVal);
66     MEDCOUPLING_EXPORT void setWeight(int gaussPtIdInCell, double newVal);
67     MEDCOUPLING_EXPORT void setRefCoords(const std::vector<double>& refCoo);
68     MEDCOUPLING_EXPORT void setGaussCoords(const std::vector<double>& gsCoo);
69     MEDCOUPLING_EXPORT void setWeights(const std::vector<double>& w);
70     //
71     MEDCOUPLING_EXPORT static MEDCouplingGaussLocalization BuildNewInstanceFromTinyInfo(mcIdType dim, const std::vector<mcIdType>& tinyData);
72     MEDCOUPLING_EXPORT static bool AreAlmostEqual(const std::vector<double>& v1, const std::vector<double>& v2, double eps);
73   private:
74     int checkCoherencyOfRequest(mcIdType gaussPtIdInCell, int comp) const;
75   private:
76     INTERP_KERNEL::NormalizedCellType _type;
77     std::vector<double> _ref_coord;
78     std::vector<double> _gauss_coord;
79     std::vector<double> _weight;
80   };
81 }
82
83 #endif