-// 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
{
_time_discr->copyTinyAttrFrom(*other->_time_discr);
}
-
}
void MEDCouplingFieldDouble::copyAllTinyAttrFrom(const MEDCouplingFieldDouble *other)
return ret.str();
}
-void MEDCouplingFieldDouble::writeVTK(const std::string& fileName, bool isBinary) const
+std::string MEDCouplingFieldDouble::writeVTK(const std::string& fileName, bool isBinary) const
{
std::vector<const MEDCouplingFieldDouble *> fs(1,this);
- MEDCouplingFieldDouble::WriteVTK(fileName,fs,isBinary);
+ return MEDCouplingFieldDouble::WriteVTK(fileName,fs,isBinary);
}
bool MEDCouplingFieldDouble::isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec, std::string& reason) const
*/
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<DataArrayDouble *> arrays;
}
MEDCouplingFieldDouble::MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingField(type),
- _time_discr(MEDCouplingTimeDiscretization::New(td))
+ _time_discr(MEDCouplingTimeDiscretization::New(td))
{
}
* ** 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))
{
}
}
/*!
- * Apply a liner function to a given component of \a this field, so that
+ * Apply a linear function to a given component of \a this field, so that
* a component value <em>(x)</em> becomes \f$ a * x + b \f$.
* \param [in] a - the first coefficient of the function.
* \param [in] b - the second coefficient of the function.
_time_discr->applyLin(a,b,compoId);
}
+/*!
+ * Apply a linear function to all components of \a this field, so that
+ * values <em>(x)</em> becomes \f$ a * x + b \f$.
+ * \param [in] a - the first coefficient of the function.
+ * \param [in] b - the second coefficient of the function.
+ * \throw If the data array(s) is(are) not set.
+ */
+void MEDCouplingFieldDouble::applyLin(double a, double b)
+{
+ _time_discr->applyLin(a,b);
+}
+
/*!
* This method sets \a this to a uniform scalar field with one component.
* 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 !");
}
/*!
+ * 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
* - 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() ==
* \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT").
*
- * The returned value does **not depend** on the number of tuples in the data array
+ * The returned value does \b not \b depend on the number of tuples in the data array
* (which has to be equal to the returned value), \b contrary to
* getNumberOfComponents() and getNumberOfValues() that retrieve information from the
- * data array.
+ * data array (Sorry, it is confusing !).
+ * So \b this \b method \b behaves \b exactly \b as MEDCouplingField::getNumberOfTuplesExpected \b method.
+ *
* \warning No checkCoherency() is done here.
* For more info on the data arrays, see \ref MEDCouplingArrayPage.
* \return int - the number of tuples.
* \throw If the mesh is not set.
* \throw If the spatial discretization of \a this field is NULL.
* \throw If the spatial discretization is not fully defined.
+ * \sa MEDCouplingField::getNumberOfTuplesExpected
*/
int MEDCouplingFieldDouble::getNumberOfTuples() const
{
+ //std::cerr << " ******* MEDCouplingFieldDouble::getNumberOfTuples is deprecated : use MEDCouplingField::getNumberOfTuplesExpected instead ! ******" << std::endl;
if(!_mesh)
throw INTERP_KERNEL::Exception("Impossible to retrieve number of tuples because no mesh specified !");
if(!((const MEDCouplingFieldDiscretization *)_type))
return MEDCouplingField::getHeapMemorySizeWithoutChildren();
}
-std::vector<const BigMemoryObject *> MEDCouplingFieldDouble::getDirectChildren() const
+std::vector<const BigMemoryObject *> MEDCouplingFieldDouble::getDirectChildrenWithNull() const
{
- std::vector<const BigMemoryObject *> ret(MEDCouplingField::getDirectChildren());
+ std::vector<const BigMemoryObject *> ret(MEDCouplingField::getDirectChildrenWithNull());
if(_time_discr)
{
- std::vector<const BigMemoryObject *> ret2(_time_discr->getDirectChildren());
+ std::vector<const BigMemoryObject *> ret2(_time_discr->getDirectChildrenWithNull());
ret.insert(ret.end(),ret2.begin(),ret2.end());
}
return ret;
* \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 !");
* \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 !");
* (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 !");
* \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 !");
*
* \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 !");
* \ref py_mcfielddouble_WriteVTK "Here is a Python example".
* \endif
*/
-void MEDCouplingFieldDouble::WriteVTK(const std::string& fileName, const std::vector<const MEDCouplingFieldDouble *>& fs, bool isBinary)
+std::string MEDCouplingFieldDouble::WriteVTK(const std::string& fileName, const std::vector<const MEDCouplingFieldDouble *>& fs, bool isBinary)
{
if(fs.empty())
- return;
+ return std::string();
std::size_t nfs=fs.size();
if(!fs[0])
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::WriteVTK : 1st instance of field is NULL !");
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::WriteVTK : Fields are not lying on a same mesh ! Expected by VTK ! MEDCouplingFieldDouble::setMesh or MEDCouplingFieldDouble::changeUnderlyingMesh can help to that.");
if(!m)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::WriteVTK : Fields are lying on a same mesh but it is empty !");
+ std::string ret(m->getVTKFileNameOf(fileName));
MEDCouplingAutoRefCountObjectPtr<DataArrayByte> byteArr;
if(isBinary)
{ byteArr=DataArrayByte::New(); byteArr->alloc(0,1); }
else
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::WriteVTK : only node and cell fields supported for the moment !");
}
- m->writeVTKAdvanced(fileName,coss.str(),noss.str(),byteArr);
+ m->writeVTKAdvanced(ret,coss.str(),noss.str(),byteArr);
+ return ret;
}
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 !";