Salome HOME
Merge 'agy/br810_1' branch.
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingFieldT.hxx
1 // Copyright (C) 2016  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 (EDF R&D)
20
21 #ifndef __MEDCOUPLINGFIELDT_HXX__
22 #define __MEDCOUPLINGFIELDT_HXX__
23
24 #include "MEDCouplingField.hxx"
25 #include "MEDCouplingTraits.hxx"
26 #include "MEDCouplingTimeDiscretization.hxx"
27
28 #include <sstream>
29
30 namespace MEDCoupling
31 {
32   template<class T>
33   class MEDCouplingTimeDiscretizationTemplate;
34   
35   template<class T>
36   class MEDCouplingFieldT : public MEDCouplingField
37   {
38   protected:
39     MEDCouplingFieldT(const MEDCouplingFieldT<T>& other, bool deepCopy);
40     MEDCouplingFieldT(const MEDCouplingField& other, MEDCouplingTimeDiscretizationTemplate<T> *timeDiscr, bool deepCopy=true);
41     MEDCouplingFieldT(TypeOfField type, MEDCouplingTimeDiscretizationTemplate<T> *timeDiscr);
42     MEDCouplingFieldT(MEDCouplingFieldDiscretization *type, NatureOfField n, MEDCouplingTimeDiscretizationTemplate<T> *timeDiscr);
43     ~MEDCouplingFieldT();
44   public:
45     MEDCOUPLING_EXPORT TypeOfTimeDiscretization getTimeDiscretization() const;
46     MEDCOUPLING_EXPORT virtual typename Traits<T>::FieldType *clone(bool recDeepCpy) const = 0;
47     MEDCOUPLING_EXPORT void checkConsistencyLight() const;
48     MEDCOUPLING_EXPORT typename Traits<T>::FieldType *cloneWithMesh(bool recDeepCpy) const;
49     MEDCOUPLING_EXPORT void setArray(typename Traits<T>::ArrayType *array) { _time_discr->setArray(array,this); }
50     MEDCOUPLING_EXPORT void setEndArray(typename Traits<T>::ArrayType *array) { _time_discr->setEndArray(array,this); }
51     MEDCOUPLING_EXPORT const typename Traits<T>::ArrayType *getArray() const { return _time_discr->getArray(); }
52     MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *getArray() { return _time_discr->getArray(); }
53     MEDCOUPLING_EXPORT const typename Traits<T>::ArrayType *getEndArray() const { return _time_discr->getEndArray(); }
54     MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *getEndArray() { return _time_discr->getEndArray(); }
55     MEDCOUPLING_EXPORT void setArrays(const std::vector<typename Traits<T>::ArrayType *>& arrs) { _time_discr->setArrays(arrs,this); }
56     MEDCOUPLING_EXPORT std::vector<typename Traits<T>::ArrayType *> getArrays() const { std::vector<typename Traits<T>::ArrayType *> ret; _time_discr->getArrays(ret); return ret; }
57     MEDCOUPLING_EXPORT void setTimeUnit(const std::string& unit) { _time_discr->setTimeUnit(unit); }
58     MEDCOUPLING_EXPORT std::string getTimeUnit() const { return _time_discr->getTimeUnit(); }
59     MEDCOUPLING_EXPORT void setTimeTolerance(double val) { _time_discr->setTimeTolerance(val); }
60     MEDCOUPLING_EXPORT double getTimeTolerance() const { return _time_discr->getTimeTolerance(); }
61     MEDCOUPLING_EXPORT void setIteration(int it) { _time_discr->setIteration(it); }
62     MEDCOUPLING_EXPORT void setEndIteration(int it) { _time_discr->setEndIteration(it); }
63     MEDCOUPLING_EXPORT void setOrder(int order) { _time_discr->setOrder(order); }
64     MEDCOUPLING_EXPORT void setEndOrder(int order) { _time_discr->setEndOrder(order); }
65     MEDCOUPLING_EXPORT void setTimeValue(double val) { _time_discr->setTimeValue(val); }
66     MEDCOUPLING_EXPORT void setEndTimeValue(double val) { _time_discr->setEndTimeValue(val); }
67     MEDCOUPLING_EXPORT void setTime(double val, int iteration, int order) { _time_discr->setTime(val,iteration,order); }
68     MEDCOUPLING_EXPORT void synchronizeTimeWithMesh();
69     MEDCOUPLING_EXPORT void setStartTime(double val, int iteration, int order) { _time_discr->setStartTime(val,iteration,order); }
70     MEDCOUPLING_EXPORT void setEndTime(double val, int iteration, int order) { _time_discr->setEndTime(val,iteration,order); }
71     MEDCOUPLING_EXPORT double getTime(int& iteration, int& order) const { return _time_discr->getTime(iteration,order); }
72     MEDCOUPLING_EXPORT double getStartTime(int& iteration, int& order) const { return _time_discr->getStartTime(iteration,order); }
73     MEDCOUPLING_EXPORT double getEndTime(int& iteration, int& order) const { return _time_discr->getEndTime(iteration,order); }
74     MEDCOUPLING_EXPORT T getIJ(int tupleId, int compoId) const { return getArray()->getIJ(tupleId,compoId); }
75     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec, std::string& reason) const;
76     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
77     MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingField *other);
78     MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingField *other) const;
79     MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMulDiv(const MEDCouplingField *other) const;
80     MEDCOUPLING_EXPORT std::string simpleRepr() const;
81     MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
82     // specific
83     MEDCOUPLING_EXPORT bool areCompatibleForMul(const MEDCouplingField *other) const;
84     MEDCOUPLING_EXPORT bool areCompatibleForDiv(const MEDCouplingField *other) const;
85     MEDCOUPLING_EXPORT void copyTinyAttrFrom(const MEDCouplingFieldT<T> *other);
86     MEDCOUPLING_EXPORT void copyAllTinyAttrFrom(const MEDCouplingFieldT<T> *other);
87   protected:
88     MEDCouplingTimeDiscretizationTemplate<T> *_time_discr;
89   };
90 }
91
92 #endif