Salome HOME
1st step.
[modules/med.git] / src / MEDCalculator / MEDCalculatorDBField.hxx
1 // Copyright (C) 2007-2015  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 (CEA/DEN)
20
21 #ifndef __MEDCALCULATORDBFIELD_HXX__
22 #define __MEDCALCULATORDBFIELD_HXX__
23
24 #include "MedCalculatorDefines.hxx"
25 #include "MEDCalculatorDBSliceField.hxx"
26 #include "MEDCalculatorDBRangeSelection.hxx"
27
28 #include "MEDCouplingRefCountObject.hxx"
29 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
30
31 #include "InterpKernelException.hxx"
32
33 #include <string>
34 #include <vector>
35
36 namespace MEDCoupling
37 {
38   class MEDCalculatorBrowserField;
39   class MEDCalculatorDBFieldReal;
40   class MEDCalculatorDBFieldCst;
41
42
43   class MEDCALCULATOR_EXPORT MEDCalculatorDBField : public RefCountObject
44   {
45   public:
46     static MEDCalculatorDBFieldReal *New(const MEDCalculatorBrowserField& ls);
47     static MEDCalculatorDBFieldCst *New(double val);
48     std::size_t getHeapMemorySizeWithoutChildren() const;
49     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
50     virtual MEDCalculatorDBField *operator+(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception) = 0;
51     MEDCalculatorDBField *operator+(double val) const throw(INTERP_KERNEL::Exception);
52     virtual MEDCalculatorDBField *operator-(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception) = 0;
53     MEDCalculatorDBField *operator-(double val) const throw(INTERP_KERNEL::Exception);
54     virtual MEDCalculatorDBField *operator*(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception) = 0;
55     MEDCalculatorDBField *operator*(double val) const throw(INTERP_KERNEL::Exception);
56     virtual MEDCalculatorDBField *operator/(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception) = 0;
57     MEDCalculatorDBField *operator/(double val) const throw(INTERP_KERNEL::Exception);
58     virtual bool isEqual(const MEDCalculatorDBField& other, double precM, double precF) const = 0;
59   };
60
61   class MEDCALCULATOR_EXPORT MEDCalculatorDBFieldReal : public MEDCalculatorDBField
62   {
63   public:
64     MEDCalculatorDBFieldReal(const MEDCalculatorBrowserField& ls);
65     ~MEDCalculatorDBFieldReal();
66     void setName(const char *name);
67     void setDescription(const char *descr);
68     void write(const char *fName, bool writeFromScratch) const throw(INTERP_KERNEL::Exception);
69     void display() const throw(INTERP_KERNEL::Exception);
70     std::string simpleRepr() const;
71     MEDCalculatorDBFieldReal *operator()(const MEDCalculatorDBRangeSelection& t, const MEDCalculatorDBRangeSelection& p, const MEDCalculatorDBRangeSelection& c) throw(INTERP_KERNEL::Exception);
72     const MEDCalculatorDBFieldReal& operator=(const MEDCalculatorDBFieldReal& other) throw(INTERP_KERNEL::Exception);
73     const MEDCalculatorDBFieldReal& operator=(double val) throw(INTERP_KERNEL::Exception);
74     MEDCalculatorDBField *operator+(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
75     MEDCalculatorDBField *add(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
76     MEDCalculatorDBField *operator-(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
77     MEDCalculatorDBField *substract(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
78     MEDCalculatorDBField *operator*(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
79     MEDCalculatorDBField *multiply(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
80     MEDCalculatorDBField *operator/(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
81     MEDCalculatorDBField *divide(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
82     MEDCalculatorDBField *operator^(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
83     MEDCalculatorDBField *dot(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
84     MEDCalculatorDBField *crossProduct(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
85     MEDCalculatorDBField *doublyContractedProduct() const throw(INTERP_KERNEL::Exception);
86     MEDCalculatorDBField *determinant() const throw(INTERP_KERNEL::Exception);
87     MEDCalculatorDBField *eigenValues() const throw(INTERP_KERNEL::Exception);
88     MEDCalculatorDBField *eigenVectors() const throw(INTERP_KERNEL::Exception);
89     MEDCalculatorDBField *inverse() const throw(INTERP_KERNEL::Exception);
90     MEDCalculatorDBField *trace() const throw(INTERP_KERNEL::Exception);
91     MEDCalculatorDBField *deviator() const throw(INTERP_KERNEL::Exception);
92     MEDCalculatorDBField *magnitude() const throw(INTERP_KERNEL::Exception);
93     void applyFunc(const char *func) throw(INTERP_KERNEL::Exception);
94     bool isEqual(const MEDCalculatorDBField& other, double precM, double precF) const;
95     bool isEqualSameType(const MEDCalculatorDBFieldReal& other, double precM, double precF) const;
96     MEDCalculatorDBFieldReal *buildCstFieldFromThis(double val) const;
97     void checkCoherency(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
98     void fetchData() const throw(INTERP_KERNEL::Exception);
99     TypeOfField getType() const { return _type; }
100     int getNumberOfSteps() const;
101     int getNumberOfFetchedSteps() const;
102     int getNumberOfComponents() const;
103     std::vector<MEDCouplingFieldDouble *> getFields() const throw(INTERP_KERNEL::Exception);
104     std::string getInfoOnComponent(int i) const throw(INTERP_KERNEL::Exception);
105     void setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL::Exception);
106   private:
107     MEDCalculatorDBFieldReal(TypeOfField type);
108   private:
109     std::string _name;
110     std::string _description;
111     //
112     std::string _file_name;
113     std::string _mesh_name;
114     std::string _field_name;
115     TypeOfField _type;
116     MEDCalculatorDBRangeSelection _t;
117     MEDCalculatorDBRangeSelection _p;
118     std::vector<std::string> _c_labels;
119     MEDCalculatorDBRangeSelection _c;
120     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCalculatorDBSliceField> > _time_steps;
121   };
122
123   class MEDCALCULATOR_EXPORT MEDCalculatorDBFieldCst : public MEDCalculatorDBField
124   {
125   public:
126     MEDCalculatorDBFieldCst(double val);
127     MEDCalculatorDBField *operator+(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
128     MEDCalculatorDBField *operator-(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
129     MEDCalculatorDBField *operator*(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
130     MEDCalculatorDBField *operator/(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
131     bool isEqual(const MEDCalculatorDBField& other, double precM, double precF) const;
132     MEDCalculatorDBFieldReal *convertIntoReal(const MEDCalculatorDBFieldReal& ref) const;
133     double getValue() const { return _val; }
134   private:
135     double _val;
136   };
137 }
138
139 #endif