1 // Copyright (C) 2007-2019 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 __MEDCOUPLINGFIELDDOUBLE_HXX__
22 #define __MEDCOUPLINGFIELDDOUBLE_HXX__
24 #include "MEDCoupling.hxx"
25 #include "MEDCouplingFieldT.hxx"
26 #include "MEDCouplingMemArray.hxx"
31 class MEDCouplingFieldInt;
32 class MEDCouplingFieldTemplate;
34 class MEDCouplingFieldDouble : public MEDCouplingFieldT<double>
37 MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME);
38 MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td=ONE_TIME);
39 MEDCOUPLING_EXPORT void synchronizeTimeWithSupport();
40 MEDCOUPLING_EXPORT std::string advancedRepr() const;
41 MEDCOUPLING_EXPORT std::string writeVTK(const std::string& fileName, bool isBinary=true) const;
42 MEDCOUPLING_EXPORT bool areCompatibleForMerge(const MEDCouplingField *other) const;
43 MEDCOUPLING_EXPORT bool areCompatibleForMeld(const MEDCouplingFieldDouble *other) const;
44 MEDCOUPLING_EXPORT void renumberNodes(const int *old2NewBg, double eps=1e-15);
45 MEDCOUPLING_EXPORT void renumberNodesWithoutMesh(const int *old2NewBg, int newNbOfNodes, double eps=1e-15);
46 MEDCOUPLING_EXPORT DataArrayInt *findIdsInRange(double vmin, double vmax) const;
47 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *deepCopy() const;
48 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *clone(bool recDeepCpy) const;
49 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCpy) const;
50 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *nodeToCellDiscretization() const;
51 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *cellToNodeDiscretization() const;
52 MEDCOUPLING_EXPORT MEDCouplingFieldInt *convertToIntField() const;
53 MEDCOUPLING_EXPORT MEDCouplingFieldFloat *convertToFloatField() const;
54 MEDCOUPLING_EXPORT double getIJK(int cellId, int nodeIdInCell, int compoId) const;
55 MEDCOUPLING_EXPORT double accumulate(int compId) const;
56 MEDCOUPLING_EXPORT void accumulate(double *res) const;
57 MEDCOUPLING_EXPORT double getMaxValue() const;
58 MEDCOUPLING_EXPORT double getMaxValue2(DataArrayInt*& tupleIds) const;
59 MEDCOUPLING_EXPORT double getMinValue() const;
60 MEDCOUPLING_EXPORT double getMinValue2(DataArrayInt*& tupleIds) const;
61 MEDCOUPLING_EXPORT double getAverageValue() const;
62 MEDCOUPLING_EXPORT double norm2() const;
63 MEDCOUPLING_EXPORT void getWeightedAverageValue(double *res, bool isWAbs=true) const;
64 MEDCOUPLING_EXPORT double getWeightedAverageValue(int compId, bool isWAbs=true) const;
65 MEDCOUPLING_EXPORT double normL1(int compId) const;
66 MEDCOUPLING_EXPORT void normL1(double *res) const;
67 MEDCOUPLING_EXPORT double normL2(int compId) const;
68 MEDCOUPLING_EXPORT void normL2(double *res) const;
69 MEDCOUPLING_EXPORT double normMax(int compId) const;
70 MEDCOUPLING_EXPORT void normMax(double *res) const;
71 MEDCOUPLING_EXPORT double integral(int compId, bool isWAbs) const;
72 MEDCOUPLING_EXPORT void integral(bool isWAbs, double *res) const;
73 MEDCOUPLING_EXPORT void getValueOnPos(int i, int j, int k, double *res) const;
74 MEDCOUPLING_EXPORT void getValueOn(const double *spaceLoc, double *res) const;
75 MEDCOUPLING_EXPORT void getValueOn(const double *spaceLoc, double time, double *res) const;
76 MEDCOUPLING_EXPORT DataArrayDouble *getValueOnMulti(const double *spaceLoc, int nbOfPoints) const;
77 MEDCOUPLING_EXPORT void applyLin(double a, double b, int compoId);
78 MEDCOUPLING_EXPORT void applyLin(double a, double b);
79 MEDCOUPLING_EXPORT MEDCouplingFieldDouble &operator=(double value);
80 MEDCOUPLING_EXPORT void fillFromAnalytic(int nbOfComp, FunctionToEvaluate func);
81 MEDCOUPLING_EXPORT void fillFromAnalytic(int nbOfComp, const std::string& func);
82 MEDCOUPLING_EXPORT void fillFromAnalyticCompo(int nbOfComp, const std::string& func);
83 MEDCOUPLING_EXPORT void fillFromAnalyticNamedCompo(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func);
84 MEDCOUPLING_EXPORT void applyFunc(int nbOfComp, FunctionToEvaluate func);
85 MEDCOUPLING_EXPORT void applyFunc(int nbOfComp, double val);
86 MEDCOUPLING_EXPORT void applyFunc(int nbOfComp, const std::string& func);
87 MEDCOUPLING_EXPORT void applyFuncCompo(int nbOfComp, const std::string& func);
88 MEDCOUPLING_EXPORT void applyFuncNamedCompo(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func);
89 MEDCOUPLING_EXPORT void applyFunc(const std::string& func);
90 MEDCOUPLING_EXPORT void applyFuncFast32(const std::string& func);
91 MEDCOUPLING_EXPORT void applyFuncFast64(const std::string& func);
92 MEDCOUPLING_EXPORT std::size_t getNumberOfComponents() const;
93 MEDCOUPLING_EXPORT std::size_t getNumberOfTuples() const;
94 MEDCOUPLING_EXPORT std::size_t getNumberOfValues() const;
95 MEDCOUPLING_EXPORT void updateTime() const;
96 MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
97 MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
99 MEDCOUPLING_EXPORT void changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double precOnMesh, double eps=1e-15);
100 MEDCOUPLING_EXPORT void substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double precOnMesh, double eps=1e-15);
101 MEDCOUPLING_EXPORT bool mergeNodes(double eps, double epsOnVals=1e-15);
102 MEDCOUPLING_EXPORT bool mergeNodesCenter(double eps, double epsOnVals=1e-15);
103 MEDCOUPLING_EXPORT bool zipCoords(double epsOnVals=1e-15);
104 MEDCOUPLING_EXPORT bool zipConnectivity(int compType, double epsOnVals=1e-15);
105 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *extractSlice3D(const double *origin, const double *vec, double eps) const;
106 MEDCOUPLING_EXPORT bool simplexize(int policy);
107 MEDCOUPLING_EXPORT MCAuto<MEDCouplingFieldDouble> voronoize(double eps) const;
108 MEDCOUPLING_EXPORT MCAuto<MEDCouplingFieldDouble> convertQuadraticCellsToLinear() const;
109 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *computeVectorFieldCyl(const double center[3], const double vect[3]) const;
110 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *doublyContractedProduct() const;
111 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *determinant() const;
112 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *eigenValues() const;
113 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *eigenVectors() const;
114 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *inverse() const;
115 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *trace() const;
116 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *deviator() const;
117 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *magnitude() const;
118 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *maxPerTuple() const;
119 MEDCOUPLING_EXPORT void changeNbOfComponents(int newNbOfComp, double dftValue=0.);
120 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *keepSelectedComponents(const std::vector<int>& compoIds) const;
121 MEDCOUPLING_EXPORT void setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector<int>& compoIds);
122 MEDCOUPLING_EXPORT void sortPerTuple(bool asc);
123 MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *MergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
124 MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *MergeFields(const std::vector<const MEDCouplingFieldDouble *>& a);
125 MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *MeldFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
126 MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *DotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
127 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *dot(const MEDCouplingFieldDouble& other) const { return DotFields(this,&other); }
128 MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *CrossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
129 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *crossProduct(const MEDCouplingFieldDouble& other) const { return CrossProductFields(this,&other); }
130 MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *MaxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
131 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *max(const MEDCouplingFieldDouble& other) const { return MaxFields(this,&other); }
132 MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *MinFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
133 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *min(const MEDCouplingFieldDouble& other) const { return MinFields(this,&other); }
134 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *negate() const;
135 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *operator+(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return AddFields(this,&other); }
136 MEDCOUPLING_EXPORT const MEDCouplingFieldDouble &operator+=(const MEDCouplingFieldDouble& other);
137 MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *AddFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
138 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *operator-(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return SubstractFields(this,&other); }
139 MEDCOUPLING_EXPORT const MEDCouplingFieldDouble &operator-=(const MEDCouplingFieldDouble& other);
140 MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *SubstractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
141 MEDCouplingFieldDouble *operator*(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return MultiplyFields(this,&other); }
142 MEDCOUPLING_EXPORT const MEDCouplingFieldDouble &operator*=(const MEDCouplingFieldDouble& other);
143 MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *MultiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
144 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *operator/(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return DivideFields(this,&other); }
145 MEDCOUPLING_EXPORT const MEDCouplingFieldDouble &operator/=(const MEDCouplingFieldDouble& other);
146 MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *DivideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
147 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *operator^(const MEDCouplingFieldDouble& other) const;
148 MEDCOUPLING_EXPORT const MEDCouplingFieldDouble &operator^=(const MEDCouplingFieldDouble& other);
149 MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *PowFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
150 MEDCOUPLING_EXPORT static std::string WriteVTK(const std::string& fileName, const std::vector<const MEDCouplingFieldDouble *>& fs, bool isBinary=true);
152 MEDCOUPLING_EXPORT const MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() const { return timeDiscr(); }
153 MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() { return timeDiscr(); }
155 ~MEDCouplingFieldDouble() { }
157 MEDCOUPLING_EXPORT MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td);
158 MEDCOUPLING_EXPORT MEDCouplingFieldDouble(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td);
159 MEDCOUPLING_EXPORT MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCpy);
160 MEDCOUPLING_EXPORT MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type);
161 MEDCOUPLING_EXPORT MCAuto<MEDCouplingFieldDouble> voronoizeGen(const Voronizer *vor, double eps) const;
162 MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *timeDiscr();
163 MEDCOUPLING_EXPORT const MEDCouplingTimeDiscretization *timeDiscr() const;