1 // Copyright (C) 2007-2013 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 std::size_t getHeapMemorySize() const { return 0; }
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 MEDCalculatorDBField *operator/(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception) = 0;
56 MEDCalculatorDBField *operator/(double val) const throw(INTERP_KERNEL::Exception);
57 virtual bool isEqual(const MEDCalculatorDBField& other, double precM, double precF) const = 0;
60 class MEDCALCULATOR_EXPORT MEDCalculatorDBFieldReal : public MEDCalculatorDBField
63 MEDCalculatorDBFieldReal(const MEDCalculatorBrowserField& ls);
64 ~MEDCalculatorDBFieldReal();
65 void setName(const char *name);
66 void setDescription(const char *descr);
67 void write(const char *fName, bool writeFromScratch) const throw(INTERP_KERNEL::Exception);
68 void display() const throw(INTERP_KERNEL::Exception);
69 std::string simpleRepr() const;
70 MEDCalculatorDBFieldReal *operator()(const MEDCalculatorDBRangeSelection& t, const MEDCalculatorDBRangeSelection& p, const MEDCalculatorDBRangeSelection& c) throw(INTERP_KERNEL::Exception);
71 const MEDCalculatorDBFieldReal& operator=(const MEDCalculatorDBFieldReal& other) throw(INTERP_KERNEL::Exception);
72 const MEDCalculatorDBFieldReal& operator=(double val) throw(INTERP_KERNEL::Exception);
73 MEDCalculatorDBField *operator+(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
74 MEDCalculatorDBField *add(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
75 MEDCalculatorDBField *operator-(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
76 MEDCalculatorDBField *substract(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
77 MEDCalculatorDBField *operator*(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
78 MEDCalculatorDBField *multiply(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
79 MEDCalculatorDBField *operator/(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
80 MEDCalculatorDBField *divide(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
81 MEDCalculatorDBField *operator^(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
82 MEDCalculatorDBField *dot(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
83 MEDCalculatorDBField *crossProduct(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
84 MEDCalculatorDBField *doublyContractedProduct() const throw(INTERP_KERNEL::Exception);
85 MEDCalculatorDBField *determinant() const throw(INTERP_KERNEL::Exception);
86 MEDCalculatorDBField *eigenValues() const throw(INTERP_KERNEL::Exception);
87 MEDCalculatorDBField *eigenVectors() const throw(INTERP_KERNEL::Exception);
88 MEDCalculatorDBField *inverse() const throw(INTERP_KERNEL::Exception);
89 MEDCalculatorDBField *trace() const throw(INTERP_KERNEL::Exception);
90 MEDCalculatorDBField *deviator() const throw(INTERP_KERNEL::Exception);
91 MEDCalculatorDBField *magnitude() const throw(INTERP_KERNEL::Exception);
92 void applyFunc(const char *func) throw(INTERP_KERNEL::Exception);
93 bool isEqual(const MEDCalculatorDBField& other, double precM, double precF) const;
94 bool isEqualSameType(const MEDCalculatorDBFieldReal& other, double precM, double precF) const;
95 MEDCalculatorDBFieldReal *buildCstFieldFromThis(double val) const;
96 void checkCoherency(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
97 void fetchData() const throw(INTERP_KERNEL::Exception);
98 TypeOfField getType() const { return _type; }
99 int getNumberOfSteps() const;
100 int getNumberOfFetchedSteps() const;
101 int getNumberOfComponents() const;
102 std::vector<MEDCouplingFieldDouble *> getFields() const throw(INTERP_KERNEL::Exception);
103 std::string getInfoOnComponent(int i) const throw(INTERP_KERNEL::Exception);
104 void setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL::Exception);
106 MEDCalculatorDBFieldReal(TypeOfField type);
109 std::string _description;
111 std::string _file_name;
112 std::string _mesh_name;
113 std::string _field_name;
115 MEDCalculatorDBRangeSelection _t;
116 MEDCalculatorDBRangeSelection _p;
117 std::vector<std::string> _c_labels;
118 MEDCalculatorDBRangeSelection _c;
119 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCalculatorDBSliceField> > _time_steps;
122 class MEDCALCULATOR_EXPORT MEDCalculatorDBFieldCst : public MEDCalculatorDBField
125 MEDCalculatorDBFieldCst(double val);
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 MEDCalculatorDBField *operator/(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
130 bool isEqual(const MEDCalculatorDBField& other, double precM, double precF) const;
131 MEDCalculatorDBFieldReal *convertIntoReal(const MEDCalculatorDBFieldReal& ref) const;
132 double getValue() const { return _val; }