MEDCouplingCurveLinearMesh.*xx \
MEDCouplingMappedExtrudedMesh.*xx \
MEDCouplingFieldDouble.*xx \
+ MEDCouplingFieldInt.*xx \
+ MEDCouplingFieldT.*xx \
MEDCouplingField.*xx \
MEDCouplingNatureOfFieldEnum \
MEDCouplingNatureOfField.hxx \
* 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 std::string& unit)
-{
- timeDiscr()->setTimeUnit(unit);
-}
+//void MEDCouplingFieldDouble::setTimeUnit(const std::string& unit)
/*!
* Returns a time unit of \a this field.
* \return a string describing units in which time is measured.
*/
-std::string MEDCouplingFieldDouble::getTimeUnit() const
-{
- return timeDiscr()->getTimeUnit();
-}
+//std::string MEDCouplingFieldDouble::getTimeUnit() const
+
/*!
* This method if possible the time information (time unit, time iteration, time unit and time value) with its support
return new MEDCouplingFieldDouble(*this,recDeepCpy);
}
-/*!
- * Returns a new MEDCouplingFieldDouble which is a copy of \a this one. The data
- * of \a this field is copied either deep or shallow depending on \a recDeepCpy
- * parameter. But the underlying mesh is always deep copied.
- * Data that can be copied either deeply or shallow are:
- * - \ref MEDCouplingTemporalDisc "temporal discretization" data that holds array(s)
- * of field values,
- * - \ref MEDCouplingSpatialDisc "a spatial discretization".
- *
- * This method behaves exactly like clone() except that here the underlying **mesh is
- * always deeply duplicated**, whatever the value \a recDeepCpy parameter.
- * The result of \c cloneWithMesh(true) is exactly the same as that of deepCopy().
- * So the resulting field can not be used together with \a this one in the methods
- * like operator+(), operator*() etc. To avoid deep copying the underlying mesh,
- * the user can call clone().
- * \param [in] recDeepCpy - 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.
- * \sa clone()
- */
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::cloneWithMesh(bool recDeepCpy) const
-{
- MCAuto<MEDCouplingFieldDouble> ret=clone(recDeepCpy);
- if(_mesh)
- {
- MCAuto<MEDCouplingMesh> mCpy=_mesh->deepCopy();
- ret->setMesh(mCpy);
- }
- return ret.retn();
-}
-
/*!
* Returns a new MEDCouplingFieldDouble which is a deep copy of \a this one **including
* the mesh**.
{
}
-/*!
- * Checks if \a this field is correctly defined, else an exception is thrown.
- * \throw If the mesh is not set.
- * \throw If the data array is not set.
- * \throw If the spatial discretization of \a this field is NULL.
- * \throw If \a this->getTimeTolerance() < 0.
- * \throw If the temporal discretization data is incorrect.
- * \throw If mesh data does not correspond to field data.
- */
-void MEDCouplingFieldDouble::checkConsistencyLight() const
-{
- MEDCouplingField::checkConsistencyLight();
- timeDiscr()->checkConsistencyLight();
- _type->checkCoherencyBetween(_mesh,getArray());
-}
-
/*!
* Accumulate values of a given component of \a this field.
* \param [in] compId - the index of the component of interest.
_type->checkCompatibilityWithNature(nat);
}
-/*!
- * This method synchronizes time information (time, iteration, order, time unit) regarding the information in \c this->_mesh.
- * \throw If no mesh is set in this. Or if \a this is not compatible with time setting (typically NO_TIME)
- */
-void MEDCouplingFieldDouble::synchronizeTimeWithMesh()
-{
- if(!_mesh)
- throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::synchronizeTimeWithMesh : no mesh set in this !");
- int it=-1,ordr=-1;
- double val=_mesh->getTime(it,ordr);
- std::string timeUnit(_mesh->getTimeUnit());
- setTime(val,it,ordr);
- setTimeUnit(timeUnit);
-}
+
/*!
* Returns a value of \a this field of type either
* \ref MEDCouplingSpatialDisc "spatial discretization" of \a this field
* (see getNumberOfTuples()), but this size is not checked here.
*/
-void MEDCouplingFieldDouble::setArray(DataArrayDouble *array)
-{
- timeDiscr()->setArray(array,this);
-}
+//void MEDCouplingFieldDouble::setArray(DataArrayDouble *array)
/*!
* Sets the data array holding values corresponding to an end of a time interval
* \ref MEDCouplingSpatialDisc "spatial discretization" of \a this field
* (see getNumberOfTuples()), but this size is not checked here.
*/
-void MEDCouplingFieldDouble::setEndArray(DataArrayDouble *array)
-{
- timeDiscr()->setEndArray(array,this);
-}
+//void MEDCouplingFieldDouble::setEndArray(DataArrayDouble *array)
/*!
* Sets all data arrays needed to define the field values.
* \throw If number of arrays in \a arrs does not correspond to type of
* \ref MEDCouplingTemporalDisc "temporal discretization" of \a this field.
*/
-void MEDCouplingFieldDouble::setArrays(const std::vector<DataArrayDouble *>& arrs)
-{
- timeDiscr()->setArrays(arrs,this);
-}
+//void MEDCouplingFieldDouble::setArrays(const std::vector<DataArrayDouble *>& arrs)
void MEDCouplingFieldDouble::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
{
public:
MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME);
MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td=ONE_TIME);
- MEDCOUPLING_EXPORT void setTimeUnit(const std::string& unit);
- MEDCOUPLING_EXPORT std::string getTimeUnit() const;
MEDCOUPLING_EXPORT void synchronizeTimeWithSupport();
MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingField *other);
MEDCOUPLING_EXPORT void copyTinyAttrFrom(const MEDCouplingFieldDouble *other);
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildSubPartRange(int begin, int end, int step) const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *deepCopy() const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *clone(bool recDeepCpy) const;
- MEDCOUPLING_EXPORT MEDCouplingFieldDouble *cloneWithMesh(bool recDeepCpy) const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCopy) const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *nodeToCellDiscretization() const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *cellToNodeDiscretization() const;
MEDCOUPLING_EXPORT TypeOfTimeDiscretization getTimeDiscretization() const;
- MEDCOUPLING_EXPORT void checkConsistencyLight() const;
MEDCOUPLING_EXPORT void setNature(NatureOfField nat);
- MEDCOUPLING_EXPORT void setTimeTolerance(double val) { _time_discr->setTimeTolerance(val); }
- MEDCOUPLING_EXPORT double getTimeTolerance() const { return _time_discr->getTimeTolerance(); }
- MEDCOUPLING_EXPORT void setIteration(int it) { _time_discr->setIteration(it); }
- MEDCOUPLING_EXPORT void setEndIteration(int it) { _time_discr->setEndIteration(it); }
- MEDCOUPLING_EXPORT void setOrder(int order) { _time_discr->setOrder(order); }
- MEDCOUPLING_EXPORT void setEndOrder(int order) { _time_discr->setEndOrder(order); }
- MEDCOUPLING_EXPORT void setTimeValue(double val) { _time_discr->setTimeValue(val); }
- MEDCOUPLING_EXPORT void setEndTimeValue(double val) { _time_discr->setEndTimeValue(val); }
- MEDCOUPLING_EXPORT void setTime(double val, int iteration, int order) { _time_discr->setTime(val,iteration,order); }
- MEDCOUPLING_EXPORT void synchronizeTimeWithMesh();
- MEDCOUPLING_EXPORT void setStartTime(double val, int iteration, int order) { _time_discr->setStartTime(val,iteration,order); }
- MEDCOUPLING_EXPORT void setEndTime(double val, int iteration, int order) { _time_discr->setEndTime(val,iteration,order); }
- MEDCOUPLING_EXPORT double getTime(int& iteration, int& order) const { return _time_discr->getTime(iteration,order); }
- MEDCOUPLING_EXPORT double getStartTime(int& iteration, int& order) const { return _time_discr->getStartTime(iteration,order); }
- MEDCOUPLING_EXPORT double getEndTime(int& iteration, int& order) const { return _time_discr->getEndTime(iteration,order); }
- MEDCOUPLING_EXPORT double getIJ(int tupleId, int compoId) const { return getArray()->getIJ(tupleId,compoId); }
MEDCOUPLING_EXPORT double getIJK(int cellId, int nodeIdInCell, int compoId) const;
- MEDCOUPLING_EXPORT void setArray(DataArrayDouble *array);
- MEDCOUPLING_EXPORT void setEndArray(DataArrayDouble *array);
- MEDCOUPLING_EXPORT void setArrays(const std::vector<DataArrayDouble *>& arrs);
- MEDCOUPLING_EXPORT const DataArrayDouble *getArray() const { return _time_discr->getArray(); }
- MEDCOUPLING_EXPORT DataArrayDouble *getArray() { return _time_discr->getArray(); }
- MEDCOUPLING_EXPORT const DataArrayDouble *getEndArray() const { return _time_discr->getEndArray(); }
- MEDCOUPLING_EXPORT DataArrayDouble *getEndArray() { return _time_discr->getEndArray(); }
- MEDCOUPLING_EXPORT std::vector<DataArrayDouble *> getArrays() const { std::vector<DataArrayDouble *> ret; _time_discr->getArrays(ret); return ret; }
MEDCOUPLING_EXPORT double accumulate(int compId) const;
MEDCOUPLING_EXPORT void accumulate(double *res) const;
MEDCOUPLING_EXPORT double getMaxValue() const;
return new MEDCouplingFieldInt(ft,td);
}
-void MEDCouplingFieldInt::checkConsistencyLight() const
-{
- MEDCouplingField::checkConsistencyLight();
- timeDiscr()->checkConsistencyLight();
- _type->checkCoherencyBetween(_mesh,getArray());
-}
-
std::string MEDCouplingFieldInt::simpleRepr() const
{
std::ostringstream ret;
{
}
-void MEDCouplingFieldInt::setTimeUnit(const std::string& unit)
-{
- timeDiscr()->setTimeUnit(unit);
-}
-
-std::string MEDCouplingFieldInt::getTimeUnit() const
-{
- return timeDiscr()->getTimeUnit();
-}
-
-void MEDCouplingFieldInt::setTime(double val, int iteration, int order)
-{
- timeDiscr()->setTime(val,iteration,order);
-}
-
-double MEDCouplingFieldInt::getTime(int& iteration, int& order) const
-{
- return timeDiscr()->getTime(iteration,order);
-}
-
-void MEDCouplingFieldInt::setArray(DataArrayInt *array)
-{
- timeDiscr()->setArray(array,this);
-}
-
-const DataArrayInt *MEDCouplingFieldInt::getArray() const
-{
- return timeDiscr()->getArray();
-}
-
-DataArrayInt *MEDCouplingFieldInt::getArray()
-{
- return timeDiscr()->getArray();
-}
-
MEDCouplingFieldInt::MEDCouplingFieldInt(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingFieldT<int>(type,MEDCouplingTimeDiscretizationInt::New(td))
{
}
return cloneWithMesh(true);
}
-MEDCouplingFieldInt *MEDCouplingFieldInt::cloneWithMesh(bool recDeepCpy) const
-{
- MCAuto<MEDCouplingFieldInt> ret(clone(recDeepCpy));
- if(_mesh)
- {
- MCAuto<MEDCouplingMesh> mCpy(_mesh->deepCopy());
- ret->setMesh(mCpy);
- }
- return ret.retn();
-}
-
MEDCouplingFieldInt *MEDCouplingFieldInt::clone(bool recDeepCpy) const
{
return new MEDCouplingFieldInt(*this,recDeepCpy);
public:
MEDCOUPLING_EXPORT static MEDCouplingFieldInt *New(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME);
MEDCOUPLING_EXPORT static MEDCouplingFieldInt *New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td=ONE_TIME);
- MEDCOUPLING_EXPORT void checkConsistencyLight() const;
MEDCOUPLING_EXPORT std::string simpleRepr() const;
MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void setTimeUnit(const std::string& unit);
- MEDCOUPLING_EXPORT std::string getTimeUnit() const;
- MEDCOUPLING_EXPORT void setTime(double val, int iteration, int order);
- MEDCOUPLING_EXPORT double getTime(int& iteration, int& order) const;
- MEDCOUPLING_EXPORT void setArray(DataArrayInt *array);
- MEDCOUPLING_EXPORT const DataArrayInt *getArray() const;
- MEDCOUPLING_EXPORT DataArrayInt *getArray();
MEDCOUPLING_EXPORT MEDCouplingFieldInt *deepCopy() const;
MEDCOUPLING_EXPORT MEDCouplingFieldInt *clone(bool recDeepCpy) const;
- MEDCOUPLING_EXPORT MEDCouplingFieldInt *cloneWithMesh(bool recDeepCpy) const;
MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec, std::string& reason) const;
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingField *other);
#define __MEDCOUPLINGFIELDT_HXX__
#include "MEDCouplingField.hxx"
+#include "MEDCouplingTraits.hxx"
#include "MEDCouplingTimeDiscretization.hxx"
namespace MEDCoupling
MEDCouplingFieldT(TypeOfField type, MEDCouplingTimeDiscretizationTemplate<T> *timeDiscr);
MEDCouplingFieldT(MEDCouplingFieldDiscretization *type, NatureOfField n, MEDCouplingTimeDiscretizationTemplate<T> *timeDiscr);
~MEDCouplingFieldT();
+ public:
+ MEDCOUPLING_EXPORT virtual typename Traits<T>::FieldType *clone(bool recDeepCpy) const = 0;
+ MEDCOUPLING_EXPORT void checkConsistencyLight() const;
+ MEDCOUPLING_EXPORT typename Traits<T>::FieldType *cloneWithMesh(bool recDeepCpy) const;
+ MEDCOUPLING_EXPORT void setArray(typename Traits<T>::ArrayType *array) { _time_discr->setArray(array,this); }
+ MEDCOUPLING_EXPORT void setEndArray(typename Traits<T>::ArrayType *array) { _time_discr->setEndArray(array,this); }
+ MEDCOUPLING_EXPORT const typename Traits<T>::ArrayType *getArray() const { return _time_discr->getArray(); }
+ MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *getArray() { return _time_discr->getArray(); }
+ MEDCOUPLING_EXPORT const typename Traits<T>::ArrayType *getEndArray() const { return _time_discr->getEndArray(); }
+ MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *getEndArray() { return _time_discr->getEndArray(); }
+ MEDCOUPLING_EXPORT void setArrays(const std::vector<typename Traits<T>::ArrayType *>& arrs) { _time_discr->setArrays(arrs,this); }
+ MEDCOUPLING_EXPORT std::vector<typename Traits<T>::ArrayType *> getArrays() const { std::vector<typename Traits<T>::ArrayType *> ret; _time_discr->getArrays(ret); return ret; }
+ MEDCOUPLING_EXPORT void setTimeUnit(const std::string& unit) { _time_discr->setTimeUnit(unit); }
+ MEDCOUPLING_EXPORT std::string getTimeUnit() const { return _time_discr->getTimeUnit(); }
+ MEDCOUPLING_EXPORT void setTimeTolerance(double val) { _time_discr->setTimeTolerance(val); }
+ MEDCOUPLING_EXPORT double getTimeTolerance() const { return _time_discr->getTimeTolerance(); }
+ MEDCOUPLING_EXPORT void setIteration(int it) { _time_discr->setIteration(it); }
+ MEDCOUPLING_EXPORT void setEndIteration(int it) { _time_discr->setEndIteration(it); }
+ MEDCOUPLING_EXPORT void setOrder(int order) { _time_discr->setOrder(order); }
+ MEDCOUPLING_EXPORT void setEndOrder(int order) { _time_discr->setEndOrder(order); }
+ MEDCOUPLING_EXPORT void setTimeValue(double val) { _time_discr->setTimeValue(val); }
+ MEDCOUPLING_EXPORT void setEndTimeValue(double val) { _time_discr->setEndTimeValue(val); }
+ MEDCOUPLING_EXPORT void setTime(double val, int iteration, int order) { _time_discr->setTime(val,iteration,order); }
+ MEDCOUPLING_EXPORT void synchronizeTimeWithMesh();
+ MEDCOUPLING_EXPORT void setStartTime(double val, int iteration, int order) { _time_discr->setStartTime(val,iteration,order); }
+ MEDCOUPLING_EXPORT void setEndTime(double val, int iteration, int order) { _time_discr->setEndTime(val,iteration,order); }
+ MEDCOUPLING_EXPORT double getTime(int& iteration, int& order) const { return _time_discr->getTime(iteration,order); }
+ MEDCOUPLING_EXPORT double getStartTime(int& iteration, int& order) const { return _time_discr->getStartTime(iteration,order); }
+ MEDCOUPLING_EXPORT double getEndTime(int& iteration, int& order) const { return _time_discr->getEndTime(iteration,order); }
+ MEDCOUPLING_EXPORT T getIJ(int tupleId, int compoId) const { return getArray()->getIJ(tupleId,compoId); }
protected:
MEDCouplingTimeDiscretizationTemplate<T> *_time_discr;
};
#define __MEDCOUPLINGFIELDT_TXX__
#include "MEDCouplingTimeDiscretization.hxx"
+#include "MEDCouplingMesh.hxx"
namespace MEDCoupling
{
MEDCouplingFieldT<T>::MEDCouplingFieldT(const MEDCouplingFieldT<T>& other, bool deepCopy):MEDCouplingField(other,deepCopy),_time_discr(other._time_discr->performCopyOrIncrRef(deepCopy))
{
}
+
+ /*!
+ * Checks if \a this field is correctly defined, else an exception is thrown.
+ * \throw If the mesh is not set.
+ * \throw If the data array is not set.
+ * \throw If the spatial discretization of \a this field is NULL.
+ * \throw If \a this->getTimeTolerance() < 0.
+ * \throw If the temporal discretization data is incorrect.
+ * \throw If mesh data does not correspond to field data.
+ */
+ template<class T>
+ void MEDCouplingFieldT<T>::checkConsistencyLight() const
+ {
+ MEDCouplingField::checkConsistencyLight();
+ _time_discr->checkConsistencyLight();
+ _type->checkCoherencyBetween(_mesh,getArray());
+ }
template<class T>
MEDCouplingFieldT<T>::MEDCouplingFieldT(const MEDCouplingField& other, MEDCouplingTimeDiscretizationTemplate<T> *timeDiscr, bool deepCopy):MEDCouplingField(other,deepCopy),_time_discr(timeDiscr)
{
delete _time_discr;
}
+
+ /*!
+ * This method synchronizes time information (time, iteration, order, time unit) regarding the information in \c this->_mesh.
+ * \throw If no mesh is set in this. Or if \a this is not compatible with time setting (typically NO_TIME)
+ */
+ template<class T>
+ void MEDCouplingFieldT<T>::synchronizeTimeWithMesh()
+ {
+ if(!_mesh)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldT::synchronizeTimeWithMesh : no mesh set in this !");
+ int it(-1),ordr(-1);
+ double val(_mesh->getTime(it,ordr));
+ std::string timeUnit(_mesh->getTimeUnit());
+ setTime(val,it,ordr);
+ setTimeUnit(timeUnit);
+ }
+
+ /*!
+ * Returns a new MEDCouplingFieldDouble which is a copy of \a this one. The data
+ * of \a this field is copied either deep or shallow depending on \a recDeepCpy
+ * parameter. But the underlying mesh is always deep copied.
+ * Data that can be copied either deeply or shallow are:
+ * - \ref MEDCouplingTemporalDisc "temporal discretization" data that holds array(s)
+ * of field values,
+ * - \ref MEDCouplingSpatialDisc "a spatial discretization".
+ *
+ * This method behaves exactly like clone() except that here the underlying **mesh is
+ * always deeply duplicated**, whatever the value \a recDeepCpy parameter.
+ * The result of \c cloneWithMesh(true) is exactly the same as that of deepCopy().
+ * So the resulting field can not be used together with \a this one in the methods
+ * like operator+(), operator*() etc. To avoid deep copying the underlying mesh,
+ * the user can call clone().
+ * \param [in] recDeepCpy - 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.
+ * \sa clone()
+ */
+ template<class T>
+ typename Traits<T>::FieldType *MEDCouplingFieldT<T>::cloneWithMesh(bool recDeepCpy) const
+ {
+ MCAuto< typename Traits<T>::FieldType > ret(clone(recDeepCpy));
+ if(_mesh)
+ {
+ MCAuto<MEDCouplingMesh> mCpy=_mesh->deepCopy();
+ ret->setMesh(mCpy);
+ }
+ return ret.retn();
+ }
}
#endif
class DataArrayInt;
class DataArrayDouble;
class DataArrayChar;
+ class MEDCouplingFieldDouble;
+ class MEDCouplingFieldInt;
template<>
struct Traits<double>
{
static const char ArrayTypeName[];
typedef DataArrayDouble ArrayType;
+ typedef MEDCouplingFieldDouble FieldType;
};
template<>
{
static const char ArrayTypeName[];
typedef DataArrayInt ArrayType;
+ typedef MEDCouplingFieldInt FieldType;
};
template<>