Salome HOME
Merge from V6_main 13/12/2012
[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 // 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 MEDCOUPLING_EXPORT MEDCouplingField : public RefCountObject, public TimeLabel
45   {
46   public:
47     virtual void checkCoherency() const throw(INTERP_KERNEL::Exception) = 0;
48     virtual bool areCompatibleForMerge(const MEDCouplingField *other) const;
49     virtual bool areStrictlyCompatible(const MEDCouplingField *other) const;
50     virtual bool isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec, std::string& reason) const throw(INTERP_KERNEL::Exception);
51     virtual bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
52     virtual bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
53     void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh);
54     const ParaMEDMEM::MEDCouplingMesh *getMesh() const { return _mesh; }
55     void setName(const char *name) { _name=name; }
56     const char *getDescription() const { return _desc.c_str(); }
57     void setDescription(const char *desc) { _desc=desc; }
58     const char *getName() const { return _name.c_str(); }
59     TypeOfField getTypeOfField() const;
60     NatureOfField getNature() const;
61     virtual void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception);
62     DataArrayDouble *getLocalizationOfDiscr() const throw(INTERP_KERNEL::Exception);
63     MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception);
64     MEDCouplingMesh *buildSubMeshData(const int *start, const int *end, DataArrayInt *&di) const;
65     DataArrayInt *computeTupleIdsToSelectFromCellIds(const int *startCellIds, const int *endCellIds) const;
66     const MEDCouplingFieldDiscretization *getDiscretization() const { return _type; }
67     MEDCouplingFieldDiscretization *getDiscretization() { return _type; }
68     void setDiscretization(MEDCouplingFieldDiscretization *newDisc) { _type=newDisc; }
69     int getNumberOfTuplesExpected() const throw(INTERP_KERNEL::Exception);
70     int getNumberOfMeshPlacesExpected() const throw(INTERP_KERNEL::Exception);
71     // Gauss point specific methods
72     void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
73                                     const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
74     void setGaussLocalizationOnCells(const int *begin, const int *end, const std::vector<double>& refCoo,
75                                      const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
76     void clearGaussLocalizations();
77     MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception);
78     int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
79     std::set<int> getGaussLocalizationIdsOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
80     int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception);
81     int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception);
82     void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const throw(INTERP_KERNEL::Exception);
83     const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception);
84     void updateTime() const;
85   protected:
86     MEDCouplingField(TypeOfField type);
87     MEDCouplingField(const MEDCouplingField& other);
88     MEDCouplingField(MEDCouplingFieldDiscretization *type, NatureOfField nature=NoNature);
89     virtual ~MEDCouplingField();
90   protected:
91     std::string _name;
92     std::string _desc;
93     NatureOfField _nature;
94     const MEDCouplingMesh *_mesh;
95     MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDiscretization> _type;
96   };
97 }
98
99 #endif