Salome HOME
Copyright update 2020
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingField.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_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 "MCAuto.hxx"
30 #include "MEDCouplingFieldDiscretization.hxx"
31 #include "InterpKernelException.hxx"
32
33 #include <string>
34 #include <vector>
35
36 namespace MEDCoupling
37 {
38   class DataArrayIdType;
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 checkConsistencyLight() const;
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 void copyTinyStringsFrom(const MEDCouplingField *other);
52     MEDCOUPLING_EXPORT void setMesh(const MEDCoupling::MEDCouplingMesh *mesh);
53     MEDCOUPLING_EXPORT const MEDCoupling::MEDCouplingMesh *getMesh() const { return _mesh; }
54     MEDCOUPLING_EXPORT MEDCoupling::MEDCouplingMesh *getMesh() { return const_cast<MEDCoupling::MEDCouplingMesh *>(_mesh); }
55     MEDCOUPLING_EXPORT void setName(const std::string& name) { _name=name; }
56     MEDCOUPLING_EXPORT std::string getDescription() const { return _desc; }
57     MEDCOUPLING_EXPORT void setDescription(const std::string& desc) { _desc=desc; }
58     MEDCOUPLING_EXPORT std::string getName() const { return _name; }
59     MEDCOUPLING_EXPORT TypeOfField getTypeOfField() const;
60     MEDCOUPLING_EXPORT NatureOfField getNature() const;
61     MEDCOUPLING_EXPORT virtual void setNature(NatureOfField nat);
62     MEDCOUPLING_EXPORT DataArrayDouble *getLocalizationOfDiscr() const;
63     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const;
64     MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshData(const mcIdType *start, const mcIdType *end, DataArrayIdType *&di) const;
65     MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshDataRange(mcIdType begin, mcIdType end, mcIdType step, mcIdType& beginOut, mcIdType& endOut, mcIdType& stepOut, DataArrayIdType *&di) const;
66     MEDCOUPLING_EXPORT DataArrayIdType *computeTupleIdsToSelectFromCellIds(const mcIdType *startCellIds, const mcIdType *endCellIds) const;
67     MEDCOUPLING_EXPORT const MEDCouplingFieldDiscretization *getDiscretization() const { return _type; }
68     MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization *getDiscretization() { return _type; }
69     MEDCOUPLING_EXPORT void setDiscretization(MEDCouplingFieldDiscretization *newDisc);
70     MEDCOUPLING_EXPORT mcIdType getNumberOfTuplesExpected() const;
71     MEDCOUPLING_EXPORT mcIdType getNumberOfMeshPlacesExpected() const;
72     // Gauss point specific methods
73     MEDCOUPLING_EXPORT void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
74                                                        const std::vector<double>& gsCoo, const std::vector<double>& wg);
75     MEDCOUPLING_EXPORT void setGaussLocalizationOnCells(const mcIdType *begin, const mcIdType *end, const std::vector<double>& refCoo,
76                                                         const std::vector<double>& gsCoo, const std::vector<double>& wg);
77     MEDCOUPLING_EXPORT void clearGaussLocalizations();
78     MEDCOUPLING_EXPORT MEDCouplingGaussLocalization& getGaussLocalization(int locId);
79     MEDCOUPLING_EXPORT mcIdType getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const;
80     MEDCOUPLING_EXPORT std::set<mcIdType> getGaussLocalizationIdsOfOneType(INTERP_KERNEL::NormalizedCellType type) const;
81     MEDCOUPLING_EXPORT mcIdType getNbOfGaussLocalization() const;
82     MEDCOUPLING_EXPORT mcIdType getGaussLocalizationIdOfOneCell(mcIdType cellId) const;
83     MEDCOUPLING_EXPORT void getCellIdsHavingGaussLocalization(int locId, std::vector<mcIdType>& cellIds) const;
84     MEDCOUPLING_EXPORT const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const;
85     MEDCOUPLING_EXPORT void updateTime() const;
86     MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
87     MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
88     // for MED file RW
89     MEDCOUPLING_EXPORT mcIdType getNumberOfTuplesExpectedRegardingCode(const std::vector<mcIdType>& code, const std::vector<const DataArrayIdType *>& idsPerType) const;
90     MEDCOUPLING_EXPORT virtual void reprQuickOverview(std::ostream& stream) const = 0;
91   protected:
92     MEDCOUPLING_EXPORT MEDCouplingField(TypeOfField type);
93     MEDCOUPLING_EXPORT MEDCouplingField(const MEDCouplingField& other, bool deepCopy=true);
94     MEDCOUPLING_EXPORT MEDCouplingField(MEDCouplingFieldDiscretization *type, NatureOfField nature=NoNature);
95     MEDCOUPLING_EXPORT virtual ~MEDCouplingField();
96     MEDCOUPLING_EXPORT bool isEqualIfNotWhyProtected(const MEDCouplingField *other, double meshPrec, std::string& reason) const;
97     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStrProtected(const MEDCouplingField *other, double meshPrec) const;
98   protected:
99     std::string _name;
100     std::string _desc;
101     NatureOfField _nature;
102     const MEDCouplingMesh *_mesh;
103     MCAuto<MEDCouplingFieldDiscretization> _type;
104   };
105 }
106
107 #endif