1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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 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;
61 class MEDCALCULATOR_EXPORT MEDCalculatorDBFieldReal : public MEDCalculatorDBField
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);
107 MEDCalculatorDBFieldReal(TypeOfField type);
110 std::string _description;
112 std::string _file_name;
113 std::string _mesh_name;
114 std::string _field_name;
116 MEDCalculatorDBRangeSelection _t;
117 MEDCalculatorDBRangeSelection _p;
118 std::vector<std::string> _c_labels;
119 MEDCalculatorDBRangeSelection _c;
120 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCalculatorDBSliceField> > _time_steps;
123 class MEDCALCULATOR_EXPORT MEDCalculatorDBFieldCst : public MEDCalculatorDBField
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; }