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
20 #ifndef __MEDCALCULATORDBFIELD_HXX__
21 #define __MEDCALCULATORDBFIELD_HXX__
23 #include "MedCalculatorDefines.hxx"
24 #include "MEDCalculatorDBSliceField.hxx"
25 #include "MEDCalculatorDBRangeSelection.hxx"
27 #include "MEDCouplingRefCountObject.hxx"
28 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
30 #include "InterpKernelException.hxx"
37 class MEDCalculatorBrowserField;
38 class MEDCalculatorDBFieldReal;
39 class MEDCalculatorDBFieldCst;
42 class MEDCALCULATOR_EXPORT MEDCalculatorDBField : public RefCountObject
45 static MEDCalculatorDBFieldReal *New(const MEDCalculatorBrowserField& ls);
46 static MEDCalculatorDBFieldCst *New(double val);
47 virtual MEDCalculatorDBField *operator+(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception) = 0;
48 MEDCalculatorDBField *operator+(double val) const throw(INTERP_KERNEL::Exception);
49 virtual MEDCalculatorDBField *operator-(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception) = 0;
50 MEDCalculatorDBField *operator-(double val) const throw(INTERP_KERNEL::Exception);
51 virtual MEDCalculatorDBField *operator*(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception) = 0;
52 MEDCalculatorDBField *operator*(double val) const throw(INTERP_KERNEL::Exception);
53 virtual MEDCalculatorDBField *operator/(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception) = 0;
54 MEDCalculatorDBField *operator/(double val) const throw(INTERP_KERNEL::Exception);
55 virtual bool isEqual(const MEDCalculatorDBField& other, double precM, double precF) const = 0;
58 class MEDCALCULATOR_EXPORT MEDCalculatorDBFieldReal : public MEDCalculatorDBField
61 MEDCalculatorDBFieldReal(const MEDCalculatorBrowserField& ls);
62 ~MEDCalculatorDBFieldReal();
63 void setName(const char *name);
64 void setDescription(const char *descr);
65 void write(const char *fName, bool writeFromScratch) const throw(INTERP_KERNEL::Exception);
66 void display() const throw(INTERP_KERNEL::Exception);
67 std::string simpleRepr() const;
68 MEDCalculatorDBFieldReal *operator()(const MEDCalculatorDBRangeSelection& t, const MEDCalculatorDBRangeSelection& p, const MEDCalculatorDBRangeSelection& c) throw(INTERP_KERNEL::Exception);
69 const MEDCalculatorDBFieldReal& operator=(const MEDCalculatorDBFieldReal& other) throw(INTERP_KERNEL::Exception);
70 const MEDCalculatorDBFieldReal& operator=(double val) throw(INTERP_KERNEL::Exception);
71 MEDCalculatorDBField *operator+(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
72 MEDCalculatorDBField *add(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
73 MEDCalculatorDBField *operator-(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
74 MEDCalculatorDBField *substract(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
75 MEDCalculatorDBField *operator*(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
76 MEDCalculatorDBField *multiply(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
77 MEDCalculatorDBField *operator/(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
78 MEDCalculatorDBField *divide(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
79 MEDCalculatorDBField *operator^(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
80 MEDCalculatorDBField *dot(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
81 MEDCalculatorDBField *crossProduct(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
82 MEDCalculatorDBField *doublyContractedProduct() const throw(INTERP_KERNEL::Exception);
83 MEDCalculatorDBField *determinant() const throw(INTERP_KERNEL::Exception);
84 MEDCalculatorDBField *eigenValues() const throw(INTERP_KERNEL::Exception);
85 MEDCalculatorDBField *eigenVectors() const throw(INTERP_KERNEL::Exception);
86 MEDCalculatorDBField *inverse() const throw(INTERP_KERNEL::Exception);
87 MEDCalculatorDBField *trace() const throw(INTERP_KERNEL::Exception);
88 MEDCalculatorDBField *deviator() const throw(INTERP_KERNEL::Exception);
89 MEDCalculatorDBField *magnitude() const throw(INTERP_KERNEL::Exception);
90 void applyFunc(const char *func) throw(INTERP_KERNEL::Exception);
91 bool isEqual(const MEDCalculatorDBField& other, double precM, double precF) const;
92 bool isEqualSameType(const MEDCalculatorDBFieldReal& other, double precM, double precF) const;
93 MEDCalculatorDBFieldReal *buildCstFieldFromThis(double val) const;
94 void checkCoherency(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
95 void fetchData() const throw(INTERP_KERNEL::Exception);
96 TypeOfField getType() const { return _type; }
97 int getNumberOfSteps() const;
98 int getNumberOfFetchedSteps() const;
99 int getNumberOfComponents() const;
100 std::vector<MEDCouplingFieldDouble *> getFields() const throw(INTERP_KERNEL::Exception);
101 std::string getInfoOnComponent(int i) const throw(INTERP_KERNEL::Exception);
102 void setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL::Exception);
104 MEDCalculatorDBFieldReal(TypeOfField type);
107 std::string _description;
109 std::string _file_name;
110 std::string _mesh_name;
111 std::string _field_name;
113 MEDCalculatorDBRangeSelection _t;
114 MEDCalculatorDBRangeSelection _p;
115 std::vector<std::string> _c_labels;
116 MEDCalculatorDBRangeSelection _c;
117 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCalculatorDBSliceField> > _time_steps;
120 class MEDCALCULATOR_EXPORT MEDCalculatorDBFieldCst : public MEDCalculatorDBField
123 MEDCalculatorDBFieldCst(double val);
124 MEDCalculatorDBField *operator+(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
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 bool isEqual(const MEDCalculatorDBField& other, double precM, double precF) const;
129 MEDCalculatorDBFieldReal *convertIntoReal(const MEDCalculatorDBFieldReal& ref) const;
130 double getValue() const { return _val; }