Salome HOME
Move medtool folder to MED base repository
[modules/med.git] / medtool / src / MEDCoupling / MEDCouplingField.hxx
1 // Copyright (C) 2007-2015  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_MEDCOUPLINGFIELD_HXX__
22 #define __PARAMEDMEM_MEDCOUPLINGFIELD_HXX__
23
24 #include "MEDCoupling.hxx"
25 #include "MEDCouplingTimeLabel.hxx"
26 #include "MEDCouplingNatureOfField.hxx"
27 #include "MEDCouplingRefCountObject.hxx"
28 #include "NormalizedUnstructuredMesh.hxx"
29 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
30 #include "MEDCouplingFieldDiscretization.hxx"
31 #include "InterpKernelException.hxx"
32
33 #include <string>
34 #include <vector>
35
36 namespace ParaMEDMEM
37 {
38   class DataArrayInt;
39   class DataArrayDouble;
40   class MEDCouplingMesh;
41   class MEDCouplingFieldDouble;
42   class MEDCouplingGaussLocalization;
43
44   class MEDCouplingField : public RefCountObject, public TimeLabel
45   {
46   public:
47     MEDCOUPLING_EXPORT virtual void checkCoherency() const = 0;
48     MEDCOUPLING_EXPORT virtual bool areCompatibleForMerge(const MEDCouplingField *other) const;
49     MEDCOUPLING_EXPORT virtual bool areStrictlyCompatible(const MEDCouplingField *other) const;
50     MEDCOUPLING_EXPORT virtual bool areStrictlyCompatibleForMulDiv(const MEDCouplingField *other) const;
51     MEDCOUPLING_EXPORT virtual bool isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec, std::string& reason) const;
52     MEDCOUPLING_EXPORT virtual bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
53     MEDCOUPLING_EXPORT virtual bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
54     MEDCOUPLING_EXPORT virtual void copyTinyStringsFrom(const MEDCouplingField *other);
55     MEDCOUPLING_EXPORT void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh);
56     MEDCOUPLING_EXPORT const ParaMEDMEM::MEDCouplingMesh *getMesh() const { return _mesh; }
57     MEDCOUPLING_EXPORT ParaMEDMEM::MEDCouplingMesh *getMesh() { return const_cast<ParaMEDMEM::MEDCouplingMesh *>(_mesh); }
58     MEDCOUPLING_EXPORT void setName(const std::string& name) { _name=name; }
59     MEDCOUPLING_EXPORT std::string getDescription() const { return _desc; }
60     MEDCOUPLING_EXPORT void setDescription(const std::string& desc) { _desc=desc; }
61     MEDCOUPLING_EXPORT std::string getName() const { return _name; }
62     MEDCOUPLING_EXPORT TypeOfField getTypeOfField() const;
63     MEDCOUPLING_EXPORT NatureOfField getNature() const;
64     MEDCOUPLING_EXPORT virtual void setNature(NatureOfField nat);
65     MEDCOUPLING_EXPORT DataArrayDouble *getLocalizationOfDiscr() const;
66     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const;
67     MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshData(const int *start, const int *end, DataArrayInt *&di) const;
68     MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshDataRange(int begin, int end, int step, int& beginOut, int& endOut, int& stepOut, DataArrayInt *&di) const;
69     MEDCOUPLING_EXPORT DataArrayInt *computeTupleIdsToSelectFromCellIds(const int *startCellIds, const int *endCellIds) const;
70     MEDCOUPLING_EXPORT const MEDCouplingFieldDiscretization *getDiscretization() const { return _type; }
71     MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization *getDiscretization() { return _type; }
72     MEDCOUPLING_EXPORT void setDiscretization(MEDCouplingFieldDiscretization *newDisc);
73     MEDCOUPLING_EXPORT int getNumberOfTuplesExpected() const;
74     MEDCOUPLING_EXPORT int getNumberOfMeshPlacesExpected() const;
75     // Gauss point specific methods
76     MEDCOUPLING_EXPORT void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
77                                                        const std::vector<double>& gsCoo, const std::vector<double>& wg);
78     MEDCOUPLING_EXPORT void setGaussLocalizationOnCells(const int *begin, const int *end, const std::vector<double>& refCoo,
79                                                         const std::vector<double>& gsCoo, const std::vector<double>& wg);
80     MEDCOUPLING_EXPORT void clearGaussLocalizations();
81     MEDCOUPLING_EXPORT MEDCouplingGaussLocalization& getGaussLocalization(int locId);
82     MEDCOUPLING_EXPORT int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const;
83     MEDCOUPLING_EXPORT std::set<int> getGaussLocalizationIdsOfOneType(INTERP_KERNEL::NormalizedCellType type) const;
84     MEDCOUPLING_EXPORT int getNbOfGaussLocalization() const;
85     MEDCOUPLING_EXPORT int getGaussLocalizationIdOfOneCell(int cellId) const;
86     MEDCOUPLING_EXPORT void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const;
87     MEDCOUPLING_EXPORT const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const;
88     MEDCOUPLING_EXPORT void updateTime() const;
89     MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
90     MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
91     // for MED file RW
92     MEDCOUPLING_EXPORT int getNumberOfTuplesExpectedRegardingCode(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const;
93     MEDCOUPLING_EXPORT virtual void reprQuickOverview(std::ostream& stream) const = 0;
94   protected:
95     MEDCOUPLING_EXPORT MEDCouplingField(TypeOfField type);
96     MEDCOUPLING_EXPORT MEDCouplingField(const MEDCouplingField& other, bool deepCopy=true);
97     MEDCOUPLING_EXPORT MEDCouplingField(MEDCouplingFieldDiscretization *type, NatureOfField nature=NoNature);
98     MEDCOUPLING_EXPORT virtual ~MEDCouplingField();
99   protected:
100     std::string _name;
101     std::string _desc;
102     NatureOfField _nature;
103     const MEDCouplingMesh *_mesh;
104     MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDiscretization> _type;
105   };
106 }
107
108 #endif