-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2024 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// Author : Anthony Geay (CEA/DEN)
+// Author : Anthony Geay (EDF R&D)
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingFieldTemplate.hxx"
#include "MEDCouplingFieldT.txx"
-#include "MEDCouplingFieldInt.hxx"
+#include "MEDCouplingFieldInt32.hxx"
+#include "MEDCouplingFieldInt64.hxx"
+#include "MEDCouplingFieldFloat.hxx"
#include "MEDCouplingUMesh.hxx"
#include "MEDCouplingTimeDiscretization.hxx"
#include "MEDCouplingFieldDiscretization.hxx"
#include "MCAuto.txx"
#include "MEDCouplingVoronoi.hxx"
#include "MEDCouplingNatureOfField.hxx"
+#include "MEDCouplingMemArray.txx"
#include "InterpKernelAutoPtr.hxx"
#include "InterpKernelGaussCoords.hxx"
* 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)
{
/*!
* 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
* \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)
{
/*!
* 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.
*/
* - \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
* 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] deepCopy - if \c true, the copy of the underlying data arrays is
+ * \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."<br>
* \ref py_mcfielddouble_buildNewTimeReprFromThis "Here is a Python example."
* \endif
* \sa clone()
*/
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCopy) const
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCpy) const
{
- MEDCouplingTimeDiscretization *tdo=timeDiscr()->buildNewTimeReprFromThis(td,deepCopy);
+ MEDCouplingTimeDiscretization *tdo=timeDiscr()->buildNewTimeReprFromThis(td,deepCpy);
MCAuto<MEDCouplingFieldDiscretization> disc;
if(_type)
disc=_type->clone();
}
/*!
- * This method converts a field on nodes (\a this) to a cell field (returned field). The convertion is a \b non \b conservative remapping !
- * This method is useful only for users that need a fast convertion from node to cell spatial discretization. The algorithm applied is simply to attach
+ * This method converts a field on nodes (\a this) to a cell field (returned field). The conversion is a \b non \b conservative remapping !
+ * This method is useful only for users that need a fast conversion from node to cell spatial discretization. The algorithm applied is simply to attach
* to each cell the average of values on nodes constituting this cell.
*
* \return MEDCouplingFieldDouble* - a new instance of MEDCouplingFieldDouble. The
* 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.
*/
MCAuto<MEDCouplingFieldDiscretizationP0> nsp(new MEDCouplingFieldDiscretizationP0);
ret->setDiscretization(nsp);
const MEDCouplingMesh *m(getMesh());//m is non empty thanks to checkConsistencyLight call
- int nbCells(m->getNumberOfCells());
+ mcIdType nbCells=ToIdType(m->getNumberOfCells());
std::vector<DataArrayDouble *> arrs(getArrays());
std::size_t sz(arrs.size());
std::vector< MCAuto<DataArrayDouble> > outArrsSafe(sz); std::vector<DataArrayDouble *> outArrs(sz);
for(std::size_t j=0;j<sz;j++)
{
- int nbCompo(arrs[j]->getNumberOfComponents());
+ std::size_t nbCompo(arrs[j]->getNumberOfComponents());
outArrsSafe[j]=DataArrayDouble::New(); outArrsSafe[j]->alloc(nbCells,nbCompo);
outArrsSafe[j]->copyStringInfoFrom(*arrs[j]);
outArrs[j]=outArrsSafe[j];
double *pt(outArrsSafe[j]->getPointer());
const double *srcPt(arrs[j]->begin());
- for(int i=0;i<nbCells;i++,pt+=nbCompo)
+ for(mcIdType i=0;i<nbCells;i++,pt+=nbCompo)
{
- std::vector<int> nodeIds;
+ std::vector<mcIdType> nodeIds;
m->getNodeIdsOfCell(i,nodeIds);
std::fill(pt,pt+nbCompo,0.);
std::size_t nbNodesInCell(nodeIds.size());
for(std::size_t k=0;k<nbNodesInCell;k++)
std::transform(srcPt+nodeIds[k]*nbCompo,srcPt+(nodeIds[k]+1)*nbCompo,pt,pt,std::plus<double>());
if(nbNodesInCell!=0)
- std::transform(pt,pt+nbCompo,pt,std::bind2nd(std::multiplies<double>(),1./((double)nbNodesInCell)));
+ std::transform(pt,pt+nbCompo,pt,std::bind(std::multiplies<double>(),std::placeholders::_1,1./((double)nbNodesInCell)));
else
{
std::ostringstream oss; oss << "MEDCouplingFieldDouble::nodeToCellDiscretization : Cell id #" << i << " has been detected to have no nodes !";
}
/*!
- * This method converts a field on cell (\a this) to a node field (returned field). The convertion is a \b non \b conservative remapping !
- * This method is useful only for users that need a fast convertion from cell to node spatial discretization. The algorithm applied is simply to attach
+ * This method converts a field on cell (\a this) to a node field (returned field). The conversion is a \b non \b conservative remapping !
+ * This method is useful only for users that need a fast conversion from cell to node spatial discretization. The algorithm applied is simply to attach
* to each node the average of values on cell sharing this node. If \a this lies on a mesh having orphan nodes the values applied on them will be NaN (division by 0.).
*
* \return MEDCouplingFieldDouble* - a new instance of MEDCouplingFieldDouble. The
MCAuto<MEDCouplingFieldDiscretizationP1> nsp(new MEDCouplingFieldDiscretizationP1);
ret->setDiscretization(nsp);
const MEDCouplingMesh *m(getMesh());//m is non empty thanks to checkConsistencyLight call
- MCAuto<DataArrayInt> rn(DataArrayInt::New()),rni(DataArrayInt::New());
+ MCAuto<DataArrayIdType> rn(DataArrayIdType::New()),rni(DataArrayIdType::New());
m->getReverseNodalConnectivity(rn,rni);
- MCAuto<DataArrayInt> rni2(rni->deltaShiftIndex());
+ MCAuto<DataArrayIdType> rni2(rni->deltaShiftIndex());
MCAuto<DataArrayDouble> rni3(rni2->convertToDblArr()); rni2=0;
std::vector<DataArrayDouble *> arrs(getArrays());
std::size_t sz(arrs.size());
return true;
}
-/*!
- * Permutes values of \a this field according to a given permutation array for cells
- * renumbering. The underlying mesh is deeply copied and its cells are also permuted.
- * The number of cells remains the same; for that the permutation array \a old2NewBg
- * should not contain equal ids.
- * ** Warning, this method modifies the mesh aggreagated by \a this (by performing a deep copy ) **.
- *
- * \param [in] old2NewBg - the permutation array in "Old to New" mode. Its length is
- * to be equal to \a this->getMesh()->getNumberOfCells().
- * \param [in] check - if \c true, \a old2NewBg is transformed to a new permutation
- * array, so that its maximal cell id to correspond to (be less than) the number
- * of cells in mesh. This new array is then used for the renumbering. If \a
- * check == \c false, \a old2NewBg is used as is, that is less secure as validity
- * of ids in \a old2NewBg is not checked.
- * \throw If the mesh is not set.
- * \throw If the spatial discretization of \a this field is NULL.
- * \throw If \a check == \c true and \a old2NewBg contains equal ids.
- * \throw If mesh nature does not allow renumbering (e.g. structured mesh).
- *
- * \if ENABLE_EXAMPLES
- * \ref cpp_mcfielddouble_renumberCells "Here is a C++ example".<br>
- * \ref py_mcfielddouble_renumberCells "Here is a Python example".
- * \endif
- */
-void MEDCouplingFieldDouble::renumberCells(const int *old2NewBg, bool check)
-{
- renumberCellsWithoutMesh(old2NewBg,check);
- MCAuto<MEDCouplingMesh> m=_mesh->deepCopy();
- m->renumberCells(old2NewBg,check);
- setMesh(m);
- updateTime();
-}
-
-/*!
- * Permutes values of \a this field according to a given permutation array for cells
- * renumbering. The underlying mesh is \b not permuted.
- * The number of cells remains the same; for that the permutation array \a old2NewBg
- * should not contain equal ids.
- * This method performs a part of job of renumberCells(). 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.
- * \warning Use this method with a lot of care!
- * \param [in] old2NewBg - the permutation array in "Old to New" mode. Its length is
- * to be equal to \a this->getMesh()->getNumberOfCells().
- * \param [in] check - if \c true, \a old2NewBg is transformed to a new permutation
- * array, so that its maximal cell id to correspond to (be less than) the number
- * of cells in mesh. This new array is then used for the renumbering. If \a
- * check == \c false, \a old2NewBg is used as is, that is less secure as validity
- * of ids in \a old2NewBg is not checked.
- * \throw If the mesh is not set.
- * \throw If the spatial discretization of \a this field is NULL.
- * \throw If \a check == \c true and \a old2NewBg contains equal ids.
- * \throw If mesh nature does not allow renumbering (e.g. structured mesh).
- */
-void MEDCouplingFieldDouble::renumberCellsWithoutMesh(const int *old2NewBg, bool check)
-{
- if(!_mesh)
- throw INTERP_KERNEL::Exception("Expecting a defined mesh to be able to operate a renumbering !");
- if(_type.isNull())
- throw INTERP_KERNEL::Exception("Expecting a spatial discretization to be able to operate a renumbering !");
- //
- _type->renumberCells(old2NewBg,check);
- std::vector<DataArrayDouble *> arrays;
- timeDiscr()->getArrays(arrays);
- std::vector<DataArray *> arrays2(arrays.size()); std::copy(arrays.begin(),arrays.end(),arrays2.begin());
- _type->renumberArraysForCell(_mesh,arrays2,old2NewBg,check);
- //
- updateTime();
-}
-
/*!
* 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().
* \throw If the spatial discretization of \a this field is NULL.
* \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 deffer more than \a eps.
- *
+ * \throw If values at merged nodes differ more than \a eps.
+ *
* \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_renumberNodes "Here is a C++ example".<br>
* \ref py_mcfielddouble_renumberNodes "Here is a Python example".
* \endif
*/
-void MEDCouplingFieldDouble::renumberNodes(const int *old2NewBg, double eps)
+void MEDCouplingFieldDouble::renumberNodes(const mcIdType *old2NewBg, double eps)
{
const MEDCouplingPointSet *meshC=dynamic_cast<const MEDCouplingPointSet *>(_mesh);
if(!meshC)
throw INTERP_KERNEL::Exception("Invalid mesh to apply renumberNodes on it !");
- int nbOfNodes=meshC->getNumberOfNodes();
+ mcIdType nbOfNodes=meshC->getNumberOfNodes();
MCAuto<MEDCouplingPointSet> meshC2((MEDCouplingPointSet *)meshC->deepCopy());
- int newNbOfNodes=*std::max_element(old2NewBg,old2NewBg+nbOfNodes)+1;
+ mcIdType newNbOfNodes=*std::max_element(old2NewBg,old2NewBg+nbOfNodes)+1;
renumberNodesWithoutMesh(old2NewBg,newNbOfNodes,eps);
meshC2->renumberNodes(old2NewBg,newNbOfNodes);
setMesh(meshC2);
/*!
* 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.
* the values differ more than \a eps, an exception is thrown.
* \throw If the mesh is not set.
* \throw If the spatial discretization of \a this field is NULL.
- * \throw If values at merged nodes deffer more than \a eps.
+ * \throw If values at merged nodes differ more than \a eps.
*/
-void MEDCouplingFieldDouble::renumberNodesWithoutMesh(const int *old2NewBg, int newNbOfNodes, double eps)
+void MEDCouplingFieldDouble::renumberNodesWithoutMesh(const mcIdType *old2NewBg, mcIdType newNbOfNodes, double eps)
{
if(_type.isNull())
throw INTERP_KERNEL::Exception("Expecting a spatial discretization to be able to operate a renumbering !");
* vmin are not included in the result array.
* \param [in] vmax - an upper boundary of the range. Tuples with values more than \a
* vmax are not included in the result array.
- * \return DataArrayInt * - a new instance of DataArrayInt holding ids of selected
+ * \return DataArrayIdType * - a new instance of DataArrayIdType holding ids of selected
* tuples. The caller is to delete this array using decrRef() as it is no
* more needed.
* \throw If the data array is not set.
* \throw If \a this->getNumberOfComponents() != 1.
*/
-DataArrayInt *MEDCouplingFieldDouble::findIdsInRange(double vmin, double vmax) const
+DataArrayIdType *MEDCouplingFieldDouble::findIdsInRange(double vmin, double vmax) const
{
if(getArray()==0)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::findIdsInRange : no default array set !");
return getArray()->findIdsInRange(vmin,vmax);
}
-/*!
- * Builds a newly created field, that the caller will have the responsability to deal with (decrRef()).
- * This method makes the assumption that the field is correctly defined when this method is called, no check of this will be done.
- * This method returns a restriction of \a this so that only tuples with ids specified in \a part will be contained in the returned field.
- * Parameter \a part specifies **cell ids whatever the spatial discretization of this** (
- * \ref MEDCoupling::ON_CELLS "ON_CELLS",
- * \ref MEDCoupling::ON_NODES "ON_NODES",
- * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
- * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE",
- * \ref MEDCoupling::ON_NODES_KR "ON_NODES_KR").
- *
- * For example, \a this is a field on cells lying on a mesh that have 10 cells, \a part contains following cell ids [3,7,6].
- * Then the returned field will lie on mesh having 3 cells and the returned field will contain 3 tuples.<br>
- * Tuple #0 of the result field will refer to the cell #0 of returned mesh. The cell #0 of returned mesh will be equal to the cell #3 of \a this->getMesh().<br>
- * Tuple #1 of the result field will refer to the cell #1 of returned mesh. The cell #1 of returned mesh will be equal to the cell #7 of \a this->getMesh().<br>
- * Tuple #2 of the result field will refer to the cell #2 of returned mesh. The cell #2 of returned mesh will be equal to the cell #6 of \a this->getMesh().
- *
- * Let, for example, \a this be a field on nodes lying on a mesh that have 10 cells and 11 nodes, and \a part contains following cellIds [3,7,6].
- * Thus \a this currently contains 11 tuples. If the restriction of mesh to 3 cells leads to a mesh with 6 nodes, then the returned field
- * will contain 6 tuples and \a this field will lie on this restricted mesh.
- *
- * \param [in] part - an array of cell ids to include to the result field.
- * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The caller is to delete this field using decrRef() as it is no more needed.
- *
- * \if ENABLE_EXAMPLES
- * \ref cpp_mcfielddouble_subpart1 "Here is a C++ example".<br>
- * \ref py_mcfielddouble_subpart1 "Here is a Python example".
- * \endif
- * \sa MEDCouplingFieldDouble::buildSubPartRange
- */
-
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildSubPart(const DataArrayInt *part) const
-{
- if(part==0)
- throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::buildSubPart : not empty array must be passed to this method !");
- return buildSubPart(part->begin(),part->end());
-}
-
-/*!
- * Builds a newly created field, that the caller will have the responsability to deal with.
- * \n This method makes the assumption that \a this field is correctly defined when this method is called (\a this->checkConsistencyLight() returns without any exception thrown), **no check of this will be done**.
- * \n This method returns a restriction of \a this so that only tuple ids specified in [ \a partBg , \a partEnd ) will be contained in the returned field.
- * \n Parameter [\a partBg, \a partEnd ) specifies **cell ids whatever the spatial discretization** of \a this (
- * \ref MEDCoupling::ON_CELLS "ON_CELLS",
- * \ref MEDCoupling::ON_NODES "ON_NODES",
- * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
- * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE",
- * \ref MEDCoupling::ON_NODES_KR "ON_NODES_KR").
- *
- * For example, \a this is a field on cells lying on a mesh that have 10 cells, \a partBg contains the following cell ids [3,7,6].
- * Then the returned field will lie on mesh having 3 cells and will contain 3 tuples.
- *- Tuple #0 of the result field will refer to the cell #0 of returned mesh. The cell #0 of returned mesh will be equal to the cell #3 of \a this->getMesh().
- *- Tuple #1 of the result field will refer to the cell #1 of returned mesh. The cell #1 of returned mesh will be equal to the cell #7 of \a this->getMesh().
- *- Tuple #2 of the result field will refer to the cell #2 of returned mesh. The cell #2 of returned mesh will be equal to the cell #6 of \a this->getMesh().
- *
- * Let, for example, \a this be a field on nodes lying on a mesh that have 10 cells and 11 nodes, and \a partBg contains following cellIds [3,7,6].
- * Thus \a this currently contains 11 tuples. If the restriction of mesh to 3 cells leads to a mesh with 6 nodes, then the returned field
- * will contain 6 tuples and \a this field will lie on this restricted mesh.
- *
- * \param [in] partBg - start (included) of input range of cell ids to select [ \a partBg, \a partEnd )
- * \param [in] partEnd - end (not included) of input range of cell ids to select [ \a partBg, \a partEnd )
- * \return a newly allocated field the caller should deal with.
- *
- * \throw if there is presence of an invalid cell id in [ \a partBg, \a partEnd ) regarding the number of cells of \a this->getMesh().
- *
- * \if ENABLE_EXAMPLES
- * \ref cpp_mcfielddouble_subpart1 "Here a C++ example."<br>
- * \ref py_mcfielddouble_subpart1 "Here a Python example."
- * \endif
- * \sa MEDCoupling::MEDCouplingFieldDouble::buildSubPart(const DataArrayInt *) const, MEDCouplingFieldDouble::buildSubPartRange
- */
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildSubPart(const int *partBg, const int *partEnd) const
+template<class U>
+typename Traits<U>::FieldType *ConvertToUField(const MEDCouplingFieldDouble *self)
{
- if(_type.isNull())
- throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::buildSubPart : Expecting a not NULL spatial discretization !");
- DataArrayInt *arrSelect;
- MCAuto<MEDCouplingMesh> m=_type->buildSubMeshData(_mesh,partBg,partEnd,arrSelect);
- MCAuto<DataArrayInt> arrSelect2(arrSelect);
- MCAuto<MEDCouplingFieldDouble> ret(clone(false));//quick shallow copy.
- const MEDCouplingFieldDiscretization *disc=getDiscretization();
- if(disc)
- ret->setDiscretization(MCAuto<MEDCouplingFieldDiscretization>(disc->clonePart(partBg,partEnd)));
- ret->setMesh(m);
- std::vector<DataArrayDouble *> arrays;
- timeDiscr()->getArrays(arrays);
- std::vector<DataArrayDouble *> arrs;
- std::vector< MCAuto<DataArrayDouble> > arrsSafe;
- const int *arrSelBg=arrSelect->begin();
- const int *arrSelEnd=arrSelect->end();
- for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
+ MCAuto<MEDCouplingFieldTemplate> tmp(MEDCouplingFieldTemplate::New(*self));
+ int t1,t2;
+ double t0(self->getTime(t1,t2));
+ MCAuto<typename Traits<U>::FieldType > ret(Traits<U>::FieldType::New(*tmp,self->getTimeDiscretization()));
+ ret->setTime(t0,t1,t2);
+ if(self->getArray())
{
- DataArrayDouble *arr=0;
- if(*iter)
- arr=(*iter)->selectByTupleIdSafe(arrSelBg,arrSelEnd);
- arrs.push_back(arr); arrsSafe.push_back(arr);
+ MCAuto<typename Traits<U>::ArrayType> arr(self->getArray()->convertToOtherTypeOfArr<U>());
+ ret->setArray(arr);
}
- ret->timeDiscr()->setArrays(arrs,0);
return ret.retn();
}
-/*!
- * This method is equivalent to MEDCouplingFieldDouble::buildSubPart, the only difference is that the input range of cell ids is
- * given using a range given \a begin, \a end and \a step to optimize the part computation.
- *
- * \sa MEDCouplingFieldDouble::buildSubPart
- */
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildSubPartRange(int begin, int end, int step) const
+MEDCouplingFieldInt32 *MEDCouplingFieldDouble::convertToIntField() const
{
- if(_type.isNull())
- throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::buildSubPart : Expecting a not NULL spatial discretization !");
- DataArrayInt *arrSelect;
- int beginOut,endOut,stepOut;
- MCAuto<MEDCouplingMesh> m(_type->buildSubMeshDataRange(_mesh,begin,end,step,beginOut,endOut,stepOut,arrSelect));
- MCAuto<DataArrayInt> arrSelect2(arrSelect);
- MCAuto<MEDCouplingFieldDouble> ret(clone(false));//quick shallow copy.
- const MEDCouplingFieldDiscretization *disc=getDiscretization();
- if(disc)
- ret->setDiscretization(MCAuto<MEDCouplingFieldDiscretization>(disc->clonePartRange(begin,end,step)));
- ret->setMesh(m);
- std::vector<DataArrayDouble *> arrays;
- timeDiscr()->getArrays(arrays);
- std::vector<DataArrayDouble *> arrs;
- std::vector< MCAuto<DataArrayDouble> > arrsSafe;
- for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
- {
- DataArrayDouble *arr=0;
- if(*iter)
- {
- if(arrSelect)
- {
- const int *arrSelBg=arrSelect->begin();
- const int *arrSelEnd=arrSelect->end();
- arr=(*iter)->selectByTupleIdSafe(arrSelBg,arrSelEnd);
- }
- else
- arr=(*iter)->selectByTupleIdSafeSlice(beginOut,endOut,stepOut);
- }
- arrs.push_back(arr); arrsSafe.push_back(arr);
- }
- ret->timeDiscr()->setArrays(arrs,0);
- return ret.retn();
+ return ConvertToUField<int>(this);
}
-
-MEDCouplingFieldInt *MEDCouplingFieldDouble::convertToIntField() const
+MEDCouplingFieldInt64 *MEDCouplingFieldDouble::convertToInt64Field() const
{
- MCAuto<MEDCouplingFieldTemplate> tmp(MEDCouplingFieldTemplate::New(*this));
- int t1,t2;
- double t0(getTime(t1,t2));
- MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*tmp,getTimeDiscretization()));
- ret->setTime(t0,t1,t2);
- if(getArray())
- {
- MCAuto<DataArrayInt> arr(getArray()->convertToIntArr());
- ret->setArray(arr);
- }
- return ret.retn();
+ return ConvertToUField<Int64>(this);
+}
+MEDCouplingFieldFloat *MEDCouplingFieldDouble::convertToFloatField() const
+{
+ return ConvertToUField<float>(this);
}
MEDCouplingFieldDouble::MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingFieldT<double>(type,MEDCouplingTimeDiscretization::New(td))
{
}
-MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCopy):MEDCouplingFieldT<double>(other,deepCopy)
+MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCpy):MEDCouplingFieldT<double>(other,deepCpy)
{
}
/*!
* 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.
if(*iter)
{
isExistingArr=true;
- int loc;
+ mcIdType loc;
ret=std::max(ret,(*iter)->getMaxValue(loc));
}
}
/*!
* Returns the maximal value and all its locations within \a this scalar field.
* Only the first of available data arrays is checked.
- * \param [out] tupleIds - a new instance of DataArrayInt containg indices of
+ * \param [out] tupleIds - a new instance of DataArrayIdType containing indices of
* tuples holding the maximal value. The caller is to delete it using
* decrRef() as it is no more needed.
* \return double - the maximal value among all values of the first array of \a this filed.
* \throw If \a this->getNumberOfComponents() != 1.
* \throw If there is an empty data array in \a this field.
*/
-double MEDCouplingFieldDouble::getMaxValue2(DataArrayInt*& tupleIds) const
+double MEDCouplingFieldDouble::getMaxValue2(DataArrayIdType*& tupleIds) const
{
std::vector<DataArrayDouble *> arrays;
timeDiscr()->getArrays(arrays);
double ret(-std::numeric_limits<double>::max());
bool isExistingArr=false;
tupleIds=0;
- MCAuto<DataArrayInt> ret1;
+ MCAuto<DataArrayIdType> ret1;
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
{
if(*iter)
{
isExistingArr=true;
- DataArrayInt *tmp;
+ DataArrayIdType *tmp;
ret=std::max(ret,(*iter)->getMaxValue2(tmp));
- MCAuto<DataArrayInt> tmpSafe(tmp);
- if(!((const DataArrayInt *)ret1))
+ MCAuto<DataArrayIdType> tmpSafe(tmp);
+ if(!((const DataArrayIdType *)ret1))
ret1=tmpSafe;
}
}
if(*iter)
{
isExistingArr=true;
- int loc;
+ mcIdType loc;
ret=std::min(ret,(*iter)->getMinValue(loc));
}
}
/*!
* Returns the minimal value and all its locations within \a this scalar field.
* Only the first of available data arrays is checked.
- * \param [out] tupleIds - a new instance of DataArrayInt containg indices of
+ * \param [out] tupleIds - a new instance of DataArrayIdType containing indices of
* tuples holding the minimal value. The caller is to delete it using
* decrRef() as it is no more needed.
* \return double - the minimal value among all values of the first array of \a this filed.
* \throw If \a this->getNumberOfComponents() != 1.
* \throw If there is an empty data array in \a this field.
*/
-double MEDCouplingFieldDouble::getMinValue2(DataArrayInt*& tupleIds) const
+double MEDCouplingFieldDouble::getMinValue2(DataArrayIdType*& tupleIds) const
{
std::vector<DataArrayDouble *> arrays;
timeDiscr()->getArrays(arrays);
double ret(-std::numeric_limits<double>::max());
bool isExistingArr=false;
tupleIds=0;
- MCAuto<DataArrayInt> ret1;
+ MCAuto<DataArrayIdType> ret1;
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
{
if(*iter)
{
isExistingArr=true;
- DataArrayInt *tmp;
+ DataArrayIdType *tmp;
ret=std::max(ret,(*iter)->getMinValue2(tmp));
- MCAuto<DataArrayInt> tmpSafe(tmp);
- if(!((const DataArrayInt *)ret1))
+ MCAuto<DataArrayIdType> tmpSafe(tmp);
+ if(!((const DataArrayIdType *)ret1))
ret1=tmpSafe;
}
}
return getArray()->norm2();
}
-/*!
- * This method returns the max norm of \a this field.
- * \f[
- * \max_{0 \leq i < nbOfEntity}{abs(val[i])}
- * \f]
- * \throw If the data array is not set.
- */
-double MEDCouplingFieldDouble::normMax() const
-{
- if(getArray()==0)
- throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::normMax : no default array defined !");
- return getArray()->normMax();
-}
/*!
* 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
if(getArray()==0)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getWeightedAverageValue : no default array defined !");
MCAuto<MEDCouplingFieldDouble> w=buildMeasureField(isWAbs);
- double deno=w->getArray()->accumulate(0);
+ double deno=w->getArray()->accumulate((std::size_t)0);
MCAuto<DataArrayDouble> arr=getArray()->deepCopy();
arr->multiplyEqual(w->getArray());
arr->accumulate(res);
- int nCompo = getArray()->getNumberOfComponents();
- std::transform(res,res+nCompo,res,std::bind2nd(std::multiplies<double>(),1./deno));
+ std::size_t nCompo = getArray()->getNumberOfComponents();
+ std::transform(res,res+nCompo,res,std::bind(std::multiplies<double>(),std::placeholders::_1,1./deno));
}
/*!
*/
double MEDCouplingFieldDouble::getWeightedAverageValue(int compId, bool isWAbs) const
{
- int nbComps=getArray()->getNumberOfComponents();
- if(compId<0 || compId>=nbComps)
+ std::size_t nbComps=getArray()->getNumberOfComponents();
+ if(compId<0 || compId>=ToIdType(nbComps))
{
std::ostringstream oss; oss << "MEDCouplingFieldDouble::getWeightedAverageValue : Invalid compId specified : No such nb of components ! Should be in [0," << nbComps << ") !";
throw INTERP_KERNEL::Exception(oss.str());
throw INTERP_KERNEL::Exception("No mesh underlying this field to perform normL1 !");
if(_type.isNull())
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform normL1 !");
- int nbComps=getArray()->getNumberOfComponents();
- if(compId<0 || compId>=nbComps)
+ std::size_t nbComps=getArray()->getNumberOfComponents();
+ if(compId<0 || compId>=ToIdType(nbComps))
{
std::ostringstream oss; oss << "MEDCouplingFieldDouble::normL1 : Invalid compId specified : No such nb of components ! Should be in [0," << nbComps << ") !";
throw INTERP_KERNEL::Exception(oss.str());
throw INTERP_KERNEL::Exception("No mesh underlying this field to perform normL2");
if(_type.isNull())
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform normL2 !");
- int nbComps=getArray()->getNumberOfComponents();
- if(compId<0 || compId>=nbComps)
+ std::size_t nbComps=getArray()->getNumberOfComponents();
+ if(compId<0 || compId>=ToIdType(nbComps))
{
std::ostringstream oss; oss << "MEDCouplingFieldDouble::normL2 : Invalid compId specified : No such nb of components ! Should be in [0," << nbComps << ") !";
throw INTERP_KERNEL::Exception(oss.str());
_type->normL2(_mesh,getArray(),res);
}
+/*!
+ * Returns the \c infinite norm of values of a given component of \a this field:
+* \f[
+ * \max_{0 \leq i < nbOfEntity}{abs(val[i])}
+ * \f]
+ * \param [in] compId - an index of the component of interest.
+ * \throw If \a compId is not valid.
+ A valid range is ( 0 <= \a compId < \a this->getNumberOfComponents() ).
+ * \throw If the data array is not set.
+ */
+double MEDCouplingFieldDouble::normMax(int compId) const
+{
+ if(getArray()==0)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::normMax : no default array defined !");
+ std::size_t nbComps=getArray()->getNumberOfComponents();
+ if(compId<0 || compId>=ToIdType(nbComps))
+ {
+ std::ostringstream oss; oss << "MEDCouplingFieldDouble::normMax : Invalid compId specified : No such nb of components ! Should be in [0," << nbComps << ") !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ INTERP_KERNEL::AutoPtr<double> res=new double[nbComps];
+ getArray()->normMaxPerComponent(res);
+ return res[compId];
+}
+
+/*!
+ * Returns the \c infinite norm of values of each component of \a this field:
+ * \f[
+ * \max_{0 \leq i < nbOfEntity}{abs(val[i])}
+ * \f]
+ * \param [out] res - pointer to an array of result values, of size at least \a
+ * this->getNumberOfComponents(), that is to be allocated by the caller.
+ * \throw If the data array is not set.
+ *
+ */
+void MEDCouplingFieldDouble::normMax(double *res) const
+{
+ if(getArray()==0)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::normMax : no default array defined !");
+ getArray()->normMaxPerComponent(res);
+}
+
/*!
* Computes a sum of values of a given component of \a this field multiplied by
* values returned by buildMeasureField().
throw INTERP_KERNEL::Exception("No mesh underlying this field to perform integral");
if(_type.isNull())
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform integral !");
- int nbComps=getArray()->getNumberOfComponents();
- if(compId<0 || compId>=nbComps)
+ std::size_t nbComps=getArray()->getNumberOfComponents();
+ if(compId<0 || compId>=ToIdType(nbComps))
{
std::ostringstream oss; oss << "MEDCouplingFieldDouble::integral : Invalid compId specified : No such nb of components ! Should be in [0," << nbComps << ") !";
throw INTERP_KERNEL::Exception(oss.str());
* \ref py_mcfielddouble_getValueOnPos "Here is a Python example".
* \endif
*/
-void MEDCouplingFieldDouble::getValueOnPos(int i, int j, int k, double *res) const
+void MEDCouplingFieldDouble::getValueOnPos(mcIdType i, mcIdType j, mcIdType k, double *res) const
{
const DataArrayDouble *arr=timeDiscr()->getArray();
if(!_mesh)
* \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.
* \ref py_mcfielddouble_getValueOnMulti "Here is a Python example".
* \endif
*/
-DataArrayDouble *MEDCouplingFieldDouble::getValueOnMulti(const double *spaceLoc, int nbOfPoints) const
+DataArrayDouble *MEDCouplingFieldDouble::getValueOnMulti(const double *spaceLoc, mcIdType nbOfPoints) const
{
const DataArrayDouble *arr=timeDiscr()->getArray();
if(!_mesh)
std::vector<double> res2;
for(std::vector< const DataArrayDouble *>::const_iterator iter=arrs.begin();iter!=arrs.end();iter++)
{
- int sz=(int)res2.size();
+ std::size_t sz=res2.size();
res2.resize(sz+(*iter)->getNumberOfComponents());
_type->getValueOn(*iter,_mesh,spaceLoc,&res2[sz]);
}
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::operator= : no mesh defined !");
if(_type.isNull())
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform operator = !");
- int nbOfTuple=_type->getNumberOfTuples(_mesh);
+ mcIdType nbOfTuple=_type->getNumberOfTuples(_mesh);
timeDiscr()->setOrCreateUniformValueOnAllComponents(nbOfTuple,value);
return *this;
}
* a corresponding node coordinates array (where it is set via
* DataArrayDouble::setInfoOnComponent()).<br>
* For more info on supported expressions that can be used in the function, see \ref
- * MEDCouplingArrayApplyFuncExpr. <br>
+ * MEDCouplingArrayApplyFuncExpr. <br>
* 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
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::applyFunc : no mesh defined !");
if(_type.isNull())
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform applyFunc !");
- int nbOfTuple=_type->getNumberOfTuples(_mesh);
+ mcIdType nbOfTuple=_type->getNumberOfTuples(_mesh);
timeDiscr()->setUniformValue(nbOfTuple,nbOfComp,val);
}
* - "2*x + z" produces (5.,5.,5.,5.)
* - "2*x + 0*y + z" produces (9.,9.,9.,9.)
* - "2*x*IVec + (x+z)*LVec" produces (2.,0.,0.,4.)
- * - "2*y*IVec + z*KVec + x" produces (7.,1.,1.,4.)
+ * - "2*y*IVec + z*KVec + x" produces (7.,1.,8.,1.)
*
* \param [in] nbOfComp - the number of components for \a this field to have.
* \param [in] func - the function used to compute values of \a this field.
* - "2*x + z" produces (5.,5.,5.,5.)
* - "2*x + 0*y + z" produces (9.,9.,9.,9.)
* - "2*x*IVec + (x+z)*LVec" produces (2.,0.,0.,4.)
- * - "2*y*IVec + z*KVec + x" produces (7.,1.,1.,4.)
+ * - "2*y*IVec + z*KVec + x" produces (7.,1.,8.,1.)
*
* \param [in] nbOfComp - the number of components for \a this field to have.
* \param [in] func - the function used to compute values of \a this field.
* MEDCouplingArrayApplyFuncExpr. <br>
* The function can include **only one** arbitrary named variable
* (e.g. "x","y" or "va44") to refer to a field atomic value. <br>
- * 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
* 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
* \throw If the spatial discretization is not fully defined.
* \sa MEDCouplingField::getNumberOfTuplesExpected
*/
-std::size_t MEDCouplingFieldDouble::getNumberOfTuples() const
+mcIdType MEDCouplingFieldDouble::getNumberOfTuples() const
{
if(!_mesh)
throw INTERP_KERNEL::Exception("Impossible to retrieve number of tuples because no mesh specified !");
* data array.
* \throw If the data array is not set.
*/
-std::size_t MEDCouplingFieldDouble::getNumberOfValues() const
+mcIdType MEDCouplingFieldDouble::getNumberOfValues() const
{
if(getArray()==0)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getNumberOfValues : No array specified !");
* \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".
*/
-double MEDCouplingFieldDouble::getIJK(int cellId, int nodeIdInCell, int compoId) const
+double MEDCouplingFieldDouble::getIJK(mcIdType cellId, int nodeIdInCell, int compoId) const
{
if(_type.isNull())
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform getIJK !");
}
/*!
- * 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
*/
//void MEDCouplingFieldDouble::setArrays(const std::vector<DataArrayDouble *>& arrs)
-void MEDCouplingFieldDouble::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
-{
- tinyInfo.clear();
- timeDiscr()->getTinySerializationStrInformation(tinyInfo);
- tinyInfo.push_back(_name);
- tinyInfo.push_back(_desc);
- tinyInfo.push_back(getTimeUnit());
-}
-
-/*!
- * This method retrieves some critical values to resize and prepare remote instance.
- * The first two elements returned in tinyInfo correspond to the parameters to give in constructor.
- * @param tinyInfo out parameter resized correctly after the call. The length of this vector is tiny.
- */
-void MEDCouplingFieldDouble::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
-{
- if(_type.isNull())
- throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform getTinySerializationIntInformation !");
- tinyInfo.clear();
- tinyInfo.push_back((int)_type->getEnum());
- tinyInfo.push_back((int)timeDiscr()->getEnum());
- tinyInfo.push_back((int)_nature);
- timeDiscr()->getTinySerializationIntInformation(tinyInfo);
- std::vector<int> tinyInfo2;
- _type->getTinySerializationIntInformation(tinyInfo2);
- tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end());
- tinyInfo.push_back((int)tinyInfo2.size());
-}
-
-/*!
- * This method retrieves some critical values to resize and prepare remote instance.
- * @param tinyInfo out parameter resized correctly after the call. The length of this vector is tiny.
- */
-void MEDCouplingFieldDouble::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
-{
- if(_type.isNull())
- throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform getTinySerializationDbleInformation !");
- tinyInfo.clear();
- timeDiscr()->getTinySerializationDbleInformation(tinyInfo);
- std::vector<double> tinyInfo2;
- _type->getTinySerializationDbleInformation(tinyInfo2);
- tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end());
- tinyInfo.push_back((int)tinyInfo2.size());//very bad, lack of time to improve it
-}
-
-/*!
- * This method has to be called to the new instance filled by CORBA, MPI, File...
- * @param tinyInfoI is the value retrieves from distant result of getTinySerializationIntInformation on source instance to be copied.
- * @param dataInt out parameter. If not null the pointer is already owned by \a this after the call of this method. In this case no decrRef must be applied.
- * @param arrays out parameter is a vector resized to the right size. The pointers in the vector is already owned by \a this after the call of this method.
- * No decrRef must be applied to every instances in returned vector.
- * \sa checkForUnserialization
- */
-void MEDCouplingFieldDouble::resizeForUnserialization(const std::vector<int>& tinyInfoI, DataArrayInt *&dataInt, std::vector<DataArrayDouble *>& arrays)
-{
- if(_type.isNull())
- throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform resizeForUnserialization !");
- dataInt=0;
- std::vector<int> tinyInfoITmp(tinyInfoI);
- int sz=tinyInfoITmp.back();
- tinyInfoITmp.pop_back();
- std::vector<int> tinyInfoITmp2(tinyInfoITmp.begin(),tinyInfoITmp.end()-sz);
- std::vector<int> tinyInfoI2(tinyInfoITmp2.begin()+3,tinyInfoITmp2.end());
- timeDiscr()->resizeForUnserialization(tinyInfoI2,arrays);
- std::vector<int> tinyInfoITmp3(tinyInfoITmp.end()-sz,tinyInfoITmp.end());
- _type->resizeForUnserialization(tinyInfoITmp3,dataInt);
-}
-
-/*!
- * This method is extremely close to resizeForUnserialization except that here the arrays in \a dataInt and in \a arrays are attached in \a this
- * after having checked that size is correct. This method is used in python pickeling context to avoid copy of data.
- * \sa resizeForUnserialization
- */
-void MEDCouplingFieldDouble::checkForUnserialization(const std::vector<int>& tinyInfoI, const DataArrayInt *dataInt, const std::vector<DataArrayDouble *>& arrays)
-{
- if(_type.isNull())
- throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform resizeForUnserialization !");
- std::vector<int> tinyInfoITmp(tinyInfoI);
- int sz=tinyInfoITmp.back();
- tinyInfoITmp.pop_back();
- std::vector<int> tinyInfoITmp2(tinyInfoITmp.begin(),tinyInfoITmp.end()-sz);
- std::vector<int> tinyInfoI2(tinyInfoITmp2.begin()+3,tinyInfoITmp2.end());
- timeDiscr()->checkForUnserialization(tinyInfoI2,arrays);
- std::vector<int> tinyInfoITmp3(tinyInfoITmp.end()-sz,tinyInfoITmp.end());
- _type->checkForUnserialization(tinyInfoITmp3,dataInt);
-}
-
-void MEDCouplingFieldDouble::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
-{
- if(_type.isNull())
- throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform finishUnserialization !");
- std::vector<int> tinyInfoI2(tinyInfoI.begin()+3,tinyInfoI.end());
- //
- std::vector<double> tmp(tinyInfoD);
- int sz=(int)tinyInfoD.back();//very bad, lack of time to improve it
- tmp.pop_back();
- std::vector<double> tmp1(tmp.begin(),tmp.end()-sz);
- std::vector<double> tmp2(tmp.end()-sz,tmp.end());
- //
- timeDiscr()->finishUnserialization(tinyInfoI2,tmp1,tinyInfoS);
- _nature=(NatureOfField)tinyInfoI[2];
- _type->finishUnserialization(tmp2);
- int nbOfElemS=(int)tinyInfoS.size();
- _name=tinyInfoS[nbOfElemS-3];
- _desc=tinyInfoS[nbOfElemS-2];
- setTimeUnit(tinyInfoS[nbOfElemS-1]);
-}
-
-/*!
- * Contrary to MEDCouplingPointSet class the returned arrays are \b not the responsabilities of the caller.
- * The values returned must be consulted only in readonly mode.
- */
-void MEDCouplingFieldDouble::serialize(DataArrayInt *&dataInt, std::vector<DataArrayDouble *>& arrays) const
-{
- if(_type.isNull())
- throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform serialize !");
- timeDiscr()->getArrays(arrays);
- _type->getSerializationIntArray(dataInt);
-}
-
/*!
* Tries to set an \a other mesh as the support of \a this field. An attempt fails, if
* a current and the \a other meshes are different with use of specified equality
* \throw If \a other == NULL.
* \throw If any of the meshes is not well defined.
* \throw If the two meshes do not match.
- * \throw If field values at merged nodes (if any) deffer more than \a eps.
+ * \throw If field values at merged nodes (if any) differ more than \a eps.
*
* \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_changeUnderlyingMesh "Here is a C++ example".<br>
{
if(_mesh==0 || other==0)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::changeUnderlyingMesh : is expected to operate on not null meshes !");
- DataArrayInt *cellCor=0,*nodeCor=0;
+ DataArrayIdType *cellCor=0,*nodeCor=0;
other->checkGeoEquivalWith(_mesh,levOfCheck,precOnMesh,cellCor,nodeCor);
- MCAuto<DataArrayInt> cellCor2(cellCor),nodeCor2(nodeCor);
+ MCAuto<DataArrayIdType> cellCor2(cellCor),nodeCor2(nodeCor);
if(cellCor)
renumberCellsWithoutMesh(cellCor->getConstPointer(),false);
if(nodeCor)
* 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.<br>
* \throw If any of the meshes is not set or is not well defined.
* \throw If the two meshes do not match.
* \throw If the two fields are not coherent for merge.
- * \throw If field values at merged nodes (if any) deffer more than \a eps.
+ * \throw If field values at merged nodes (if any) differ more than \a eps.
*
* \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_substractInPlaceDM "Here is a C++ example".<br>
* \throw If the mesh is not well defined.
* \throw If the spatial discretization of \a this field is NULL.
* \throw If the data array is not set.
- * \throw If field values at merged nodes (if any) deffer more than \a epsOnVals.
+ * \throw If field values at merged nodes (if any) differ more than \a epsOnVals.
*/
bool MEDCouplingFieldDouble::mergeNodes(double eps, double epsOnVals)
{
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform mergeNodes !");
MCAuto<MEDCouplingPointSet> meshC2((MEDCouplingPointSet *)meshC->deepCopy());
bool ret;
- int ret2;
- MCAuto<DataArrayInt> arr=meshC2->mergeNodes(eps,ret,ret2);
+ mcIdType ret2;
+ MCAuto<DataArrayIdType> arr=meshC2->mergeNodes(eps,ret,ret2);
if(!ret)//no nodes have been merged.
return ret;
std::vector<DataArrayDouble *> arrays;
* \throw If the mesh is not well defined.
* \throw If the spatial discretization of \a this field is NULL.
* \throw If the data array is not set.
- * \throw If field values at merged nodes (if any) deffer more than \a epsOnVals.
+ * \throw If field values at merged nodes (if any) differ more than \a epsOnVals.
*/
bool MEDCouplingFieldDouble::mergeNodesCenter(double eps, double epsOnVals)
{
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform mergeNodesCenter !");
MCAuto<MEDCouplingPointSet> meshC2((MEDCouplingPointSet *)meshC->deepCopy());
bool ret;
- int ret2;
- MCAuto<DataArrayInt> arr=meshC2->mergeNodesCenter(eps,ret,ret2);
+ mcIdType ret2;
+ MCAuto<DataArrayIdType> arr=meshC2->mergeNodesCenter(eps,ret,ret2);
if(!ret)//no nodes have been merged.
return ret;
std::vector<DataArrayDouble *> arrays;
* \throw If the mesh is not well defined.
* \throw If the spatial discretization of \a this field is NULL.
* \throw If the data array is not set.
- * \throw If field values at merged nodes (if any) deffer more than \a epsOnVals.
+ * \throw If field values at merged nodes (if any) differ more than \a epsOnVals.
*/
bool MEDCouplingFieldDouble::zipCoords(double epsOnVals)
{
if(_type.isNull())
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform zipCoords !");
MCAuto<MEDCouplingPointSet> meshC2((MEDCouplingPointSet *)meshC->deepCopy());
- int oldNbOfNodes=meshC2->getNumberOfNodes();
- MCAuto<DataArrayInt> arr=meshC2->zipCoordsTraducer();
+ mcIdType oldNbOfNodes=meshC2->getNumberOfNodes();
+ MCAuto<DataArrayIdType> arr=meshC2->zipCoordsTraducer();
if(meshC2->getNumberOfNodes()!=oldNbOfNodes)
{
std::vector<DataArrayDouble *> arrays;
* \throw If the mesh is not well defined.
* \throw If the spatial discretization of \a this field is NULL.
* \throw If the data array is not set.
- * \throw If field values at merged cells (if any) deffer more than \a epsOnVals.
+ * \throw If field values at merged cells (if any) differ more than \a epsOnVals.
*/
bool MEDCouplingFieldDouble::zipConnectivity(int compType, double epsOnVals)
{
if(_type.isNull())
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform zipConnectivity !");
MCAuto<MEDCouplingUMesh> meshC2((MEDCouplingUMesh *)meshC->deepCopy());
- int oldNbOfCells=meshC2->getNumberOfCells();
- MCAuto<DataArrayInt> arr=meshC2->zipConnectivityTraducer(compType);
+ mcIdType oldNbOfCells(meshC2->getNumberOfCells());
+ MCAuto<DataArrayIdType> arr=meshC2->zipConnectivityTraducer(compType);
if(meshC2->getNumberOfCells()!=oldNbOfCells)
{
std::vector<DataArrayDouble *> arrays;
timeDiscr()->getArrays(arrays);
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
if(*iter)
- _type->renumberValuesOnCells(epsOnVals,meshC,arr->getConstPointer(),meshC2->getNumberOfCells(),*iter);
+ _type->renumberValuesOnCells(epsOnVals,meshC,arr->getConstPointer(),ToIdType(meshC2->getNumberOfCells()),*iter);
setMesh(meshC2);
return true;
}
/*!
* 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
const MCAuto<MEDCouplingUMesh> umesh(mesh->buildUnstructured());
MCAuto<MEDCouplingFieldDouble> ret(clone(false));
ret->setMesh(umesh);
- DataArrayInt *cellIds=0;
+ DataArrayIdType *cellIds=0;
MCAuto<MEDCouplingUMesh> mesh2=umesh->buildSlice3D(origin,vec,eps,cellIds);
- MCAuto<DataArrayInt> cellIds2=cellIds;
+ MCAuto<DataArrayIdType> cellIds2=cellIds;
ret->setMesh(mesh2);
- MCAuto<DataArrayInt> tupleIds=computeTupleIdsToSelectFromCellIds(cellIds->begin(),cellIds->end());
+ MCAuto<DataArrayIdType> tupleIds=computeTupleIdsToSelectFromCellIds(cellIds->begin(),cellIds->end());
std::vector<DataArrayDouble *> arrays;
timeDiscr()->getArrays(arrays);
int i=0;
/*!
* 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.<br>
+ * mesh instance containing the simplices.<br>
* \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.
throw INTERP_KERNEL::Exception("No underlying mesh on this field to perform simplexize !");
if(_type.isNull())
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform simplexize !");
- int oldNbOfCells=_mesh->getNumberOfCells();
+ std::size_t oldNbOfCells=_mesh->getNumberOfCells();
MCAuto<MEDCouplingMesh> meshC2(_mesh->deepCopy());
- MCAuto<DataArrayInt> arr=meshC2->simplexize(policy);
- int newNbOfCells=meshC2->getNumberOfCells();
+ MCAuto<DataArrayIdType> arr=meshC2->simplexize(policy);
+ std::size_t newNbOfCells=meshC2->getNumberOfCells();
if(oldNbOfCells==newNbOfCells)
return false;
std::vector<DataArrayDouble *> arrays;
timeDiscr()->getArrays(arrays);
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
if(*iter)
- _type->renumberValuesOnCellsR(_mesh,arr->getConstPointer(),arr->getNbOfElems(),*iter);
+ _type->renumberValuesOnCellsR(_mesh,arr->getConstPointer(),ToIdType(arr->getNbOfElems()),*iter);
setMesh(meshC2);
return true;
}
checkConsistencyLight();
const MEDCouplingMesh *mesh(getMesh());
INTERP_KERNEL::AutoCppPtr<Voronizer> vor;
- int meshDim(mesh->getMeshDimension()),spaceDim(mesh->getSpaceDimension());
+ std::size_t meshDim(mesh->getMeshDimension()),spaceDim(mesh->getSpaceDimension());
if(meshDim==1 && (spaceDim==1 || spaceDim==2 || spaceDim==3))
vor=new Voronizer1D;
else if(meshDim==2 && (spaceDim==2 || spaceDim==3))
MCAuto<MEDCouplingUMesh> umesh(mesh->buildUnstructured());
umesh=umesh->clone(false);
umesh->convertQuadraticCellsToLinear();
- MCAuto<DataArrayInt> o2n(umesh->zipCoordsTraducer());
- MCAuto<DataArrayInt> n2o(o2n->invertArrayO2N2N2O(umesh->getNumberOfNodes()));
+ MCAuto<DataArrayIdType> o2n(umesh->zipCoordsTraducer());
+ MCAuto<DataArrayIdType> n2o(o2n->invertArrayO2N2N2O(umesh->getNumberOfNodes()));
MCAuto<DataArrayDouble> arr(getArray()->selectByTupleIdSafe(n2o->begin(),n2o->end()));
MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(ON_NODES));
ret->setArray(arr);
if(!disc2)
throw INTERP_KERNEL::Exception("convertQuadraticCellsToLinear : Not a ON_GAUSS_PT field");
std::set<INTERP_KERNEL::NormalizedCellType> gt2(umesh->getAllGeoTypes());
- const DataArrayDouble *arr(getArray());
- std::vector< MCAuto<DataArrayInt> > cellIdsV;
+ std::vector< MCAuto<DataArrayIdType> > cellIdsV;
std::vector< MCAuto<MEDCouplingUMesh> > meshesV;
std::vector< MEDCouplingGaussLocalization > glV;
bool isZipReq(false);
for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=gt.begin();it!=gt.end();it++)
{
const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(*it));
- MCAuto<DataArrayInt> cellIds(umesh->giveCellsWithType(*it));
+ MCAuto<DataArrayIdType> cellIds(umesh->giveCellsWithType(*it));
cellIdsV.push_back(cellIds);
MCAuto<MEDCouplingUMesh> part(umesh->buildPartOfMySelf(cellIds->begin(),cellIds->end()));
- int id(disc2->getGaussLocalizationIdOfOneType(*it));
+ mcIdType id(disc2->getGaussLocalizationIdOfOneType(*it));
const MEDCouplingGaussLocalization& gl(disc2->getGaussLocalization(id));
if(!cm.isQuadratic())
{
{
std::vector< const MEDCouplingUMesh * > meshesPtr(VecAutoToVecOfCstPt(meshesV));
umesh=MEDCouplingUMesh::MergeUMeshesOnSameCoords(meshesPtr);
- std::vector< const DataArrayInt * > zeCellIds(VecAutoToVecOfCstPt(cellIdsV));
- MCAuto<DataArrayInt> zeIds(DataArrayInt::Aggregate(zeCellIds));
+ std::vector< const DataArrayIdType * > zeCellIds(VecAutoToVecOfCstPt(cellIdsV));
+ MCAuto<DataArrayIdType> zeIds(DataArrayIdType::Aggregate(zeCellIds));
umesh->renumberCells(zeIds->begin());
umesh->setName(mesh->getName());
}
/*!
* This is expected to be a 3 components vector field on nodes (if not an exception will be thrown). \a this is also expected to lie on a MEDCouplingPointSet mesh.
- * Finaly \a this is also expected to be consistent.
+ * 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.
*
* every tensor of \a this 6-componental field.
* \return MEDCouplingFieldDouble * - the new instance of MEDCouplingFieldDouble, whose
* each tuple is calculated from the tuple <em>(t)</em> 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.
/*!
* 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.
/*!
* 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.
*/
/*!
* 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.
*/
* 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.
*/
* 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.
*/
/*!
* 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.
*/
/*!
* 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
* 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
* 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.
*/
-void MEDCouplingFieldDouble::changeNbOfComponents(int newNbOfComp, double dftValue)
+void MEDCouplingFieldDouble::changeNbOfComponents(std::size_t newNbOfComp, double dftValue)
{
timeDiscr()->changeNbOfComponents(newNbOfComp,dftValue);
}
* 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<int>& compoIds) const
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::keepSelectedComponents(const std::vector<std::size_t>& compoIds) const
{
if(_type.isNull())
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform keepSelectedComponents !");
return ret.retn();
}
-
/*!
* Copy all components in a specified order from another field.
* The number of tuples in \a this and the other field can be different.
* \throw If \a compoIds.size() != \a a->getNumberOfComponents().
* \throw If \a compoIds[i] < 0 or \a compoIds[i] > \a this->getNumberOfComponents().
*/
-void MEDCouplingFieldDouble::setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector<int>& compoIds)
+void MEDCouplingFieldDouble::setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector<std::size_t>& compoIds)
{
timeDiscr()->setSelectedComponents(f->timeDiscr(),compoIds);
}
* \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.
*/
MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
{
- if(!f1->areCompatibleForMerge(f2))
- throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply MergeFields on them ! Check support mesh, field nature, and spatial and time discretisation.");
- const MEDCouplingMesh *m1(f1->getMesh()),*m2(f2->getMesh());
- if(!f1->timeDiscr())
- throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::MergeFields : no time discr of f1 !");
- if(!f1->_type)
- throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::MergeFields : no spatial discr of f1 !");
- MEDCouplingTimeDiscretization *td(f1->timeDiscr()->aggregate(f2->timeDiscr()));
- td->copyTinyAttrFrom(*f1->timeDiscr());
- MCAuto<MEDCouplingFieldDouble> ret(new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()));
- ret->setName(f1->getName());
- ret->setDescription(f1->getDescription());
- if(m1)
- {
- MCAuto<MEDCouplingMesh> m=m1->mergeMyselfWith(m2);
- ret->setMesh(m);
- }
- return ret.retn();
+ std::vector<const MEDCouplingFieldDouble *> a(2);
+ a[0]=f1; a[1]=f2;
+ return MergeFields(a);
}
/*!
* 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.
*/
MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const std::vector<const MEDCouplingFieldDouble *>& a)
{
- if(a.size()<1)
- throw INTERP_KERNEL::Exception("FieldDouble::MergeFields : size of array must be >= 1 !");
+ if(a.empty())
+ throw INTERP_KERNEL::Exception("FieldDouble::MergeFields : input array is empty !");
std::vector< MCAuto<MEDCouplingUMesh> > ms(a.size());
std::vector< const MEDCouplingUMesh *> ms2(a.size());
std::vector< const MEDCouplingTimeDiscretization *> tds(a.size());
- std::vector<const MEDCouplingFieldDouble *>::const_iterator it=a.begin();
- const MEDCouplingFieldDouble *ref=(*it++);
+ std::vector< const MEDCouplingFieldDouble *>::const_iterator it=a.begin();
+ std::vector<const MEDCouplingFieldDiscretization *> fds(a.size());
+ const MEDCouplingFieldDouble *ref((*it++));
if(!ref)
- throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::MergeFields : presence of NULL instance in first place of input vector !");
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::MergeFields : presence of nullptr instance in first place of input vector !");
+ if(!ref->getDiscretization())
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::MergeFields : nullptr spatial discretization !");
for(;it!=a.end();it++)
if(!ref->areCompatibleForMerge(*it))
throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply MergeFields on them! Check support mesh, field nature, and spatial and time discretisation.");
- for(int i=0;i<(int)a.size();i++)
+ for(std::size_t i=0;i<a.size();i++)
{
+ if(!a[i])
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::MergeFields : presence of nullptr instance in input vector !");
if(a[i]->getMesh())
{ ms[i]=a[i]->getMesh()->buildUnstructured(); ms2[i]=ms[i]; }
else
{ ms[i]=0; ms2[i]=0; }
tds[i]=a[i]->timeDiscr();
+ fds[i]=a[i]->getDiscretization();
}
MEDCouplingTimeDiscretization *td(tds[0]->aggregate(tds));
+ MCAuto<MEDCouplingFieldDiscretization> fda(fds[0]->aggregate(fds));
td->copyTinyAttrFrom(*(a[0]->timeDiscr()));
- MCAuto<MEDCouplingFieldDouble> ret(new MEDCouplingFieldDouble(a[0]->getNature(),td,a[0]->_type->clone()));
+ MCAuto<MEDCouplingFieldDouble> ret(new MEDCouplingFieldDouble(a[0]->getNature(),td,fda.retn()));
ret->setName(a[0]->getName());
ret->setDescription(a[0]->getDescription());
if(ms2[0])
}
/*!
- * 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.
}
/*!
- * 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.
/*!
* 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.
*/
/*!
* Directly called by MEDCouplingFieldDouble::operator^.
- *
+ *
* \sa MEDCouplingFieldDouble::operator^
*/
MEDCouplingFieldDouble *MEDCouplingFieldDouble::PowFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
/*!
* Directly call MEDCouplingFieldDouble::PowFields static method.
- *
+ *
* \sa MEDCouplingFieldDouble::PowFields
*/
MEDCouplingFieldDouble *MEDCouplingFieldDouble::operator^(const MEDCouplingFieldDouble& other) const
inpMeshBase=fieldToWO->getMesh();
inpMesh=inpMeshBase->buildUnstructured();
}
- int nbCells(inpMesh->getNumberOfCells());
+ mcIdType nbCells(inpMesh->getNumberOfCells());
const MEDCouplingFieldDiscretization *disc(fieldToWO->getDiscretization());
const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc));
if(!disc2)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::voronoize2D : Not a ON_GAUSS_PT field");
- int nbLocs(disc2->getNbOfGaussLocalization());
+ mcIdType nbLocs(disc2->getNbOfGaussLocalization());
std::vector< MCAuto<MEDCouplingUMesh> > cells(nbCells);
- for(int i=0;i<nbLocs;i++)
+ for(mcIdType i=0;i<nbLocs;i++)
{
const MEDCouplingGaussLocalization& gl(disc2->getGaussLocalization(i));
if(gl.getDimension()!=vor->getDimension())
MCAuto<MEDCouplingUMesh> coo3(MEDCouplingUMesh::Build0DMeshFromCoords(coo2));
//
MCAuto<MEDCouplingUMesh> vorCellsForCurDisc(vor->doIt(mesh,coo2,eps));
- std::vector<int> ids;
+ std::vector<mcIdType> ids;
MCAuto<DataArrayDouble> ptsInReal;
disc2->getCellIdsHavingGaussLocalization(i,ids);
{
MCAuto<MEDCouplingUMesh> subMesh(inpMesh->buildPartOfMySelf(&ids[0],&ids[0]+ids.size()));
ptsInReal=gl.localizePtsInRefCooForEachCell(vorCellsForCurDisc->getCoords(),subMesh);
}
- int nbPtsPerCell(vorCellsForCurDisc->getNumberOfNodes());
- for(std::size_t i=0;i<ids.size();i++)
+ mcIdType nbPtsPerCell(vorCellsForCurDisc->getNumberOfNodes());
+ for(mcIdType j=0;j<ToIdType(ids.size());j++)
{
MCAuto<MEDCouplingUMesh> elt(vorCellsForCurDisc->clone(false));
- MCAuto<DataArrayDouble> coo(ptsInReal->selectByTupleIdSafeSlice(i*nbPtsPerCell,(i+1)*nbPtsPerCell,1));
- elt->setCoords(coo);
- cells[ids[i]]=elt;
+ MCAuto<DataArrayDouble> coo4(ptsInReal->selectByTupleIdSafeSlice(j*nbPtsPerCell,(j+1)*nbPtsPerCell,1));
+ elt->setCoords(coo4);
+ cells[ids[j]]=elt;
}
}
std::vector< const MEDCouplingUMesh * > cellsPtr(VecAutoToVecOfCstPt(cells));
throw INTERP_KERNEL::Exception("Field Double Null invalid type of time discr !");
return retc;
}
-