1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #ifndef __MEDCALCULATORDBFIELD_HXX__
22 #define __MEDCALCULATORDBFIELD_HXX__
24 #include "MedCalculatorDefines.hxx"
25 #include "MEDCalculatorDBSliceField.hxx"
26 #include "MEDCalculatorDBRangeSelection.hxx"
28 #include "MEDCouplingRefCountObject.hxx"
29 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
31 #include "InterpKernelException.hxx"
38 class MEDCalculatorBrowserField;
39 class MEDCalculatorDBFieldReal;
40 class MEDCalculatorDBFieldCst;
43 class MEDCALCULATOR_EXPORT MEDCalculatorDBField : public RefCountObject
46 static MEDCalculatorDBFieldReal *New(const MEDCalculatorBrowserField& ls);
47 static MEDCalculatorDBFieldCst *New(double val);
48 virtual MEDCalculatorDBField *operator+(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception) = 0;
49 MEDCalculatorDBField *operator+(double val) const throw(INTERP_KERNEL::Exception);
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 bool isEqual(const MEDCalculatorDBField& other, double precM, double precF) const = 0;
59 class MEDCALCULATOR_EXPORT MEDCalculatorDBFieldReal : public MEDCalculatorDBField
62 MEDCalculatorDBFieldReal(const MEDCalculatorBrowserField& ls);
63 ~MEDCalculatorDBFieldReal();
64 void setName(const char *name);
65 void setDescription(const char *descr);
66 void write(const char *fName, bool writeFromScratch) const throw(INTERP_KERNEL::Exception);
67 void display() const throw(INTERP_KERNEL::Exception);
68 std::string simpleRepr() const;
69 MEDCalculatorDBFieldReal *operator()(const MEDCalculatorDBRangeSelection& t, const MEDCalculatorDBRangeSelection& p, const MEDCalculatorDBRangeSelection& c) throw(INTERP_KERNEL::Exception);
70 const MEDCalculatorDBFieldReal& operator=(const MEDCalculatorDBFieldReal& other) throw(INTERP_KERNEL::Exception);
71 const MEDCalculatorDBFieldReal& operator=(double val) throw(INTERP_KERNEL::Exception);
72 MEDCalculatorDBField *operator+(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
73 MEDCalculatorDBField *add(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
74 MEDCalculatorDBField *operator-(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
75 MEDCalculatorDBField *substract(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
76 MEDCalculatorDBField *operator*(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
77 MEDCalculatorDBField *multiply(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
78 MEDCalculatorDBField *operator/(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
79 MEDCalculatorDBField *divide(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
80 MEDCalculatorDBField *operator^(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
81 MEDCalculatorDBField *dot(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
82 MEDCalculatorDBField *crossProduct(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
83 MEDCalculatorDBField *doublyContractedProduct() const throw(INTERP_KERNEL::Exception);
84 MEDCalculatorDBField *determinant() const throw(INTERP_KERNEL::Exception);
85 MEDCalculatorDBField *eigenValues() const throw(INTERP_KERNEL::Exception);
86 MEDCalculatorDBField *eigenVectors() const throw(INTERP_KERNEL::Exception);
87 MEDCalculatorDBField *inverse() const throw(INTERP_KERNEL::Exception);
88 MEDCalculatorDBField *trace() const throw(INTERP_KERNEL::Exception);
89 MEDCalculatorDBField *deviator() const throw(INTERP_KERNEL::Exception);
90 MEDCalculatorDBField *magnitude() const throw(INTERP_KERNEL::Exception);
91 void applyFunc(const char *func) throw(INTERP_KERNEL::Exception);
92 bool isEqual(const MEDCalculatorDBField& other, double precM, double precF) const;
93 bool isEqualSameType(const MEDCalculatorDBFieldReal& other, double precM, double precF) const;
94 MEDCalculatorDBFieldReal *buildCstFieldFromThis(double val) const;
95 void checkCoherency(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
96 void fetchData() const throw(INTERP_KERNEL::Exception);
97 TypeOfField getType() const { return _type; }
98 int getNumberOfSteps() const;
99 int getNumberOfFetchedSteps() const;
100 int getNumberOfComponents() const;
101 std::vector<MEDCouplingFieldDouble *> getFields() const throw(INTERP_KERNEL::Exception);
102 std::string getInfoOnComponent(int i) const throw(INTERP_KERNEL::Exception);
103 void setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL::Exception);
105 MEDCalculatorDBFieldReal(TypeOfField type);
108 std::string _description;
110 std::string _file_name;
111 std::string _mesh_name;
112 std::string _field_name;
114 MEDCalculatorDBRangeSelection _t;
115 MEDCalculatorDBRangeSelection _p;
116 std::vector<std::string> _c_labels;
117 MEDCalculatorDBRangeSelection _c;
118 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCalculatorDBSliceField> > _time_steps;
121 class MEDCALCULATOR_EXPORT MEDCalculatorDBFieldCst : public MEDCalculatorDBField
124 MEDCalculatorDBFieldCst(double val);
125 MEDCalculatorDBField *operator+(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
126 MEDCalculatorDBField *operator-(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
127 MEDCalculatorDBField *operator*(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
128 MEDCalculatorDBField *operator/(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
129 bool isEqual(const MEDCalculatorDBField& other, double precM, double precF) const;
130 MEDCalculatorDBFieldReal *convertIntoReal(const MEDCalculatorDBFieldReal& ref) const;
131 double getValue() const { return _val; }