Salome HOME
162a17834324c7ef0da5e79dd0177e9acaa6c15b
[modules/med.git] / src / MEDCoupling / MEDCouplingField.hxx
1 // Copyright (C) 2007-2012  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
20 #ifndef __PARAMEDMEM_MEDCOUPLINGFIELD_HXX__
21 #define __PARAMEDMEM_MEDCOUPLINGFIELD_HXX__
22
23 #include "MEDCoupling.hxx"
24 #include "MEDCouplingTimeLabel.hxx"
25 #include "MEDCouplingNatureOfField.hxx"
26 #include "MEDCouplingRefCountObject.hxx"
27 #include "NormalizedUnstructuredMesh.hxx"
28 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
29 #include "MEDCouplingFieldDiscretization.hxx"
30 #include "InterpKernelException.hxx"
31
32 #include <string>
33 #include <vector>
34
35 namespace ParaMEDMEM
36 {
37   class DataArrayInt;
38   class DataArrayDouble;
39   class MEDCouplingMesh;
40   class MEDCouplingFieldDouble;
41   class MEDCouplingGaussLocalization;
42
43   class MEDCOUPLING_EXPORT MEDCouplingField : public RefCountObject, public TimeLabel
44   {
45   public:
46     virtual void checkCoherency() const throw(INTERP_KERNEL::Exception) = 0;
47     virtual bool areCompatibleForMerge(const MEDCouplingField *other) const;
48     virtual bool areStrictlyCompatible(const MEDCouplingField *other) const;
49     virtual bool isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec, std::string& reason) const throw(INTERP_KERNEL::Exception);
50     virtual bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
51     virtual bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
52     void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh);
53     const ParaMEDMEM::MEDCouplingMesh *getMesh() const { return _mesh; }
54     void setName(const char *name) { _name=name; }
55     const char *getDescription() const { return _desc.c_str(); }
56     void setDescription(const char *desc) { _desc=desc; }
57     const char *getName() const { return _name.c_str(); }
58     TypeOfField getTypeOfField() const;
59     NatureOfField getNature() const;
60     virtual void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception);
61     DataArrayDouble *getLocalizationOfDiscr() const throw(INTERP_KERNEL::Exception);
62     MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception);
63     MEDCouplingMesh *buildSubMeshData(const int *start, const int *end, DataArrayInt *&di) const;
64     DataArrayInt *computeTupleIdsToSelectFromCellIds(const int *startCellIds, const int *endCellIds) const;
65     const MEDCouplingFieldDiscretization *getDiscretization() const { return _type; }
66     MEDCouplingFieldDiscretization *getDiscretization() { return _type; }
67     int getNumberOfTuplesExpected() const throw(INTERP_KERNEL::Exception);
68     int getNumberOfMeshPlacesExpected() const throw(INTERP_KERNEL::Exception);
69     // Gauss point specific methods
70     void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
71                                     const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
72     void setGaussLocalizationOnCells(const int *begin, const int *end, const std::vector<double>& refCoo,
73                                      const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
74     void clearGaussLocalizations();
75     MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception);
76     int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
77     int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception);
78     int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception);
79     void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const throw(INTERP_KERNEL::Exception);
80     const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception);
81     void updateTime() const;
82   protected:
83     MEDCouplingField(TypeOfField type);
84     MEDCouplingField(const MEDCouplingField& other);
85     MEDCouplingField(MEDCouplingFieldDiscretization *type, NatureOfField nature=NoNature);
86     virtual ~MEDCouplingField();
87   protected:
88     std::string _name;
89     std::string _desc;
90     NatureOfField _nature;
91     const MEDCouplingMesh *_mesh;
92     MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDiscretization> _type;
93   };
94 }
95
96 #endif