X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FMEDCoupling%2FMEDCouplingFieldDouble.cxx;h=3c2e2eb8c8c955c23917b717e72adb8bf2a6e4f4;hb=a7a49bcd1fbbf89a8d7e4de71baf27d323b0a109;hp=e721d1423edb000fda95a7a592f8c3c516c5cd50;hpb=267a4b340f2b5b7e5e2c00797486a7611777313a;p=tools%2Fmedcoupling.git
diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx
index e721d1423..3c2e2eb8c 100644
--- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx
+++ b/src/MEDCoupling/MEDCouplingFieldDouble.cxx
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2014 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -85,7 +85,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::New(const MEDCouplingFieldTempla
* Sets a time \a unit of \a this field. For more info, see \ref MEDCouplingFirstSteps3.
* \param [in] unit \a unit (string) in which time is measured.
*/
-void MEDCouplingFieldDouble::setTimeUnit(const char *unit)
+void MEDCouplingFieldDouble::setTimeUnit(const std::string& unit)
{
_time_discr->setTimeUnit(unit);
}
@@ -94,7 +94,7 @@ void MEDCouplingFieldDouble::setTimeUnit(const char *unit)
* Returns a time unit of \a this field.
* \return a string describing units in which time is measured.
*/
-const char *MEDCouplingFieldDouble::getTimeUnit() const
+std::string MEDCouplingFieldDouble::getTimeUnit() const
{
return _time_discr->getTimeUnit();
}
@@ -200,8 +200,10 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::deepCpy() const
* \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_buildNewTimeReprFromThis "Here is a C++ example."
* \ref py_mcfielddouble_buildNewTimeReprFromThis "Here is a Python example."
+ * \endif
* \sa clone()
*/
MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCopy) const
@@ -212,8 +214,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildNewTimeReprFromThis(TypeOfT
disc=_type->clone();
MEDCouplingAutoRefCountObjectPtr ret=new MEDCouplingFieldDouble(getNature(),tdo,disc.retn());
ret->setMesh(getMesh());
- ret->setName(getName().c_str());
- ret->setDescription(getDescription().c_str());
+ ret->setName(getName());
+ ret->setDescription(getDescription());
return ret.retn();
}
@@ -240,7 +242,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::nodeToCellDiscretization() const
MEDCouplingAutoRefCountObjectPtr nsp(new MEDCouplingFieldDiscretizationP0);
ret->setDiscretization(nsp);
const MEDCouplingMesh *m(getMesh());//m is non empty thanks to checkCoherency call
- int nbCells(m->getNumberOfCells()),nbNodes(m->getNumberOfNodes());
+ int nbCells(m->getNumberOfCells());
std::vector arrs(getArrays());
std::size_t sz(arrs.size());
std::vector< MEDCouplingAutoRefCountObjectPtr > outArrsSafe(sz); std::vector outArrs(sz);
@@ -273,6 +275,48 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::nodeToCellDiscretization() const
return ret.retn();
}
+/*!
+ * 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
+ * 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
+ * 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_CELLS.
+ * \throw If \a this is not coherent (see MEDCouplingFieldDouble::checkCoherency).
+ *
+ * \warning This method is a \b non \b conservative method of remapping from cell spatial discretization to node spatial discretization.
+ * If a conservative method of interpolation is required ParaMEDMEM::MEDCouplingRemapper class should be used instead with "P0P1" method.
+ */
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::cellToNodeDiscretization() const
+{
+ checkCoherency();
+ TypeOfField tf(getTypeOfField());
+ if(tf!=ON_CELLS)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::cellToNodeDiscretization : this field is expected to be on ON_CELLS !");
+ MEDCouplingAutoRefCountObjectPtr ret(clone(false));
+ MEDCouplingAutoRefCountObjectPtr nsp(new MEDCouplingFieldDiscretizationP1);
+ ret->setDiscretization(nsp);
+ const MEDCouplingMesh *m(getMesh());//m is non empty thanks to checkCoherency call
+ MEDCouplingAutoRefCountObjectPtr rn(DataArrayInt::New()),rni(DataArrayInt::New());
+ m->getReverseNodalConnectivity(rn,rni);
+ MEDCouplingAutoRefCountObjectPtr rni2(rni->deltaShiftIndex());
+ MEDCouplingAutoRefCountObjectPtr rni3(rni2->convertToDblArr()); rni2=0;
+ std::vector arrs(getArrays());
+ std::size_t sz(arrs.size());
+ std::vector< MEDCouplingAutoRefCountObjectPtr > outArrsSafe(sz); std::vector outArrs(sz);
+ for(std::size_t j=0;j tmp(arrs[j]->selectByTupleIdSafe(rn->begin(),rn->end()));
+ outArrsSafe[j]=(tmp->accumulatePerChunck(rni->begin(),rni->end())); tmp=0;
+ outArrsSafe[j]->divideEqual(rni3);
+ outArrsSafe[j]->copyStringInfoFrom(*arrs[j]);
+ outArrs[j]=outArrsSafe[j];
+ }
+ ret->setArrays(outArrs);
+ return ret.retn();
+}
+
/*!
* Copies tiny info (component names, name and description) from an \a other field to
* \a this one.
@@ -303,7 +347,6 @@ void MEDCouplingFieldDouble::copyTinyAttrFrom(const MEDCouplingFieldDouble *othe
{
_time_discr->copyTinyAttrFrom(*other->_time_discr);
}
-
}
void MEDCouplingFieldDouble::copyAllTinyAttrFrom(const MEDCouplingFieldDouble *other)
@@ -408,7 +451,7 @@ std::string MEDCouplingFieldDouble::advancedRepr() const
return ret.str();
}
-void MEDCouplingFieldDouble::writeVTK(const char *fileName, bool isBinary) const
+void MEDCouplingFieldDouble::writeVTK(const std::string& fileName, bool isBinary) const
{
std::vector fs(1,this);
MEDCouplingFieldDouble::WriteVTK(fileName,fs,isBinary);
@@ -554,8 +597,10 @@ 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).
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_renumberCells "Here is a C++ example".
* \ref py_mcfielddouble_renumberCells "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::renumberCells(const int *old2NewBg, bool check)
{
@@ -589,10 +634,10 @@ void MEDCouplingFieldDouble::renumberCells(const int *old2NewBg, bool check)
*/
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(!((const MEDCouplingFieldDiscretization *)_type))
- throw INTERP_KERNEL::Exception("Expecting a spatial discretization to be able to operate a renumbering !");
+ if(!_mesh)
+ throw INTERP_KERNEL::Exception("Expecting a defined mesh to be able to operate a renumbering !");
+ if(!((const MEDCouplingFieldDiscretization *)_type))
+ throw INTERP_KERNEL::Exception("Expecting a spatial discretization to be able to operate a renumbering !");
//
_type->renumberCells(old2NewBg,check);
std::vector arrays;
@@ -617,8 +662,10 @@ void MEDCouplingFieldDouble::renumberCellsWithoutMesh(const int *old2NewBg, bool
* \throw If mesh nature does not allow renumbering (e.g. structured mesh).
* \throw If values at merged nodes deffer 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".
+ * \endif
*/
void MEDCouplingFieldDouble::renumberNodes(const int *old2NewBg, double eps)
{
@@ -710,8 +757,10 @@ DataArrayInt *MEDCouplingFieldDouble::getIdsInRange(double vmin, double vmax) co
* \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".
* \ref py_mcfielddouble_subpart1 "Here is a Python example".
+ * \endif
* \sa MEDCouplingFieldDouble::buildSubPartRange
*/
@@ -749,8 +798,10 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildSubPart(const DataArrayInt
*
* \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."
* \ref py_mcfielddouble_subpart1 "Here a Python example."
+ * \endif
* \sa ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart(const DataArrayInt *) const, MEDCouplingFieldDouble::buildSubPartRange
*/
MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildSubPart(const int *partBg, const int *partEnd) const
@@ -836,7 +887,7 @@ TypeOfTimeDiscretization MEDCouplingFieldDouble::getTimeDiscretization() const
}
MEDCouplingFieldDouble::MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingField(type),
- _time_discr(MEDCouplingTimeDiscretization::New(td))
+ _time_discr(MEDCouplingTimeDiscretization::New(td))
{
}
@@ -844,12 +895,12 @@ MEDCouplingFieldDouble::MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscr
* ** WARINING : This method do not deeply copy neither mesh nor spatial discretization. Only a shallow copy (reference) is done for mesh and spatial discretization ! **
*/
MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td):MEDCouplingField(ft,false),
- _time_discr(MEDCouplingTimeDiscretization::New(td))
+ _time_discr(MEDCouplingTimeDiscretization::New(td))
{
}
MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCopy):MEDCouplingField(other,deepCopy),
- _time_discr(other._time_discr->performCpy(deepCopy))
+ _time_discr(other._time_discr->performCpy(deepCopy))
{
}
@@ -1292,8 +1343,10 @@ void MEDCouplingFieldDouble::integral(bool isWAbs, double *res) const
* \throw If the mesh is not set.
* \throw If the mesh is not a structured one.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_getValueOnPos "Here is a C++ example".
* \ref py_mcfielddouble_getValueOnPos "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::getValueOnPos(int i, int j, int k, double *res) const
{
@@ -1314,8 +1367,10 @@ void MEDCouplingFieldDouble::getValueOnPos(int i, int j, int k, double *res) con
* \throw If the mesh is not set.
* \throw If \a spaceLoc is out of the spatial discretization.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_getValueOn "Here is a C++ example".
* \ref py_mcfielddouble_getValueOn "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double *res) const
{
@@ -1340,8 +1395,10 @@ void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double *res) con
* \throw If the mesh is not set.
* \throw If any point in \a spaceLoc is out of the spatial discretization.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_getValueOnMulti "Here is a C++ example".
* \ref py_mcfielddouble_getValueOnMulti "Here is a Python example".
+ * \endif
*/
DataArrayDouble *MEDCouplingFieldDouble::getValueOnMulti(const double *spaceLoc, int nbOfPoints) const
{
@@ -1365,8 +1422,10 @@ DataArrayDouble *MEDCouplingFieldDouble::getValueOnMulti(const double *spaceLoc,
* \throw If \a spaceLoc is out of the spatial discretization.
* \throw If \a time is not covered by \a this->_time_discr.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_getValueOn_time "Here is a C++ example".
* \ref py_mcfielddouble_getValueOn_time "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double time, double *res) const
{
@@ -1403,7 +1462,7 @@ void MEDCouplingFieldDouble::applyLin(double a, double b, int compoId)
* All tuples will have the same value 'value'.
* An exception is thrown if no underlying mesh is defined.
*/
-MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator=(double value) throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator=(double value)
{
if(!_mesh)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::operator= : no mesh defined !");
@@ -1424,7 +1483,9 @@ MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator=(double value) throw(IN
* \throw If \a func returns \c false.
* \throw If the spatial discretization of \a this field is NULL.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_fillFromAnalytic_c_func "Here is a C++ example".
+ * \endif
*/
void MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, FunctionToEvaluate func)
{
@@ -1468,10 +1529,12 @@ void MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, FunctionToEvaluate f
* \throw If the spatial discretization of \a this field is NULL.
* \throw If computing \a func fails.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_fillFromAnalytic "Here is a C++ example".
* \ref py_mcfielddouble_fillFromAnalytic "Here is a Python example".
+ * \endif
*/
-void MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const char *func)
+void MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const std::string& func)
{
if(!_mesh)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalytic : no mesh defined !");
@@ -1486,7 +1549,7 @@ void MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const char *func)
* The function is applied to coordinates of value location points. For example, if
* \a this field is on cells, the function is applied to cell barycenters.
* This method differs from
- * \ref ParaMEDMEM::MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const char *func) "fillFromAnalytic()"
+ * \ref ParaMEDMEM::MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const std::string& func) "fillFromAnalytic()"
* by the way how variable
* names, used in the function, are associated with components of coordinates of field
* location points; here, a variable name corresponding to a component is retrieved from
@@ -1515,10 +1578,12 @@ void MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const char *func)
* \throw If the spatial discretization of \a this field is NULL.
* \throw If computing \a func fails.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_fillFromAnalytic2 "Here is a C++ example".
* \ref py_mcfielddouble_fillFromAnalytic2 "Here is a Python example".
+ * \endif
*/
-void MEDCouplingFieldDouble::fillFromAnalytic2(int nbOfComp, const char *func)
+void MEDCouplingFieldDouble::fillFromAnalytic2(int nbOfComp, const std::string& func)
{
if(!_mesh)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalytic2 : no mesh defined !");
@@ -1533,7 +1598,7 @@ void MEDCouplingFieldDouble::fillFromAnalytic2(int nbOfComp, const char *func)
* The function is applied to coordinates of value location points. For example, if
* \a this field is on cells, the function is applied to cell barycenters.
* This method differs from
- * \ref ParaMEDMEM::MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const char *func) "fillFromAnalytic()"
+ * \ref ParaMEDMEM::MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const std::string& func) "fillFromAnalytic()"
* by the way how variable
* names, used in the function, are associated with components of coordinates of field
* location points; here, a component index of a variable is defined by a
@@ -1562,10 +1627,12 @@ void MEDCouplingFieldDouble::fillFromAnalytic2(int nbOfComp, const char *func)
* \throw If the spatial discretization of \a this field is NULL.
* \throw If computing \a func fails.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_fillFromAnalytic3 "Here is a C++ example".
* \ref py_mcfielddouble_fillFromAnalytic3 "Here is a Python example".
+ * \endif
*/
-void MEDCouplingFieldDouble::fillFromAnalytic3(int nbOfComp, const std::vector& varsOrder, const char *func)
+void MEDCouplingFieldDouble::fillFromAnalytic3(int nbOfComp, const std::vector& varsOrder, const std::string& func)
{
if(!_mesh)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalytic2 : no mesh defined !");
@@ -1583,7 +1650,9 @@ void MEDCouplingFieldDouble::fillFromAnalytic3(int nbOfComp, const std::vector
* \ref py_mcfielddouble_applyFunc_val "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::applyFunc(int nbOfComp, double val)
{
@@ -1639,10 +1710,12 @@ void MEDCouplingFieldDouble::applyFunc(int nbOfComp, double val)
* This function is to compute a field value basing on a current field value.
* \throw If computing \a func fails.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_applyFunc "Here is a C++ example".
* \ref py_mcfielddouble_applyFunc "Here is a Python example".
+ * \endif
*/
-void MEDCouplingFieldDouble::applyFunc(int nbOfComp, const char *func)
+void MEDCouplingFieldDouble::applyFunc(int nbOfComp, const std::string& func)
{
_time_discr->applyFunc(nbOfComp,func);
}
@@ -1654,7 +1727,7 @@ void MEDCouplingFieldDouble::applyFunc(int nbOfComp, const char *func)
* For more info on supported expressions that can be used in the function, see \ref
* MEDCouplingArrayApplyFuncExpr.
* This method differs from
- * \ref ParaMEDMEM::MEDCouplingFieldDouble::applyFunc(int nbOfComp, const char *func) "applyFunc()"
+ * \ref ParaMEDMEM::MEDCouplingFieldDouble::applyFunc(int nbOfComp, const std::string& func) "applyFunc()"
* by the way how variable
* names, used in the function, are associated with components of field values;
* here, a variable name corresponding to a component is retrieved from
@@ -1677,10 +1750,12 @@ void MEDCouplingFieldDouble::applyFunc(int nbOfComp, const char *func)
* This function is to compute a new field value basing on a current field value.
* \throw If computing \a func fails.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_applyFunc2 "Here is a C++ example".
* \ref py_mcfielddouble_applyFunc2 "Here is a Python example".
+ * \endif
*/
-void MEDCouplingFieldDouble::applyFunc2(int nbOfComp, const char *func)
+void MEDCouplingFieldDouble::applyFunc2(int nbOfComp, const std::string& func)
{
_time_discr->applyFunc2(nbOfComp,func);
}
@@ -1689,7 +1764,7 @@ void MEDCouplingFieldDouble::applyFunc2(int nbOfComp, const char *func)
* Modifies values of \a this field by applying a function to each tuple of all
* data arrays.
* This method differs from
- * \ref ParaMEDMEM::MEDCouplingFieldDouble::applyFunc(int nbOfComp, const char *func) "applyFunc()"
+ * \ref ParaMEDMEM::MEDCouplingFieldDouble::applyFunc(int nbOfComp, const std::string& func) "applyFunc()"
* by the way how variable
* names, used in the function, are associated with components of field values;
* here, a component index of a variable is defined by a
@@ -1714,10 +1789,12 @@ void MEDCouplingFieldDouble::applyFunc2(int nbOfComp, const char *func)
* This function is to compute a new field value basing on a current field value.
* \throw If computing \a func fails.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_applyFunc3 "Here is a C++ example".
* \ref py_mcfielddouble_applyFunc3 "Here is a Python example".
+ * \endif
*/
-void MEDCouplingFieldDouble::applyFunc3(int nbOfComp, const std::vector& varsOrder, const char *func)
+void MEDCouplingFieldDouble::applyFunc3(int nbOfComp, const std::vector& varsOrder, const std::string& func)
{
_time_discr->applyFunc3(nbOfComp,varsOrder,func);
}
@@ -1744,10 +1821,12 @@ void MEDCouplingFieldDouble::applyFunc3(int nbOfComp, const std::vector
* \ref py_mcfielddouble_applyFunc_same_nb_comp "Here is a Python example".
+ * \endif
*/
-void MEDCouplingFieldDouble::applyFunc(const char *func)
+void MEDCouplingFieldDouble::applyFunc(const std::string& func)
{
_time_discr->applyFunc(func);
}
@@ -1757,7 +1836,7 @@ void MEDCouplingFieldDouble::applyFunc(const char *func)
* The field will contain exactly the same number of components after the call.
* Use is not warranted for the moment !
*/
-void MEDCouplingFieldDouble::applyFuncFast32(const char *func)
+void MEDCouplingFieldDouble::applyFuncFast32(const std::string& func)
{
_time_discr->applyFuncFast32(func);
}
@@ -1767,7 +1846,7 @@ void MEDCouplingFieldDouble::applyFuncFast32(const char *func)
* The field will contain exactly the same number of components after the call.
* Use is not warranted for the moment !
*/
-void MEDCouplingFieldDouble::applyFuncFast64(const char *func)
+void MEDCouplingFieldDouble::applyFuncFast64(const std::string& func)
{
_time_discr->applyFuncFast64(func);
}
@@ -1875,7 +1954,7 @@ void MEDCouplingFieldDouble::synchronizeTimeWithMesh()
double val=_mesh->getTime(it,ordr);
std::string timeUnit(_mesh->getTimeUnit());
setTime(val,it,ordr);
- setTimeUnit(timeUnit.c_str());
+ setTimeUnit(timeUnit);
}
/*!
@@ -2024,7 +2103,7 @@ void MEDCouplingFieldDouble::finishUnserialization(const std::vector& tinyI
int nbOfElemS=(int)tinyInfoS.size();
_name=tinyInfoS[nbOfElemS-3];
_desc=tinyInfoS[nbOfElemS-2];
- setTimeUnit(tinyInfoS[nbOfElemS-1].c_str());
+ setTimeUnit(tinyInfoS[nbOfElemS-1]);
}
/*!
@@ -2059,8 +2138,10 @@ void MEDCouplingFieldDouble::serialize(DataArrayInt *&dataInt, std::vector
* \ref py_mcfielddouble_changeUnderlyingMesh "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double precOnMesh, double eps)
{
@@ -2073,7 +2154,7 @@ void MEDCouplingFieldDouble::changeUnderlyingMesh(const MEDCouplingMesh *other,
renumberCellsWithoutMesh(cellCor->getConstPointer(),false);
if(nodeCor)
renumberNodesWithoutMesh(nodeCor->getConstPointer(),nodeCor->getMaxValueInArray()+1,eps);
- setMesh(const_cast(other));
+ setMesh(other);
}
/*!
@@ -2105,8 +2186,10 @@ void MEDCouplingFieldDouble::changeUnderlyingMesh(const MEDCouplingMesh *other,
* \throw If the two fields are not coherent for merge.
* \throw If field values at merged nodes (if any) deffer more than \a eps.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_substractInPlaceDM "Here is a C++ example".
* \ref py_mcfielddouble_substractInPlaceDM "Here is a Python example".
+ * \endif
* \sa changeUnderlyingMesh().
*/
void MEDCouplingFieldDouble::substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double precOnMesh, double eps)
@@ -2556,7 +2639,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::maxPerTuple() const
MEDCouplingAutoRefCountObjectPtr ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
std::ostringstream oss;
oss << "Max_" << getName();
- ret->setName(oss.str().c_str());
+ ret->setName(oss.str());
ret->setMesh(getMesh());
return ret.retn();
}
@@ -2595,7 +2678,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::keepSelectedComponents(const std
MEDCouplingTimeDiscretization *td=_time_discr->keepSelectedComponents(compoIds);
td->copyTinyAttrFrom(*_time_discr);
MEDCouplingAutoRefCountObjectPtr ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
- ret->setName(getName().c_str());
+ ret->setName(getName());
ret->setMesh(getMesh());
return ret.retn();
}
@@ -2641,8 +2724,10 @@ void MEDCouplingFieldDouble::sortPerTuple(bool asc)
* \throw If the spatial discretization of \a f1 is NULL.
* \throw If the time discretization of \a f1 is NULL.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_MergeFields "Here is a C++ example".
* \ref py_mcfielddouble_MergeFields "Here is a Python example".
+ * \endif
*/
MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
{
@@ -2656,8 +2741,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const MEDCouplingFie
MEDCouplingTimeDiscretization *td=f1->_time_discr->aggregate(f2->_time_discr);
td->copyTinyAttrFrom(*f1->_time_discr);
MEDCouplingAutoRefCountObjectPtr ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
- ret->setName(f1->getName().c_str());
- ret->setDescription(f1->getDescription().c_str());
+ ret->setName(f1->getName());
+ ret->setDescription(f1->getDescription());
if(m1)
{
MEDCouplingAutoRefCountObjectPtr m=m1->mergeMyselfWith(m2);
@@ -2680,8 +2765,10 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const MEDCouplingFie
* \throw If \a a is empty.
* \throw If the fields are not compatible for the merge.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_MergeFields "Here is a C++ example".
* \ref py_mcfielddouble_MergeFields "Here is a Python example".
+ * \endif
*/
MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const std::vector& a)
{
@@ -2708,8 +2795,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const std::vectoraggregate(tds);
td->copyTinyAttrFrom(*(a[0]->_time_discr));
MEDCouplingAutoRefCountObjectPtr ret=new MEDCouplingFieldDouble(a[0]->getNature(),td,a[0]->_type->clone());
- ret->setName(a[0]->getName().c_str());
- ret->setDescription(a[0]->getDescription().c_str());
+ ret->setName(a[0]->getName());
+ ret->setDescription(a[0]->getDescription());
if(ms2[0])
{
MEDCouplingAutoRefCountObjectPtr m=MEDCouplingUMesh::MergeUMeshes(ms2);
@@ -2815,8 +2902,10 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::CrossProductFields(const MEDCoup
* \throw If the fields are not strictly compatible (areStrictlyCompatible()), i.e. they
* differ not only in values.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_MaxFields "Here is a C++ example".
* \ref py_mcfielddouble_MaxFields "Here is a Python example".
+ * \endif
*/
MEDCouplingFieldDouble *MEDCouplingFieldDouble::MaxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
{
@@ -2843,8 +2932,10 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::MaxFields(const MEDCouplingField
* \throw If the fields are not strictly compatible (areStrictlyCompatible()), i.e. they
* differ not only in values.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_MaxFields "Here is a C++ example".
* \ref py_mcfielddouble_MaxFields "Here is a Python example".
+ * \endif
*/
MEDCouplingFieldDouble *MEDCouplingFieldDouble::MinFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
{
@@ -2915,7 +3006,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::AddFields(const MEDCouplingField
* \throw If the fields are not strictly compatible (areStrictlyCompatible()), i.e. they
* differ not only in values.
*/
-const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator+=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception)
+const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator+=(const MEDCouplingFieldDouble& other)
{
if(!areStrictlyCompatible(&other))
throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply += on them !");
@@ -2959,7 +3050,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::SubstractFields(const MEDCouplin
* \throw If the fields are not strictly compatible (areStrictlyCompatible()), i.e. they
* differ not only in values.
*/
-const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator-=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception)
+const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator-=(const MEDCouplingFieldDouble& other)
{
if(!areStrictlyCompatible(&other))
throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply -= on them !");
@@ -3021,7 +3112,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::MultiplyFields(const MEDCoupling
* (areCompatibleForMul()),
* i.e. they differ not only in values and possibly in number of components.
*/
-const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator*=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception)
+const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator*=(const MEDCouplingFieldDouble& other)
{
if(!areCompatibleForMul(&other))
throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply *= on them !");
@@ -3077,7 +3168,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::DivideFields(const MEDCouplingFi
* \throw If the fields are not compatible for division (areCompatibleForDiv()),
* i.e. they differ not only in values and possibly in number of components.
*/
-const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator/=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception)
+const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator/=(const MEDCouplingFieldDouble& other)
{
if(!areCompatibleForDiv(&other))
throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply /= on them !");
@@ -3108,12 +3199,12 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::PowFields(const MEDCouplingField
*
* \sa MEDCouplingFieldDouble::PowFields
*/
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::operator^(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::operator^(const MEDCouplingFieldDouble& other) const
{
return PowFields(this,&other);
}
-const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator^=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception)
+const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator^=(const MEDCouplingFieldDouble& other)
{
if(!areCompatibleForDiv(&other))
throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply /= on them !");
@@ -3134,10 +3225,12 @@ const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator^=(const MEDCoupli
* \throw If the mesh is not set.
* \throw If any of the fields has no name.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_WriteVTK "Here is a C++ example".
* \ref py_mcfielddouble_WriteVTK "Here is a Python example".
+ * \endif
*/
-void MEDCouplingFieldDouble::WriteVTK(const char *fileName, const std::vector& fs, bool isBinary)
+void MEDCouplingFieldDouble::WriteVTK(const std::string& fileName, const std::vector& fs, bool isBinary)
{
if(fs.empty())
return;
@@ -3167,9 +3260,9 @@ void MEDCouplingFieldDouble::WriteVTK(const char *fileName, const std::vectorgetTypeOfField();
if(typ==ON_CELLS)
- cur->getArray()->writeVTK(coss,8,cur->getName().c_str(),byteArr);
+ cur->getArray()->writeVTK(coss,8,cur->getName(),byteArr);
else if(typ==ON_NODES)
- cur->getArray()->writeVTK(noss,8,cur->getName().c_str(),byteArr);
+ cur->getArray()->writeVTK(noss,8,cur->getName(),byteArr);
else
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::WriteVTK : only node and cell fields supported for the moment !");
}
@@ -3181,12 +3274,12 @@ void MEDCouplingFieldDouble::reprQuickOverview(std::ostream& stream) const
stream << "MEDCouplingFieldDouble C++ instance at " << this << ". Name : \"" << _name << "\"." << std::endl;
const char *nat=0;
try
- {
+ {
nat=MEDCouplingNatureOfField::GetRepr(_nature);
stream << "Nature of field : " << nat << ".\n";
- }
+ }
catch(INTERP_KERNEL::Exception& /*e*/)
- { }
+ { }
const MEDCouplingFieldDiscretization *fd(_type);
if(!fd)
stream << "No spatial discretization set !";