Back to index

salome-med  6.5.0
MEDCouplingDefinitionTime.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #ifndef __PARAMEDMEM_MEDCOUPLINGDEFINITIONTIME_HXX__
00021 #define __PARAMEDMEM_MEDCOUPLINGDEFINITIONTIME_HXX__
00022 
00023 #include "MEDCouplingRefCountObject.hxx"
00024 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
00025 
00026 #include "InterpKernelException.hxx"
00027 
00028 #include <vector>
00029 #include <sstream>
00030 
00031 namespace ParaMEDMEM
00032 {
00033   class MEDCouplingFieldDouble;
00034 
00035   class MEDCOUPLING_EXPORT MEDCouplingDefinitionTimeSlice : public RefCountObject
00036   {
00037   public:
00038     static MEDCouplingDefinitionTimeSlice *New(const MEDCouplingFieldDouble *f, int meshId, const std::vector<int>& arrId, int fieldId) throw(INTERP_KERNEL::Exception);
00039     static MEDCouplingDefinitionTimeSlice *New(TypeOfTimeDiscretization type, const std::vector<int>& tiI, const std::vector<double>& tiD) throw(INTERP_KERNEL::Exception);
00040     int getArrayId() const { return _array_id; }
00041     virtual MEDCouplingDefinitionTimeSlice *copy() const = 0;
00042     virtual bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
00043     virtual void getHotSpotsTime(std::vector<double>& ret) const = 0;
00044     virtual void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception) = 0;
00045     virtual bool isContaining(double tmp, double eps) const = 0;
00046     virtual int getStartId() const;
00047     virtual int getEndId() const;
00048     virtual void appendRepr(std::ostream& stream) const;
00049     virtual double getStartTime() const = 0;
00050     virtual double getEndTime() const = 0;
00051     virtual void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const = 0;
00052     virtual TypeOfTimeDiscretization getTimeType() const = 0;
00053     bool isFullyIncludedInMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const;
00054     bool isOverllapingWithMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const;
00055     bool isAfterMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const;
00056     bool isBeforeMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const;
00057   protected:
00058     MEDCouplingDefinitionTimeSlice() { }
00059     MEDCouplingDefinitionTimeSlice(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception);
00060   protected:
00061     int _mesh_id;
00062     int _array_id;
00063     int _field_id;
00064   };
00065 
00066   class MEDCouplingDefinitionTimeSliceInst : public MEDCouplingDefinitionTimeSlice
00067   {
00068   public:
00069     static MEDCouplingDefinitionTimeSliceInst *New(const std::vector<int>& tiI, const std::vector<double>& tiD);
00070     MEDCouplingDefinitionTimeSlice *copy() const;
00071     bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
00072     void getHotSpotsTime(std::vector<double>& ret) const;
00073     void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
00074     bool isContaining(double tmp, double eps) const;
00075     void appendRepr(std::ostream& stream) const;
00076     double getStartTime() const;
00077     double getEndTime() const;
00078     void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const;
00079     void unserialize(const std::vector<int>& tiI, const std::vector<double>& tiD);
00080     TypeOfTimeDiscretization getTimeType() const;
00081   public:
00082     MEDCouplingDefinitionTimeSliceInst(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception);
00083   protected:
00084     MEDCouplingDefinitionTimeSliceInst() { }
00085   protected:
00086     double _instant;
00087   };
00088 
00089   class MEDCouplingDefinitionTimeSliceCstOnTI : public  MEDCouplingDefinitionTimeSlice
00090   {
00091   public:
00092     static MEDCouplingDefinitionTimeSliceCstOnTI *New(const std::vector<int>& tiI, const std::vector<double>& tiD);
00093     MEDCouplingDefinitionTimeSlice *copy() const;
00094     bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
00095     void getHotSpotsTime(std::vector<double>& ret) const;
00096     void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
00097     bool isContaining(double tmp, double eps) const;
00098     void appendRepr(std::ostream& stream) const;
00099     double getStartTime() const;
00100     double getEndTime() const;
00101     void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const;
00102     void unserialize(const std::vector<int>& tiI, const std::vector<double>& tiD);
00103     TypeOfTimeDiscretization getTimeType() const;
00104   public:
00105     MEDCouplingDefinitionTimeSliceCstOnTI(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception);
00106   protected:
00107     MEDCouplingDefinitionTimeSliceCstOnTI() { }
00108   protected:
00109     double _start;
00110     double _end;
00111   };
00112   
00113   class MEDCouplingDefinitionTimeSliceLT : public MEDCouplingDefinitionTimeSlice
00114   {
00115   public:
00116     static MEDCouplingDefinitionTimeSliceLT *New(const std::vector<int>& tiI, const std::vector<double>& tiD);
00117     MEDCouplingDefinitionTimeSlice *copy() const;
00118     bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
00119     void getHotSpotsTime(std::vector<double>& ret) const;
00120     void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
00121     bool isContaining(double tmp, double eps) const;
00122     void appendRepr(std::ostream& stream) const;
00123     double getStartTime() const;
00124     double getEndTime() const;
00125     int getEndId() const;
00126     void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const;
00127     void unserialize(const std::vector<int>& tiI, const std::vector<double>& tiD);
00128     TypeOfTimeDiscretization getTimeType() const;
00129   public:
00130     MEDCouplingDefinitionTimeSliceLT(const MEDCouplingFieldDouble *f, int meshId, int arrId, int arr2Id, int fieldId) throw(INTERP_KERNEL::Exception);
00131   protected:
00132     MEDCouplingDefinitionTimeSliceLT() { }
00133   protected:
00134     int _array_id_end;
00135     double _start;
00136     double _end;
00137   };
00138 
00139   class MEDCOUPLING_EXPORT MEDCouplingDefinitionTime
00140   {
00141   public:
00142     MEDCouplingDefinitionTime();
00143     MEDCouplingDefinitionTime(const std::vector<const MEDCouplingFieldDouble *>& fs, const std::vector<int>& meshRefs, const std::vector<std::vector<int> >& arrRefs) throw(INTERP_KERNEL::Exception);
00144     void assign(const MEDCouplingDefinitionTime& other);
00145     bool isEqual(const MEDCouplingDefinitionTime& other) const;
00146     double getTimeResolution() const { return _eps; }
00147     void getIdsOnTimeRight(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
00148     void getIdsOnTimeLeft(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
00149     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);
00150     std::vector<double> getHotSpotsTime() const;
00151     void appendRepr(std::ostream& stream) const;
00152   public:
00153     void getTinySerializationInformation(std::vector<int>& tinyInfoI, std::vector<double>& tinyInfoD) const;
00154     void unserialize(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
00155   private:
00156     double _eps;
00157     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingDefinitionTimeSlice> > _slices;
00158     static const double EPS_DFT;
00159   };
00160 }
00161 
00162 #endif