Salome HOME
Modification of the getHeapMemorySize computation.
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingDefinitionTime.hxx
1 // Copyright (C) 2007-2013  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_MEDCOUPLINGDEFINITIONTIME_HXX__
22 #define __PARAMEDMEM_MEDCOUPLINGDEFINITIONTIME_HXX__
23
24 #include "MEDCouplingRefCountObject.hxx"
25 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
26
27 #include "InterpKernelException.hxx"
28
29 #include <vector>
30 #include <sstream>
31
32 namespace ParaMEDMEM
33 {
34   class MEDCouplingFieldDouble;
35
36   class MEDCOUPLING_EXPORT MEDCouplingDefinitionTimeSlice : public RefCountObject
37   {
38   public:
39     static MEDCouplingDefinitionTimeSlice *New(const MEDCouplingFieldDouble *f, int meshId, const std::vector<int>& arrId, int fieldId) throw(INTERP_KERNEL::Exception);
40     static MEDCouplingDefinitionTimeSlice *New(TypeOfTimeDiscretization type, const std::vector<int>& tiI, const std::vector<double>& tiD) throw(INTERP_KERNEL::Exception);
41     int getArrayId() const { return _array_id; }
42     virtual MEDCouplingDefinitionTimeSlice *copy() const = 0;
43     virtual bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
44     virtual void getHotSpotsTime(std::vector<double>& ret) const = 0;
45     virtual void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception) = 0;
46     virtual bool isContaining(double tmp, double eps) const = 0;
47     virtual int getStartId() const;
48     virtual int getEndId() const;
49     virtual void appendRepr(std::ostream& stream) const;
50     virtual double getStartTime() const = 0;
51     virtual double getEndTime() const = 0;
52     virtual void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const = 0;
53     virtual TypeOfTimeDiscretization getTimeType() const = 0;
54     std::size_t getHeapMemorySizeWithoutChildren() const;
55     std::vector<RefCountObject *> getDirectChildren() const;
56     bool isFullyIncludedInMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const;
57     bool isOverllapingWithMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const;
58     bool isAfterMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const;
59     bool isBeforeMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const;
60   protected:
61     MEDCouplingDefinitionTimeSlice() { }
62     MEDCouplingDefinitionTimeSlice(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception);
63   protected:
64     int _mesh_id;
65     int _array_id;
66     int _field_id;
67   };
68
69   class MEDCouplingDefinitionTimeSliceInst : public MEDCouplingDefinitionTimeSlice
70   {
71   public:
72     static MEDCouplingDefinitionTimeSliceInst *New(const std::vector<int>& tiI, const std::vector<double>& tiD);
73     MEDCouplingDefinitionTimeSlice *copy() const;
74     bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
75     void getHotSpotsTime(std::vector<double>& ret) const;
76     void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
77     bool isContaining(double tmp, double eps) const;
78     void appendRepr(std::ostream& stream) const;
79     double getStartTime() const;
80     double getEndTime() const;
81     void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const;
82     void unserialize(const std::vector<int>& tiI, const std::vector<double>& tiD);
83     TypeOfTimeDiscretization getTimeType() const;
84   public:
85     MEDCouplingDefinitionTimeSliceInst(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception);
86   protected:
87     MEDCouplingDefinitionTimeSliceInst() { }
88   protected:
89     double _instant;
90   };
91
92   class MEDCouplingDefinitionTimeSliceCstOnTI : public  MEDCouplingDefinitionTimeSlice
93   {
94   public:
95     static MEDCouplingDefinitionTimeSliceCstOnTI *New(const std::vector<int>& tiI, const std::vector<double>& tiD);
96     MEDCouplingDefinitionTimeSlice *copy() const;
97     bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
98     void getHotSpotsTime(std::vector<double>& ret) const;
99     void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
100     bool isContaining(double tmp, double eps) const;
101     void appendRepr(std::ostream& stream) const;
102     double getStartTime() const;
103     double getEndTime() const;
104     void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const;
105     void unserialize(const std::vector<int>& tiI, const std::vector<double>& tiD);
106     TypeOfTimeDiscretization getTimeType() const;
107   public:
108     MEDCouplingDefinitionTimeSliceCstOnTI(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception);
109   protected:
110     MEDCouplingDefinitionTimeSliceCstOnTI() { }
111   protected:
112     double _start;
113     double _end;
114   };
115   
116   class MEDCouplingDefinitionTimeSliceLT : public MEDCouplingDefinitionTimeSlice
117   {
118   public:
119     static MEDCouplingDefinitionTimeSliceLT *New(const std::vector<int>& tiI, const std::vector<double>& tiD);
120     MEDCouplingDefinitionTimeSlice *copy() const;
121     bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
122     void getHotSpotsTime(std::vector<double>& ret) const;
123     void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
124     bool isContaining(double tmp, double eps) const;
125     void appendRepr(std::ostream& stream) const;
126     double getStartTime() const;
127     double getEndTime() const;
128     int getEndId() const;
129     void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const;
130     void unserialize(const std::vector<int>& tiI, const std::vector<double>& tiD);
131     TypeOfTimeDiscretization getTimeType() const;
132   public:
133     MEDCouplingDefinitionTimeSliceLT(const MEDCouplingFieldDouble *f, int meshId, int arrId, int arr2Id, int fieldId) throw(INTERP_KERNEL::Exception);
134   protected:
135     MEDCouplingDefinitionTimeSliceLT() { }
136   protected:
137     int _array_id_end;
138     double _start;
139     double _end;
140   };
141
142   class MEDCOUPLING_EXPORT MEDCouplingDefinitionTime
143   {
144   public:
145     MEDCouplingDefinitionTime();
146     MEDCouplingDefinitionTime(const std::vector<const MEDCouplingFieldDouble *>& fs, const std::vector<int>& meshRefs, const std::vector<std::vector<int> >& arrRefs) throw(INTERP_KERNEL::Exception);
147     std::size_t getHeapMemorySizeWithoutChildren() const;
148     std::vector<RefCountObject *> getDirectChildren() const;
149     void assign(const MEDCouplingDefinitionTime& other);
150     bool isEqual(const MEDCouplingDefinitionTime& other) const;
151     double getTimeResolution() const { return _eps; }
152     void getIdsOnTimeRight(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
153     void getIdsOnTimeLeft(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
154     void getIdsOnTime(double tm, std::vector<int>& meshIds, std::vector<int>& arrIds, std::vector<int>& arrIdsInField, std::vector<int>& fieldIds) const throw(INTERP_KERNEL::Exception);
155     std::vector<double> getHotSpotsTime() const;
156     void appendRepr(std::ostream& stream) const;
157   public:
158     void getTinySerializationInformation(std::vector<int>& tinyInfoI, std::vector<double>& tinyInfoD) const;
159     void unserialize(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
160   private:
161     double _eps;
162     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingDefinitionTimeSlice> > _slices;
163     static const double EPS_DFT;
164   };
165 }
166
167 #endif