From 33bef9c33b06748118a99ec0b81a5f627b5db8aa Mon Sep 17 00:00:00 2001 From: Yoann Audouin Date: Wed, 1 Sep 2021 08:28:11 +0200 Subject: [PATCH] Adding conversion to int64 for MEDcouplingField --- src/MEDCoupling/MEDCouplingFieldDouble.cxx | 146 +++++------ src/MEDCoupling/MEDCouplingFieldDouble.hxx | 1 + src/MEDCoupling/MEDCouplingFieldFloat.cxx | 30 ++- src/MEDCoupling/MEDCouplingFieldFloat.hxx | 4 +- src/MEDCoupling/MEDCouplingFieldInt32.cxx | 30 ++- src/MEDCoupling/MEDCouplingFieldInt32.hxx | 4 +- src/MEDCoupling/MEDCouplingMemArray.hxx | 13 +- src/MEDCoupling/MEDCouplingMemArray.txx | 268 +++++++++++---------- src/MEDCoupling_Swig/MEDCouplingMemArray.i | 95 ++++---- src/MEDLoader/MEDFileField1TS.cxx | 115 ++++++--- src/MEDLoader/MEDFileField1TS.hxx | 9 +- src/MEDLoader/Swig/MEDLoaderCommon.i | 186 +++++++------- src/MEDLoader/Swig/MEDLoaderTest3.py | 20 +- 13 files changed, 523 insertions(+), 398 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx index f229e5fc3..0eab16b26 100755 --- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.cxx @@ -22,6 +22,7 @@ #include "MEDCouplingFieldTemplate.hxx" #include "MEDCouplingFieldT.txx" #include "MEDCouplingFieldInt32.hxx" +#include "MEDCouplingFieldInt64.hxx" #include "MEDCouplingFieldFloat.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingTimeDiscretization.hxx" @@ -47,18 +48,18 @@ template class MEDCoupling::MEDCouplingFieldT; * Creates a new MEDCouplingFieldDouble, of given spatial type and time discretization. * For more info, see \ref MEDCouplingFirstSteps3. * \param [in] type - the type of spatial discretization of the created field, one of - * (\ref MEDCoupling::ON_CELLS "ON_CELLS", + * (\ref MEDCoupling::ON_CELLS "ON_CELLS", * \ref MEDCoupling::ON_NODES "ON_NODES", - * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT", + * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT", * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE", * \ref MEDCoupling::ON_NODES_KR "ON_NODES_KR"). * \param [in] td - the type of time discretization of the created field, one of - * (\ref MEDCoupling::NO_TIME "NO_TIME", - * \ref MEDCoupling::ONE_TIME "ONE_TIME", - * \ref MEDCoupling::LINEAR_TIME "LINEAR_TIME", + * (\ref MEDCoupling::NO_TIME "NO_TIME", + * \ref MEDCoupling::ONE_TIME "ONE_TIME", + * \ref MEDCoupling::LINEAR_TIME "LINEAR_TIME", * \ref MEDCoupling::CONST_ON_TIME_INTERVAL "CONST_ON_TIME_INTERVAL"). * \return MEDCouplingFieldDouble* - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. + * caller is to delete this field using decrRef() as it is no more needed. */ MEDCouplingFieldDouble* MEDCouplingFieldDouble::New(TypeOfField type, TypeOfTimeDiscretization td) { @@ -67,7 +68,7 @@ MEDCouplingFieldDouble* MEDCouplingFieldDouble::New(TypeOfField type, TypeOfTime /*! * Creates a new MEDCouplingFieldDouble, of a given time discretization and with a - * spatial type and supporting mesh copied from a given + * spatial type and supporting mesh copied from a given * \ref MEDCouplingFieldTemplatesPage "field template". * For more info, see \ref MEDCouplingFirstSteps3. * \warning This method does not deeply copy neither the mesh nor the spatial @@ -76,12 +77,12 @@ MEDCouplingFieldDouble* MEDCouplingFieldDouble::New(TypeOfField type, TypeOfTime * \param [in] ft - the \ref MEDCouplingFieldTemplatesPage "field template" defining * the spatial discretization and the supporting mesh. * \param [in] td - the type of time discretization of the created field, one of - * (\ref MEDCoupling::NO_TIME "NO_TIME", - * \ref MEDCoupling::ONE_TIME "ONE_TIME", - * \ref MEDCoupling::LINEAR_TIME "LINEAR_TIME", + * (\ref MEDCoupling::NO_TIME "NO_TIME", + * \ref MEDCoupling::ONE_TIME "ONE_TIME", + * \ref MEDCoupling::LINEAR_TIME "LINEAR_TIME", * \ref MEDCoupling::CONST_ON_TIME_INTERVAL "CONST_ON_TIME_INTERVAL"). * \return MEDCouplingFieldDouble* - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. + * caller is to delete this field using decrRef() as it is no more needed. */ MEDCouplingFieldDouble *MEDCouplingFieldDouble::New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td) { @@ -104,7 +105,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::New(const MEDCouplingFieldTempla /*! * This method if possible the time information (time unit, time iteration, time unit and time value) with its support * that is to say its mesh. - * + * * \throw If \c this->_mesh is null an exception will be thrown. An exception will also be throw if the spatial discretization is * NO_TIME. */ @@ -121,11 +122,11 @@ void MEDCouplingFieldDouble::synchronizeTimeWithSupport() * - \ref MEDCouplingTemporalDisc "temporal discretization" data that holds array(s) * of field values, * - \ref MEDCouplingSpatialDisc "a spatial discretization". - * + * * \c clone(false) is rather dedicated for advanced users that want to limit the amount * of memory. It allows the user to perform methods like operator+(), operator*() * etc. with \a this and the returned field. If the user wants to duplicate deeply the - * underlying mesh he should call cloneWithMesh() method or deepCopy() instead. + * underlying mesh he should call cloneWithMesh() method or deepCopy() instead. * \warning The underlying \b mesh of the returned field is **always the same** * (pointer) as \a this one **whatever the value** of \a recDeepCpy parameter. * \param [in] recDeepCpy - if \c true, the copy of the underlying data arrays is @@ -161,15 +162,15 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::deepCopy() const * shares the data array(s) with \a this field, or holds a deep copy of it, depending on * \a deepCopy parameter. But the underlying \b mesh is always **shallow copied**. * \param [in] td - the type of time discretization of the created field, one of - * (\ref MEDCoupling::NO_TIME "NO_TIME", - * \ref MEDCoupling::ONE_TIME "ONE_TIME", - * \ref MEDCoupling::LINEAR_TIME "LINEAR_TIME", + * (\ref MEDCoupling::NO_TIME "NO_TIME", + * \ref MEDCoupling::ONE_TIME "ONE_TIME", + * \ref MEDCoupling::LINEAR_TIME "LINEAR_TIME", * \ref MEDCoupling::CONST_ON_TIME_INTERVAL "CONST_ON_TIME_INTERVAL"). * \param [in] deepCpy - if \c true, the copy of the underlying data arrays is * deep, else all data arrays of \a this field are shared by the new field. * \return MEDCouplingFieldDouble* - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. - * + * caller is to delete this field using decrRef() as it is no more needed. + * * \if ENABLE_EXAMPLES * \ref cpp_mcfielddouble_buildNewTimeReprFromThis "Here is a C++ example."
* \ref py_mcfielddouble_buildNewTimeReprFromThis "Here is a Python example." @@ -198,7 +199,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildNewTimeReprFromThis(TypeOfT * caller is to delete this field using decrRef() as it is no more needed. The returned field will share the same mesh object object than those in \a this. * \throw If \a this spatial discretization is empty or not ON_NODES. * \throw If \a this is not coherent (see MEDCouplingFieldDouble::checkConsistencyLight). - * + * * \warning This method is a \b non \b conservative method of remapping from node spatial discretization to cell spatial discretization. * If a conservative method of interpolation is required MEDCoupling::MEDCouplingRemapper class should be used instead with "P1P0" method. */ @@ -371,7 +372,7 @@ bool MEDCouplingFieldDouble::areCompatibleForMeld(const MEDCouplingFieldDouble * /*! * Permutes values of \a this field according to a given permutation array for node - * renumbering. The underlying mesh is deeply copied and its nodes are also permuted. + * renumbering. The underlying mesh is deeply copied and its nodes are also permuted. * The number of nodes can change, contrary to renumberCells(). * \param [in] old2NewBg - the permutation array in "Old to New" mode. Its length is * to be equal to \a this->getMesh()->getNumberOfNodes(). @@ -382,7 +383,7 @@ bool MEDCouplingFieldDouble::areCompatibleForMeld(const MEDCouplingFieldDouble * * \throw If \a check == \c true and \a old2NewBg contains equal ids. * \throw If mesh nature does not allow renumbering (e.g. structured mesh). * \throw If values at merged nodes differ more than \a eps. - * + * * \if ENABLE_EXAMPLES * \ref cpp_mcfielddouble_renumberNodes "Here is a C++ example".
* \ref py_mcfielddouble_renumberNodes "Here is a Python example". @@ -403,17 +404,17 @@ void MEDCouplingFieldDouble::renumberNodes(const mcIdType *old2NewBg, double eps /*! * Permutes values of \a this field according to a given permutation array for nodes - * renumbering. The underlying mesh is \b not permuted. + * renumbering. The underlying mesh is \b not permuted. * The number of nodes can change, contrary to renumberCells(). * A given epsilon specifies a threshold of error in case of two nodes are merged but * the difference of values on these nodes are higher than \a eps. * This method performs a part of job of renumberNodes(), excluding node renumbering * in mesh. The reasonable use of this * method is only for multi-field instances lying on the same mesh to avoid a - * systematic duplication and renumbering of _mesh attribute. + * systematic duplication and renumbering of _mesh attribute. * \warning Use this method with a lot of care! * \warning In case of an exception thrown, the contents of the data array can be - * partially modified until the exception occurs. + * partially modified until the exception occurs. * \param [in] old2NewBg - the permutation array in "Old to New" mode. Its length is * to be equal to \a this->getMesh()->getNumberOfNodes(). * \param [in] newNbOfNodes - a number of nodes in the mesh after renumbering. @@ -474,7 +475,10 @@ MEDCouplingFieldInt32 *MEDCouplingFieldDouble::convertToIntField() const { return ConvertToUField(this); } - +MEDCouplingFieldInt64 *MEDCouplingFieldDouble::convertToInt64Field() const +{ + return ConvertToUField(this); +} MEDCouplingFieldFloat *MEDCouplingFieldDouble::convertToFloatField() const { return ConvertToUField(this); @@ -516,7 +520,7 @@ double MEDCouplingFieldDouble::accumulate(int compId) const /*! * Accumulates values of each component of \a this array. - * \param [out] res - an array of length \a this->getNumberOfComponents(), allocated + * \param [out] res - an array of length \a this->getNumberOfComponents(), allocated * by the caller, that is filled by this method with sum value for each * component. * \throw If the data array is not set. @@ -686,7 +690,7 @@ double MEDCouplingFieldDouble::norm2() const /*! * Computes the weighted average of values of each component of \a this field, the weights being the - * values returned by buildMeasureField(). + * values returned by buildMeasureField(). * \param [out] res - pointer to an array of result sum values, of size at least \a * this->getNumberOfComponents(), that is to be allocated by the caller. * \param [in] isWAbs - if \c true (default), \c abs() is applied to the weights computed by @@ -986,7 +990,7 @@ void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double *res) con * \param [in] nbOfPoints - number of points of interest. * \return DataArrayDouble * - a new instance of DataArrayDouble holding field * values relating to the input points. This array is of size \a nbOfPoints - * tuples per \a this->getNumberOfComponents() components. The caller is to + * tuples per \a this->getNumberOfComponents() components. The caller is to * delete this array using decrRef() as it is no more needed. * \throw If the spatial discretization of \a this field is NULL. * \throw If the mesh is not set. @@ -1165,7 +1169,7 @@ void MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const std::string& f * a corresponding node coordinates array (where it is set via * DataArrayDouble::setInfoOnComponent()).
* For more info on supported expressions that can be used in the function, see \ref - * MEDCouplingArrayApplyFuncExpr.
+ * MEDCouplingArrayApplyFuncExpr.
* In a general case, a value resulting from the function evaluation is assigned to all * components of a field value. But there is a possibility to have its own expression for * each component within one function. For this purpose, there are predefined variable @@ -1415,7 +1419,7 @@ void MEDCouplingFieldDouble::applyFuncNamedCompo(int nbOfComp, const std::vector * MEDCouplingArrayApplyFuncExpr.
* The function can include **only one** arbitrary named variable * (e.g. "x","y" or "va44") to refer to a field atomic value.
- * In a general case, a value resulting from the function evaluation is assigned to + * In a general case, a value resulting from the function evaluation is assigned to * a single field value. But there is a possibility to have its own expression for * each component within one function. For this purpose, there are predefined variable * names (IVec, JVec, KVec, LVec etc) each dedicated to a certain component (IVec, to @@ -1477,10 +1481,10 @@ std::size_t MEDCouplingFieldDouble::getNumberOfComponents() const * Use MEDCouplingField::getNumberOfTuplesExpected instead of this method. This method will be removed soon, because it is * confusing compared to getNumberOfComponents() and getNumberOfValues() behaviour. * - * Returns number of tuples in \a this field, that depends on + * Returns number of tuples in \a this field, that depends on * - the number of entities in the underlying mesh * - \ref MEDCouplingSpatialDisc "spatial discretization" of \a this field (e.g. number - * of Gauss points if \a this->getTypeOfField() == + * of Gauss points if \a this->getTypeOfField() == * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"). * * The returned value does \b not \b depend on the number of tuples in the data array @@ -1557,7 +1561,7 @@ std::vector MEDCouplingFieldDouble::getDirectChildrenWi * \throw If the data array is not set. * \throw If the mesh is not set. * \throw If the spatial discretization of \a this field is NULL. - * \throw If \a this field if of type other than + * \throw If \a this field if of type other than * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" or * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE". */ @@ -1569,7 +1573,7 @@ double MEDCouplingFieldDouble::getIJK(mcIdType cellId, int nodeIdInCell, int com } /*! - * Sets the data array. + * Sets the data array. * \param [in] array - the data array holding values of \a this field. It's size * should correspond to the mesh and * \ref MEDCouplingSpatialDisc "spatial discretization" of \a this field @@ -1641,7 +1645,7 @@ void MEDCouplingFieldDouble::changeUnderlyingMesh(const MEDCouplingMesh *other, * Subtracts another field from \a this one in case when the two fields have different * supporting meshes. The subtraction is performed provided that the tho meshes can be * considered equal with use of specified equality criteria, else an exception is thrown. - * If the meshes match, the mesh of \a f is set to \a this field (\a this is permuted if + * If the meshes match, the mesh of \a f is set to \a this field (\a this is permuted if * necessary) and field values are subtracted. No interpolation is done here, only an * analysis of two underlying mesh is done to see if the meshes are geometrically * equivalent.
@@ -1842,7 +1846,7 @@ bool MEDCouplingFieldDouble::zipConnectivity(int compType, double epsOnVals) /*! * This method calls MEDCouplingUMesh::buildSlice3D method. So this method makes the assumption that underlying mesh exists. * For the moment, this method is implemented for fields on cells. - * + * * \return a newly allocated field double containing the result that the user should deallocate. */ MEDCouplingFieldDouble *MEDCouplingFieldDouble::extractSlice3D(const double *origin, const double *vec, double eps) const @@ -1880,12 +1884,12 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::extractSlice3D(const double *ori /*! * Divides every cell of the underlying mesh into simplices (triangles in 2D and * tetrahedra in 3D). If some cells are divided, the underlying mesh is replaced by a new - * mesh instance containing the simplices.
+ * mesh instance containing the simplices.
* \param [in] policy - specifies a pattern used for splitting. For its description, see * MEDCouplingUMesh::simplexize(). * \return bool - \c true if some cells have been divided and hence \a this field lies * on another mesh. - * \throw If \a policy has an invalid value. For valid values, see the description of + * \throw If \a policy has an invalid value. For valid values, see the description of * MEDCouplingUMesh::simplexize(). * \throw If MEDCouplingMesh::simplexize() is not applicable to the underlying mesh. * \throw If the mesh is not well defined. @@ -2045,7 +2049,7 @@ MCAuto MEDCouplingFieldDouble::convertQuadraticCellsToLi * Finally \a this is also expected to be consistent. * In these conditions this method returns a newly created field (to be dealed by the caller). * The returned field will also 3 compo vector field be on nodes lying on the same mesh than \a this. - * + * * For each 3 compo tuple \a tup in \a this the returned tuple is the result of the transformation of \a tup in the new referential. This referential is defined by \a Ur, \a Uteta, \a Uz. * \a Ur is the vector between \a center point and the associated node with \a tuple. \a Uz is \a vect normalized. And Uteta is the cross product of \a Uz with \a Ur. * @@ -2068,7 +2072,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::computeVectorFieldCyl(const doub * every tensor of \a this 6-componental field. * \return MEDCouplingFieldDouble * - the new instance of MEDCouplingFieldDouble, whose * each tuple is calculated from the tuple (t) of \a this field as - * follows: \f$ t[0]^2+t[1]^2+t[2]^2+2*t[3]^2+2*t[4]^2+2*t[5]^2\f$. + * follows: \f$ t[0]^2+t[1]^2+t[2]^2+2*t[3]^2+2*t[4]^2+2*t[5]^2\f$. * This new field lies on the same mesh as \a this one. The caller is to delete * this field using decrRef() as it is no more needed. * \throw If \a this->getNumberOfComponents() != 6. @@ -2089,10 +2093,10 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::doublyContractedProduct() const /*! * Creates a new MEDCouplingFieldDouble filled with the determinant of a square * matrix defined by every tuple of \a this field, having either 4, 6 or 9 components. - * The case of 6 components corresponds to that of the upper triangular matrix. + * The case of 6 components corresponds to that of the upper triangular matrix. * \return MEDCouplingFieldDouble * - the new instance of MEDCouplingFieldDouble, whose - * each tuple is the determinant of matrix of the corresponding tuple of \a this - * field. This new field lies on the same mesh as \a this one. The caller is to + * each tuple is the determinant of matrix of the corresponding tuple of \a this + * field. This new field lies on the same mesh as \a this one. The caller is to * delete this field using decrRef() as it is no more needed. * \throw If \a this->getNumberOfComponents() is not in [4,6,9]. * \throw If the spatial discretization of \a this field is NULL. @@ -2113,11 +2117,11 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::determinant() const /*! * Creates a new MEDCouplingFieldDouble with 3 components filled with 3 eigenvalues of * an upper triangular matrix defined by every tuple of \a this 6-componental field. - * \return MEDCouplingFieldDouble * - the new instance of MEDCouplingFieldDouble, + * \return MEDCouplingFieldDouble * - the new instance of MEDCouplingFieldDouble, * having 3 components, whose each tuple contains the eigenvalues of the matrix of * corresponding tuple of \a this field. This new field lies on the same mesh as * \a this one. The caller is to delete this field using decrRef() as it is no - * more needed. + * more needed. * \throw If \a this->getNumberOfComponents() != 6. * \throw If the spatial discretization of \a this field is NULL. */ @@ -2136,11 +2140,11 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::eigenValues() const /*! * Creates a new MEDCouplingFieldDouble with 9 components filled with 3 eigenvectors of * an upper triangular matrix defined by every tuple of \a this 6-componental field. - * \return MEDCouplingFieldDouble * - the new instance of MEDCouplingFieldDouble, + * \return MEDCouplingFieldDouble * - the new instance of MEDCouplingFieldDouble, * having 9 components, whose each tuple contains the eigenvectors of the matrix of * corresponding tuple of \a this field. This new field lies on the same mesh as * \a this one. The caller is to delete this field using decrRef() as it is no - * more needed. + * more needed. * \throw If \a this->getNumberOfComponents() != 6. * \throw If the spatial discretization of \a this field is NULL. */ @@ -2161,11 +2165,11 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::eigenVectors() const * a matrix defined by every tuple of \a this field having either 4, 6 or 9 * components. The case of 6 components corresponds to that of the upper triangular * matrix. - * \return MEDCouplingFieldDouble * - the new instance of MEDCouplingFieldDouble, + * \return MEDCouplingFieldDouble * - the new instance of MEDCouplingFieldDouble, * having the same number of components as \a this one, whose each tuple * contains the inverse matrix of the matrix of corresponding tuple of \a this * field. This new field lies on the same mesh as \a this one. The caller is to - * delete this field using decrRef() as it is no more needed. + * delete this field using decrRef() as it is no more needed. * \throw If \a this->getNumberOfComponents() is not in [4,6,9]. * \throw If the spatial discretization of \a this field is NULL. */ @@ -2186,11 +2190,11 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::inverse() const * a matrix defined by every tuple of \a this field having either 4, 6 or 9 * components. The case of 6 components corresponds to that of the upper triangular * matrix. - * \return MEDCouplingFieldDouble * - the new instance of MEDCouplingFieldDouble, + * \return MEDCouplingFieldDouble * - the new instance of MEDCouplingFieldDouble, * having 1 component, whose each tuple is the trace of the matrix of * corresponding tuple of \a this field. * This new field lies on the same mesh as \a this one. The caller is to - * delete this field using decrRef() as it is no more needed. + * delete this field using decrRef() as it is no more needed. * \throw If \a this->getNumberOfComponents() is not in [4,6,9]. * \throw If the spatial discretization of \a this field is NULL. */ @@ -2209,12 +2213,12 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::trace() const /*! * Creates a new MEDCouplingFieldDouble filled with the stress deviator tensor of * a stress tensor defined by every tuple of \a this 6-componental field. - * \return MEDCouplingFieldDouble * - the new instance of MEDCouplingFieldDouble, + * \return MEDCouplingFieldDouble * - the new instance of MEDCouplingFieldDouble, * having same number of components and tuples as \a this field, * whose each tuple contains the stress deviator tensor of the stress tensor of * corresponding tuple of \a this field. This new field lies on the same mesh as * \a this one. The caller is to delete this field using decrRef() as it is no - * more needed. + * more needed. * \throw If \a this->getNumberOfComponents() != 6. * \throw If the spatial discretization of \a this field is NULL. */ @@ -2233,11 +2237,11 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::deviator() const /*! * Creates a new MEDCouplingFieldDouble filled with the magnitude of * every vector of \a this field. - * \return MEDCouplingFieldDouble * - the new instance of MEDCouplingFieldDouble, + * \return MEDCouplingFieldDouble * - the new instance of MEDCouplingFieldDouble, * having one component, whose each tuple is the magnitude of the vector * of corresponding tuple of \a this field. This new field lies on the * same mesh as \a this one. The caller is to - * delete this field using decrRef() as it is no more needed. + * delete this field using decrRef() as it is no more needed. * \throw If the spatial discretization of \a this field is NULL. */ MEDCouplingFieldDouble *MEDCouplingFieldDouble::magnitude() const @@ -2257,7 +2261,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::magnitude() const * values of every tuple of \a this field. * \return MEDCouplingFieldDouble * - the new instance of MEDCouplingFieldDouble. * This new field lies on the same mesh as \a this one. The caller is to - * delete this field using decrRef() as it is no more needed. + * delete this field using decrRef() as it is no more needed. * \throw If the spatial discretization of \a this field is NULL. */ MEDCouplingFieldDouble *MEDCouplingFieldDouble::maxPerTuple() const @@ -2278,8 +2282,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::maxPerTuple() const * Changes number of components in \a this field. If \a newNbOfComp is less * than \a this->getNumberOfComponents() then each tuple * is truncated to have \a newNbOfComp components, keeping first components. If \a - * newNbOfComp is more than \a this->getNumberOfComponents() then - * each tuple is populated with \a dftValue to have \a newNbOfComp components. + * newNbOfComp is more than \a this->getNumberOfComponents() then + * each tuple is populated with \a dftValue to have \a newNbOfComp components. * \param [in] newNbOfComp - number of components for the new field to have. * \param [in] dftValue - value assigned to new values added to \a this field. * \throw If \a this is not allocated. @@ -2298,7 +2302,7 @@ void MEDCouplingFieldDouble::changeNbOfComponents(std::size_t newNbOfComp, doubl * into the new field. * \return MEDCouplingFieldDouble * - the new instance of MEDCouplingFieldDouble that the caller * is to delete using decrRef() as it is no more needed. - * \throw If a component index (\a i) is not valid: + * \throw If a component index (\a i) is not valid: * \a i < 0 || \a i >= \a this->getNumberOfComponents(). */ MEDCouplingFieldDouble *MEDCouplingFieldDouble::keepSelectedComponents(const std::vector& compoIds) const @@ -2347,7 +2351,7 @@ void MEDCouplingFieldDouble::sortPerTuple(bool asc) * \param [in] f1 - the first field. * \param [in] f2 - the second field. * \return MEDCouplingFieldDouble * - the result field. It is a new instance of - * MEDCouplingFieldDouble. The caller is to delete this mesh using decrRef() + * MEDCouplingFieldDouble. The caller is to delete this mesh using decrRef() * as it is no more needed. * \throw If the fields are not compatible for the merge. * \throw If the spatial discretization of \a f1 is NULL. @@ -2369,12 +2373,12 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const MEDCouplingFie * Creates a new MEDCouplingFieldDouble by concatenating all given fields. * Values of the *i*-th field precede values of the (*i*+1)-th field within the result. * If there is only one field in \a a, a deepCopy() (except time information of mesh and - * field) of the field is returned. + * field) of the field is returned. * Generally speaking the first field in \a a is used to assign tiny attributes of the - * returned field. + * returned field. * \param [in] a - a vector of fields (MEDCouplingFieldDouble) to concatenate. * \return MEDCouplingFieldDouble * - the result field. It is a new instance of - * MEDCouplingFieldDouble. The caller is to delete this mesh using decrRef() + * MEDCouplingFieldDouble. The caller is to delete this mesh using decrRef() * as it is no more needed. * \throw If \a a is empty. * \throw If the fields are not compatible for the merge. @@ -2456,9 +2460,9 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::MeldFields(const MEDCouplingFiel } /*! - * Returns a new MEDCouplingFieldDouble containing a dot product of two given fields, + * Returns a new MEDCouplingFieldDouble containing a dot product of two given fields, * so that the i-th tuple of the result field is a sum of products of j-th components of - * i-th tuples of given fields (\f$ f_i = \sum_{j=1}^n f1_j * f2_j \f$). + * i-th tuples of given fields (\f$ f_i = \sum_{j=1}^n f1_j * f2_j \f$). * Number of tuples and components in the given fields must be the same. * \param [in] f1 - a given field. * \param [in] f2 - another given field. @@ -2483,7 +2487,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::DotFields(const MEDCouplingField } /*! - * Returns a new MEDCouplingFieldDouble containing a cross product of two given fields, + * Returns a new MEDCouplingFieldDouble containing a cross product of two given fields, * so that * the i-th tuple of the result field is a 3D vector which is a cross * product of two vectors defined by the i-th tuples of given fields. @@ -2576,9 +2580,9 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::MinFields(const MEDCouplingField /*! * Returns a copy of \a this field in which sign of all values is reversed. * \return MEDCouplingFieldDouble * - the new instance of MEDCouplingFieldDouble - * containing the same number of tuples and components as \a this field. + * containing the same number of tuples and components as \a this field. * The caller is to delete this result field using decrRef() as it is no more - * needed. + * needed. * \throw If the spatial discretization of \a this field is NULL. * \throw If a data array is not allocated. */ @@ -2803,7 +2807,7 @@ const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator/=(const MEDCoupli /*! * Directly called by MEDCouplingFieldDouble::operator^. - * + * * \sa MEDCouplingFieldDouble::operator^ */ MEDCouplingFieldDouble *MEDCouplingFieldDouble::PowFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) @@ -2821,7 +2825,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::PowFields(const MEDCouplingField /*! * Directly call MEDCouplingFieldDouble::PowFields static method. - * + * * \sa MEDCouplingFieldDouble::PowFields */ MEDCouplingFieldDouble *MEDCouplingFieldDouble::operator^(const MEDCouplingFieldDouble& other) const diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.hxx b/src/MEDCoupling/MEDCouplingFieldDouble.hxx index 684dd4bfe..e7d4afbbc 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.hxx @@ -50,6 +50,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT MEDCouplingFieldDouble *nodeToCellDiscretization() const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *cellToNodeDiscretization() const; MEDCOUPLING_EXPORT MEDCouplingFieldInt32 *convertToIntField() const; + MEDCOUPLING_EXPORT MEDCouplingFieldInt64 *convertToInt64Field() const; MEDCOUPLING_EXPORT MEDCouplingFieldFloat *convertToFloatField() const; MEDCOUPLING_EXPORT double getIJK(mcIdType cellId, int nodeIdInCell, int compoId) const; MEDCOUPLING_EXPORT double accumulate(int compId) const; diff --git a/src/MEDCoupling/MEDCouplingFieldFloat.cxx b/src/MEDCoupling/MEDCouplingFieldFloat.cxx index e1ad96970..989897eb2 100644 --- a/src/MEDCoupling/MEDCouplingFieldFloat.cxx +++ b/src/MEDCoupling/MEDCouplingFieldFloat.cxx @@ -21,6 +21,8 @@ #include "MEDCouplingFieldFloat.hxx" #include "MEDCouplingFieldT.txx" #include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingFieldInt.hxx" +#include "MEDCouplingFieldInt64.hxx" #include "MEDCouplingFieldTemplate.hxx" #include "MEDCouplingMesh.hxx" #include "MEDCouplingMemArray.txx" @@ -68,17 +70,33 @@ MEDCouplingFieldFloat *MEDCouplingFieldFloat::clone(bool recDeepCpy) const return new MEDCouplingFieldFloat(*this,recDeepCpy); } -MEDCouplingFieldDouble *MEDCouplingFieldFloat::convertToDblField() const +template +typename Traits::FieldType *ConvertToUField(const MEDCouplingFieldFloat *self) { - MCAuto tmp(MEDCouplingFieldTemplate::New(*this)); + MCAuto tmp(MEDCouplingFieldTemplate::New(*self)); int t1,t2; - double t0(getTime(t1,t2)); - MCAuto ret(MEDCouplingFieldDouble::New(*tmp,getTimeDiscretization())); + double t0(self->getTime(t1,t2)); + MCAuto::FieldType> ret(Traits::FieldType::New(*tmp,self->getTimeDiscretization())); ret->setTime(t0,t1,t2); - if(getArray()) + if(self->getArray()) { - MCAuto arr(getArray()->convertToDblArr()); + MCAuto::ArrayType> arr(self->getArray()->convertToOtherTypeOfArr()); ret->setArray(arr); } return ret.retn(); } + +MEDCouplingFieldDouble * MEDCouplingFieldFloat::convertToDblField() const +{ + return ConvertToUField(this); +} + +MEDCouplingFieldInt32 * MEDCouplingFieldFloat::convertToIntField() const +{ + return ConvertToUField(this); +} + +MEDCouplingFieldInt64 * MEDCouplingFieldFloat::convertToInt64Field() const +{ + return ConvertToUField(this); +} diff --git a/src/MEDCoupling/MEDCouplingFieldFloat.hxx b/src/MEDCoupling/MEDCouplingFieldFloat.hxx index 4352ca252..280317c02 100644 --- a/src/MEDCoupling/MEDCouplingFieldFloat.hxx +++ b/src/MEDCoupling/MEDCouplingFieldFloat.hxx @@ -31,7 +31,7 @@ namespace MEDCoupling { class MEDCouplingFieldDouble; class MEDCouplingFieldTemplate; - + class MEDCouplingFieldFloat : public MEDCouplingFieldT { public: @@ -40,6 +40,8 @@ namespace MEDCoupling MEDCOUPLING_EXPORT MEDCouplingFieldFloat *deepCopy() const; MEDCOUPLING_EXPORT MEDCouplingFieldFloat *clone(bool recDeepCpy) const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *convertToDblField() const; + MEDCOUPLING_EXPORT MEDCouplingFieldInt32 *convertToIntField() const; + MEDCOUPLING_EXPORT MEDCouplingFieldInt64 *convertToInt64Field() const; MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingFieldFloat"); } protected: MEDCouplingFieldFloat(TypeOfField type, TypeOfTimeDiscretization td); diff --git a/src/MEDCoupling/MEDCouplingFieldInt32.cxx b/src/MEDCoupling/MEDCouplingFieldInt32.cxx index 72141f9ea..d07a5c36b 100644 --- a/src/MEDCoupling/MEDCouplingFieldInt32.cxx +++ b/src/MEDCoupling/MEDCouplingFieldInt32.cxx @@ -19,8 +19,10 @@ // Author : Yann Pora (EDF R&D) #include "MEDCouplingFieldInt32.hxx" +#include "MEDCouplingFieldInt64.hxx" #include "MEDCouplingFieldT.txx" #include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingFieldFloat.hxx" #include "MEDCouplingFieldTemplate.hxx" #include "MEDCouplingMesh.hxx" #include "MEDCouplingMemArray.txx" @@ -68,17 +70,33 @@ MEDCouplingFieldInt32 *MEDCouplingFieldInt32::clone(bool recDeepCpy) const return new MEDCouplingFieldInt32(*this,recDeepCpy); } -MEDCouplingFieldDouble *MEDCouplingFieldInt32::convertToDblField() const +template +typename Traits::FieldType *ConvertToUField(const MEDCouplingFieldInt32 *self) { - MCAuto tmp(MEDCouplingFieldTemplate::New(*this)); + MCAuto tmp(MEDCouplingFieldTemplate::New(*self)); int t1,t2; - double t0(getTime(t1,t2)); - MCAuto ret(MEDCouplingFieldDouble::New(*tmp,getTimeDiscretization())); + double t0(self->getTime(t1,t2)); + MCAuto::FieldType > ret(Traits::FieldType::New(*tmp,self->getTimeDiscretization())); ret->setTime(t0,t1,t2); - if(getArray()) + if(self->getArray()) { - MCAuto arr(getArray()->convertToDblArr()); + MCAuto::ArrayType> arr(self->getArray()->convertToOtherTypeOfArr()); ret->setArray(arr); } return ret.retn(); } + +MEDCouplingFieldDouble *MEDCouplingFieldInt32::convertToDblField() const +{ + return ConvertToUField(this); +} + +MEDCouplingFieldInt64 *MEDCouplingFieldInt32::convertToInt64Field() const +{ + return ConvertToUField(this); +} + +MEDCouplingFieldFloat *MEDCouplingFieldInt32::convertToFloatField() const +{ + return ConvertToUField(this); +} \ No newline at end of file diff --git a/src/MEDCoupling/MEDCouplingFieldInt32.hxx b/src/MEDCoupling/MEDCouplingFieldInt32.hxx index 4ce6e7821..7e5bac54a 100644 --- a/src/MEDCoupling/MEDCouplingFieldInt32.hxx +++ b/src/MEDCoupling/MEDCouplingFieldInt32.hxx @@ -30,7 +30,7 @@ namespace MEDCoupling { class MEDCouplingFieldDouble; class MEDCouplingFieldTemplate; - + class MEDCouplingFieldInt32 : public MEDCouplingFieldT { public: @@ -39,6 +39,8 @@ namespace MEDCoupling MEDCOUPLING_EXPORT MEDCouplingFieldInt32 *deepCopy() const; MEDCOUPLING_EXPORT MEDCouplingFieldInt32 *clone(bool recDeepCpy) const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *convertToDblField() const; + MEDCOUPLING_EXPORT MEDCouplingFieldFloat *convertToFloatField() const; + MEDCOUPLING_EXPORT MEDCouplingFieldInt64 *convertToInt64Field() const; MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingFieldInt32"); } protected: MEDCouplingFieldInt32(TypeOfField type, TypeOfTimeDiscretization td); diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index 74d08f0d9..4850b9653 100755 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -45,7 +45,7 @@ namespace MEDCoupling // -- WARNING this enum must be synchronized with MEDCouplingCommon.i file ! -- class PartDefinition; - + template class MEDCouplingPointer { @@ -338,6 +338,7 @@ namespace MEDCoupling public: MCAuto convertToDblArr() const; MCAuto convertToIntArr() const; + MCAuto convertToInt64Arr() const; MCAuto convertToFloatArr() const; void applyLin(T a, T b, std::size_t compoId); void applyLin(T a, T b); @@ -386,7 +387,7 @@ namespace MEDCoupling template void somethingEqual(const typename Traits::ArrayType *other); }; - + template class DataArrayTemplateFP : public DataArrayTemplateClassic { @@ -700,7 +701,7 @@ namespace MEDCoupling protected: ~DataArrayDiscrete() { } }; - + template class DataArrayDiscreteSigned : public DataArrayDiscrete { @@ -831,7 +832,7 @@ namespace MEDCoupling DataArrayChar *buildEmptySpecializedDAChar() const; DataArrayByteIterator *iterator(); DataArrayByte *deepCopy() const; - DataArrayByte *copySorted(bool asc=true) const override { return this->copySortedImpl(asc); } + DataArrayByte *copySorted(bool asc=true) const override { return this->copySortedImpl(asc); } DataArrayByte *performCopyOrIncrRef(bool deepCopy) const; DataArrayByte *buildNewEmptyInstance() const { return DataArrayByte::New(); } char byteValue() const; @@ -948,7 +949,7 @@ namespace MEDCoupling float floatValue() const; DataArrayFloat *buildDAFloat(std::size_t nbOfTuples, std::size_t nbOfCompo) const; }; - + class MEDCOUPLING_EXPORT DataArrayInt32Iterator : public DataArrayIterator { public: @@ -1013,7 +1014,7 @@ namespace MEDCoupling char *_pt; std::size_t _nb_of_compo; }; - + class DataArrayByteTuple; class MEDCOUPLING_EXPORT DataArrayByteIterator diff --git a/src/MEDCoupling/MEDCouplingMemArray.txx b/src/MEDCoupling/MEDCouplingMemArray.txx index 1e8fb79f6..750620d9a 100755 --- a/src/MEDCoupling/MEDCouplingMemArray.txx +++ b/src/MEDCoupling/MEDCouplingMemArray.txx @@ -379,10 +379,10 @@ namespace MEDCoupling /*! * This method performs systematically an allocation of \a newNbOfElements elements in \a this. * \a _nb_of_elem and \a _nb_of_elem_alloc will \b NOT be systematically equal (contrary to MemArray::reAlloc method. - * So after the call of this method \a _nb_of_elem will be equal tostd::min(_nb_of_elem,newNbOfElements) and \a _nb_of_elem_alloc equal to + * So after the call of this method \a _nb_of_elem will be equal tostd::min(_nb_of_elem,newNbOfElements) and \a _nb_of_elem_alloc equal to * \a newNbOfElements. This method is typically used to perform a pushBack to avoid systematic allocations-copy-deallocation. * So after the call of this method the accessible content is perfectly set. - * + * * So this method should not be confused with MemArray::reserve that is close to MemArray::reAlloc but not same. */ template @@ -406,7 +406,7 @@ namespace MEDCoupling * This method performs systematically an allocation of \a newNbOfElements elements in \a this. * \a _nb_of_elem and \a _nb_of_elem_alloc will be equal even if only std::min(_nb_of_elem,newNbOfElements) come from the . * The remaining part of the new allocated chunk are available but not set previously ! - * + * * So this method should not be confused with MemArray::reserve that is close to MemArray::reAlloc but not same. */ template @@ -506,7 +506,7 @@ namespace MEDCoupling } } } - + template DataArrayIterator::~DataArrayIterator() { @@ -534,7 +534,7 @@ namespace MEDCoupling DataArrayTuple::DataArrayTuple(T *pt, std::size_t nbOfComp):_pt(pt),_nb_of_compo(nbOfComp) { } - + template T DataArrayTuple::zeValue() const { @@ -542,7 +542,7 @@ namespace MEDCoupling return *_pt; throw INTERP_KERNEL::Exception("DataArrayTuple::zeValue : DataArrayTuple instance has not exactly 1 component -> Not possible to convert it into a single value !"); } - + template typename Traits::ArrayType *DataArrayTuple::buildDA(std::size_t nbOfTuples, std::size_t nbOfCompo) const { @@ -559,7 +559,7 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception(oss.str().c_str()); } } - + ////////////////////////////////// /*! @@ -686,7 +686,7 @@ namespace MEDCoupling std::copy(arrBegin,arrEnd,ret->getPointer()); return ret; } - + template std::vector< MCAuto< typename Traits::ArrayTypeCh > > DataArrayTemplate::explodeComponents() const { @@ -710,7 +710,7 @@ namespace MEDCoupling } return ret; } - + template std::size_t DataArrayTemplate::getHeapMemorySizeWithoutChildren() const { @@ -718,7 +718,7 @@ namespace MEDCoupling sz*=sizeof(T); return DataArray::getHeapMemorySizeWithoutChildren()+sz; } - + /*! * Allocates the raw data in memory. If the memory was already allocated, then it is * freed and re-allocated. See an example of this method use @@ -737,7 +737,7 @@ namespace MEDCoupling /*! * Sets a C array to be used as raw data of \a this. The previously set info - * of components is retained and re-sized. + * of components is retained and re-sized. * For more info see \ref MEDCouplingArraySteps1. * \param [in] array - the C array to be used as raw data of \a this. * \param [in] ownership - if \a true, \a array will be deallocated at destruction of \a this. @@ -754,7 +754,7 @@ namespace MEDCoupling _mem.useArray(array,ownership,type,nbOfTuple*nbOfCompo); declareAsNew(); } - + template void DataArrayTemplate::useExternalArrayWithRWAccess(const T *array, std::size_t nbOfTuple, std::size_t nbOfCompo) { @@ -813,7 +813,7 @@ namespace MEDCoupling { return getConstPointer()!=0; } - + /*! * Checks if raw data is allocated and throws an exception if it is not the case. * \throw If the raw data is not allocated. @@ -827,7 +827,7 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception(oss.str().c_str()); } } - + /*! * This method deallocated \a this without modification of information relative to the components. * After call of this method, DataArrayDouble::isAllocated will return false. @@ -844,7 +844,7 @@ namespace MEDCoupling * If \a this has already been allocated, this method checks that \a this has only one component. If not an INTERP_KERNEL::Exception will be thrown. * If \a this has not already been allocated, number of components is set to one. * This method allows to reduce number of reallocations on invocation of DataArrayDouble::pushBackSilent and DataArrayDouble::pushBackValsSilent on \a this. - * + * * \sa DataArrayDouble::pack, DataArrayDouble::pushBackSilent, DataArrayDouble::pushBackValsSilent */ template @@ -866,7 +866,7 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception(oss.str().c_str()); } } - + /*! * This method adds at the end of \a this the single value \a val. This method do \b not update its time label to avoid useless incrementation * of counter. So the caller is expected to call TimeLabel::declareAsNew on \a this at the end of the push session. @@ -892,7 +892,7 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception(oss.str().c_str()); } } - + /*! * This method adds at the end of \a this a series of values [\c valsBg,\c valsEnd). This method do \b not update its time label to avoid useless incrementation * of counter. So the caller is expected to call TimeLabel::declareAsNew on \a this at the end of the push session. @@ -920,7 +920,7 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception(oss.str().c_str()); } } - + /*! * This method returns silently ( without updating time label in \a this ) the last value, if any and suppress it. * \throw If \a this is already empty. @@ -937,7 +937,7 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception(oss.str().c_str()); } } - + /*! * Allocates the raw data in memory. If exactly same memory as needed already * allocated, it is not re-allocated. @@ -1020,7 +1020,7 @@ namespace MEDCoupling /*! * Changes number of tuples in the array. If the new number of tuples is smaller * than the current number the array is truncated, otherwise the array is extended. - * \param [in] nbOfTuples - new number of tuples. + * \param [in] nbOfTuples - new number of tuples. * \throw If \a this is not allocated. * \throw If \a nbOfTuples is negative. */ @@ -1100,7 +1100,7 @@ namespace MEDCoupling /*! * Sorts values of the array. \b Warning, this method is not const, it alterates \a this content. - * + * * \param [in] asc - \a true means ascending order, \a false, descending. * \throw If \a this is not allocated. * \throw If \a this->getNumberOfComponents() != 1. @@ -1122,7 +1122,7 @@ namespace MEDCoupling /*! * Sorts values of the array and put the result in a newly allocated returned array. * This method does not alterate \a this content. - * + * * \param [in] asc - \a true means ascending order, \a false, descending. * \throw If \a this is not allocated. * \throw If \a this->getNumberOfComponents() != 1. @@ -1199,7 +1199,7 @@ namespace MEDCoupling * Returns a shorten and permuted copy of \a this array. The new DataArrayDouble is * of size \a newNbOfTuple and it's values are permuted as required by \a old2New array. * The values are permuted so that \c new[ \a old2New[ i ]] = \c old[ i ] for all - * \a old2New[ i ] >= 0. In other words every i-th tuple in \a this array, for which + * \a old2New[ i ] >= 0. In other words every i-th tuple in \a this array, for which * \a old2New[ i ] is negative, is missing from the result array. * For more info on renumbering see \ref numbering. * \param [in] old2New - C array of length equal to \a this->getNumberOfTuples() @@ -1299,11 +1299,11 @@ namespace MEDCoupling MCAuto arr(dpd->toDAI()); MCAuto ret2(selectByTupleIdSafe(arr->begin(),arr->end())); return DynamicCastSafe::ArrayTypeCh>(ret2); - + } throw INTERP_KERNEL::Exception("DataArrayTemplate::selectPartDef : unrecognized part def !"); } - + /*! * Returns a shorten and permuted copy of \a this array. The new DataArrayDouble is * of size \a new2OldEnd - \a new2OldBg and it's values are permuted as required by @@ -1386,7 +1386,7 @@ namespace MEDCoupling /*! * Changes the number of components within \a this array to be equal to its number - * of tuples, and inversely its number of tuples to become equal to its number of + * of tuples, and inversely its number of tuples to become equal to its number of * components. So that its raw data **does not** change, instead splitting this * data into tuples changes. * \warning This method erases all (name and unit) component info set before! @@ -1407,7 +1407,7 @@ namespace MEDCoupling * is truncated to have \a newNbOfComp components, keeping first components. If \a * newNbOfComp is more than \a this->getNumberOfComponents() then the result array is * expanded as each tuple is populated with \a dftValue to have \a newNbOfComp - * components. + * components. * \param [in] newNbOfComp - number of components for the new array to have. * \param [in] dftValue - value assigned to new values added to the new array. * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller @@ -1451,7 +1451,7 @@ namespace MEDCoupling * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller * is to delete using decrRef() as it is no more needed. * \throw If \a this is not allocated. - * \throw If a component index (\a i) is not valid: + * \throw If a component index (\a i) is not valid: * \a i < 0 || \a i >= \a this->getNumberOfComponents(). * * \if ENABLE_EXAMPLES @@ -1565,7 +1565,7 @@ namespace MEDCoupling ret->copyStringInfoFrom(*this); return ret.retn(); } - + /*! * Copy all values from another DataArrayDouble into specified tuples and components * of \a this array. Textual data is not copied. @@ -1580,13 +1580,13 @@ namespace MEDCoupling * \param [in] endComp - index of the component before which the components to assign * to are located. * \param [in] stepComp - index increment to get index of the next component to assign to. - * \param [in] strictCompoCompare - if \a true (by default), then \a a->getNumberOfComponents() + * \param [in] strictCompoCompare - if \a true (by default), then \a a->getNumberOfComponents() * must be equal to the number of columns to assign to, else an * exception is thrown; if \a false, then it is only required that \a * a->getNbOfElems() equals to number of values to assign to (this condition - * must be respected even if \a strictCompoCompare is \a true). The number of + * must be respected even if \a strictCompoCompare is \a true). The number of * values to assign to is given by following Python expression: - * \a nbTargetValues = + * \a nbTargetValues = * \c len(\c range(\a bgTuples,\a endTuples,\a stepTuples)) * * \c len(\c range(\a bgComp,\a endComp,\a stepComp)). * \throw If \a a is NULL. @@ -1648,7 +1648,7 @@ namespace MEDCoupling } } } - + /*! * Assign a given value to values at specified tuples and components of \a this array. * The tree parameters defining set of indices of tuples and components are similar to @@ -1687,14 +1687,14 @@ namespace MEDCoupling for(mcIdType j=0;jgetNbOfElems() equals to number of values to assign to, then every value - * of \a a is assigned to its own location within \a this array. + * of \a a is assigned to its own location within \a this array. * - If \a a includes one tuple, then all values of \a a are assigned to the specified * components of every specified tuple of \a this array. In this mode it is required * that \a a->getNumberOfComponents() equals to the number of specified components. @@ -1703,16 +1703,16 @@ namespace MEDCoupling * \param [in] bgTuples - pointer to an array of tuple indices of \a this array to * assign values of \a a to. * \param [in] endTuples - specifies the end of the array \a bgTuples, so that - * pointer to a tuple index (pi) varies as this: + * pointer to a tuple index (pi) varies as this: * \a bgTuples <= \a pi < \a endTuples. * \param [in] bgComp - pointer to an array of component indices of \a this array to * assign values of \a a to. * \param [in] endComp - specifies the end of the array \a bgTuples, so that - * pointer to a component index (pi) varies as this: + * pointer to a component index (pi) varies as this: * \a bgComp <= \a pi < \a endComp. * \param [in] strictCompoCompare - this parameter is checked only if the - * *mode of usage* is the first; if it is \a true (default), - * then \a a->getNumberOfComponents() must be equal + * *mode of usage* is the first; if it is \a true (default), + * then \a a->getNumberOfComponents() must be equal * to the number of specified columns, else this is not required. * \throw If \a a is NULL. * \throw If \a a is not allocated. @@ -1756,12 +1756,12 @@ namespace MEDCoupling T *pt(getPointer()); const T *srcPt(a->getConstPointer()); if(assignTech) - { + { for(const mcIdType *w=bgTuples;w!=endTuples;w++) { DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id"); for(const mcIdType *z=bgComp;z!=endComp;z++,srcPt++) - { + { pt[(std::size_t)(*w)*nbComp+(*z)]=*srcPt; } } @@ -1773,13 +1773,13 @@ namespace MEDCoupling const T *srcPt2=srcPt; DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id"); for(const mcIdType *z=bgComp;z!=endComp;z++,srcPt2++) - { + { pt[(std::size_t)(*w)*nbComp+(*z)]=*srcPt2; } } } } - + /*! * Assign a given value to values at specified tuples and components of \a this array. * The tuples and components to assign to are defined by C arrays of indices. @@ -1787,12 +1787,12 @@ namespace MEDCoupling * \param [in] bgTuples - pointer to an array of tuple indices of \a this array to * assign \a a to. * \param [in] endTuples - specifies the end of the array \a bgTuples, so that - * pointer to a tuple index (\a pi) varies as this: + * pointer to a tuple index (\a pi) varies as this: * \a bgTuples <= \a pi < \a endTuples. * \param [in] bgComp - pointer to an array of component indices of \a this array to * assign \a a to. * \param [in] endComp - specifies the end of the array \a bgTuples, so that - * pointer to a component index (\a pi) varies as this: + * pointer to a component index (\a pi) varies as this: * \a bgComp <= \a pi < \a endComp. * \throw If \a this is not allocated. * \throw If any index of tuple/component given by bgTuples / bgComp is @@ -1818,16 +1818,16 @@ namespace MEDCoupling pt[(std::size_t)(*w)*nbComp+(*z)]=a; } } - + /*! - * Copy all values from another DataArrayDouble (\a a) into specified tuples and + * Copy all values from another DataArrayDouble (\a a) into specified tuples and * components of \a this array. Textual data is not copied. * The tuples to assign to are defined by a C array of indices. * The components to assign to are defined by three values similar to parameters of * the Python function \c range(\c start,\c stop,\c step). * There are two *modes of usage*: * - If \a a->getNbOfElems() equals to number of values to assign to, then every value - * of \a a is assigned to its own location within \a this array. + * of \a a is assigned to its own location within \a this array. * - If \a a includes one tuple, then all values of \a a are assigned to the specified * components of every specified tuple of \a this array. In this mode it is required * that \a a->getNumberOfComponents() equals to the number of specified components. @@ -1836,20 +1836,20 @@ namespace MEDCoupling * \param [in] bgTuples - pointer to an array of tuple indices of \a this array to * assign values of \a a to. * \param [in] endTuples - specifies the end of the array \a bgTuples, so that - * pointer to a tuple index (pi) varies as this: + * pointer to a tuple index (pi) varies as this: * \a bgTuples <= \a pi < \a endTuples. * \param [in] bgComp - index of the first component of \a this array to assign to. * \param [in] endComp - index of the component before which the components to assign * to are located. * \param [in] stepComp - index increment to get index of the next component to assign to. * \param [in] strictCompoCompare - this parameter is checked only in the first - * *mode of usage*; if \a strictCompoCompare is \a true (default), - * then \a a->getNumberOfComponents() must be equal + * *mode of usage*; if \a strictCompoCompare is \a true (default), + * then \a a->getNumberOfComponents() must be equal * to the number of specified columns, else this is not required. * \throw If \a a is NULL. * \throw If \a a is not allocated. * \throw If \a this is not allocated. - * \throw If any index of tuple given by \a bgTuples is out of a valid range for + * \throw If any index of tuple given by \a bgTuples is out of a valid range for * \a this array. * \throw In the first *mode of usage*, if strictCompoCompare == true and * if a->getNumberOfComponents() is unequal to the number of components @@ -1913,7 +1913,7 @@ namespace MEDCoupling } } } - + /*! * Assign a given value to values at specified tuples and components of \a this array. * The tuples to assign to are defined by a C array of indices. @@ -1923,14 +1923,14 @@ namespace MEDCoupling * \param [in] bgTuples - pointer to an array of tuple indices of \a this array to * assign \a a to. * \param [in] endTuples - specifies the end of the array \a bgTuples, so that - * pointer to a tuple index (pi) varies as this: + * pointer to a tuple index (pi) varies as this: * \a bgTuples <= \a pi < \a endTuples. * \param [in] bgComp - index of the first component of \a this array to assign to. * \param [in] endComp - index of the component before which the components to assign * to are located. * \param [in] stepComp - index increment to get index of the next component to assign to. * \throw If \a this is not allocated. - * \throw If any index of tuple given by \a bgTuples is out of a valid range for + * \throw If any index of tuple given by \a bgTuples is out of a valid range for * \a this array. * \throw If parameters specifying components to assign to, do not give a * non-empty range of increasing indices or indices are out of a valid range @@ -1971,15 +1971,15 @@ namespace MEDCoupling * \param [in] bgComp - pointer to an array of component indices of \a this array to * assign \a a to. * \param [in] endComp - specifies the end of the array \a bgTuples, so that - * pointer to a component index (\a pi) varies as this: + * pointer to a component index (\a pi) varies as this: * \a bgComp <= \a pi < \a endComp. - * \param [in] strictCompoCompare - if \a true (by default), then \a a->getNumberOfComponents() + * \param [in] strictCompoCompare - if \a true (by default), then \a a->getNumberOfComponents() * must be equal to the number of columns to assign to, else an * exception is thrown; if \a false, then it is only required that \a * a->getNbOfElems() equals to number of values to assign to (this condition - * must be respected even if \a strictCompoCompare is \a true). The number of + * must be respected even if \a strictCompoCompare is \a true). The number of * values to assign to is given by following Python expression: - * \a nbTargetValues = + * \a nbTargetValues = * \c len(\c range(\a bgTuples,\a endTuples,\a stepTuples)) * * \c len(\c range(\a bgComp,\a endComp,\a stepComp)). * \throw If \a a is NULL. @@ -2052,7 +2052,7 @@ namespace MEDCoupling for(const mcIdType *z=bgComp;z!=endComp;z++) pt[*z]=a; } - + /*! * Copy some tuples from another DataArrayDouble into specified tuples * of \a this array. Textual data is not copied. Both arrays must have equal number of @@ -2071,7 +2071,7 @@ namespace MEDCoupling * \throw If \a tuplesSelec is not allocated. * \throw If this->getNumberOfComponents() != a->getNumberOfComponents(). * \throw If \a tuplesSelec->getNumberOfComponents() != 2. - * \throw If any tuple index given by \a tuplesSelec is out of a valid range for + * \throw If any tuple index given by \a tuplesSelec is out of a valid range for * the corresponding (\a this or \a a) array. */ template @@ -2112,7 +2112,7 @@ namespace MEDCoupling } } } - + /*! * Copy some tuples from another DataArrayDouble (\a aBase) into contiguous tuples * of \a this array. Textual data is not copied. Both arrays must have equal number of @@ -2133,7 +2133,7 @@ namespace MEDCoupling * \throw If this->getNumberOfComponents() != aBase->getNumberOfComponents(). * \throw If \a tuplesSelec->getNumberOfComponents() != 1. * \throw If tupleIdStart + tuplesSelec->getNumberOfTuples() > this->getNumberOfTuples(). - * \throw If any tuple index given by \a tuplesSelec is out of a valid range for + * \throw If any tuple index given by \a tuplesSelec is out of a valid range for * \a aBase array. */ template @@ -2173,7 +2173,7 @@ namespace MEDCoupling } } } - + /*! * Copy some tuples from another DataArrayDouble (\a aBase) into contiguous tuples * of \a this array. Textual data is not copied. Both arrays must have equal number of @@ -2298,7 +2298,7 @@ namespace MEDCoupling } /*! - * Returns the first value of \a this. + * Returns the first value of \a this. * \return double - the last value of \a this array. * \throw If \a this is not allocated. * \throw If \a this->getNumberOfComponents() != 1. @@ -2315,9 +2315,9 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception("DataArrayTemplate::front : number of tuples must be >= 1 !"); return *(getConstPointer()); } - + /*! - * Returns the last value of \a this. + * Returns the last value of \a this. * \return double - the last value of \a this array. * \throw If \a this is not allocated. * \throw If \a this->getNumberOfComponents() != 1. @@ -2334,7 +2334,7 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception("DataArrayTemplate::back : number of tuples must be >= 1 !"); return *(getConstPointer()+nbOfTuples-1); } - + /*! * Returns the maximal value and its location within \a this one-dimensional array. * \param [out] tupleId - index of the tuple holding the maximal value. @@ -2357,7 +2357,7 @@ namespace MEDCoupling tupleId=ToIdType(std::distance(vals,loc)); return *loc; } - + /*! * Returns the maximal value within \a this array that is allowed to have more than * one component. @@ -2372,7 +2372,7 @@ namespace MEDCoupling const T *loc(std::max_element(begin(),end())); return *loc; } - + /*! * Returns the maximal absolute value in \a this and the first occurrence location associated to it. * \return the element in this (positive or negative) having the max abs value in \a this. @@ -2438,7 +2438,7 @@ namespace MEDCoupling tupleId=ToIdType(std::distance(vals,loc)); return *loc; } - + /*! * Returns the minimal value within \a this array that is allowed to have more than * one component. @@ -2452,7 +2452,7 @@ namespace MEDCoupling const T *loc=std::min_element(begin(),end()); return *loc; } - + template void DataArrayTemplate::circularPermutation(mcIdType nbOfShift) { @@ -2478,7 +2478,7 @@ namespace MEDCoupling std::copy((T*)buf,(T *)buf+(nbTuples-effNbSh)*nbOfCompo,work); } } - + template void DataArrayTemplate::circularPermutationPerTuple(mcIdType nbOfShift) { @@ -2514,7 +2514,7 @@ namespace MEDCoupling sts[i]=_info_on_compo[(i+effNbSh)%nbOfCompo]; setInfoOnComponents(sts); } - + template void DataArrayTemplate::reversePerTuple() { @@ -2588,7 +2588,7 @@ namespace MEDCoupling ret->copyStringInfoFrom(*this); return ret; } - + /*! * Creates a new DataArrayDouble and assigns all (textual and numerical) data of \a this * array to the new one. @@ -2611,6 +2611,16 @@ namespace MEDCoupling return convertToOtherTypeOfArr(); } + /*! + * Creates a new DataArrayInt64 and assigns all (textual and numerical) data of \a this + * array to the new one. + * \return DataArrayInt * - the new instance of DataArrayInt64. + */ + template + MCAuto DataArrayTemplateClassic::convertToInt64Arr() const + { + return convertToOtherTypeOfArr(); + } /*! * Creates a new DataArrayFloat and assigns all (textual and numerical) data of \a this * array to the new one. @@ -2664,7 +2674,7 @@ namespace MEDCoupling *ptr=a*(*ptr)+b; this->declareAsNew(); } - + /*! * Returns a full copy of \a this array except that sign of all elements is reversed. * \return DataArrayDouble * - the new instance of DataArrayDouble containing the @@ -2732,7 +2742,7 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception(msg); this->declareAsNew(); } - + /*! * Adds values of another DataArrayDouble to values of \a this one. There are 3 * valid cases. @@ -2778,7 +2788,7 @@ namespace MEDCoupling { this->somethingEqual< std::minus >(other); } - + /*! * Multiply values of another DataArrayDouble to values of \a this one. There are 3 * valid cases. @@ -2825,7 +2835,7 @@ namespace MEDCoupling { this->somethingEqual< std::divides >(other); } - + template typename Traits::ArrayType *DivSub(const typename Traits::ArrayType *a1, const typename Traits::ArrayType *a2) { @@ -2880,7 +2890,7 @@ namespace MEDCoupling return 0; } } - + /*! * Returns a new DataArrayDouble that is a subtraction of two given arrays. There are 3 * valid cases. @@ -2911,7 +2921,7 @@ namespace MEDCoupling { return DivSub< T,std::minus >(a1,a2); } - + /*! * Returns a new DataArrayDouble that is a division of two given arrays. There are 3 * valid cases. @@ -3014,7 +3024,7 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array MulAdd !"); return ret.retn(); } - + /*! * Returns a new DataArrayDouble that is a product of two given arrays. There are 3 * valid cases. @@ -3045,7 +3055,7 @@ namespace MEDCoupling { return MulAdd< T , std::multiplies >(a1,a2); } - + /*! * Returns a new DataArrayDouble that is a sum of two given arrays. There are 3 * valid cases. @@ -3076,7 +3086,7 @@ namespace MEDCoupling { return MulAdd< T , std::plus >(a1,a2); } - + /*! * Returns either a \a deep or \a shallow copy of this array. For more info see * \ref MEDCouplingArrayBasicsCopyDeep and \ref MEDCouplingArrayBasicsCopyShallow. @@ -3103,7 +3113,7 @@ namespace MEDCoupling bool operator()(T v) const { return v>=_v; } T _v; }; - + template struct GreaterThan { @@ -3111,7 +3121,7 @@ namespace MEDCoupling bool operator()(T v) const { return v>_v; } T _v; }; - + template struct LowerEqual { @@ -3119,7 +3129,7 @@ namespace MEDCoupling bool operator()(T v) const { return v<=_v; } T _v; }; - + template struct LowerThan { @@ -3127,7 +3137,7 @@ namespace MEDCoupling bool operator()(T v) const { return v<_v; } T _v; }; - + template struct InRange { @@ -3157,28 +3167,28 @@ struct NotInRange MCAuto ret(findIdsAdv(lt)); return ret.retn(); } - + template MCAuto DataArrayTemplateClassic::findIdsGreaterOrEqualTo(T val) const { GreatEqual ge(val); return findIdsAdv(ge); } - + template MCAuto DataArrayTemplateClassic::findIdsGreaterThan(T val) const { GreaterThan gt(val); return findIdsAdv(gt); } - + template MCAuto DataArrayTemplateClassic::findIdsLowerOrEqualTo(T val) const { LowerEqual le(val); return findIdsAdv(le); } - + template MCAuto DataArrayTemplateClassic::findIdsLowerThan(T val) const { @@ -3308,10 +3318,10 @@ struct NotInRange ret->useArray(tab,true,DeallocType::C_DEALLOC,this->getNumberOfTuples(),this->getNumberOfComponents()); return ret.retn(); } - + /*! * Appends components of another array to components of \a this one, tuple by tuple. - * So that the number of tuples of \a this array remains the same and the number of + * So that the number of tuples of \a this array remains the same and the number of * components increases. * \param [in] other - the DataArrayDouble to append to \a this one. * \throw If \a this is not allocated. @@ -3349,7 +3359,7 @@ struct NotInRange } /*! - * + * * \param [in] nbTimes specifies the nb of times each tuples in \a this will be duplicated contiguouly in returned DataArrayDouble instance. * \a nbTimes should be at least equal to 1. * \return a newly allocated DataArrayDouble having one component and number of tuples equal to \a nbTimes * \c this->getNumberOfTuples. @@ -3376,7 +3386,7 @@ struct NotInRange ret->copyStringInfoFrom(*this); return ret.retn(); } - + template void DataArrayTemplateClassic::aggregate(const typename Traits::ArrayType *other) { @@ -3445,7 +3455,7 @@ struct NotInRange /*! * Computes for each tuple the sum of number of components values in the tuple and return it. - * + * * \return DataArrayDouble * - the new instance of DataArrayDouble containing the * same number of tuples as \a this array and one component. * The caller is to delete this result array using decrRef() as it is no more @@ -3492,10 +3502,10 @@ struct NotInRange template<> struct ImplReprTraits { static void SetPrecision(std::ostream& oss) { oss.precision(17); } }; - + template<> struct ImplReprTraits { static void SetPrecision(std::ostream& oss) { oss.precision(7); } }; - + template void DataArrayTemplateClassic::reprStream(std::ostream& stream) const { @@ -3553,7 +3563,7 @@ struct NotInRange reprNotTooLongStream(ret); return ret.str(); } - + /*! * Returns a textual and human readable representation of \a this instance of * DataArrayInt. This text is shown when a DataArrayInt is printed in Python. @@ -3568,7 +3578,7 @@ struct NotInRange DataArrayTemplateClassic::reprStream(ret); return ret.str(); } - + template std::string DataArrayTemplateClassic::reprZip() const { @@ -3576,9 +3586,9 @@ struct NotInRange DataArrayTemplateClassic::reprZipStream(ret); return ret.str(); } - + ///////////////////////////////// - + /*! * Checks if all values in \a this array are equal to \a val at precision \a eps. * \param [in] val - value to check equality of array values to. @@ -3629,7 +3639,7 @@ struct NotInRange /*! * Equivalent to DataArrayInt::isEqual except that if false the reason of * mismatch is given. - * + * * \param [in] other the instance to be compared with \a this * \param [out] reason In case of inequality returns the reason. * \sa DataArrayInt::isEqual @@ -3654,7 +3664,7 @@ struct NotInRange std::string tmp; return isEqualIfNotWhy(other,tmp); } - + /*! * Returns a new instance of DataArrayInt. The caller is to delete this array * using decrRef() as it is no more needed. @@ -3664,7 +3674,7 @@ struct NotInRange { return new typename Traits::ArrayType; } - + /*! * Checks if values of \a this and another DataArrayInt are equal. For more info see * \ref MEDCouplingArrayBasicsCompare. @@ -3694,7 +3704,7 @@ struct NotInRange b->sort(); return a->isEqualWithoutConsideringStr(*b); } - + template template void DataArrayDiscrete::switchOnTupleAlg(T val, std::vector& vec, ALG algo) const @@ -3710,7 +3720,7 @@ struct NotInRange if(algo(pt[i],val)) vec[i]=true; } - + /*! * This method assumes that \a this has one component and is allocated. This method scans all tuples in \a this and for all tuple equal to \a val * put True to the corresponding entry in \a vec. @@ -3728,7 +3738,7 @@ struct NotInRange * This method assumes that \a this has one component and is allocated. This method scans all tuples in \a this and for all tuple different from \a val * put True to the corresponding entry in \a vec. * \a vec is expected to be with the same size than the number of tuples of \a this. - * + * * \sa DataArrayInt::switchOnTupleEqualTo. */ template @@ -3780,7 +3790,7 @@ struct NotInRange /*! * Creates a new one-dimensional DataArrayInt of the same size as \a this and a given * one-dimensional arrays that must be of the same length. The result array describes - * correspondence between \a this and \a other arrays, so that + * correspondence between \a this and \a other arrays, so that * other.getIJ(i,0) == this->getIJ(ret->getIJ(i),0). If such a permutation is * not possible because some element in \a other is not in \a this, an exception is thrown. * \param [in] other - an array to compute permutation to. @@ -3791,7 +3801,7 @@ struct NotInRange * \throw If \a other->getNumberOfComponents() != 1. * \throw If \a this->getNumberOfTuples() != \a other->getNumberOfTuples(). * \throw If \a other includes a value which is not in \a this array. - * + * * \if ENABLE_EXAMPLES * \ref cpp_mcdataarrayint_buildpermutationarr "Here is a C++ example". * @@ -4271,9 +4281,9 @@ struct NotInRange /*! * Computes distribution of values of \a this one-dimensional array between given value * ranges (casts). This method is typically useful for entity number splitting by types, - * for example. + * for example. * \warning The values contained in \a arrBg should be sorted ascendently. No - * check of this is be done. If not, the result is not warranted. + * check of this is be done. If not, the result is not warranted. * \param [in] arrBg - the array of ascending values defining the value ranges. The i-th * value of \a arrBg (\a arrBg[ i ]) gives the lowest value of the i-th range, * and the greatest value of the i-th range equals to \a arrBg[ i+1 ] - 1. \a @@ -4560,7 +4570,7 @@ struct NotInRange /*! * Creates a map, whose contents are computed - * from values of \a this array, which is supposed to contain a renumbering map in + * from values of \a this array, which is supposed to contain a renumbering map in * "New to Old" mode. The result array contains a renumbering map in "New to Old" mode as C++ map for performance reasons. * * \sa invertArrayN2O2O2NOptimized, MEDCouplingPointSet::renumberNodesInConn @@ -4934,7 +4944,7 @@ struct NotInRange ret->pushBackSilent(i); return ret.retn(); } - + /*! * Creates a new DataArrayInt containing IDs (indices) of tuples holding tuple equal to those defined by [ \a tupleBg , \a tupleEnd ) * This method is an extension of DataArrayInt::findIdsEqual method. @@ -5001,7 +5011,7 @@ struct NotInRange ret->pushBackSilent(i); return ret.retn(); } - + /*! * Creates a new DataArrayInt containing IDs (indices) of tuples holding values \b not * equal to any of given values. @@ -5046,7 +5056,7 @@ struct NotInRange return ToIdType(std::distance(cptr,ret)); return -1; } - + /*! * This method expects to be called when number of components of this is equal to one. * This method returns the tuple id, if it exists, of the first tuple so that the value is contained in \b vals. @@ -5198,8 +5208,8 @@ struct NotInRange { return this->findIdFirstEqualTuple(tupl)!=-1; } - - + + /*! * Returns \a true if a given value is present within \a this one-dimensional array. * \param [in] value - the value to find within \a this array. @@ -5213,7 +5223,7 @@ struct NotInRange { return this->findIdFirstEqual(value)!=-1; } - + /*! * This method expects to be called when number of components of this is equal to one. * This method returns true if it exists a tuple so that the value is contained in \b vals. @@ -5244,7 +5254,7 @@ struct NotInRange for(mcIdType i=0;i()); } - + template T DataArrayDiscrete::accumulate(std::size_t compId) const { @@ -5478,7 +5488,7 @@ struct NotInRange } this->declareAsNew(); } - + /*! * Modify all elements of \a this array, so that * an element _x_ becomes \f$ val ^ x \f$. @@ -5532,7 +5542,7 @@ struct NotInRange MCAuto ret(this->findIdsAdv(ir)); return ret.retn(); } - + /*! * This method works only on data array with one component. * This method returns a newly allocated array storing stored ascendantly tuple ids in \b this so that @@ -5727,7 +5737,7 @@ struct NotInRange * Locate groups of all consecutive same values in \a this and return them into an indexed array of positions pointing to \a this starting with 0. * Number of tuples of returned array is equal to size of \a this->buildUnique() + 1. * Last value of returned array is equal to \a this->getNumberOfTuples() - * + * * \b Example: * - \a this : [0, 1, 1, 2, 2, 3, 4, 4, 5, 5, 5, 11] * - \a return is : [0, 1, 3, 5, 6, 8, 11, 12] @@ -6784,9 +6794,9 @@ struct NotInRange * \a ids1 and \a ids2 are expected to be both a list of ids (both with number of components equal to one) not sorted and with values that can be negative. * This method will throw an exception is no such permutation array can be obtained. It is typically the case if there is some ids in \a ids1 not in \a ids2 or * inversely. - * The difference with DataArrayInt::FindPermutationFromFirstToSecond is that this method supports multiple same values in \a ids1 and \a ids2 whereas + * The difference with DataArrayInt::FindPermutationFromFirstToSecond is that this method supports multiple same values in \a ids1 and \a ids2 whereas * DataArrayInt::FindPermutationFromFirstToSecond doesn't. It implies that this method my be slower than the DataArrayInt::FindPermutationFromFirstToSecond one. - * + * * In case of success both assertion will be true (no throw) : * \c ids1->renumber(ret)->isEqual(ids2) where \a ret is the return of this method. * \c ret->transformWithIndArr(ids2)->isEqual(ids1) @@ -6848,10 +6858,10 @@ struct NotInRange } else { - std::ostringstream oss; oss << MSG0 << "At pos " << std::distance(ids1->begin(),it1) << " value is " << *it1 << " and occurence rank is " << occRk1 << ". No such item into second array !"; + std::ostringstream oss; oss << MSG0 << "At pos " << std::distance(ids1->begin(),it1) << " value is " << *it1 << " and occurence rank is " << occRk1 << ". No such item into second array !"; throw INTERP_KERNEL::Exception(oss.str()); } - + } return ret.retn(); } diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index b567b4fc8..6afd214c3 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -367,7 +367,7 @@ typedef DataArrayInt64 DataArrayIdType; public: static MCAuto< MapII > New(); }; - + class PartDefinition : public RefCountObject, public TimeLabel { public: @@ -422,7 +422,7 @@ typedef DataArrayInt64 DataArrayIdType; { return self->getRepr(); } - + std::string __repr__() const { std::ostringstream oss; oss << "DataArrayPartDefinition C++ instance at " << self << "." << std::endl; @@ -452,12 +452,12 @@ typedef DataArrayInt64 DataArrayIdType; self->getSlice(a,b,c); return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(c)); } - + std::string __str__() const { return self->getRepr(); } - + std::string __repr__() const { std::ostringstream oss; oss << "SlicePartDefinition C++ instance at " << self << "." << std::endl; @@ -468,7 +468,7 @@ typedef DataArrayInt64 DataArrayIdType; protected: virtual ~SlicePartDefinition(); }; - + class DataArray : public RefCountObject, public TimeLabel { public: @@ -528,7 +528,7 @@ typedef DataArrayInt64 DataArrayIdType; PyList_SetItem(ret,i,PyString_FromString(comps[i].c_str())); return ret; } - + void copyPartOfStringInfoFrom(const DataArray& other, PyObject *li) { std::vector tmp; @@ -616,7 +616,7 @@ typedef DataArrayInt64 DataArrayIdType; } self->setContigPartOfSelectedValues(tupleIdStart,a,tuplesSelecPtr2); } - + virtual void setContigPartOfSelectedValuesSlice(mcIdType tupleIdStart, PyObject *aBase, mcIdType bg, mcIdType end2, mcIdType step) { DataArray *a=CheckAndRetrieveDataArrayInstance(aBase,"DataArray::setContigPartOfSelectedValuesSlice : 2nd parameter \"aBase\" should be of type DataArray"); @@ -719,7 +719,7 @@ typedef DataArrayInt64 DataArrayIdType; GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !"); return DataArray::GetNumberOfItemGivenBESRelative(ToIdType(strt),ToIdType(stp),ToIdType(step),""); } - + static DataArray *Aggregate(PyObject *arrs) { std::vector tmp; @@ -806,7 +806,7 @@ typedef DataArrayInt64 DataArrayIdType; { return DataArrayT_New(elt0,nbOfTuples,elt2); } - + DataArrayFloat(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *elt2=0) { return MEDCoupling_DataArrayFloat_New__SWIG_1(elt0,nbOfTuples,elt2); @@ -866,7 +866,7 @@ typedef DataArrayInt64 DataArrayIdType; PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str())); return ret; } - + PyObject *__getitem__(PyObject *obj) { return DataArrayT__getitem(self,obj); @@ -876,7 +876,7 @@ typedef DataArrayInt64 DataArrayIdType; { return DataArrayT__setitem__(self,obj,value); } - + PyObject *___iadd___(PyObject *trueSelf, PyObject *obj) { return DataArrayT_iadd(trueSelf,obj,self); @@ -901,7 +901,7 @@ typedef DataArrayInt64 DataArrayIdType; { return DataArrayT_idiv(trueSelf,obj,self); } - + #ifdef WITH_NUMPY PyObject *toNumPyArray() // not const. It is not a bug ! { @@ -955,7 +955,7 @@ typedef DataArrayInt64 DataArrayIdType; { return self->buildDAFloat(1,self->getNumberOfCompo()); } - + /*PyObject *___imul___(PyObject *trueSelf, PyObject *obj) { MCAuto ret=self->buildDAFloat(1,self->getNumberOfCompo()); @@ -970,9 +970,9 @@ typedef DataArrayInt64 DataArrayIdType; } } }; - + class DataArrayDoubleIterator; - + class DataArrayDouble : public DataArray { public: @@ -1092,6 +1092,7 @@ typedef DataArrayInt64 DataArrayIdType; MCAuto findIdsLowerOrEqualTo(double val) const; MCAuto findIdsLowerThan(double val) const; MCAuto convertToIntArr() const; + MCAuto convertToInt64Arr() const; MCAuto selectPartDef(const PartDefinition* pd) const; MCAuto cumSum() const; MCAuto convertToFloatArr() const; @@ -1106,7 +1107,7 @@ typedef DataArrayInt64 DataArrayIdType; { return DataArrayT_New(elt0,nbOfTuples,elt2); } - + DataArrayDouble(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *elt2=0) { return MEDCoupling_DataArrayDouble_New__SWIG_1(elt0,nbOfTuples,elt2); @@ -1163,7 +1164,7 @@ typedef DataArrayInt64 DataArrayIdType; PyTuple_SetItem(ret,0,ret0); } PyTuple_SetItem(ret,1,PyFloat_FromDouble(radius)); - PyTuple_SetItem(ret,2,PyFloat_FromDouble(ang)); + PyTuple_SetItem(ret,2,PyFloat_FromDouble(ang)); return ret; } @@ -1171,7 +1172,7 @@ typedef DataArrayInt64 DataArrayIdType; { return self->iterator(); } - + void setValues(PyObject *li, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) { const char *msg="MEDCoupling::DataArrayDouble::setValues : Available API are : \n-DataArrayDouble.setValues([1.,3.,4.])\n-DataArrayDouble.setValues([1.,3.,4.],3)\n-DataArrayDouble.setValues([1.,3.,4.,5.],2,2)\n-DataArrayDouble.setValues([(1.,1.7),(3.,3.7),(4.,4.7)])\n !"; @@ -1272,7 +1273,7 @@ typedef DataArrayInt64 DataArrayIdType; PyTuple_SetItem(ret,1,PyFloat_FromDouble(res1)); return ret; } - + DataArrayDouble *symmetry3DPlane(PyObject *point, PyObject *normalVector) { const char msg[]="Python wrap of DataArrayDouble::symmetry3DPlane : "; @@ -1313,7 +1314,7 @@ typedef DataArrayInt64 DataArrayIdType; const double *vectorPtr=convertObjToPossibleCpp5_Safe(vector,sw,val2,a2,aa2,bb2,msg,1,3,true); return self->fromCartToCylGiven(coords,centerPtr,vectorPtr); } - + DataArrayDouble *renumber(PyObject *li) { void *da=0; @@ -1470,7 +1471,7 @@ typedef DataArrayInt64 DataArrayIdType; PyObject *ret=convertDblArrToPyListOfTuple(tmp,2,ToIdType(nbOfCompo)); return ret; } - + PyObject *normMaxPerComponent() const { std::size_t nbOfCompo(self->getNumberOfComponents()); @@ -1539,7 +1540,7 @@ typedef DataArrayInt64 DataArrayIdType; PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(retCpp[i].retn()),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 )); return res; } - + PyObject *getTuple(mcIdType tupleId) { std::size_t sz=self->getNumberOfComponents(); @@ -1694,7 +1695,7 @@ typedef DataArrayInt64 DataArrayIdType; throw INTERP_KERNEL::Exception(msg); } } - + PyObject *___iadd___(PyObject *trueSelf, PyObject *obj) { return DataArrayT_iadd(trueSelf,obj,self); @@ -1947,7 +1948,7 @@ typedef DataArrayInt64 DataArrayIdType; { return DataArrayT_idiv(trueSelf,obj,self); } - + DataArrayDouble *__pow__(PyObject *obj) { const char msg[]="Unexpected situation in __pow__ !"; @@ -2057,7 +2058,7 @@ typedef DataArrayInt64 DataArrayIdType; throw INTERP_KERNEL::Exception(msg); } } - + PyObject *computeTupleIdsNearTuples(const DataArrayDouble *other, double eps) { DataArrayIdType *c=0,*cI=0; @@ -2133,7 +2134,7 @@ typedef DataArrayInt64 DataArrayIdType; Py_XINCREF(trueSelf); return trueSelf; } - + PyObject *___isub___(PyObject *trueSelf, PyObject *obj) { MCAuto ret=self->buildDADouble(1,self->getNumberOfCompo()); @@ -2141,7 +2142,7 @@ typedef DataArrayInt64 DataArrayIdType; Py_XINCREF(trueSelf); return trueSelf; } - + PyObject *___imul___(PyObject *trueSelf, PyObject *obj) { MCAuto ret=self->buildDADouble(1,self->getNumberOfCompo()); @@ -2441,7 +2442,7 @@ typedef DataArrayInt64 DataArrayIdType; throw INTERP_KERNEL::Exception("DataArrayChar::__len__ : Instance is NOT allocated !"); } } - + PyObject *isEqualIfNotWhy(const DataArrayChar& other) const { std::string ret1; @@ -2453,7 +2454,7 @@ typedef DataArrayInt64 DataArrayIdType; PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str())); return ret; } - + DataArrayChar *renumber(PyObject *li) { void *da=0; @@ -2482,7 +2483,7 @@ typedef DataArrayInt64 DataArrayIdType; return self->renumber(da2->getConstPointer()); } } - + DataArrayChar *renumberR(PyObject *li) { void *da=0; @@ -2511,7 +2512,7 @@ typedef DataArrayInt64 DataArrayIdType; return self->renumberR(da2->getConstPointer()); } } - + DataArrayChar *renumberAndReduce(PyObject *li, mcIdType newNbOfTuple) { void *da=0; @@ -2540,14 +2541,14 @@ typedef DataArrayInt64 DataArrayIdType; return self->renumberAndReduce(da2->getConstPointer(),newNbOfTuple); } } - + static DataArrayChar *Aggregate(PyObject *dachs) { std::vector tmp; convertFromPyObjVectorOfObj(dachs,SWIGTYPE_p_MEDCoupling__DataArrayChar,"DataArrayChar",tmp); return DataArrayChar::Aggregate(tmp); } - + static DataArrayChar *Meld(PyObject *dachs) { std::vector tmp; @@ -2556,7 +2557,7 @@ typedef DataArrayInt64 DataArrayIdType; } } }; - + class DataArrayByteIterator; class DataArrayByte : public DataArrayChar @@ -2666,14 +2667,14 @@ typedef DataArrayInt64 DataArrayIdType; { return MEDCoupling_DataArrayByte_New__SWIG_1(elt0,nbOfTuples,nbOfComp); } - + std::string __repr__() const { std::ostringstream oss; self->reprQuickOverview(oss); return oss.str(); } - + int __int__() const { return (int) self->byteValue(); @@ -2688,7 +2689,7 @@ typedef DataArrayInt64 DataArrayIdType; { return (mcIdType)self->getIJ(tupleId,compoId); } - + mcIdType getIJSafe(mcIdType tupleId, mcIdType compoId) const { return (mcIdType)self->getIJSafe(tupleId,compoId); @@ -2706,7 +2707,7 @@ typedef DataArrayInt64 DataArrayIdType; mcIdType nbOfTuples=self->getNumberOfTuples(); return convertCharArrToPyListOfTuple(vals,(int)nbOfComp,nbOfTuples); } - + bool presenceOfTuple(PyObject *tupl) const { mcIdType sz=-1,sw=-1; @@ -2828,7 +2829,7 @@ typedef DataArrayInt64 DataArrayIdType; return MEDCoupling_DataArrayByte_presenceOfTuple(self,obj); } } - + #ifdef WITH_NUMPY PyObject *toNumPyArray() // not const. It is not a bug ! { @@ -3077,21 +3078,21 @@ typedef DataArrayInt64 DataArrayIdType; { return self->repr(); } - + char __int__() const { return self->byteValue(); } - + DataArrayByte *buildDAByte() { return self->buildDAByte(1,self->getNumberOfCompo()); } } }; - + class DataArrayAsciiCharIterator; - + class DataArrayAsciiChar : public DataArrayChar { public: @@ -3244,7 +3245,7 @@ typedef DataArrayInt64 DataArrayIdType; tmp[0]=self->getIJ(tupleId,compoId); return std::string(tmp); } - + std::string getIJSafe(mcIdType tupleId, mcIdType compoId) const { char tmp[2]; tmp[1]='\0'; @@ -3286,7 +3287,7 @@ typedef DataArrayInt64 DataArrayIdType; else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::presenceOfTuple : only strings in input supported !"); } - + bool presenceOfValue(PyObject *vals) const { if(PyString_Check(vals)) @@ -3374,7 +3375,7 @@ typedef DataArrayInt64 DataArrayIdType; else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::search : only strings in input supported !"); } - + PyObject *getTuple(mcIdType tupleId) const { std::size_t sz=self->getNumberOfComponents(); @@ -3693,7 +3694,7 @@ typedef DataArrayInt64 DataArrayIdType; { return self->repr(); } - + DataArrayAsciiChar *buildDAAsciiChar() { return self->buildDAAsciiChar(1,self->getNumberOfCompo()); diff --git a/src/MEDLoader/MEDFileField1TS.cxx b/src/MEDLoader/MEDFileField1TS.cxx index f7f4d8223..61ad03b66 100644 --- a/src/MEDLoader/MEDFileField1TS.cxx +++ b/src/MEDLoader/MEDFileField1TS.cxx @@ -76,7 +76,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::accept(MEDFileFieldVisitor& visitor) cons } /*! - * Prints a string describing \a this field into a stream. This string is outputted + * Prints a string describing \a this field into a stream. This string is outputted * by \c print Python command. * \param [in] bkOffset - number of white spaces printed at the beginning of each line. * \param [in,out] oss - the out stream. @@ -214,7 +214,7 @@ int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const * iteration order number. * \param [in] iteration - the iteration number of interest. * \param [in] order - the iteration order number of interest. - * \return bool - \c true if \a this->getIteration() == \a iteration && + * \return bool - \c true if \a this->getIteration() == \a iteration && * \a this->getOrder() == \a order. */ bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const @@ -358,9 +358,9 @@ void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector * for the case with only one underlying mesh. (Actually, the number of meshes is * not checked if \a mname == \c NULL). * \param [in,out] types - a sequence of types of underlying mesh entities. A type per - * a field part is returned. + * a field part is returned. * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations. - * This sequence is of the same length as \a types. + * This sequence is of the same length as \a types. * \param [in,out] pfls - a sequence returning a profile name per each type of spatial * discretization. A profile name can be empty. * Length of this and of nested sequences is the same as that of \a typesF. @@ -369,7 +369,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector * Length of this and of nested sequences is the same as that of \a typesF. * \return std::vector< std::vector< std::pair > > - a sequence holding a range * of ids of tuples within the data array, per each type of spatial - * discretization within one mesh entity type. + * discretization within one mesh entity type. * Length of this and of nested sequences is the same as that of \a typesF. * \throw If no field is lying on \a mname. */ @@ -382,18 +382,18 @@ std::vector< std::vector< std::pair > > MEDFileAnyTypeField1T /*! * Returns dimensions of mesh elements \a this field lies on. The returned value is a - * maximal absolute dimension and values returned via the out parameter \a levs are + * maximal absolute dimension and values returned via the out parameter \a levs are * dimensions relative to the maximal absolute dimension.
* This method is designed for MEDFileField1TS instances that have a discretization - * \ref MEDCoupling::ON_CELLS "ON_CELLS", - * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT", + * \ref MEDCoupling::ON_CELLS "ON_CELLS", + * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT", * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE". * Only these 3 discretizations will be taken into account here. If \a this is * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.
* This method is useful to make the link between the dimension of the underlying mesh * and the levels of \a this, because it is possible that the highest dimension of \a this * field is not equal to the dimension of the underlying mesh. - * + * * Let's consider the following case: * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements * TETRA4, HEXA8, TRI3 and SEG2. @@ -408,7 +408,7 @@ std::vector< std::vector< std::pair > > MEDFileAnyTypeField1T * meshDimRelToMax = absDim - meshDim + relativeLev . * For example
* to retrieve the highest level of - * \a f1: f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev
+ * \a f1: f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev
* to retrieve the lowest level of \a f1: f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );
* to retrieve the highest level of \a f2: f2->getFieldAtLevel( ON_CELLS, 2-3+0 );
* to retrieve the lowest level of \a f2: f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) ). @@ -494,7 +494,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::makeReduction(INTERP_KERNEL::NormalizedCe /*! * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh. * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. - * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of + * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0. */ MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) @@ -507,7 +507,7 @@ MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGive /*! * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh. * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. - * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of + * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0. */ const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const @@ -821,7 +821,7 @@ std::vector MEDFileAnyTypeField1TSWithoutSDA::getDirect /*! * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is * checked if its elements are sorted suitable for writing to MED file ("STB" stands for - * "Sort By Type"), if not, an exception is thrown. + * "Sort By Type"), if not, an exception is thrown. * \param [in] field - the field to add to \a this. The array of field \a field is ignored * \param [in] arr - the array of values. * \param [in,out] glob - the global data where profiles and localization present in @@ -854,12 +854,12 @@ void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const TimeHolder *th /*! * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension - * of a given mesh are used as the support of the given field (a real support is not used). - * Elements of the given mesh must be sorted suitable for writing to MED file. + * of a given mesh are used as the support of the given field (a real support is not used). + * Elements of the given mesh must be sorted suitable for writing to MED file. * Order of underlying mesh entities of the given field specified by \a profile parameter * is not prescribed; this method permutes field values to have them sorted by element * type as required for writing to MED file. A new profile is added only if no equal - * profile is missing. + * profile is missing. * \param [in] field - the field to add to \a this. The field double values are ignored. * \param [in] arrOfVals - the values of the field \a field used. * \param [in] mesh - the supporting mesh of \a field. @@ -892,7 +892,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const TimeHolder *th, con { m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType,smartPflKiller); std::vector< MCAuto > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin()); - std::vector< MCAuto > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin()); + std::vector< MCAuto > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin()); std::vector idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin()); // start of check MCAuto field2=field->clone(false); @@ -1128,7 +1128,7 @@ MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDF * * \param [in] glob - the global data storing profiles and localization. * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. + * caller is to delete this field using decrRef() as it is no more needed. * \throw If the MED file is not readable. * \throw If there is no mesh named \a mName in the MED file. * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh. @@ -1159,7 +1159,7 @@ MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOf * \param [in] glob - the global data storing profiles and localization. * \param [in] mesh - the supporting mesh. * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. + * caller is to delete this field using decrRef() as it is no more needed. * \throw If the MED file is not readable. * \throw If no field of \a this is lying on \a mesh. * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh. @@ -1176,7 +1176,7 @@ MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel( /*! * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a - * given mesh. + * given mesh. * \param [in] type - a spatial discretization of the new field. * \param [in] mName - a name of the supporting mesh. * \param [in] renumPol - specifies how to permute values of the result field according to @@ -1188,7 +1188,7 @@ MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel( * * \param [in] glob - the global data storing profiles and localization. * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. + * caller is to delete this field using decrRef() as it is no more needed. * \throw If the MED file is not readable. * \throw If there is no mesh named \a mName in the MED file. * \throw If there are no mesh entities in the mesh. @@ -1223,7 +1223,7 @@ MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(Typ * \param [in] nodeRenum - the node numbers array used for permutation of the result * field according to \a renumPol. * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. + * caller is to delete this field using decrRef() as it is no more needed. * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh. * \throw If no field of \a this is lying on \a mesh. * \throw If no field values of the given \a type or given \a meshDimRelToMax are available. @@ -1300,7 +1300,7 @@ MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel( * \param [out] pfl - a new instance of DataArrayIdType holding ids of mesh entities the * field of interest lies on. If the field lies on all entities of the given * dimension, all ids in \a pfl are zero. The caller is to delete this array - * using decrRef() as it is no more needed. + * using decrRef() as it is no more needed. * \param [in] glob - the global data storing profiles and localization. * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the * field. The caller is to delete this array using decrRef() as it is no more needed. @@ -1330,12 +1330,12 @@ void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax) } /*! - * Checks if elements of a given mesh are in the order suitable for writing + * Checks if elements of a given mesh are in the order suitable for writing * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a * vector describing types of elements and their number. * \param [in] mesh - the mesh to check. * \return std::vector - a vector holding for each element type (1) item of - * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1. + * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1. * These values are in full-interlace mode. * \throw If elements in \a mesh are not in the order suitable for writing to the MED file. */ @@ -1394,12 +1394,12 @@ MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fie * for the case with only one underlying mesh. (Actually, the number of meshes is * not checked if \a mname == \c NULL). * \param [in,out] types - a sequence of types of underlying mesh entities. A type per - * a field part is returned. + * a field part is returned. * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations. * A field part can include sub-parts with several different spatial discretizations, - * \ref MEDCoupling::ON_CELLS "ON_CELLS" and + * \ref MEDCoupling::ON_CELLS "ON_CELLS" and * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example. - * This sequence is of the same length as \a types. + * This sequence is of the same length as \a types. * \param [in,out] pfls - a sequence returning a profile name per each type of spatial * discretization. A profile name can be empty. * Length of this and of nested sequences is the same as that of \a typesF. @@ -1453,6 +1453,20 @@ MEDFileInt32Field1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const return ret.retn(); } +MEDFileInt64Field1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt64() const +{ + MCAuto ret(new MEDFileInt64Field1TSWithoutSDA); + ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this); + ret->deepCpyLeavesFrom(*this); + const DataArrayDouble *arr(_arr); + if(arr) + { + MCAuto arr2(arr->convertToInt64Arr()); + ret->setArray(arr2); + } + return ret.retn(); +} + /*! * Returns a pointer to the underground DataArrayDouble instance and a * sequence describing parameters of a support of each part of \a this field. The @@ -2142,7 +2156,7 @@ int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, int fieldIdCFormat, bool c /*! * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName. - * + * * \return in case of success the number of time steps available for the field with name \a fieldName. */ int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector& infos, std::string& dtunitOut, std::string& meshName) @@ -2185,7 +2199,7 @@ int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldNam * * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh. * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. - * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of + * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0. * \param [in] newLocName is the new localization name. * \param [in] forceRenameOnGlob specifies the behaviour in case of profile \b newPflName already exists. If true, the renaming is done without check. It can lead to major bug. @@ -2223,7 +2237,7 @@ void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTE * * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh. * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. - * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of + * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0. * \param [in] newLocName is the new localization name. * \param [in] forceRenameOnGlob specifies the behaviour in case of profile \b newLocName already exists. If true, the renaming is done without check. It can lead to major bug. @@ -2268,7 +2282,7 @@ const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBa * This method alloc the arrays and load potentially huge arrays contained in this field. * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter. * This method can be also called to refresh or reinit values from a file. - * + * * \throw If the fileName is not set or points to a non readable MED file. * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary */ @@ -2284,7 +2298,7 @@ void MEDFileAnyTypeField1TS::loadArrays() * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays. * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays * this method does not throw if \a this does not come from file read. - * + * * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays */ void MEDFileAnyTypeField1TS::loadArraysIfNecessary() @@ -2300,7 +2314,7 @@ void MEDFileAnyTypeField1TS::loadArraysIfNecessary() * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false. * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file. * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead. - * + * * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss */ void MEDFileAnyTypeField1TS::unloadArrays() @@ -2312,7 +2326,7 @@ void MEDFileAnyTypeField1TS::unloadArrays() * This method potentially releases big data arrays if \a this is coming from a file. If \a this has been built from scratch this method will have no effect. * This method is the symmetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary. * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database. - * + * * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary */ void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss() @@ -2354,7 +2368,7 @@ std::vector MEDFileAnyTypeField1TS::getDirectChildrenWi } /*! - * Returns a string describing \a this field. This string is outputted + * Returns a string describing \a this field. This string is outputted * by \c print Python command. */ std::string MEDFileAnyTypeField1TS::simpleRepr() const @@ -2679,6 +2693,35 @@ MEDFileInt32Field1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const return ret.retn(); } +/*! + * This method performs a copy with datatype modification ( float64->int64 ) of \a this. The globals information are copied + * following the given input policy. + * + * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations) + * By default (true) the globals are deeply copied. + * \return MEDFileInt32Field1TS * - a new object that is the result of the conversion of \a this to int64 field. + */ +MEDFileInt64Field1TS *MEDFileField1TS::convertToInt64(bool isDeepCpyGlobs) const +{ + MCAuto ret; + const MEDFileAnyTypeField1TSWithoutSDA *content(_content); + if(content) + { + const MEDFileField1TSWithoutSDA *contc=dynamic_cast(content); + if(!contc) + throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !"); + MCAuto newc(contc->convertToInt64()); + ret=static_cast(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileInt64Field1TSWithoutSDA *)newc)); + } + else + ret=MEDFileInt64Field1TS::New(); + if(isDeepCpyGlobs) + ret->deepCpyGlobs(*this); + else + ret->shallowCpyGlobs(*this); + return ret.retn(); +} + MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms) try:MEDFileTemplateField1TS(fid,loadAll,ms) { diff --git a/src/MEDLoader/MEDFileField1TS.hxx b/src/MEDLoader/MEDFileField1TS.hxx index eb8063d03..b2ba9fc92 100644 --- a/src/MEDLoader/MEDFileField1TS.hxx +++ b/src/MEDLoader/MEDFileField1TS.hxx @@ -32,7 +32,7 @@ namespace MEDCoupling { class TimeHolder; class MEDFileMeshes; - + /*! * SDA is for Shared Data Arrays such as profiles. */ @@ -185,6 +185,8 @@ namespace MEDCoupling MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *shallowCpy() const; MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *deepCopy() const; MEDLOADER_EXPORT MEDFileInt32Field1TSWithoutSDA *convertToInt() const; + MEDLOADER_EXPORT MEDFileInt64Field1TSWithoutSDA *convertToInt64() const; + MEDLOADER_EXPORT MEDFileFloatField1TSWithoutSDA *convertToFloat() const; public: static const char TYPE_STR[]; }; @@ -198,7 +200,7 @@ namespace MEDCoupling MEDFileField1TSNDTemplateWithoutSDA() { } MEDFileField1TSNDTemplateWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos):MEDFileField1TSTemplateWithoutSDA(fieldName,meshName,csit,iteration,order) { } }; - + /*! * SDA is for Shared Data Arrays such as profiles. */ @@ -413,6 +415,7 @@ namespace MEDCoupling friend class MEDFileTemplateField1TS; public: MEDLOADER_EXPORT MEDFileInt32Field1TS *convertToInt(bool isDeepCpyGlobs=true) const; + MEDLOADER_EXPORT MEDFileInt64Field1TS *convertToInt64(bool isDeepCpyGlobs=true) const; public: MEDLOADER_EXPORT MEDFileField1TS *shallowCpy() const; MEDLOADER_EXPORT std::vector< std::vector > getFieldSplitedByType2(const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, @@ -435,6 +438,8 @@ namespace MEDCoupling { public: MEDLOADER_EXPORT MEDFileField1TS *convertToDouble(bool isDeepCpyGlobs=true) const; + MEDLOADER_EXPORT MEDFileField1TS *convertToInt(bool isDeepCpyGlobs=true) const; + MEDLOADER_EXPORT MEDFileField1TS *convertToInt64(bool isDeepCpyGlobs=true) const; protected: ~MEDFileNDTemplateField1TS() { } MEDFileNDTemplateField1TS() { } diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index d53d6d623..1ad2475ed 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -230,6 +230,7 @@ using namespace MEDCoupling; %newobject MEDCoupling::MEDFileField1TS::getFieldAtLevelOld; %newobject MEDCoupling::MEDFileField1TS::getUndergroundDataArray; %newobject MEDCoupling::MEDFileField1TS::convertToInt; +%newobject MEDCoupling::MEDFileField1TS::convertToInt64; %newobject MEDCoupling::MEDFileInt32Field1TS::New; %newobject MEDCoupling::MEDFileInt32Field1TS::field; @@ -453,7 +454,7 @@ namespace MEDCoupling PyTuple_SetItem(ret,1,b.retn()); return ret.retn(); } - + MEDCoupling::MEDCouplingField *ReadFieldSwig(const std::string& fileName) { MCAuto ret(MEDCoupling::ReadField(fileName)); @@ -465,13 +466,13 @@ namespace MEDCoupling MCAuto ret(MEDCoupling::ReadField(fileName,fieldName)); return ret.retn(); } - + MEDCoupling::MEDCouplingField *ReadFieldSwig(const std::string& fileName, const std::string& fieldName, int iteration, int order) { MCAuto ret(MEDCoupling::ReadField(fileName,fieldName,iteration,order)); return ret.retn(); } - + MEDCoupling::MEDCouplingField *ReadFieldSwig(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) { MCAuto ret(MEDCoupling::ReadField(type,fileName,meshName,meshDimRelToMax,fieldName,iteration,order)); @@ -492,7 +493,7 @@ namespace MEDCoupling } return ret; } - + PyObject *GetAllFieldIterationsSwig(const std::string& fileName, const std::string& fieldName) { std::vector< std::pair< std::pair, double> > res=MEDCoupling::GetAllFieldIterations(fileName,fieldName); @@ -508,7 +509,7 @@ namespace MEDCoupling } return ret; } - + PyObject *GetCellFieldIterationsSwig(const std::string& fileName, const std::string& meshName, const std::string& fieldName) { std::vector< std::pair > res=MEDCoupling::GetCellFieldIterations(fileName,meshName,fieldName); @@ -582,7 +583,7 @@ namespace MEDCoupling PyTuple_SetItem(ret,3,SWIG_From_long(numberOfNodes)); return ret; } - + PyObject *ReadFieldsOnSameMeshSwig(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, PyObject *liIts) { @@ -590,28 +591,28 @@ namespace MEDCoupling std::vector res=MEDCoupling::ReadFieldsOnSameMesh(type,fileName,meshName,meshDimRelToMax,fieldName,its); return convertFieldDoubleVecToPy(res); } - + void WriteUMeshesPartitionSwig(const std::string& fileName, const std::string& meshName, PyObject *li, bool writeFromScratch) { std::vector v; convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__MEDCouplingUMesh,"MEDCouplingUMesh",v); MEDCoupling::WriteUMeshesPartition(fileName,meshName,v,writeFromScratch); } - + void WriteUMeshesPartitionDepSwig(const std::string& fileName, const std::string& meshName, PyObject *li, bool writeFromScratch) { std::vector v; convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__MEDCouplingUMesh,"MEDCouplingUMesh",v); MEDCoupling::WriteUMeshesPartitionDep(fileName,meshName,v,writeFromScratch); } - + void WriteUMeshesSwig(const std::string& fileName, PyObject *li, bool writeFromScratch) { std::vector v; convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__MEDCouplingUMesh,"MEDCouplingUMesh",v); MEDCoupling::WriteUMeshes(fileName,v,writeFromScratch); } - + PyObject *GetTypesOfFieldSwig(const std::string& fileName, const std::string& meshName, const std::string& fieldName) { std::vector< MEDCoupling::TypeOfField > v=MEDCoupling::GetTypesOfField(fileName,meshName,fieldName); @@ -621,7 +622,7 @@ namespace MEDCoupling PyList_SetItem(ret,i,PyInt_FromLong((int)v[i])); return ret; } - + MEDCoupling::MEDCouplingUMesh *ReadUMeshFromGroupsSwig(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, PyObject *li) { std::vector grps; @@ -648,7 +649,7 @@ namespace MEDCoupling int getZipConnPolicy(); void setZipConnPolicy(int newVal); }; - + class MEDFileWritableStandAlone : public MEDFileWritable { public: @@ -674,7 +675,7 @@ namespace MEDCoupling } } }; - + class MEDFileMeshReadSelector { public: @@ -706,7 +707,7 @@ namespace MEDCoupling self->reprAll(oss); return oss.str(); } - + std::string __repr__() const { std::ostringstream oss; oss << "MEDFileMeshReadSelector C++ instance at " << self << " (with code=" << self->getCode() << ")."; @@ -759,7 +760,7 @@ namespace MEDCoupling { return self->simpleRepr(); } - + DataArrayIdType *getCorrespondence() const { const DataArrayIdType *ret(self->getCorrespondence()); @@ -802,7 +803,7 @@ namespace MEDCoupling { return self->simpleRepr(); } - + MEDFileJointCorrespondence *getCorrespondenceAtPos(int i) const { MEDFileJointCorrespondence *ret(self->getCorrespondenceAtPos(i)); @@ -847,7 +848,7 @@ namespace MEDCoupling { return MEDFileJoint::New(); } - + MEDFileJoint(const std::string& fileName, const std::string& mName, int num) { return MEDFileJoint::New(fileName,mName,num); @@ -862,7 +863,7 @@ namespace MEDCoupling { return self->simpleRepr(); } - + MEDFileJointOneStep *getStepAtPos(int i) const { MEDFileJointOneStep *ret(self->getStepAtPos(i)); @@ -899,7 +900,7 @@ namespace MEDCoupling { return MEDFileJoints::New(); } - + MEDFileJoints(const std::string& fileName, const std::string& meshName) { return MEDFileJoints::New(fileName,meshName); @@ -948,7 +949,7 @@ namespace MEDCoupling } } }; - + class MEDFileEquivalenceBase : public RefCountObject, public MEDFileWritableStandAlone { private: @@ -995,7 +996,7 @@ namespace MEDCoupling if(ret) ret->incrRef(); return ret; } - + PyObject *getTypes() const { std::vector result(self->getTypes()); @@ -1033,14 +1034,14 @@ namespace MEDCoupling if(ret) ret->incrRef(); return ret; } - + MEDFileEquivalenceCell *getCell() { MEDFileEquivalenceCell *ret(self->getCell()); if(ret) ret->incrRef(); return ret; } - + MEDFileEquivalenceNode *getNode() { MEDFileEquivalenceNode *ret(self->getNode()); @@ -1049,7 +1050,7 @@ namespace MEDCoupling } } }; - + class MEDFileEquivalences : public RefCountObject, public MEDFileWritableStandAlone { private: @@ -1269,7 +1270,7 @@ namespace MEDCoupling convertFromPyObjVectorOfObj(li,SWIGTITraits::TI,"DataArrayInt",grps); self->setGroupsAtLevel(meshDimRelToMaxExt,grps,renum); } - + PyObject *areFamsEqual(const MEDFileMesh *other) const { std::string what; @@ -1345,7 +1346,7 @@ namespace MEDCoupling tmp->incrRef(); return SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 ); } - + PyObject *getNameFieldAtLevel(int meshDimRelToMaxExt) const { const DataArrayAsciiChar *tmp=self->getNameFieldAtLevel(meshDimRelToMaxExt); @@ -1363,7 +1364,7 @@ namespace MEDCoupling PyTuple_SetItem(ret,1,SWIG_From_bool(ret1)); return ret; } - + PyObject *unPolyze() { DataArrayIdType *ret3=0; @@ -1458,7 +1459,7 @@ namespace MEDCoupling MEDFileUMesh *quadraticToLinear(double eps=1e-12) const; MEDCouplingMappedExtrudedMesh *convertToExtrudedMesh() const; %extend - { + { MEDFileUMesh(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) { return MEDFileUMesh::New(fileName,mName,dt,it,mrs); @@ -1638,7 +1639,7 @@ namespace MEDCoupling std::vector< std::pair > ret(self->getAllDistributionOfTypes()); return convertVecPairIntToPy(ret); } - + DataArrayIdType *deduceNodeSubPartFromCellSubPart(PyObject *extractDef) const { std::map > extractDefCpp; @@ -1666,7 +1667,7 @@ namespace MEDCoupling convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__MEDCouplingUMesh,"MEDCouplingUMesh",ms); self->setGroupsFromScratch(meshDimRelToMax,ms,renum); } - + void setGroupsOnSetMesh(int meshDimRelToMax, PyObject *li, bool renum=false) { std::vector ms; @@ -1700,7 +1701,7 @@ namespace MEDCoupling PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(ret2),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); return ret; } - + MEDCoupling1GTUMesh *getDirectUndergroundSingleGeoTypeMesh(INTERP_KERNEL::NormalizedCellType gt) const { MEDCoupling1GTUMesh *ret(self->getDirectUndergroundSingleGeoTypeMesh(gt)); @@ -1770,7 +1771,7 @@ namespace MEDCoupling { return MEDFileCMesh::New(db); } - + PyObject *getMesh() const { const MEDCouplingCMesh *tmp=self->getMesh(); @@ -1812,7 +1813,7 @@ namespace MEDCoupling { return MEDFileCurveLinearMesh::New(db); } - + PyObject *getMesh() const { const MEDCouplingCurveLinearMesh *tmp=self->getMesh(); @@ -1834,7 +1835,7 @@ namespace MEDCoupling void setOneTimeStep(MEDFileMesh *mesh1TimeStep); void cartesianizeMe(); %extend - { + { MEDFileMeshMultiTS() { return MEDFileMeshMultiTS::New(); @@ -1951,7 +1952,7 @@ namespace MEDCoupling { return self->getNumberOfMeshes(); } - + MEDFileMesh *getMeshAtPos(int i) const { MEDFileMesh *ret=self->getMeshAtPos(i); @@ -2046,7 +2047,7 @@ namespace MEDCoupling loc->incrRef(); return SWIG_NewPointerObj(SWIG_as_voidptr(loc),SWIGTYPE_p_MEDCoupling__MEDFileFieldLoc, SWIG_POINTER_OWN | 0 ); } - + PyObject *getLocalization(const std::string& locName) const { const MEDFileFieldLoc *loc=&self->getLocalization(locName); @@ -2054,7 +2055,7 @@ namespace MEDCoupling loc->incrRef(); return SWIG_NewPointerObj(SWIG_as_voidptr(loc),SWIGTYPE_p_MEDCoupling__MEDFileFieldLoc, SWIG_POINTER_OWN | 0 ); } - + PyObject *zipPflsNames() { std::vector< std::pair, std::string > > ret=self->zipPflsNames(); @@ -2096,7 +2097,7 @@ namespace MEDCoupling std::vector< std::pair, std::string > > v=convertVecPairVecStFromPy(li); self->changeLocsRefsNamesGen(v); } - + void changeLocsNamesInStruct(PyObject *li) { std::vector< std::pair, std::string > > v=convertVecPairVecStFromPy(li); @@ -2190,7 +2191,7 @@ namespace MEDCoupling { self->setProfileNameOnLeaf(0,typ,locId,newPflName,forceRenameOnGlob); } - + void setLocNameOnLeaf(INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob=false) { self->setLocNameOnLeaf(0,typ,locId,newLocName,forceRenameOnGlob); @@ -2201,7 +2202,7 @@ namespace MEDCoupling std::vector< std::pair > modifTab=convertVecPairStStFromPy(li); return self->changeMeshNames(modifTab); } - + PyObject *getTypesOfFieldAvailable() const { std::vector ret=self->getTypesOfFieldAvailable(); @@ -2304,6 +2305,7 @@ namespace MEDCoupling static MEDFileField1TS *New(DataArrayByte *db); static MEDFileField1TS *New(); MEDCoupling::MEDFileInt32Field1TS *convertToInt(bool isDeepCpyGlobs=true) const; + MEDCoupling::MEDFileInt64Field1TS *convertToInt64(bool isDeepCpyGlobs=true) const; void copyTimeInfoFrom(MEDCouplingFieldDouble *mcf); MEDCouplingFieldDouble *field(const MEDFileMesh *mesh) const; MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const; @@ -2323,7 +2325,7 @@ namespace MEDCoupling { return MEDFileField1TS::New(fileName,loadAll); } - + MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll=true) { return MEDFileField1TS::New(fileName,fieldName,loadAll); @@ -2343,7 +2345,7 @@ namespace MEDCoupling { return MEDFileField1TS::New(); } - + void copyTinyInfoFrom(const MEDCouplingFieldDouble *field) { const DataArrayDouble *arr=0; @@ -2351,12 +2353,12 @@ namespace MEDCoupling arr=field->getArray(); self->copyTinyInfoFrom(field,arr); } - + std::string __str__() const { return self->simpleRepr(); } - + PyObject *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh) const { return MEDFileField1TS_getFieldWithProfile(self,type,meshDimRelToMax,mesh); @@ -2467,7 +2469,7 @@ namespace MEDCoupling { return MEDFileField1TS_getFieldWithProfile(self,type,meshDimRelToMax,mesh); } - + DataArrayInt32 *getUndergroundDataArray() const { DataArrayInt32 *ret=self->getUndergroundDataArray(); @@ -2539,7 +2541,7 @@ namespace MEDCoupling { return MEDFileField1TS_getFieldWithProfile(self,type,meshDimRelToMax,mesh); } - + DataArrayInt64 *getUndergroundDataArray() const { DataArrayInt64 *ret=self->getUndergroundDataArray(); @@ -2611,7 +2613,7 @@ namespace MEDCoupling { return MEDFileField1TS_getFieldWithProfile(self,type,meshDimRelToMax,mesh); } - + DataArrayFloat *getUndergroundDataArray() const { DataArrayFloat *ret=self->getUndergroundDataArray(); @@ -2619,7 +2621,7 @@ namespace MEDCoupling ret->incrRef(); return ret; } - + PyObject *getUndergroundDataArrayExt() const { return MEDFileField1TS_getUndergroundDataArrayExt(self); @@ -2717,13 +2719,13 @@ namespace MEDCoupling else throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::__getitem__ : invalid input params ! expected fmts[int], fmts[int,int] or fmts[double] to request time step !"); } - + PyObject *getIterations() const { std::vector< std::pair > res(self->getIterations()); return convertVecPairIntToPy(res); } - + PyObject *getTimeSteps() const { std::vector ret1; @@ -2740,7 +2742,7 @@ namespace MEDCoupling } return ret2; } - + PyObject *getTypesOfFieldAvailable() const { std::vector< std::vector > ret=self->getTypesOfFieldAvailable(); @@ -2755,7 +2757,7 @@ namespace MEDCoupling } return ret2; } - + PyObject *getNonEmptyLevels(int iteration, int order, const std::string& mname=std::string()) const { std::vector ret1; @@ -2765,7 +2767,7 @@ namespace MEDCoupling PyTuple_SetItem(elt,1,convertIntArrToPyList2(ret1)); return elt; } - + PyObject *getFieldSplitedByType(int iteration, int order, const std::string& mname=std::string()) const { std::vector types; @@ -2821,7 +2823,7 @@ namespace MEDCoupling return ret; } } - + void __delitem__(PyObject *elts) { if(PySlice_Check(elts)) @@ -2837,7 +2839,7 @@ namespace MEDCoupling self->eraseTimeStepIds(&idsToRemove[0],&idsToRemove[0]+idsToRemove.size()); } } - + void eraseTimeStepIds(PyObject *li) { mcIdType sw; @@ -2980,7 +2982,7 @@ namespace MEDCoupling } return retPy; } - + static PyObject *MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(PyObject *li, const MEDFileMesh *mesh) { std::vector vectFMTS; @@ -3017,7 +3019,7 @@ namespace MEDCoupling class MEDFileInt32FieldMultiTS; class MEDFileInt64FieldMultiTS; - + class MEDFileFieldMultiTS : public MEDFileAnyTypeFieldMultiTS { public: @@ -3063,7 +3065,7 @@ namespace MEDCoupling { return MEDFileFieldMultiTS::New(fileName,fieldName,loadAll); } - + MEDFileFieldMultiTS(DataArrayByte *db) { return MEDFileFieldMultiTS::New(db); @@ -3081,7 +3083,7 @@ namespace MEDCoupling } return MEDFileFieldMultiTS::LoadSpecificEntities(fileName,fieldName,entitiesCpp,loadAll); } - + std::string __str__() const { return self->simpleRepr(); @@ -3137,7 +3139,7 @@ namespace MEDCoupling ret->incrRef(); return ret; } - + PyObject *getUndergroundDataArrayExt(int iteration, int order) const { std::vector< std::pair,std::pair > > elt1Cpp; @@ -3209,12 +3211,12 @@ namespace MEDCoupling { return MEDFileInt32FieldMultiTS::New(); } - + MEDFileInt32FieldMultiTS(const std::string& fileName, bool loadAll=true) { return MEDFileInt32FieldMultiTS::New(fileName,loadAll); } - + MEDFileInt32FieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll=true) { return MEDFileInt32FieldMultiTS::New(fileName,fieldName,loadAll); @@ -3224,7 +3226,7 @@ namespace MEDCoupling { return MEDFileInt32FieldMultiTS::New(db); } - + static MEDFileInt32FieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, PyObject *entities, bool loadAll=true) { std::vector > tmp(convertTimePairIdsFromPy(entities)); @@ -3280,12 +3282,12 @@ namespace MEDCoupling { return MEDFileInt64FieldMultiTS::New(); } - + MEDFileInt64FieldMultiTS(const std::string& fileName, bool loadAll=true) { return MEDFileInt64FieldMultiTS::New(fileName,loadAll); } - + MEDFileInt64FieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll=true) { return MEDFileInt64FieldMultiTS::New(fileName,fieldName,loadAll); @@ -3295,7 +3297,7 @@ namespace MEDCoupling { return MEDFileInt64FieldMultiTS::New(db); } - + static MEDFileInt64FieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, PyObject *entities, bool loadAll=true) { std::vector > tmp(convertTimePairIdsFromPy(entities)); @@ -3351,12 +3353,12 @@ namespace MEDCoupling { return MEDFileFloatFieldMultiTS::New(); } - + MEDFileFloatFieldMultiTS(const std::string& fileName, bool loadAll=true) { return MEDFileFloatFieldMultiTS::New(fileName,loadAll); } - + MEDFileFloatFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll=true) { return MEDFileFloatFieldMultiTS::New(fileName,fieldName,loadAll); @@ -3366,7 +3368,7 @@ namespace MEDCoupling { return MEDFileFloatFieldMultiTS::New(db); } - + static MEDFileFloatFieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, PyObject *entities, bool loadAll=true) { std::vector > tmp(convertTimePairIdsFromPy(entities)); @@ -3398,7 +3400,7 @@ namespace MEDCoupling } } }; - + class MEDFileMeshSupports : public RefCountObject, public MEDFileWritableStandAlone { public: @@ -3416,7 +3418,7 @@ namespace MEDCoupling } } }; - + class MEDFileStructureElements : public RefCountObject, public MEDFileWritableStandAlone { public: @@ -3480,12 +3482,12 @@ namespace MEDCoupling { return MEDFileFields::NewAdv(fileName,loadAll,entities); } - + std::string __str__() const { return self->simpleRepr(); } - + MEDFileFields *partOfThisOnStructureElements() const { MCAuto ret(self->partOfThisOnStructureElements()); @@ -3497,7 +3499,7 @@ namespace MEDCoupling MCAuto ret(self->partOfThisLyingOnSpecifiedMeshSEName(meshName,seName)); return ret.retn(); } - + static MEDFileFields *LoadSpecificEntities(const std::string& fileName, PyObject *entities, bool loadAll=true) { std::vector > tmp(convertTimePairIdsFromPy(entities)); @@ -3549,7 +3551,7 @@ namespace MEDCoupling std::vector< std::pair > ts=convertTimePairIdsFromPy(timeSteps); return self->partOfThisNotLyingOnSpecifiedTimeSteps(ts); } - + PyObject *__getitem__(PyObject *obj) { if(obj && PyList_Check(obj)) @@ -3583,7 +3585,7 @@ namespace MEDCoupling { return self->iterator(); } - + bool changeMeshNames(PyObject *li) { std::vector< std::pair > modifTab=convertVecPairStStFromPy(li); @@ -3601,7 +3603,7 @@ namespace MEDCoupling } return self->getPosFromFieldName(convertPyObjectToStr(elt0,msg)); } - + std::vector getPosOfFields(PyObject *elts) const { if(PyList_Check(elts)) @@ -3629,7 +3631,7 @@ namespace MEDCoupling convertFromPyObjVectorOfObj(fields,SWIGTYPE_p_MEDCoupling__MEDFileAnyTypeFieldMultiTS,"MEDFileAnyTypeFieldMultiTS",tmp); self->pushFields(tmp); } - + void __delitem__(PyObject *elts) { if(elts && PySlice_Check(elts)) @@ -3716,7 +3718,7 @@ namespace MEDCoupling { return MEDFileParameterDouble1TS::New(); } - + MEDFileParameterDouble1TS(const std::string& fileName) { return MEDFileParameterDouble1TS::New(fileName); @@ -3773,7 +3775,7 @@ namespace MEDCoupling { return MEDFileParameterMultiTS::New(); } - + MEDFileParameterMultiTS(const std::string& fileName) { return MEDFileParameterMultiTS::New(fileName); @@ -3788,7 +3790,7 @@ namespace MEDCoupling { return self->simpleRepr(); } - + PyObject *isEqual(const MEDFileParameterMultiTS *other, double eps) const { std::string what; @@ -3800,7 +3802,7 @@ namespace MEDCoupling PyList_SetItem(res,1,PyString_FromString(what.c_str())); return res; } - + void eraseTimeStepIds(PyObject *ids) { mcIdType sw; @@ -3902,7 +3904,7 @@ namespace MEDCoupling if(!idsToRemove.empty()) self->eraseTimeStepIds(&idsToRemove[0],&idsToRemove[0]+idsToRemove.size()); } - + MEDFileParameter1TS *getTimeStepAtPos(int posId) const { MEDFileParameter1TS *ret=self->getTimeStepAtPos(posId); @@ -3966,7 +3968,7 @@ namespace MEDCoupling { return MEDFileParameters::New(); } - + MEDFileParameters(const std::string& fileName) { return MEDFileParameters::New(fileName); @@ -3976,7 +3978,7 @@ namespace MEDCoupling { return MEDFileParameters::New(db); } - + std::string __str__() const { return self->simpleRepr(); @@ -4002,7 +4004,7 @@ namespace MEDCoupling { return self->getNumberOfParams(); } - + MEDFileParameterMultiTS *getParamAtPos(int i) const { MEDFileParameterMultiTS *ret=self->getParamAtPos(i); @@ -4018,7 +4020,7 @@ namespace MEDCoupling ret->incrRef(); return ret; } - + PyObject *isEqual(const MEDFileParameters *other, double eps) const { std::string what; @@ -4145,7 +4147,7 @@ namespace MEDCoupling } } }; - + /////////////// class MEDFileMeshStruct; @@ -4163,7 +4165,7 @@ namespace MEDCoupling protected: ~MEDFileMeshStruct(); }; - + class MEDMeshMultiLev : public RefCountObject { public: @@ -4200,7 +4202,7 @@ namespace MEDCoupling PyTuple_SetItem(ret,1,ret1Py); return ret; } - + PyObject *retrieveFamilyIdsOnNodes() const { DataArrayIdType *famIds(0); @@ -4347,7 +4349,7 @@ namespace MEDCoupling } } }; - + class MeshFormatReader { public: @@ -4372,7 +4374,7 @@ namespace MEDCoupling void setMEDFileDS(MEDCoupling::MEDFileData* mfd); void write(); }; - + } %pythoncode %{ diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index 38d8614cd..1c80c68f9 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -3158,8 +3158,16 @@ class MEDLoaderTest3(unittest.TestCase): ff1=ff0i.convertToDouble() self.assertTrue(ff1.getUndergroundDataArray().isEqual(ff0.getUndergroundDataArray(),1e-13)) self.assertEqual(ff1.getFieldSplitedByType(),fspExp) + # For int64 + ff0i64=ff0.convertToInt64() + self.assertEqual(ff0i64.getFieldSplitedByType(),fspExp) + self.assertTrue(arr.convertToInt64Arr().isEqual(ff0i64.getUndergroundDataArray())) + # + ff2=ff0i64.convertToDouble() + self.assertTrue(ff2.getUndergroundDataArray().isEqual(ff0.getUndergroundDataArray(),1e-13)) + self.assertEqual(ff2.getFieldSplitedByType(),fspExp) # With profiles - del arr,f0,ff0,ff1,ff0i,fspExp + del arr,f0,ff0,ff1,ff2,ff0i,ff0i64,fspExp ff0=MEDFileField1TS() f0=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME) ; f0.setMesh(m[:7]) ; arr=DataArrayDouble(7*2) ; arr.iota() ; arr.rearrange(2) ; arr.setInfoOnComponents(["XX [pm]","YYY [hm]"]) ; f0.setArray(arr) ; f0.setName("FieldCellPfl") f0.checkConsistencyLight() @@ -3177,6 +3185,16 @@ class MEDLoaderTest3(unittest.TestCase): self.assertTrue(isinstance(ff1,MEDFileField1TS)) self.assertTrue(ff1.getUndergroundDataArray().isEqual(ff0.getUndergroundDataArray(),1e-13)) self.assertEqual(ff1.getFieldSplitedByType(),fspExp) + # For Int64 + ff0i64=ff0.convertToInt64() + self.assertTrue(isinstance(ff0i64,MEDFileInt64Field1TS)) + self.assertEqual(ff0i64.getFieldSplitedByType(),fspExp) + self.assertTrue(arr.convertToInt64Arr().isEqual(ff0i64.getUndergroundDataArray())) + # + ff2=ff0i64.convertToDouble() + self.assertTrue(isinstance(ff2,MEDFileField1TS)) + self.assertTrue(ff2.getUndergroundDataArray().isEqual(ff0.getUndergroundDataArray(),1e-13)) + self.assertEqual(ff2.getFieldSplitedByType(),fspExp) ## MultiTimeSteps ff0=MEDFileFieldMultiTS() f0=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME) ; f0.setMesh(m[:7]) ; arr=DataArrayDouble(7*2) ; arr.iota() ; arr.rearrange(2) ; arr.setInfoOnComponents(["X [km]","YY [mm]"]) ; f0.setArray(arr) ; f0.setName("FieldCellMTime") ; f0.setTime(0.1,0,10) -- 2.39.2