MEDCouplingCurveLinearMesh.*xx \
MEDCouplingMappedExtrudedMesh.*xx \
MEDCouplingFieldDouble.*xx \
+ MEDCouplingFieldInt.*xx \
+ MEDCouplingFieldT.*xx \
MEDCouplingField.*xx \
MEDCouplingNatureOfFieldEnum \
MEDCouplingNatureOfField.hxx \
{
}
+INTERP_KERNEL::Exception::Exception(const std::string& reason):_reason(reason)
+{
+}
+
INTERP_KERNEL::Exception::Exception(const char *reason, const char *file, int line):_reason(reason)
{
}
{
public:
INTERPKERNEL_EXPORT Exception(const char *reason);
+ INTERPKERNEL_EXPORT Exception(const std::string& reason);
INTERPKERNEL_EXPORT Exception(const char *reason, const char *file, int line);
INTERPKERNEL_EXPORT ~Exception() throw ();
INTERPKERNEL_EXPORT const char *what() const throw();
void MEDCouplingField::setNature(NatureOfField nat)
{
MEDCouplingNatureOfField::GetRepr(nat);//generate a throw if nat not recognized
+ if(_type)
+ _type->checkCompatibilityWithNature(nat);
_nature=nat;
}
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingFieldTemplate.hxx"
+#include "MEDCouplingFieldT.txx"
+#include "MEDCouplingFieldInt.hxx"
#include "MEDCouplingUMesh.hxx"
#include "MEDCouplingTimeDiscretization.hxx"
#include "MEDCouplingFieldDiscretization.hxx"
using namespace MEDCoupling;
+template class MEDCouplingFieldT<double>;
/*!
* Creates a new MEDCouplingFieldDouble, of given spatial type and time discretization.
* 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)
-{
- _time_discr->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 _time_discr->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
*/
void MEDCouplingFieldDouble::synchronizeTimeWithSupport()
{
- _time_discr->synchronizeTimeWith(_mesh);
+ timeDiscr()->synchronizeTimeWith(_mesh);
}
/*!
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**.
*/
MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCopy) const
{
- MEDCouplingTimeDiscretization *tdo=_time_discr->buildNewTimeReprFromThis(td,deepCopy);
+ MEDCouplingTimeDiscretization *tdo=timeDiscr()->buildNewTimeReprFromThis(td,deepCopy);
MCAuto<MEDCouplingFieldDiscretization> disc;
if(_type)
disc=_type->clone();
else
{
std::ostringstream oss; oss << "MEDCouplingFieldDouble::nodeToCellDiscretization : Cell id #" << i << " has been detected to have no nodes !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
}
return ret.retn();
}
-/*!
- * Copies tiny info (component names, name and description) from an \a other field to
- * \a this one.
- * \warning The underlying mesh is not renamed (for safety reason).
- * \param [in] other - the field to copy the tiny info from.
- * \throw If \a this->getNumberOfComponents() != \a other->getNumberOfComponents()
- */
-void MEDCouplingFieldDouble::copyTinyStringsFrom(const MEDCouplingField *other)
-{
- MEDCouplingField::copyTinyStringsFrom(other);
- const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
- if(otherC)
- {
- _time_discr->copyTinyStringsFrom(*otherC->_time_discr);
- }
-}
-
-/*!
- * Copies only times, order and iteration from an \a other field to
- * \a this one. The underlying mesh is not impacted by this method.
- * Arrays are not impacted neither.
- * \param [in] other - the field to tiny attributes from.
- * \throw If \a this->getNumberOfComponents() != \a other->getNumberOfComponents()
- */
-void MEDCouplingFieldDouble::copyTinyAttrFrom(const MEDCouplingFieldDouble *other)
-{
- if(other)
- {
- _time_discr->copyTinyAttrFrom(*other->_time_discr);
- }
-}
-
-void MEDCouplingFieldDouble::copyAllTinyAttrFrom(const MEDCouplingFieldDouble *other)
-{
- copyTinyStringsFrom(other);
- copyTinyAttrFrom(other);
-}
-
-/*!
- * Returns a string describing \a this field. This string is outputted by \c print
- * Python command. The string includes info on
- * - name,
- * - description,
- * - \ref MEDCouplingSpatialDisc "spatial discretization",
- * - \ref MEDCouplingTemporalDisc "time discretization",
- * - \ref NatureOfField,
- * - components,
- * - mesh.
- *
- * \return std::string - the string describing \a this field.
- */
-std::string MEDCouplingFieldDouble::simpleRepr() const
-{
- std::ostringstream ret;
- ret << "FieldDouble with name : \"" << getName() << "\"\n";
- ret << "Description of field is : \"" << getDescription() << "\"\n";
- if(_type)
- { ret << "FieldDouble space discretization is : " << _type->getStringRepr() << "\n"; }
- else
- { ret << "FieldDouble has no spatial discretization !\n"; }
- if(_time_discr)
- { ret << "FieldDouble time discretization is : " << _time_discr->getStringRepr() << "\n"; }
- else
- { ret << "FieldDouble has no time discretization !\n"; }
- ret << "FieldDouble nature of field is : \"" << MEDCouplingNatureOfField::GetReprNoThrow(_nature) << "\"\n";
- if(getArray())
- {
- if(getArray()->isAllocated())
- {
- int nbOfCompo=getArray()->getNumberOfComponents();
- ret << "FieldDouble default array has " << nbOfCompo << " components and " << getArray()->getNumberOfTuples() << " tuples.\n";
- ret << "FieldDouble default array has following info on components : ";
- for(int i=0;i<nbOfCompo;i++)
- ret << "\"" << getArray()->getInfoOnComponent(i) << "\" ";
- ret << "\n";
- }
- else
- {
- ret << "Array set but not allocated !\n";
- }
- }
- if(_mesh)
- ret << "Mesh support information :\n__________________________\n" << _mesh->simpleRepr();
- else
- ret << "Mesh support information : No mesh set !\n";
- return ret.str();
-}
-
/*!
* Returns a string describing \a this field. The string includes info on
* - name,
{ ret << "FieldDouble space discretization is : " << _type->getStringRepr() << "\n"; }
else
{ ret << "FieldDouble has no space discretization set !\n"; }
- if(_time_discr)
- { ret << "FieldDouble time discretization is : " << _time_discr->getStringRepr() << "\n"; }
+ if(timeDiscr())
+ { ret << "FieldDouble time discretization is : " << timeDiscr()->getStringRepr() << "\n"; }
else
{ ret << "FieldDouble has no time discretization set !\n"; }
if(getArray())
else
ret << "Mesh support information : No mesh set !\n";
std::vector<DataArrayDouble *> arrays;
- _time_discr->getArrays(arrays);
+ timeDiscr()->getArrays(arrays);
int arrayId=0;
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++,arrayId++)
{
return MEDCouplingFieldDouble::WriteVTK(fileName,fs,isBinary);
}
-bool MEDCouplingFieldDouble::isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec, std::string& reason) const
-{
- if(!other)
- throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::isEqualIfNotWhy : other instance is NULL !");
- const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
- if(!otherC)
- {
- reason="field given in input is not castable in MEDCouplingFieldDouble !";
- return false;
- }
- if(!MEDCouplingField::isEqualIfNotWhy(other,meshPrec,valsPrec,reason))
- return false;
- if(!_time_discr->isEqualIfNotWhy(otherC->_time_discr,valsPrec,reason))
- {
- reason.insert(0,"In FieldDouble time discretizations differ :");
- return false;
- }
- return true;
-}
-
-/*!
- * Checks equality of \a this and \a other field. Only numeric data is considered,
- * i.e. names, description etc are not compared.
- * \param [in] other - the field to compare with.
- * \param [in] meshPrec - a precision used to compare node coordinates of meshes.
- * \param [in] valsPrec - a precision used to compare data arrays of the two fields.
- * \return bool - \c true if the two fields are equal, \c false else.
- * \throw If \a other == NULL.
- * \throw If the spatial discretization of \a this field is NULL.
- */
-bool MEDCouplingFieldDouble::isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const
-{
- const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
- if(!otherC)
- return false;
- if(!MEDCouplingField::isEqualWithoutConsideringStr(other,meshPrec,valsPrec))
- return false;
- if(!_time_discr->isEqualWithoutConsideringStr(otherC->_time_discr,valsPrec))
- return false;
- return true;
-}
-
/*!
* This method states if \a this and 'other' are compatibles each other before performing any treatment.
* This method is good for methods like : mergeFields.
{
if(!MEDCouplingField::areCompatibleForMerge(other))
return false;
- const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
+ const MEDCouplingFieldDouble *otherC(dynamic_cast<const MEDCouplingFieldDouble *>(other));
if(!otherC)
return false;
- if(!_time_discr->areCompatible(otherC->_time_discr))
- return false;
- return true;
-}
-
-/*!
- * This method is more strict than MEDCouplingField::areCompatibleForMerge method.
- * This method is used for operation on fields to operate a first check before attempting operation.
- */
-bool MEDCouplingFieldDouble::areStrictlyCompatible(const MEDCouplingField *other) const
-{
- std::string tmp;
- if(!MEDCouplingField::areStrictlyCompatible(other))
- return false;
- const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
- if(!otherC)
- return false;
- if(!_time_discr->areStrictlyCompatible(otherC->_time_discr,tmp))
- return false;
- return true;
-}
-
-/*!
- * Method with same principle than MEDCouplingFieldDouble::areStrictlyCompatibleForMulDiv method except that
- * number of components between \a this and 'other' can be different here (for operator*).
- */
-bool MEDCouplingFieldDouble::areCompatibleForMul(const MEDCouplingField *other) const
-{
- if(!MEDCouplingField::areStrictlyCompatibleForMulDiv(other))
- return false;
- const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
- if(!otherC)
- return false;
- if(!_time_discr->areStrictlyCompatibleForMul(otherC->_time_discr))
- return false;
- return true;
-}
-
-/*!
- * Method with same principle than MEDCouplingFieldDouble::areStrictlyCompatibleForMulDiv method except that
- * number of components between \a this and 'other' can be different here (for operator/).
- */
-bool MEDCouplingFieldDouble::areCompatibleForDiv(const MEDCouplingField *other) const
-{
- if(!MEDCouplingField::areStrictlyCompatibleForMulDiv(other))
- return false;
- const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
- if(!otherC)
- return false;
- if(!_time_discr->areStrictlyCompatibleForDiv(otherC->_time_discr))
+ if(!timeDiscr()->areCompatible(otherC->timeDiscr()))
return false;
return true;
}
{
if(!MEDCouplingField::areStrictlyCompatible(other))
return false;
- if(!_time_discr->areCompatibleForMeld(other->_time_discr))
+ if(!timeDiscr()->areCompatibleForMeld(other->timeDiscr()))
return false;
return true;
}
//
_type->renumberCells(old2NewBg,check);
std::vector<DataArrayDouble *> arrays;
- _time_discr->getArrays(arrays);
+ timeDiscr()->getArrays(arrays);
std::vector<DataArray *> arrays2(arrays.size()); std::copy(arrays.begin(),arrays.end(),arrays2.begin());
_type->renumberArraysForCell(_mesh,arrays2,old2NewBg,check);
//
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("Expecting a spatial discretization to be able to operate a renumbering !");
std::vector<DataArrayDouble *> arrays;
- _time_discr->getArrays(arrays);
+ timeDiscr()->getArrays(arrays);
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
if(*iter)
_type->renumberValuesOnNodes(eps,old2NewBg,newNbOfNodes,*iter);
ret->setDiscretization(MCAuto<MEDCouplingFieldDiscretization>(disc->clonePart(partBg,partEnd)));
ret->setMesh(m);
std::vector<DataArrayDouble *> arrays;
- _time_discr->getArrays(arrays);
+ timeDiscr()->getArrays(arrays);
std::vector<DataArrayDouble *> arrs;
std::vector< MCAuto<DataArrayDouble> > arrsSafe;
const int *arrSelBg=arrSelect->begin();
arr=(*iter)->selectByTupleIdSafe(arrSelBg,arrSelEnd);
arrs.push_back(arr); arrsSafe.push_back(arr);
}
- ret->_time_discr->setArrays(arrs,0);
+ ret->timeDiscr()->setArrays(arrs,0);
return ret.retn();
}
ret->setDiscretization(MCAuto<MEDCouplingFieldDiscretization>(disc->clonePartRange(begin,end,step)));
ret->setMesh(m);
std::vector<DataArrayDouble *> arrays;
- _time_discr->getArrays(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++)
}
arrs.push_back(arr); arrsSafe.push_back(arr);
}
- ret->_time_discr->setArrays(arrs,0);
+ ret->timeDiscr()->setArrays(arrs,0);
return ret.retn();
}
-/*!
- * Returns a type of \ref MEDCouplingTemporalDisc "time discretization" of \a this field.
- * \return MEDCoupling::TypeOfTimeDiscretization - an enum item describing the time
- * discretization type.
- */
-TypeOfTimeDiscretization MEDCouplingFieldDouble::getTimeDiscretization() const
+MEDCouplingFieldInt *MEDCouplingFieldDouble::convertToIntField() const
{
- return _time_discr->getEnum();
+ 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();
}
-MEDCouplingFieldDouble::MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingField(type),
- _time_discr(MEDCouplingTimeDiscretization::New(td))
+MEDCouplingFieldDouble::MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingFieldT<double>(type,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))
+MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td):MEDCouplingFieldT<double>(ft,MEDCouplingTimeDiscretization::New(td),false)
{
}
-MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCopy):MEDCouplingField(other,deepCopy),
- _time_discr(dynamic_cast<MEDCouplingTimeDiscretization *>(other._time_discr->performCopyOrIncrRef(deepCopy)))
+MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCopy):MEDCouplingFieldT<double>(other,deepCopy)
{
}
-MEDCouplingFieldDouble::MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type):MEDCouplingField(type,n),_time_discr(td)
+MEDCouplingFieldDouble::MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type):MEDCouplingFieldT<double>(type,n,td)
{
}
-MEDCouplingFieldDouble::~MEDCouplingFieldDouble()
-{
- delete _time_discr;
-}
-
-/*!
- * 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();
- _time_discr->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.
double MEDCouplingFieldDouble::getMaxValue() const
{
std::vector<DataArrayDouble *> arrays;
- _time_discr->getArrays(arrays);
+ timeDiscr()->getArrays(arrays);
double ret=-std::numeric_limits<double>::max();
bool isExistingArr=false;
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
double MEDCouplingFieldDouble::getMaxValue2(DataArrayInt*& tupleIds) const
{
std::vector<DataArrayDouble *> arrays;
- _time_discr->getArrays(arrays);
+ timeDiscr()->getArrays(arrays);
double ret=-std::numeric_limits<double>::max();
bool isExistingArr=false;
tupleIds=0;
double MEDCouplingFieldDouble::getMinValue() const
{
std::vector<DataArrayDouble *> arrays;
- _time_discr->getArrays(arrays);
+ timeDiscr()->getArrays(arrays);
double ret=std::numeric_limits<double>::max();
bool isExistingArr=false;
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
double MEDCouplingFieldDouble::getMinValue2(DataArrayInt*& tupleIds) const
{
std::vector<DataArrayDouble *> arrays;
- _time_discr->getArrays(arrays);
+ timeDiscr()->getArrays(arrays);
double ret=-std::numeric_limits<double>::max();
bool isExistingArr=false;
tupleIds=0;
if(compId<0 || compId>=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().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
INTERP_KERNEL::AutoPtr<double> res=new double[nbComps];
getWeightedAverageValue(res,isWAbs);
if(compId<0 || compId>=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().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
INTERP_KERNEL::AutoPtr<double> res=new double[nbComps];
_type->normL1(_mesh,getArray(),res);
if(compId<0 || compId>=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().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
INTERP_KERNEL::AutoPtr<double> res=new double[nbComps];
_type->normL2(_mesh,getArray(),res);
if(compId<0 || compId>=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().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
INTERP_KERNEL::AutoPtr<double> res=new double[nbComps];
_type->integral(_mesh,getArray(),isWAbs,res);
*/
void MEDCouplingFieldDouble::getValueOnPos(int i, int j, int k, double *res) const
{
- const DataArrayDouble *arr=_time_discr->getArray();
+ const DataArrayDouble *arr=timeDiscr()->getArray();
if(!_mesh)
throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOnPos");
if(!((const MEDCouplingFieldDiscretization *)_type))
*/
void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double *res) const
{
- const DataArrayDouble *arr=_time_discr->getArray();
+ const DataArrayDouble *arr=timeDiscr()->getArray();
if(!_mesh)
throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOn");
if(!((const MEDCouplingFieldDiscretization *)_type))
*/
DataArrayDouble *MEDCouplingFieldDouble::getValueOnMulti(const double *spaceLoc, int nbOfPoints) const
{
- const DataArrayDouble *arr=_time_discr->getArray();
+ const DataArrayDouble *arr=timeDiscr()->getArray();
if(!_mesh)
throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOnMulti");
if(!((const MEDCouplingFieldDiscretization *)_type))
*/
void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double time, double *res) const
{
- std::vector< const DataArrayDouble *> arrs=_time_discr->getArraysForTime(time);
+ std::vector< const DataArrayDouble *> arrs=timeDiscr()->getArraysForTime(time);
if(!_mesh)
throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOn");
if(!((const MEDCouplingFieldDiscretization *)_type))
res2.resize(sz+(*iter)->getNumberOfComponents());
_type->getValueOn(*iter,_mesh,spaceLoc,&res2[sz]);
}
- _time_discr->getValueForTime(time,res2,res);
+ timeDiscr()->getValueForTime(time,res2,res);
}
/*!
*/
void MEDCouplingFieldDouble::applyLin(double a, double b, int compoId)
{
- _time_discr->applyLin(a,b,compoId);
+ timeDiscr()->applyLin(a,b,compoId);
}
/*!
*/
void MEDCouplingFieldDouble::applyLin(double a, double b)
{
- _time_discr->applyLin(a,b);
+ timeDiscr()->applyLin(a,b);
}
/*!
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform operator = !");
int nbOfTuple=_type->getNumberOfTuples(_mesh);
- _time_discr->setOrCreateUniformValueOnAllComponents(nbOfTuple,value);
+ timeDiscr()->setOrCreateUniformValueOnAllComponents(nbOfTuple,value);
return *this;
}
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform fillFromAnalytic !");
MCAuto<DataArrayDouble> loc=_type->getLocalizationOfDiscValues(_mesh);
- _time_discr->fillFromAnalytic(loc,nbOfComp,func);
+ timeDiscr()->fillFromAnalytic(loc,nbOfComp,func);
}
/*!
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform fillFromAnalytic !");
MCAuto<DataArrayDouble> loc=_type->getLocalizationOfDiscValues(_mesh);
- _time_discr->fillFromAnalytic(loc,nbOfComp,func);
+ timeDiscr()->fillFromAnalytic(loc,nbOfComp,func);
}
/*!
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform fillFromAnalyticCompo !");
MCAuto<DataArrayDouble> loc=_type->getLocalizationOfDiscValues(_mesh);
- _time_discr->fillFromAnalyticCompo(loc,nbOfComp,func);
+ timeDiscr()->fillFromAnalyticCompo(loc,nbOfComp,func);
}
/*!
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform fillFromAnalyticNamedCompo !");
MCAuto<DataArrayDouble> loc=_type->getLocalizationOfDiscValues(_mesh);
- _time_discr->fillFromAnalyticNamedCompo(loc,nbOfComp,varsOrder,func);
+ timeDiscr()->fillFromAnalyticNamedCompo(loc,nbOfComp,varsOrder,func);
}
/*!
*/
void MEDCouplingFieldDouble::applyFunc(int nbOfComp, FunctionToEvaluate func)
{
- _time_discr->applyFunc(nbOfComp,func);
+ timeDiscr()->applyFunc(nbOfComp,func);
}
/*!
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform applyFunc !");
int nbOfTuple=_type->getNumberOfTuples(_mesh);
- _time_discr->setUniformValue(nbOfTuple,nbOfComp,val);
+ timeDiscr()->setUniformValue(nbOfTuple,nbOfComp,val);
}
/*!
*/
void MEDCouplingFieldDouble::applyFunc(int nbOfComp, const std::string& func)
{
- _time_discr->applyFunc(nbOfComp,func);
+ timeDiscr()->applyFunc(nbOfComp,func);
}
*/
void MEDCouplingFieldDouble::applyFuncCompo(int nbOfComp, const std::string& func)
{
- _time_discr->applyFuncCompo(nbOfComp,func);
+ timeDiscr()->applyFuncCompo(nbOfComp,func);
}
/*!
*/
void MEDCouplingFieldDouble::applyFuncNamedCompo(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func)
{
- _time_discr->applyFuncNamedCompo(nbOfComp,varsOrder,func);
+ timeDiscr()->applyFuncNamedCompo(nbOfComp,varsOrder,func);
}
/*!
*/
void MEDCouplingFieldDouble::applyFunc(const std::string& func)
{
- _time_discr->applyFunc(func);
+ timeDiscr()->applyFunc(func);
}
/*!
*/
void MEDCouplingFieldDouble::applyFuncFast32(const std::string& func)
{
- _time_discr->applyFuncFast32(func);
+ timeDiscr()->applyFuncFast32(func);
}
/*!
*/
void MEDCouplingFieldDouble::applyFuncFast64(const std::string& func)
{
- _time_discr->applyFuncFast64(func);
+ timeDiscr()->applyFuncFast64(func);
}
/*!
void MEDCouplingFieldDouble::updateTime() const
{
MEDCouplingField::updateTime();
- updateTimeWith(*_time_discr);
+ updateTimeWith(*timeDiscr());
}
std::size_t MEDCouplingFieldDouble::getHeapMemorySizeWithoutChildren() const
std::vector<const BigMemoryObject *> MEDCouplingFieldDouble::getDirectChildrenWithNull() const
{
std::vector<const BigMemoryObject *> ret(MEDCouplingField::getDirectChildrenWithNull());
- if(_time_discr)
+ if(timeDiscr())
{
- std::vector<const BigMemoryObject *> ret2(_time_discr->getDirectChildrenWithNull());
+ std::vector<const BigMemoryObject *> ret2(timeDiscr()->getDirectChildrenWithNull());
ret.insert(ret.end(),ret2.begin(),ret2.end());
}
return ret;
}
-/*!
- * Sets \ref NatureOfField.
- * \param [in] nat - an item of enum MEDCoupling::NatureOfField.
- */
-void MEDCouplingFieldDouble::setNature(NatureOfField nat)
-{
- MEDCouplingField::setNature(nat);
- if(_type)
- _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 MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" or
* \ref MEDCouplingSpatialDisc "spatial discretization" of \a this field
* (see getNumberOfTuples()), but this size is not checked here.
*/
-void MEDCouplingFieldDouble::setArray(DataArrayDouble *array)
-{
- _time_discr->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)
-{
- _time_discr->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)
-{
- _time_discr->setArrays(arrs,this);
-}
+//void MEDCouplingFieldDouble::setArrays(const std::vector<DataArrayDouble *>& arrs)
void MEDCouplingFieldDouble::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
{
tinyInfo.clear();
- _time_discr->getTinySerializationStrInformation(tinyInfo);
+ timeDiscr()->getTinySerializationStrInformation(tinyInfo);
tinyInfo.push_back(_name);
tinyInfo.push_back(_desc);
tinyInfo.push_back(getTimeUnit());
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)_time_discr->getEnum());
+ tinyInfo.push_back((int)timeDiscr()->getEnum());
tinyInfo.push_back((int)_nature);
- _time_discr->getTinySerializationIntInformation(tinyInfo);
+ timeDiscr()->getTinySerializationIntInformation(tinyInfo);
std::vector<int> tinyInfo2;
_type->getTinySerializationIntInformation(tinyInfo2);
tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end());
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform getTinySerializationDbleInformation !");
tinyInfo.clear();
- _time_discr->getTinySerializationDbleInformation(tinyInfo);
+ timeDiscr()->getTinySerializationDbleInformation(tinyInfo);
std::vector<double> tinyInfo2;
_type->getTinySerializationDbleInformation(tinyInfo2);
tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end());
tinyInfoITmp.pop_back();
std::vector<int> tinyInfoITmp2(tinyInfoITmp.begin(),tinyInfoITmp.end()-sz);
std::vector<int> tinyInfoI2(tinyInfoITmp2.begin()+3,tinyInfoITmp2.end());
- _time_discr->resizeForUnserialization(tinyInfoI2,arrays);
+ timeDiscr()->resizeForUnserialization(tinyInfoI2,arrays);
std::vector<int> tinyInfoITmp3(tinyInfoITmp.end()-sz,tinyInfoITmp.end());
_type->resizeForUnserialization(tinyInfoITmp3,dataInt);
}
tinyInfoITmp.pop_back();
std::vector<int> tinyInfoITmp2(tinyInfoITmp.begin(),tinyInfoITmp.end()-sz);
std::vector<int> tinyInfoI2(tinyInfoITmp2.begin()+3,tinyInfoITmp2.end());
- _time_discr->checkForUnserialization(tinyInfoI2,arrays);
+ timeDiscr()->checkForUnserialization(tinyInfoI2,arrays);
std::vector<int> tinyInfoITmp3(tinyInfoITmp.end()-sz,tinyInfoITmp.end());
_type->checkForUnserialization(tinyInfoITmp3,dataInt);
}
std::vector<double> tmp1(tmp.begin(),tmp.end()-sz);
std::vector<double> tmp2(tmp.end()-sz,tmp.end());
//
- _time_discr->finishUnserialization(tinyInfoI2,tmp1,tinyInfoS);
+ timeDiscr()->finishUnserialization(tinyInfoI2,tmp1,tinyInfoS);
_nature=(NatureOfField)tinyInfoI[2];
_type->finishUnserialization(tmp2);
int nbOfElemS=(int)tinyInfoS.size();
{
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform serialize !");
- _time_discr->getArrays(arrays);
+ timeDiscr()->getArrays(arrays);
_type->getSerializationIntArray(dataInt);
}
if(!ret)//no nodes have been merged.
return ret;
std::vector<DataArrayDouble *> arrays;
- _time_discr->getArrays(arrays);
+ timeDiscr()->getArrays(arrays);
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
if(*iter)
_type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),meshC2->getNumberOfNodes(),*iter);
if(!ret)//no nodes have been merged.
return ret;
std::vector<DataArrayDouble *> arrays;
- _time_discr->getArrays(arrays);
+ timeDiscr()->getArrays(arrays);
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
if(*iter)
_type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),meshC2->getNumberOfNodes(),*iter);
if(meshC2->getNumberOfNodes()!=oldNbOfNodes)
{
std::vector<DataArrayDouble *> arrays;
- _time_discr->getArrays(arrays);
+ timeDiscr()->getArrays(arrays);
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
if(*iter)
_type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),meshC2->getNumberOfNodes(),*iter);
if(meshC2->getNumberOfCells()!=oldNbOfCells)
{
std::vector<DataArrayDouble *> arrays;
- _time_discr->getArrays(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);
ret->setMesh(mesh2);
MCAuto<DataArrayInt> tupleIds=computeTupleIdsToSelectFromCellIds(cellIds->begin(),cellIds->end());
std::vector<DataArrayDouble *> arrays;
- _time_discr->getArrays(arrays);
+ timeDiscr()->getArrays(arrays);
int i=0;
std::vector<DataArrayDouble *> newArr(arrays.size());
std::vector< MCAuto<DataArrayDouble> > newArr2(arrays.size());
if(oldNbOfCells==newNbOfCells)
return false;
std::vector<DataArrayDouble *> arrays;
- _time_discr->getArrays(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);
{
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform doublyContractedProduct !");
- MEDCouplingTimeDiscretization *td=_time_discr->doublyContractedProduct();
- td->copyTinyAttrFrom(*_time_discr);
+ MEDCouplingTimeDiscretization *td=timeDiscr()->doublyContractedProduct();
+ td->copyTinyAttrFrom(*timeDiscr());
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
ret->setName("DoublyContractedProduct");
ret->setMesh(getMesh());
{
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform determinant !");
- MEDCouplingTimeDiscretization *td=_time_discr->determinant();
- td->copyTinyAttrFrom(*_time_discr);
+ MEDCouplingTimeDiscretization *td=timeDiscr()->determinant();
+ td->copyTinyAttrFrom(*timeDiscr());
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
ret->setName("Determinant");
ret->setMesh(getMesh());
{
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform eigenValues !");
- MEDCouplingTimeDiscretization *td=_time_discr->eigenValues();
- td->copyTinyAttrFrom(*_time_discr);
+ MEDCouplingTimeDiscretization *td=timeDiscr()->eigenValues();
+ td->copyTinyAttrFrom(*timeDiscr());
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
ret->setName("EigenValues");
ret->setMesh(getMesh());
{
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform eigenVectors !");
- MEDCouplingTimeDiscretization *td=_time_discr->eigenVectors();
- td->copyTinyAttrFrom(*_time_discr);
+ MEDCouplingTimeDiscretization *td=timeDiscr()->eigenVectors();
+ td->copyTinyAttrFrom(*timeDiscr());
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
ret->setName("EigenVectors");
ret->setMesh(getMesh());
{
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform inverse !");
- MEDCouplingTimeDiscretization *td=_time_discr->inverse();
- td->copyTinyAttrFrom(*_time_discr);
+ MEDCouplingTimeDiscretization *td=timeDiscr()->inverse();
+ td->copyTinyAttrFrom(*timeDiscr());
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
ret->setName("Inversion");
ret->setMesh(getMesh());
{
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform trace !");
- MEDCouplingTimeDiscretization *td=_time_discr->trace();
- td->copyTinyAttrFrom(*_time_discr);
+ MEDCouplingTimeDiscretization *td=timeDiscr()->trace();
+ td->copyTinyAttrFrom(*timeDiscr());
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
ret->setName("Trace");
ret->setMesh(getMesh());
{
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform deviator !");
- MEDCouplingTimeDiscretization *td=_time_discr->deviator();
- td->copyTinyAttrFrom(*_time_discr);
+ MEDCouplingTimeDiscretization *td=timeDiscr()->deviator();
+ td->copyTinyAttrFrom(*timeDiscr());
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
ret->setName("Deviator");
ret->setMesh(getMesh());
{
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform magnitude !");
- MEDCouplingTimeDiscretization *td=_time_discr->magnitude();
- td->copyTinyAttrFrom(*_time_discr);
+ MEDCouplingTimeDiscretization *td=timeDiscr()->magnitude();
+ td->copyTinyAttrFrom(*timeDiscr());
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
ret->setName("Magnitude");
ret->setMesh(getMesh());
{
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform maxPerTuple !");
- MEDCouplingTimeDiscretization *td=_time_discr->maxPerTuple();
- td->copyTinyAttrFrom(*_time_discr);
+ MEDCouplingTimeDiscretization *td=timeDiscr()->maxPerTuple();
+ td->copyTinyAttrFrom(*timeDiscr());
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
std::ostringstream oss;
oss << "Max_" << getName();
*/
void MEDCouplingFieldDouble::changeNbOfComponents(int newNbOfComp, double dftValue)
{
- _time_discr->changeNbOfComponents(newNbOfComp,dftValue);
+ timeDiscr()->changeNbOfComponents(newNbOfComp,dftValue);
}
/*!
{
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform keepSelectedComponents !");
- MEDCouplingTimeDiscretization *td=_time_discr->keepSelectedComponents(compoIds);
- td->copyTinyAttrFrom(*_time_discr);
+ MEDCouplingTimeDiscretization *td=timeDiscr()->keepSelectedComponents(compoIds);
+ td->copyTinyAttrFrom(*timeDiscr());
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
ret->setName(getName());
ret->setMesh(getMesh());
*/
void MEDCouplingFieldDouble::setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector<int>& compoIds)
{
- _time_discr->setSelectedComponents(f->_time_discr,compoIds);
+ timeDiscr()->setSelectedComponents(f->timeDiscr(),compoIds);
}
/*!
*/
void MEDCouplingFieldDouble::sortPerTuple(bool asc)
{
- _time_discr->sortPerTuple(asc);
+ timeDiscr()->sortPerTuple(asc);
}
/*!
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->_time_discr)
+ 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->_time_discr->aggregate(f2->_time_discr);
- td->copyTinyAttrFrom(*f1->_time_discr);
+ 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());
{ ms[i]=a[i]->getMesh()->buildUnstructured(); ms2[i]=ms[i]; }
else
{ ms[i]=0; ms2[i]=0; }
- tds[i]=a[i]->_time_discr;
+ tds[i]=a[i]->timeDiscr();
}
MEDCouplingTimeDiscretization *td=tds[0]->aggregate(tds);
- td->copyTinyAttrFrom(*(a[0]->_time_discr));
+ td->copyTinyAttrFrom(*(a[0]->timeDiscr()));
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(a[0]->getNature(),td,a[0]->_type->clone());
ret->setName(a[0]->getName());
ret->setDescription(a[0]->getDescription());
{
if(!f1->areCompatibleForMeld(f2))
throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply MeldFields on them ! Check support mesh, field nature, and spatial and time discretisation.");
- MEDCouplingTimeDiscretization *td=f1->_time_discr->meld(f2->_time_discr);
- td->copyTinyAttrFrom(*f1->_time_discr);
+ MEDCouplingTimeDiscretization *td=f1->timeDiscr()->meld(f2->timeDiscr());
+ td->copyTinyAttrFrom(*f1->timeDiscr());
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
ret->setMesh(f1->getMesh());
return ret.retn();
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::DotFields : input field is NULL !");
if(!f1->areStrictlyCompatibleForMulDiv(f2))
throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply DotFields on them! Check support mesh, and spatial and time discretisation.");
- MEDCouplingTimeDiscretization *td=f1->_time_discr->dot(f2->_time_discr);
- td->copyTinyAttrFrom(*f1->_time_discr);
+ MEDCouplingTimeDiscretization *td=f1->timeDiscr()->dot(f2->timeDiscr());
+ td->copyTinyAttrFrom(*f1->timeDiscr());
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(NoNature,td,f1->_type->clone());
ret->setMesh(f1->getMesh());
return ret;
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::CrossProductFields : input field is NULL !");
if(!f1->areStrictlyCompatibleForMulDiv(f2))
throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply CrossProductFields on them! Check support mesh, and spatial and time discretisation.");
- MEDCouplingTimeDiscretization *td=f1->_time_discr->crossProduct(f2->_time_discr);
- td->copyTinyAttrFrom(*f1->_time_discr);
+ MEDCouplingTimeDiscretization *td=f1->timeDiscr()->crossProduct(f2->timeDiscr());
+ td->copyTinyAttrFrom(*f1->timeDiscr());
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(NoNature,td,f1->_type->clone());
ret->setMesh(f1->getMesh());
return ret.retn();
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::MaxFields : input field is NULL !");
if(!f1->areStrictlyCompatible(f2))
throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply MaxFields on them! Check support mesh, field nature, and spatial and time discretisation.");
- MEDCouplingTimeDiscretization *td=f1->_time_discr->max(f2->_time_discr);
- td->copyTinyAttrFrom(*f1->_time_discr);
+ MEDCouplingTimeDiscretization *td=f1->timeDiscr()->max(f2->timeDiscr());
+ td->copyTinyAttrFrom(*f1->timeDiscr());
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
ret->setMesh(f1->getMesh());
return ret.retn();
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::MinFields : input field is NULL !");
if(!f1->areStrictlyCompatible(f2))
throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply MinFields on them! Check support mesh, field nature, and spatial and time discretisation.");
- MEDCouplingTimeDiscretization *td=f1->_time_discr->min(f2->_time_discr);
- td->copyTinyAttrFrom(*f1->_time_discr);
+ MEDCouplingTimeDiscretization *td=f1->timeDiscr()->min(f2->timeDiscr());
+ td->copyTinyAttrFrom(*f1->timeDiscr());
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
ret->setMesh(f1->getMesh());
return ret.retn();
{
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform negate !");
- MEDCouplingTimeDiscretization *td=_time_discr->negate();
- td->copyTinyAttrFrom(*_time_discr);
+ MEDCouplingTimeDiscretization *td=timeDiscr()->negate();
+ td->copyTinyAttrFrom(*timeDiscr());
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
ret->setMesh(getMesh());
return ret.retn();
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::AddFields : input field is NULL !");
if(!f1->areStrictlyCompatible(f2))
throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply AddFields on them! Check support mesh, field nature, and spatial and time discretisation.");
- MEDCouplingTimeDiscretization *td=f1->_time_discr->add(f2->_time_discr);
- td->copyTinyAttrFrom(*f1->_time_discr);
+ MEDCouplingTimeDiscretization *td=f1->timeDiscr()->add(f2->timeDiscr());
+ td->copyTinyAttrFrom(*f1->timeDiscr());
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
ret->setMesh(f1->getMesh());
return ret.retn();
{
if(!areStrictlyCompatible(&other))
throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply += on them! Check support mesh, field nature, and spatial and time discretisation.");
- _time_discr->addEqual(other._time_discr);
+ timeDiscr()->addEqual(other.timeDiscr());
return *this;
}
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::SubstractFields : input field is NULL !");
if(!f1->areStrictlyCompatible(f2))
throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply SubstractFields on them! Check support mesh, field nature, and spatial and time discretisation.");
- MEDCouplingTimeDiscretization *td=f1->_time_discr->substract(f2->_time_discr);
- td->copyTinyAttrFrom(*f1->_time_discr);
+ MEDCouplingTimeDiscretization *td=f1->timeDiscr()->substract(f2->timeDiscr());
+ td->copyTinyAttrFrom(*f1->timeDiscr());
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
ret->setMesh(f1->getMesh());
return ret.retn();
{
if(!areStrictlyCompatible(&other))
throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply -= on them! Check support mesh, field nature, and spatial and time discretisation.");
- _time_discr->substractEqual(other._time_discr);
+ timeDiscr()->substractEqual(other.timeDiscr());
return *this;
}
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::MultiplyFields : input field is NULL !");
if(!f1->areCompatibleForMul(f2))
throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply MultiplyFields on them! Check support mesh, and spatial and time discretisation.");
- MEDCouplingTimeDiscretization *td=f1->_time_discr->multiply(f2->_time_discr);
- td->copyTinyAttrFrom(*f1->_time_discr);
+ MEDCouplingTimeDiscretization *td=f1->timeDiscr()->multiply(f2->timeDiscr());
+ td->copyTinyAttrFrom(*f1->timeDiscr());
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(NoNature,td,f1->_type->clone());
ret->setMesh(f1->getMesh());
return ret.retn();
{
if(!areCompatibleForMul(&other))
throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply *= on them! Check support mesh, and spatial and time discretisation.");
- _time_discr->multiplyEqual(other._time_discr);
+ timeDiscr()->multiplyEqual(other.timeDiscr());
_nature = NoNature;
return *this;
}
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::DivideFields : input field is NULL !");
if(!f1->areCompatibleForDiv(f2))
throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply DivideFields on them! Check support mesh, and spatial and time discretisation.");
- MEDCouplingTimeDiscretization *td=f1->_time_discr->divide(f2->_time_discr);
- td->copyTinyAttrFrom(*f1->_time_discr);
+ MEDCouplingTimeDiscretization *td=f1->timeDiscr()->divide(f2->timeDiscr());
+ td->copyTinyAttrFrom(*f1->timeDiscr());
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(NoNature,td,f1->_type->clone());
ret->setMesh(f1->getMesh());
return ret.retn();
{
if(!areCompatibleForDiv(&other))
throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply /= on them! Check support mesh, and spatial and time discretisation.");
- _time_discr->divideEqual(other._time_discr);
+ timeDiscr()->divideEqual(other.timeDiscr());
_nature = NoNature;
return *this;
}
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::PowFields : input field is NULL !");
if(!f1->areCompatibleForMul(f2))
throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply PowFields on them! Check support mesh, and spatial and time discretisation.");
- MEDCouplingTimeDiscretization *td=f1->_time_discr->pow(f2->_time_discr);
- td->copyTinyAttrFrom(*f1->_time_discr);
+ MEDCouplingTimeDiscretization *td=f1->timeDiscr()->pow(f2->timeDiscr());
+ td->copyTinyAttrFrom(*f1->timeDiscr());
MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(NoNature,td,f1->_type->clone());
ret->setMesh(f1->getMesh());
return ret.retn();
{
if(!areCompatibleForDiv(&other))
throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply ^= on them! Check support mesh, and spatial and time discretisation.");
- _time_discr->powEqual(other._time_discr);
+ timeDiscr()->powEqual(other.timeDiscr());
_nature = NoNature;
return *this;
}
if(name.empty())
{
std::ostringstream oss; oss << "MEDCouplingFieldDouble::WriteVTK : Field in pos #" << i << " has no name !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
TypeOfField typ=cur->getTypeOfField();
if(typ==ON_CELLS)
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 !";
- else
- fd->reprQuickOverview(stream);
- stream << std::endl;
- if(!_mesh)
- stream << "\nNo mesh support defined !";
- else
- {
- std::ostringstream oss;
- _mesh->reprQuickOverview(oss);
- std::string tmp(oss.str());
- stream << "\nMesh info : " << tmp.substr(0,tmp.find('\n'));
- }
- if(_time_discr)
- {
- const DataArrayDouble *arr=_time_discr->getArray();
- if(arr)
- {
- stream << "\n\nArray info : ";
- arr->reprQuickOverview(stream);
- }
- else
- {
- stream << "\n\nNo data array set !";
- }
- }
+MEDCouplingTimeDiscretization *MEDCouplingFieldDouble::timeDiscr()
+{
+ MEDCouplingTimeDiscretizationTemplate<double> *ret(_time_discr);
+ if(!ret)
+ return 0;
+ MEDCouplingTimeDiscretization *retc(dynamic_cast<MEDCouplingTimeDiscretization *>(ret));
+ if(!retc)
+ throw INTERP_KERNEL::Exception("Field Double Null invalid type of time discr !");
+ return retc;
+}
+
+const MEDCouplingTimeDiscretization *MEDCouplingFieldDouble::timeDiscr() const
+{
+ const MEDCouplingTimeDiscretizationTemplate<double> *ret(_time_discr);
+ if(!ret)
+ return 0;
+ const MEDCouplingTimeDiscretization *retc(dynamic_cast<const MEDCouplingTimeDiscretization *>(ret));
+ if(!retc)
+ throw INTERP_KERNEL::Exception("Field Double Null invalid type of time discr !");
+ return retc;
}
//
// Author : Anthony Geay (CEA/DEN)
-#ifndef __PARAMEDMEM_MEDCOUPLINGFIELDDOUBLE_HXX__
-#define __PARAMEDMEM_MEDCOUPLINGFIELDDOUBLE_HXX__
+#ifndef __MEDCOUPLINGFIELDDOUBLE_HXX__
+#define __MEDCOUPLINGFIELDDOUBLE_HXX__
#include "MEDCoupling.hxx"
-#include "MEDCouplingField.hxx"
-#include "MEDCouplingTimeDiscretization.hxx"
+#include "MEDCouplingFieldT.hxx"
#include "MEDCouplingMemArray.hxx"
namespace MEDCoupling
{
+ class MEDCouplingFieldInt;
class MEDCouplingFieldTemplate;
- class MEDCouplingFieldDouble : public MEDCouplingField
+ class MEDCouplingFieldDouble : public MEDCouplingFieldT<double>
{
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 void copyAllTinyAttrFrom(const MEDCouplingFieldDouble *other);
- MEDCOUPLING_EXPORT std::string simpleRepr() const;
MEDCOUPLING_EXPORT std::string advancedRepr() const;
MEDCOUPLING_EXPORT std::string writeVTK(const std::string& fileName, bool isBinary=true) 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 bool areCompatibleForMerge(const MEDCouplingField *other) const;
- MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingField *other) const;
- MEDCOUPLING_EXPORT bool areCompatibleForMul(const MEDCouplingField *other) const;
- MEDCOUPLING_EXPORT bool areCompatibleForDiv(const MEDCouplingField *other) const;
MEDCOUPLING_EXPORT bool areCompatibleForMeld(const MEDCouplingFieldDouble *other) const;
MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check=true);
MEDCOUPLING_EXPORT void renumberCellsWithoutMesh(const int *old2NewBg, bool check=true);
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 MEDCouplingFieldInt *convertToIntField() const;
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;
MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *PowFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
MEDCOUPLING_EXPORT static std::string WriteVTK(const std::string& fileName, const std::vector<const MEDCouplingFieldDouble *>& fs, bool isBinary=true);
public:
- MEDCOUPLING_EXPORT const MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() const { return _time_discr; }
- MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() { return _time_discr; }
- MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
+ MEDCOUPLING_EXPORT const MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() const { return timeDiscr(); }
+ MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() { return timeDiscr(); }
protected:
- ~MEDCouplingFieldDouble();
+ ~MEDCouplingFieldDouble() { }
private:
MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td);
MEDCouplingFieldDouble(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td);
MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCopy);
MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type);
- private:
- MEDCouplingTimeDiscretization *_time_discr;
+ MEDCouplingTimeDiscretization *timeDiscr();
+ const MEDCouplingTimeDiscretization *timeDiscr() const;
};
}
// Author : Yann Pora (EDF R&D)
#include "MEDCouplingFieldInt.hxx"
+#include "MEDCouplingFieldT.txx"
+#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingFieldTemplate.hxx"
#include "MEDCouplingMesh.hxx"
using namespace MEDCoupling;
+template class MEDCouplingFieldT<int>;
+
MEDCouplingFieldInt *MEDCouplingFieldInt::New(TypeOfField type, TypeOfTimeDiscretization td)
{
return new MEDCouplingFieldInt(type,td);
return new MEDCouplingFieldInt(ft,td);
}
-void MEDCouplingFieldInt::checkConsistencyLight() const
-{
- MEDCouplingField::checkConsistencyLight();
- _time_discr->checkConsistencyLight();
- _type->checkCoherencyBetween(_mesh,getArray());
-}
-
-std::string MEDCouplingFieldInt::simpleRepr() const
-{
- std::ostringstream ret;
- ret << "FieldInt with name : \"" << getName() << "\"\n";
- ret << "Description of field is : \"" << getDescription() << "\"\n";
- if(_type)
- { ret << "FieldInt space discretization is : " << _type->getStringRepr() << "\n"; }
- else
- { ret << "FieldInt has no spatial discretization !\n"; }
- if(_time_discr)
- { ret << "FieldInt time discretization is : " << _time_discr->getStringRepr() << "\n"; }
- else
- { ret << "FieldInt has no time discretization !\n"; }
- ret << "FieldInt nature of field is : \"" << MEDCouplingNatureOfField::GetReprNoThrow(_nature) << "\"\n";
- if(getArray())
- {
- if(getArray()->isAllocated())
- {
- int nbOfCompo=getArray()->getNumberOfComponents();
- ret << "FieldInt default array has " << nbOfCompo << " components and " << getArray()->getNumberOfTuples() << " tuples.\n";
- ret << "FieldInt default array has following info on components : ";
- for(int i=0;i<nbOfCompo;i++)
- ret << "\"" << getArray()->getInfoOnComponent(i) << "\" ";
- ret << "\n";
- }
- else
- {
- ret << "Array set but not allocated !\n";
- }
- }
- if(_mesh)
- ret << "Mesh support information :\n__________________________\n" << _mesh->simpleRepr();
- else
- ret << "Mesh support information : No mesh set !\n";
- return ret.str();
-}
-
-void MEDCouplingFieldInt::reprQuickOverview(std::ostream& stream) const
-{
-}
-
-void MEDCouplingFieldInt::setTimeUnit(const std::string& unit)
-{
- _time_discr->setTimeUnit(unit);
-}
-
-std::string MEDCouplingFieldInt::getTimeUnit() const
-{
- return _time_discr->getTimeUnit();
-}
-
-void MEDCouplingFieldInt::setTime(double val, int iteration, int order)
-{
- _time_discr->setTime(val,iteration,order);
-}
-
-double MEDCouplingFieldInt::getTime(int& iteration, int& order) const
-{
- return _time_discr->getTime(iteration,order);
-}
-
-void MEDCouplingFieldInt::setArray(DataArrayInt *array)
-{
- _time_discr->setArray(array,this);
-}
-
-const DataArrayInt *MEDCouplingFieldInt::getArray() const
+MEDCouplingFieldInt::MEDCouplingFieldInt(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingFieldT<int>(type,MEDCouplingTimeDiscretizationInt::New(td))
{
- return _time_discr->getArray();
}
-DataArrayInt *MEDCouplingFieldInt::getArray()
+MEDCouplingFieldInt::MEDCouplingFieldInt(const MEDCouplingFieldInt& other, bool deepCopy):MEDCouplingFieldT<int>(other,deepCopy)
{
- return _time_discr->getArray();
}
-MEDCouplingFieldInt::MEDCouplingFieldInt(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingField(type),_time_discr(MEDCouplingTimeDiscretizationInt::New(td))
+MEDCouplingFieldInt::MEDCouplingFieldInt(NatureOfField n, MEDCouplingTimeDiscretizationInt *td, MEDCouplingFieldDiscretization *type):MEDCouplingFieldT<int>(type,n,td)
{
}
-MEDCouplingFieldInt::MEDCouplingFieldInt(const MEDCouplingFieldInt& other, bool deepCopy):MEDCouplingField(other,deepCopy),_time_discr(dynamic_cast<MEDCouplingTimeDiscretizationInt *>(other._time_discr->performCopyOrIncrRef(deepCopy)))
+/*!
+ * ** WARINING : This method do not deeply copy neither mesh nor spatial discretization. Only a shallow copy (reference) is done for mesh and spatial discretization ! **
+ */
+MEDCouplingFieldInt::MEDCouplingFieldInt(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td):MEDCouplingFieldT<int>(ft,MEDCouplingTimeDiscretizationInt::New(td),false)
{
}
-MEDCouplingFieldInt::MEDCouplingFieldInt(NatureOfField n, MEDCouplingTimeDiscretizationInt *td, MEDCouplingFieldDiscretization *type):MEDCouplingField(type,n),_time_discr(td)
+MEDCouplingFieldInt *MEDCouplingFieldInt::deepCopy() const
{
+ return cloneWithMesh(true);
}
-MEDCouplingFieldInt::~MEDCouplingFieldInt()
+MEDCouplingFieldInt *MEDCouplingFieldInt::clone(bool recDeepCpy) const
{
- delete _time_discr;
+ return new MEDCouplingFieldInt(*this,recDeepCpy);
}
-/*!
- * ** WARINING : This method do not deeply copy neither mesh nor spatial discretization. Only a shallow copy (reference) is done for mesh and spatial discretization ! **
- */
-MEDCouplingFieldInt::MEDCouplingFieldInt(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td):MEDCouplingField(ft,false),_time_discr(MEDCouplingTimeDiscretizationInt::New(td))
+MEDCouplingFieldDouble *MEDCouplingFieldInt::convertToDblField() const
{
+ MCAuto<MEDCouplingFieldTemplate> tmp(MEDCouplingFieldTemplate::New(*this));
+ int t1,t2;
+ double t0(getTime(t1,t2));
+ MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*tmp,getTimeDiscretization()));
+ ret->setTime(t0,t1,t2);
+ if(getArray())
+ {
+ MCAuto<DataArrayDouble> arr(getArray()->convertToDblArr());
+ ret->setArray(arr);
+ }
+ return ret.retn();
}
#define __MEDCOUPLINGFIELDINT_HXX__
#include "MEDCoupling.hxx"
-#include "MEDCouplingField.hxx"
-#include "MEDCouplingTimeDiscretization.hxx"
+#include "MEDCouplingFieldT.hxx"
#include "MEDCouplingMemArray.hxx"
#include <string>
namespace MEDCoupling
{
+ class MEDCouplingFieldDouble;
class MEDCouplingFieldTemplate;
- class MEDCouplingFieldInt : public MEDCouplingField
+ class MEDCouplingFieldInt : public MEDCouplingFieldT<int>
{
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 MEDCouplingFieldDouble *convertToDblField() const;
protected:
MEDCouplingFieldInt(TypeOfField type, TypeOfTimeDiscretization td);
MEDCouplingFieldInt(const MEDCouplingFieldInt& other, bool deepCopy);
MEDCouplingFieldInt(NatureOfField n, MEDCouplingTimeDiscretizationInt *td, MEDCouplingFieldDiscretization *type);
MEDCouplingFieldInt(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td);
- ~MEDCouplingFieldInt();
- private:
- MEDCouplingTimeDiscretizationInt *_time_discr;
+ ~MEDCouplingFieldInt() { }
};
}
--- /dev/null
+// Copyright (C) 2016 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, 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
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay (EDF R&D)
+
+#ifndef __MEDCOUPLINGFIELDT_HXX__
+#define __MEDCOUPLINGFIELDT_HXX__
+
+#include "MEDCouplingField.hxx"
+#include "MEDCouplingTraits.hxx"
+#include "MEDCouplingTimeDiscretization.hxx"
+
+#include <sstream>
+
+namespace MEDCoupling
+{
+ template<class T>
+ class MEDCouplingTimeDiscretizationTemplate;
+
+ template<class T>
+ class MEDCouplingFieldT : public MEDCouplingField
+ {
+ protected:
+ MEDCouplingFieldT(const MEDCouplingFieldT<T>& other, bool deepCopy);
+ MEDCouplingFieldT(const MEDCouplingField& other, MEDCouplingTimeDiscretizationTemplate<T> *timeDiscr, bool deepCopy=true);
+ MEDCouplingFieldT(TypeOfField type, MEDCouplingTimeDiscretizationTemplate<T> *timeDiscr);
+ MEDCouplingFieldT(MEDCouplingFieldDiscretization *type, NatureOfField n, MEDCouplingTimeDiscretizationTemplate<T> *timeDiscr);
+ ~MEDCouplingFieldT();
+ public:
+ MEDCOUPLING_EXPORT TypeOfTimeDiscretization getTimeDiscretization() const;
+ 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); }
+ 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);
+ MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingField *other) const;
+ MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMulDiv(const MEDCouplingField *other) const;
+ MEDCOUPLING_EXPORT std::string simpleRepr() const;
+ MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
+ // specific
+ MEDCOUPLING_EXPORT bool areCompatibleForMul(const MEDCouplingField *other) const;
+ MEDCOUPLING_EXPORT bool areCompatibleForDiv(const MEDCouplingField *other) const;
+ MEDCOUPLING_EXPORT void copyTinyAttrFrom(const MEDCouplingFieldT<T> *other);
+ MEDCOUPLING_EXPORT void copyAllTinyAttrFrom(const MEDCouplingFieldT<T> *other);
+ protected:
+ MEDCouplingTimeDiscretizationTemplate<T> *_time_discr;
+ };
+}
+
+#endif
--- /dev/null
+// Copyright (C) 2016 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, 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
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay (EDF R&D)
+
+#ifndef __MEDCOUPLINGFIELDT_TXX__
+#define __MEDCOUPLINGFIELDT_TXX__
+
+#include "MEDCouplingTimeDiscretization.hxx"
+#include "MEDCouplingMesh.hxx"
+
+namespace MEDCoupling
+{
+ template<class T>
+ 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)
+ {
+ }
+
+ template<class T>
+ MEDCouplingFieldT<T>::MEDCouplingFieldT(TypeOfField type, MEDCouplingTimeDiscretizationTemplate<T> *timeDiscr):MEDCouplingField(type),_time_discr(timeDiscr)
+ {
+ }
+
+ template<class T>
+ MEDCouplingFieldT<T>::MEDCouplingFieldT(MEDCouplingFieldDiscretization *type, NatureOfField n, MEDCouplingTimeDiscretizationTemplate<T> *timeDiscr):MEDCouplingField(type,n),_time_discr(timeDiscr)
+ {
+ }
+
+ template<class T>
+ MEDCouplingFieldT<T>::~MEDCouplingFieldT()
+ {
+ 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();
+ }
+
+ template<class T>
+ bool MEDCouplingFieldT<T>::isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec, std::string& reason) const
+ {
+ if(!other)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldT::isEqualIfNotWhy : other instance is NULL !");
+ const MEDCouplingFieldT<T> *otherC(dynamic_cast<const MEDCouplingFieldT<T> *>(other));
+ if(!otherC)
+ {
+ reason="field given in input is not castable in MEDCouplingFieldT !";
+ return false;
+ }
+ if(!MEDCouplingField::isEqualIfNotWhy(other,meshPrec,valsPrec,reason))
+ return false;
+ if(!_time_discr->isEqualIfNotWhy(otherC->_time_discr,T(valsPrec),reason))
+ {
+ reason.insert(0,"In FieldT time discretizations differ :");
+ return false;
+ }
+ return true;
+ }
+
+ /*!
+ * Checks equality of \a this and \a other field. Only numeric data is considered,
+ * i.e. names, description etc are not compared.
+ * \param [in] other - the field to compare with.
+ * \param [in] meshPrec - a precision used to compare node coordinates of meshes.
+ * \param [in] valsPrec - a precision used to compare data arrays of the two fields.
+ * \return bool - \c true if the two fields are equal, \c false else.
+ * \throw If \a other == NULL.
+ * \throw If the spatial discretization of \a this field is NULL.
+ */
+ template<class T>
+ bool MEDCouplingFieldT<T>::isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const
+ {
+ const MEDCouplingFieldT<T> *otherC(dynamic_cast<const MEDCouplingFieldT<T> *>(other));
+ if(!otherC)
+ return false;
+ if(!MEDCouplingField::isEqualWithoutConsideringStr(other,meshPrec,valsPrec))
+ return false;
+ if(!_time_discr->isEqualWithoutConsideringStr(otherC->_time_discr,T(valsPrec)))
+ return false;
+ return true;
+ }
+
+ /*!
+ * Copies tiny info (component names, name and description) from an \a other field to
+ * \a this one.
+ * \warning The underlying mesh is not renamed (for safety reason).
+ * \param [in] other - the field to copy the tiny info from.
+ * \throw If \a this->getNumberOfComponents() != \a other->getNumberOfComponents()
+ */
+ template<class T>
+ void MEDCouplingFieldT<T>::copyTinyStringsFrom(const MEDCouplingField *other)
+ {
+ MEDCouplingField::copyTinyStringsFrom(other);
+ const MEDCouplingFieldT<T> *otherC(dynamic_cast<const MEDCouplingFieldT<T> *>(other));
+ if(otherC)
+ {
+ _time_discr->copyTinyStringsFrom(*otherC->_time_discr);
+ }
+ }
+
+ /*!
+ * Copies only times, order and iteration from an \a other field to
+ * \a this one. The underlying mesh is not impacted by this method.
+ * Arrays are not impacted neither.
+ * \param [in] other - the field to tiny attributes from.
+ * \throw If \a this->getNumberOfComponents() != \a other->getNumberOfComponents()
+ */
+ template<class T>
+ void MEDCouplingFieldT<T>::copyTinyAttrFrom(const MEDCouplingFieldT<T> *other)
+ {
+ if(other)
+ {
+ _time_discr->copyTinyAttrFrom(*other->_time_discr);
+ }
+ }
+
+ template<class T>
+ void MEDCouplingFieldT<T>::copyAllTinyAttrFrom(const MEDCouplingFieldT<T> *other)
+ {
+ copyTinyStringsFrom(other);
+ copyTinyAttrFrom(other);
+ }
+
+ /*!
+ * This method is more strict than MEDCouplingField::areCompatibleForMerge method.
+ * This method is used for operation on fields to operate a first check before attempting operation.
+ */
+ template<class T>
+ bool MEDCouplingFieldT<T>::areStrictlyCompatible(const MEDCouplingField *other) const
+ {
+ std::string tmp;
+ if(!MEDCouplingField::areStrictlyCompatible(other))
+ return false;
+ const MEDCouplingFieldT<T> *otherC(dynamic_cast<const MEDCouplingFieldT<T> *>(other));
+ if(!otherC)
+ return false;
+ if(!_time_discr->areStrictlyCompatible(otherC->_time_discr,tmp))
+ return false;
+ return true;
+ }
+
+ template<class T>
+ bool MEDCouplingFieldT<T>::areStrictlyCompatibleForMulDiv(const MEDCouplingField *other) const
+ {
+ if(!MEDCouplingField::areStrictlyCompatibleForMulDiv(other))
+ return false;
+ const MEDCouplingFieldT<T> *otherC(dynamic_cast<const MEDCouplingFieldT<T> *>(other));
+ if(!otherC)
+ return false;
+ if(!_time_discr->areStrictlyCompatibleForDiv(otherC->_time_discr))
+ return false;
+ return true;
+ }
+
+ /*!
+ * Method with same principle than MEDCouplingFieldDouble::areStrictlyCompatibleForMulDiv method except that
+ * number of components between \a this and 'other' can be different here (for operator/).
+ */
+ template<class T>
+ bool MEDCouplingFieldT<T>::areCompatibleForDiv(const MEDCouplingField *other) const
+ {
+ if(!MEDCouplingField::areStrictlyCompatibleForMulDiv(other))
+ return false;
+ const MEDCouplingFieldT<T> *otherC(dynamic_cast<const MEDCouplingFieldT<T> *>(other));
+ if(!otherC)
+ return false;
+ if(!_time_discr->areStrictlyCompatibleForDiv(otherC->_time_discr))
+ return false;
+ return true;
+ }
+
+ template<class T>
+ bool MEDCouplingFieldT<T>::areCompatibleForMul(const MEDCouplingField *other) const
+ {
+ if(!MEDCouplingField::areStrictlyCompatibleForMulDiv(other))
+ return false;
+ const MEDCouplingFieldT<T> *otherC(dynamic_cast<const MEDCouplingFieldT<T> *>(other));
+ if(!otherC)
+ return false;
+ if(!_time_discr->areStrictlyCompatibleForMul(otherC->_time_discr))
+ return false;
+ return true;
+ }
+
+ /*!
+ * Returns a string describing \a this field. This string is outputted by \c print
+ * Python command. The string includes info on
+ * - name,
+ * - description,
+ * - \ref MEDCouplingSpatialDisc "spatial discretization",
+ * - \ref MEDCouplingTemporalDisc "time discretization",
+ * - \ref NatureOfField,
+ * - components,
+ * - mesh.
+ *
+ * \return std::string - the string describing \a this field.
+ */
+ template<class T>
+ std::string MEDCouplingFieldT<T>::simpleRepr() const
+ {
+ std::ostringstream ret;
+ ret << Traits<T>::FieldTypeName << " with name : \"" << getName() << "\"\n";
+ ret << "Description of field is : \"" << getDescription() << "\"\n";
+ if(_type)
+ { ret << Traits<T>::FieldTypeName << " space discretization is : " << _type->getStringRepr() << "\n"; }
+ else
+ { ret << Traits<T>::FieldTypeName << " has no spatial discretization !\n"; }
+ if(_time_discr)
+ { ret << Traits<T>::FieldTypeName << " time discretization is : " << _time_discr->getStringRepr() << "\n"; }
+ else
+ { ret << Traits<T>::FieldTypeName << " has no time discretization !\n"; }
+ ret << Traits<T>::FieldTypeName << " nature of field is : \"" << MEDCouplingNatureOfField::GetReprNoThrow(_nature) << "\"\n";
+ if(getArray())
+ {
+ if(getArray()->isAllocated())
+ {
+ int nbOfCompo=getArray()->getNumberOfComponents();
+ ret << Traits<T>::FieldTypeName << " default array has " << nbOfCompo << " components and " << getArray()->getNumberOfTuples() << " tuples.\n";
+ ret << Traits<T>::FieldTypeName << " default array has following info on components : ";
+ for(int i=0;i<nbOfCompo;i++)
+ ret << "\"" << getArray()->getInfoOnComponent(i) << "\" ";
+ ret << "\n";
+ }
+ else
+ {
+ ret << "Array set but not allocated !\n";
+ }
+ }
+ if(_mesh)
+ ret << "Mesh support information :\n__________________________\n" << _mesh->simpleRepr();
+ else
+ ret << "Mesh support information : No mesh set !\n";
+ return ret.str();
+ }
+
+ template<class T>
+ void MEDCouplingFieldT<T>::reprQuickOverview(std::ostream& stream) const
+ {
+ stream << Traits<T>::FieldTypeName << " 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 !";
+ else
+ fd->reprQuickOverview(stream);
+ stream << std::endl;
+ if(!_mesh)
+ stream << "\nNo mesh support defined !";
+ else
+ {
+ std::ostringstream oss;
+ _mesh->reprQuickOverview(oss);
+ std::string tmp(oss.str());
+ stream << "\nMesh info : " << tmp.substr(0,tmp.find('\n'));
+ }
+ if(_time_discr)
+ {
+ const typename Traits<T>::ArrayType *arr(_time_discr->getArray());
+ if(arr)
+ {
+ stream << "\n\nArray info : ";
+ arr->reprQuickOverview(stream);
+ }
+ else
+ {
+ stream << "\n\nNo data array set !";
+ }
+ }
+ }
+
+ /*!
+ * Returns a type of \ref MEDCouplingTemporalDisc "time discretization" of \a this field.
+ * \return MEDCoupling::TypeOfTimeDiscretization - an enum item describing the time
+ * discretization type.
+ */
+ template<class T>
+ TypeOfTimeDiscretization MEDCouplingFieldT<T>::getTimeDiscretization() const
+ {
+ return _time_discr->getEnum();
+ }
+}
+
+#endif
return true;
}
-bool MEDCouplingTimeDiscretization::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
+bool MEDCouplingTimeDiscretization::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const
{
if(!areStrictlyCompatible(other,reason))
return false;
- if(_array==other->_array)
+ if(_array==other->getArray())
return true;
- return _array->isEqualIfNotWhy(*other->_array,prec,reason);
+ return _array->isEqualIfNotWhy(*other->getArray(),prec,reason);
}
bool MEDCouplingTimeDiscretization::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
return isEqualIfNotWhy(other,prec,reason);
}
-bool MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
+bool MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const
{
std::string tmp;
if(!areStrictlyCompatible(other,tmp))
return false;
- if(_array==other->_array)
+ if(_array==other->getArray())
return true;
- return _array->isEqualWithoutConsideringStr(*other->_array,prec);
+ return _array->isEqualWithoutConsideringStr(*other->getArray(),prec);
}
MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCopy) const
tinyInfo.push_back(_array->getInfoOnComponent(i));
}
-const DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray() const
-{
- throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !");
-}
-
-DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray()
-{
- throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !");
-}
-
-void MEDCouplingTimeDiscretization::setEndArray(DataArrayDouble *array, TimeLabel *owner)
-{
- throw INTERP_KERNEL::Exception("setEndArray not available for this type of time discretization !");
-}
-
-void MEDCouplingTimeDiscretization::setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner)
-{
- if(arrays.size()!=1)
- throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretization::setArrays : number of arrays must be one.");
- setArray(arrays.back(),owner);
-}
-
-void MEDCouplingTimeDiscretization::getArrays(std::vector<DataArrayDouble *>& arrays) const
-{
- arrays.resize(1);
- arrays[0]=_array;
-}
-
bool MEDCouplingTimeDiscretization::isBefore(const MEDCouplingTimeDiscretization *other) const
{
int iteration,order;
{
}
-MEDCouplingTimeDiscretizationInt::MEDCouplingTimeDiscretizationInt(const MEDCouplingTimeDiscretizationInt& other, bool deepCopy):MEDCouplingTimeDiscretizationTemplate<int>(other,deepCopy)
+MEDCouplingTimeDiscretizationInt::MEDCouplingTimeDiscretizationInt(const MEDCouplingTimeDiscretizationInt& other, bool deepCopy):MEDCouplingTimeDiscretizationTemplate<int>(other,deepCopy),_tk(other._tk)
{
}
}
}
+bool MEDCouplingTimeDiscretizationInt::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<int> *other, int prec, std::string& reason) const
+{
+ if(prec!=0)
+ throw INTERP_KERNEL::Exception("isEqualIfNotWhy : only precision equal to 0 supported for int !");
+ if(!other)
+ {
+ reason="Time discretization is NULL.";
+ return false;
+ }
+ const MEDCouplingTimeDiscretizationInt *otherC(dynamic_cast<const MEDCouplingTimeDiscretizationInt *>(other));
+ if(!otherC)
+ throw INTERP_KERNEL::Exception("isEqualIfNotWhy : other is not a MEDCouplingTimeDiscretizationInt !");
+ if(!MEDCouplingTimeDiscretizationTemplate<int>::areStrictlyCompatible(other,reason))
+ return false;
+ if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason))
+ return false;
+ if(_array==other->getArray())
+ return true;
+ return _array->isEqualIfNotWhy(*other->getArray(),reason);
+}
+
+bool MEDCouplingTimeDiscretizationInt::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<int> *other, int prec) const
+{
+ if(prec!=0)
+ throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretizationInt::isEqualWithoutConsideringStr : only precision 0 is supported !");
+ const MEDCouplingTimeDiscretizationInt *otherC(dynamic_cast<const MEDCouplingTimeDiscretizationInt *>(other));
+ if(!otherC)
+ throw INTERP_KERNEL::Exception("isEqualWithoutConsideringStr : other is not a MEDCouplingTimeDiscretizationInt !");
+ std::string tmp;
+ if(!areStrictlyCompatible(other,tmp))
+ return false;
+ std::string reason;
+ if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason))
+ return false;
+ if(_array==other->getArray())
+ return true;
+ return _array->isEqualWithoutConsideringStr(*(other->getArray()));
+}
+
+double MEDCouplingTimeDiscretizationInt::getEndTime(int& iteration, int& order) const
+{
+ throw INTERP_KERNEL::Exception("getEndTime : invalid for this type of time discr !");
+}
+
+void MEDCouplingTimeDiscretizationInt::setEndIteration(int it)
+{
+ throw INTERP_KERNEL::Exception("setEndIteration : invalid for this type of time discr !");
+}
+
+void MEDCouplingTimeDiscretizationInt::setEndOrder(int order)
+{
+ throw INTERP_KERNEL::Exception("setEndOrder : invalid for this type of time discr !");
+}
+
+void MEDCouplingTimeDiscretizationInt::setEndTimeValue(double time)
+{
+ throw INTERP_KERNEL::Exception("setEndTimeValue : invalid for this type of time discr !");
+}
+
+void MEDCouplingTimeDiscretizationInt::setEndTime(double time, int iteration, int order)
+{
+ throw INTERP_KERNEL::Exception("setEndTime : invalid for this type of time discr !");
+}
////////////////////////
{
if(!MEDCouplingTimeDiscretization::areCompatible(other))
return false;
- const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
+ const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
return otherC!=0;
}
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
return false;
- const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
+ const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
bool ret=otherC!=0;
if(!ret)
reason.insert(0,"time discretization of this is NO_TIME, other has a different time discretization.");
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
return false;
- const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
+ const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
return otherC!=0;
}
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
return false;
- const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
+ const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
return otherC!=0;
}
{
if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
return false;
- const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
+ const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
return otherC!=0;
}
-bool MEDCouplingNoTimeLabel::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
+bool MEDCouplingNoTimeLabel::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const
{
- const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
+ const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
if(!otherC)
{
reason="This has time discretization NO_TIME, other not.";
return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
}
-bool MEDCouplingNoTimeLabel::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
+bool MEDCouplingNoTimeLabel::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const
{
- const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
+ const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
if(!otherC)
return false;
return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const MEDCouplingTimeDiscretization *other) const
{
- const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
+ const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
if(!otherC)
throw INTERP_KERNEL::Exception("NoTimeLabel::aggregation on mismatched time discretization !");
- MCAuto<DataArrayDouble> arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
- MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
+ MCAuto<DataArrayDouble> arr(DataArrayDouble::Aggregate(getArray(),other->getArray()));
+ MEDCouplingNoTimeLabel *ret(new MEDCouplingNoTimeLabel);
ret->setArray(arr,0);
return ret;
}
throw INTERP_KERNEL::Exception("NoTimeLabel::aggregate on mismatched time discretization !");
a[i]=itC->getArray();
}
- MCAuto<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
- MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
+ MCAuto<DataArrayDouble> arr(DataArrayDouble::Aggregate(a));
+ MEDCouplingNoTimeLabel *ret(new MEDCouplingNoTimeLabel);
ret->setArray(arr,0);
return ret;
}
return otherC!=0;
}
-bool MEDCouplingWithTimeStep::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
+bool MEDCouplingWithTimeStep::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
std::ostringstream oss; oss.precision(15);
return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
}
-bool MEDCouplingWithTimeStep::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
+bool MEDCouplingWithTimeStep::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
return false;
- const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
+ const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other));
return otherC!=0;
}
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
return false;
- const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
+ const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other));
return otherC!=0;
}
{
if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
return false;
- const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
+ const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other));
return otherC!=0;
}
-bool MEDCouplingConstOnTimeInterval::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
+bool MEDCouplingConstOnTimeInterval::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const
{
- const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
+ const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other));
std::ostringstream oss; oss.precision(15);
if(!otherC)
{
return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
}
-bool MEDCouplingConstOnTimeInterval::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
+bool MEDCouplingConstOnTimeInterval::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const
{
- const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
+ const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other));
if(!otherC)
return false;
if(!_start.isEqual(otherC->_start,_time_tolerance))
}
MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps(const MEDCouplingTwoTimeSteps& other, bool deepCopy):MEDCouplingTimeDiscretization(other,deepCopy),
- _start_time(other._start_time),_end_time(other._end_time),
- _start_iteration(other._start_iteration),_end_iteration(other._end_iteration),
- _start_order(other._start_order),_end_order(other._end_order)
+ _start(other._start),_end(other._end)
{
if(other._end_array)
_end_array=other._end_array->performCopyOrIncrRef(deepCopy);
throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
int it=-1,order=-1;
double val=mesh->getTime(it,order);
- _start_time=val; _start_iteration=it; _start_order=order;
- _end_time=val; _end_iteration=it; _end_order=order;
+ _start.setAllInfo(val,it,order);
+ _end.setAllInfo(val,it,order);
std::string tUnit=mesh->getTimeUnit();
_time_unit=tUnit;
}
const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
if(!otherC)
throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::copyTinyAttrFrom : mismatch of time discretization !");
- _start_time=otherC->_start_time;
- _end_time=otherC->_end_time;
- _start_iteration=otherC->_start_iteration;
- _end_iteration=otherC->_end_iteration;
- _start_order=otherC->_start_order;
- _end_order=otherC->_end_order;
+ _start.copyFrom(otherC->_start);
+ _end.copyFrom(otherC->_end);
}
void MEDCouplingTwoTimeSteps::copyTinyStringsFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other)
throw INTERP_KERNEL::Exception("The number of tuples mismatch between the start and the end arrays !");
}
-bool MEDCouplingTwoTimeSteps::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
+bool MEDCouplingTwoTimeSteps::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const
{
std::ostringstream oss;
- const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(other);
+ const MEDCouplingTwoTimeSteps *otherC(dynamic_cast<const MEDCouplingTwoTimeSteps *>(other));
if(!otherC)
{
reason="This has time discretization LINEAR_TIME, other not.";
return false;
}
- if(_start_iteration!=otherC->_start_iteration)
- {
- oss << "start iterations differ. this start iteration=" << _start_iteration << " other start iteration=" << otherC->_start_iteration;
- reason=oss.str();
- return false;
- }
- if(_start_order!=otherC->_start_order)
- {
- oss << "start orders differ. this start order=" << _start_order << " other start order=" << otherC->_start_order;
- reason=oss.str();
- return false;
- }
- if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
- {
- oss << "start times differ. this start time=" << _start_time << " other start time=" << otherC->_start_time;
- reason=oss.str();
- return false;
- }
- if(_end_iteration!=otherC->_end_iteration)
- {
- oss << "end iterations differ. this end iteration=" << _end_iteration << " other end iteration=" << otherC->_end_iteration;
- reason=oss.str();
- return false;
- }
- if(_end_order!=otherC->_end_order)
- {
- oss << "end orders differ. this end order=" << _end_order << " other end order=" << otherC->_end_order;
- reason=oss.str();
- return false;
- }
- if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
- {
- oss << "end times differ. this end time=" << _end_time << " other end time=" << otherC->_end_time;
- reason=oss.str();
- return false;
- }
+ if(!_start.isEqualIfNotWhy(otherC->_start,_time_tolerance,reason))
+ return false;
+ if(!_end.isEqualIfNotWhy(otherC->_end,_time_tolerance,reason))
+ return false;
if(_end_array!=otherC->_end_array)
if(!_end_array->isEqualIfNotWhy(*otherC->_end_array,prec,reason))
{
return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
}
-bool MEDCouplingTwoTimeSteps::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
+bool MEDCouplingTwoTimeSteps::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const
{
- const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(other);
+ const MEDCouplingTwoTimeSteps *otherC(dynamic_cast<const MEDCouplingTwoTimeSteps *>(other));
if(!otherC)
return false;
- if(_start_iteration!=otherC->_start_iteration)
- return false;
- if(_end_iteration!=otherC->_end_iteration)
- return false;
- if(_start_order!=otherC->_start_order)
- return false;
- if(_end_order!=otherC->_end_order)
- return false;
- if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
+ if(!_start.isEqual(otherC->_start,_time_tolerance))
return false;
- if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
+ if(!_end.isEqual(otherC->_end,_time_tolerance))
return false;
if(_end_array!=otherC->_end_array)
if(!_end_array->isEqualWithoutConsideringStr(*otherC->_end_array,prec))
return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
}
-MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps():_start_time(0.),_end_time(0.),_start_iteration(-1),_end_iteration(-1),_start_order(-1),_end_order(-1),_end_array(0)
+MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps():_end_array(0)
{
}
void MEDCouplingTwoTimeSteps::checkTimePresence(double time) const
{
- if(time<_start_time-_time_tolerance || time>_end_time+_time_tolerance)
+ if(time<_start.getTimeValue()-_time_tolerance || time>_end.getTimeValue()+_time_tolerance)
{
std::ostringstream stream;
- stream << "The field is defined between times " << _start_time << " and " << _end_time << " worderh tolerance ";
+ stream << "The field is defined between times " << _start.getTimeValue() << " and " << _end.getTimeValue() << " worderh tolerance ";
stream << _time_tolerance << " and trying to access on time = " << time;
throw INTERP_KERNEL::Exception(stream.str().c_str());
}
void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
{
MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
- tinyInfo.push_back(_start_iteration);
- tinyInfo.push_back(_start_order);
- tinyInfo.push_back(_end_iteration);
- tinyInfo.push_back(_end_order);
+ tinyInfo.push_back(_start.getIteration());
+ tinyInfo.push_back(_start.getOrder());
+ tinyInfo.push_back(_end.getIteration());
+ tinyInfo.push_back(_end.getOrder());
if(_end_array)
{
tinyInfo.push_back(_end_array->getNumberOfTuples());
void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
{
MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
- tinyInfo.push_back(_start_time);
- tinyInfo.push_back(_end_time);
+ tinyInfo.push_back(_start.getTimeValue());
+ tinyInfo.push_back(_end.getTimeValue());
}
void MEDCouplingTwoTimeSteps::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
void MEDCouplingTwoTimeSteps::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
{
MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
- _start_time=tinyInfoD[1];
- _end_time=tinyInfoD[2];
- _start_iteration=tinyInfoI[2];
- _start_order=tinyInfoI[3];
- _end_iteration=tinyInfoI[4];
- _end_order=tinyInfoI[5];
+ _start.setTimeValue(tinyInfoD[1]);
+ _end.setTimeValue(tinyInfoD[2]);
+ _start.setIteration(tinyInfoI[2]);
+ _start.setOrder(tinyInfoI[3]);
+ _end.setIteration(tinyInfoI[4]);
+ _end.setOrder(tinyInfoI[5]);
}
/*!
void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
{
tinyInfo.resize(4);
- tinyInfo[0]=_start_iteration;
- tinyInfo[1]=_start_order;
- tinyInfo[2]=_end_iteration;
- tinyInfo[3]=_end_order;
+ tinyInfo[0]=_start.getIteration();
+ tinyInfo[1]=_start.getOrder();
+ tinyInfo[2]=_end.getIteration();
+ tinyInfo[3]=_end.getOrder();
}
/*!
{
tinyInfo.resize(3);
tinyInfo[0]=_time_tolerance;
- tinyInfo[1]=_start_time;
- tinyInfo[2]=_end_time;
+ tinyInfo[1]=_start.getTimeValue();
+ tinyInfo[2]=_end.getTimeValue();
}
/*!
*/
void MEDCouplingTwoTimeSteps::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
{
- _start_iteration=tinyInfoI[0];
- _start_order=tinyInfoI[1];
- _end_iteration=tinyInfoI[2];
- _end_order=tinyInfoI[3];
+ _start.setIteration(tinyInfoI[0]);
+ _start.setOrder(tinyInfoI[1]);
+ _end.setIteration(tinyInfoI[2]);
+ _end.setOrder(tinyInfoI[3]);
_time_tolerance=tinyInfoD[0];
- _start_time=tinyInfoD[1];
- _end_time=tinyInfoD[2];
+ _start.setTimeValue(tinyInfoD[1]);
+ _end.setTimeValue(tinyInfoD[2]);
}
std::vector< const DataArrayDouble *> MEDCouplingTwoTimeSteps::getArraysForTime(double time) const
{
- if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
+ if(time>_start.getTimeValue()-_time_tolerance && time<_end.getTimeValue()+_time_tolerance)
{
std::vector< const DataArrayDouble *> ret(2);
ret[0]=_array;
std::string MEDCouplingLinearTime::getStringRepr() const
{
std::ostringstream stream;
- stream << REPR << " Time interval is defined by :\niteration_start=" << _start_iteration << " order_start=" << _start_order << " and time_start=" << _start_time << "\n";
- stream << "iteration_end=" << _end_iteration << " order_end=" << _end_order << " and end_time=" << _end_time << "\n";
+ stream << REPR << " Time interval is defined by :\niteration_start=" << _start.getIteration() << " order_start=" << _start.getOrder() << " and time_start=" << _start.getTimeValue() << "\n";
+ stream << "iteration_end=" << _end.getIteration() << " order_end=" << _end.getOrder() << " and end_time=" << _end.getTimeValue() << "\n";
stream << "Time unit is : \"" << _time_unit << "\"";
return stream.str();
}
void MEDCouplingLinearTime::checkConsistencyLight() const
{
MEDCouplingTwoTimeSteps::checkConsistencyLight();
- if(std::fabs(_start_time-_end_time)<_time_tolerance)
+ if(std::fabs(_start.getTimeValue()-_end.getTimeValue())<_time_tolerance)
throw INTERP_KERNEL::Exception("Start time and end time are equals regarding time tolerance.");
}
*/
void MEDCouplingLinearTime::getValueForTime(double time, const std::vector<double>& vals, double *res) const
{
- double alpha=(_end_time-time)/(_end_time-_start_time);
+ double alpha=(_end.getTimeValue()-time)/(_end.getTimeValue()-_start.getTimeValue());
std::size_t nbComp=vals.size()/2;
std::transform(vals.begin(),vals.begin()+nbComp,res,std::bind2nd(std::multiplies<double>(),alpha));
std::vector<double> tmp(nbComp);
void MEDCouplingLinearTime::getValueOnTime(int eltId, double time, double *value) const
{
- double alpha=(_end_time-time)/(_end_time-_start_time);
+ double alpha=(_end.getTimeValue()-time)/(_end.getTimeValue()-_start.getTimeValue());
int nbComp;
if(_array)
_array->getTuple(eltId,value);
void MEDCouplingLinearTime::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const
{
- if(iteration==_start_iteration && order==_start_order)
+ if(iteration==_start.getIteration() && order==_start.getOrder())
{
if(_array)
_array->getTuple(eltId,value);
else
throw INTERP_KERNEL::Exception("iteration order match with start time but no start array existing.");
}
- if(iteration==_end_iteration && order==_end_order)
+ if(iteration==_end.getIteration() && order==_end.getOrder())
{
if(_end_array)
_end_array->getTuple(eltId,value);
a[i]=itC->getArray();
b[i]=itC->getEndArray();
}
- MCAuto<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
- MCAuto<DataArrayDouble> arr2=DataArrayDouble::Aggregate(b);
- MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
+ MCAuto<DataArrayDouble> arr(DataArrayDouble::Aggregate(a)),arr2(DataArrayDouble::Aggregate(b));
+ MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
ret->setArray(arr,0);
ret->setEndArray(arr2,0);
return ret;
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::meld on mismatched time discretization !");
- MCAuto<DataArrayDouble> arr1=DataArrayDouble::Meld(getArray(),other->getArray());
- MCAuto<DataArrayDouble> arr2=DataArrayDouble::Meld(getEndArray(),other->getEndArray());
- MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
+ MCAuto<DataArrayDouble> arr1(DataArrayDouble::Meld(getArray(),other->getArray())),arr2(DataArrayDouble::Meld(getEndArray(),other->getEndArray()));
+ MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
ret->setTimeTolerance(getTimeTolerance());
ret->setArray(arr1,0);
ret->setEndArray(arr2,0);
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::dot on mismatched time discretization !");
- MCAuto<DataArrayDouble> arr1=DataArrayDouble::Dot(getArray(),other->getArray());
- MCAuto<DataArrayDouble> arr2=DataArrayDouble::Dot(getEndArray(),other->getEndArray());
- MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
+ MCAuto<DataArrayDouble> arr1(DataArrayDouble::Dot(getArray(),other->getArray())),arr2(DataArrayDouble::Dot(getEndArray(),other->getEndArray()));
+ MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
ret->setArray(arr1,0);
ret->setEndArray(arr2,0);
return ret;
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::crossProduct on mismatched time discretization !");
- MCAuto<DataArrayDouble> arr1=DataArrayDouble::CrossProduct(getArray(),other->getArray());
- MCAuto<DataArrayDouble> arr2=DataArrayDouble::CrossProduct(getEndArray(),other->getEndArray());
- MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
+ MCAuto<DataArrayDouble> arr1(DataArrayDouble::CrossProduct(getArray(),other->getArray())),arr2(DataArrayDouble::CrossProduct(getEndArray(),other->getEndArray()));
+ MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
ret->setArray(arr1,0);
ret->setEndArray(arr2,0);
return ret;
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::max on mismatched time discretization !");
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
- MCAuto<DataArrayDouble> arr1=DataArrayDouble::Max(getArray(),other->getArray());
- MCAuto<DataArrayDouble> arr2=DataArrayDouble::Max(getEndArray(),other->getEndArray());
+ MCAuto<DataArrayDouble> arr1(DataArrayDouble::Max(getArray(),other->getArray())),arr2(DataArrayDouble::Max(getEndArray(),other->getEndArray()));
ret->setArray(arr1,0);
ret->setEndArray(arr2,0);
return ret;
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::min on mismatched time discretization !");
- MCAuto<DataArrayDouble> arr1=DataArrayDouble::Min(getArray(),other->getArray());
- MCAuto<DataArrayDouble> arr2=DataArrayDouble::Min(getEndArray(),other->getEndArray());
- MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
+ MCAuto<DataArrayDouble> arr1(DataArrayDouble::Min(getArray(),other->getArray())),arr2(DataArrayDouble::Min(getEndArray(),other->getEndArray()));
+ MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
ret->setArray(arr1,0);
ret->setEndArray(arr2,0);
return ret;
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::add on mismatched time discretization !");
- MCAuto<DataArrayDouble> arr1=DataArrayDouble::Add(getArray(),other->getArray());
- MCAuto<DataArrayDouble> arr2=DataArrayDouble::Add(getEndArray(),other->getEndArray());
- MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
+ MCAuto<DataArrayDouble> arr1(DataArrayDouble::Add(getArray(),other->getArray())),arr2(DataArrayDouble::Add(getEndArray(),other->getEndArray()));
+ MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
ret->setArray(arr1,0);
ret->setEndArray(arr2,0);
return ret;
MEDCOUPLING_EXPORT virtual void setStartOrder(int order) = 0;
MEDCOUPLING_EXPORT virtual void setStartTime(double time, int iteration, int order) = 0;
MEDCOUPLING_EXPORT virtual void setStartTimeValue(double time) = 0;
+ MEDCOUPLING_EXPORT virtual double getEndTime(int& iteration, int& order) const = 0;
+ MEDCOUPLING_EXPORT virtual void setEndIteration(int it) = 0;
+ MEDCOUPLING_EXPORT virtual void setEndOrder(int order) = 0;
+ MEDCOUPLING_EXPORT virtual void setEndTimeValue(double time) = 0;
+ MEDCOUPLING_EXPORT virtual void setEndTime(double time, int iteration, int order) = 0;
+
+ MEDCOUPLING_EXPORT virtual void setEndArray(typename Traits<T>::ArrayType *array, TimeLabel *owner);
+ MEDCOUPLING_EXPORT virtual void setArrays(const std::vector< typename Traits<T>::ArrayType *>& arrays, TimeLabel *owner);
+ MEDCOUPLING_EXPORT virtual const typename Traits<T>::ArrayType *getEndArray() const;
+ MEDCOUPLING_EXPORT virtual typename Traits<T>::ArrayType *getEndArray();
+ MEDCOUPLING_EXPORT virtual void getArrays(std::vector<typename Traits<T>::ArrayType *>& arrays) const;
+
MEDCOUPLING_EXPORT virtual std::string getStringRepr() const = 0;
MEDCOUPLING_EXPORT virtual TypeOfTimeDiscretization getEnum() const = 0;
MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretizationTemplate<T> *performCopyOrIncrRef(bool deepCopy) const = 0;
MEDCOUPLING_EXPORT virtual std::size_t getHeapMemorySizeWithoutChildren() const;
MEDCOUPLING_EXPORT virtual std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
//
+ MEDCOUPLING_EXPORT virtual bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<T> *other, T prec, std::string& reason) const = 0;
+ MEDCOUPLING_EXPORT virtual bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<T> *other, T prec) const = 0;
+ //
MEDCOUPLING_EXPORT virtual bool areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<T> *other, std::string& reason) const;
MEDCOUPLING_EXPORT virtual bool areCompatible(const MEDCouplingTimeDiscretizationTemplate<T> *other) const;
MEDCOUPLING_EXPORT virtual bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<T> *other) const;
MEDCOUPLING_EXPORT virtual bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<T> *other) const;
+ MEDCOUPLING_EXPORT virtual ~MEDCouplingTimeDiscretizationTemplate();
protected:
MEDCOUPLING_EXPORT MEDCouplingTimeDiscretizationTemplate();
MEDCOUPLING_EXPORT MEDCouplingTimeDiscretizationTemplate(const MEDCouplingTimeDiscretizationTemplate<T>& other, bool deepCopy);
- MEDCOUPLING_EXPORT virtual ~MEDCouplingTimeDiscretizationTemplate();
protected:
std::string _time_unit;
double _time_tolerance;
public:
MEDCOUPLING_EXPORT static MEDCouplingTimeDiscretization *New(TypeOfTimeDiscretization type);
MEDCOUPLING_EXPORT virtual bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
- MEDCOUPLING_EXPORT virtual bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
+ MEDCOUPLING_EXPORT virtual bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const;
+ MEDCOUPLING_EXPORT virtual bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const;
MEDCOUPLING_EXPORT virtual bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
- MEDCOUPLING_EXPORT virtual bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretization *buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCopy) const;
MEDCOUPLING_EXPORT virtual void synchronizeTimeWith(const MEDCouplingMesh *mesh) = 0;
MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const = 0;
MEDCOUPLING_EXPORT virtual void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD) = 0;
MEDCOUPLING_EXPORT virtual void checkNoTimePresence() const = 0;
MEDCOUPLING_EXPORT virtual void checkTimePresence(double time) const = 0;
- MEDCOUPLING_EXPORT virtual void setEndArray(DataArrayDouble *array, TimeLabel *owner);
- MEDCOUPLING_EXPORT virtual void setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner);
- MEDCOUPLING_EXPORT virtual const DataArrayDouble *getEndArray() const;
- MEDCOUPLING_EXPORT virtual DataArrayDouble *getEndArray();
MEDCOUPLING_EXPORT virtual std::vector< const DataArrayDouble *> getArraysForTime(double time) const = 0;
- MEDCOUPLING_EXPORT virtual void getValueForTime(double time, const std::vector<double>& vals, double *res) const = 0;
- MEDCOUPLING_EXPORT virtual void getArrays(std::vector<DataArrayDouble *>& arrays) const;
+ MEDCOUPLING_EXPORT virtual void getValueForTime(double time, const std::vector<double>& vals, double *res) const = 0;
MEDCOUPLING_EXPORT virtual bool isBefore(const MEDCouplingTimeDiscretization *other) const;
MEDCOUPLING_EXPORT virtual bool isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const;
- MEDCOUPLING_EXPORT virtual double getEndTime(int& iteration, int& order) const = 0;
- MEDCOUPLING_EXPORT virtual void setEndIteration(int it) = 0;
- MEDCOUPLING_EXPORT virtual void setEndOrder(int order) = 0;
- MEDCOUPLING_EXPORT virtual void setEndTimeValue(double time) = 0;
- MEDCOUPLING_EXPORT virtual void setEndTime(double time, int iteration, int order) = 0;
MEDCOUPLING_EXPORT virtual void getValueOnTime(int eltId, double time, double *value) const = 0;
MEDCOUPLING_EXPORT virtual void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const = 0;
//
void setStartOrder(int order) { _tk.setOrder(order); }
void setStartTimeValue(double time) { _tk.setTimeValue(time); }
void setStartTime(double time, int iteration, int order) { _tk.setAllInfo(time,iteration,order); }
+ double getEndTime(int& iteration, int& order) const;
+ void setEndIteration(int it);
+ void setEndOrder(int order);
+ void setEndTimeValue(double time);
+ void setEndTime(double time, int iteration, int order);
std::string getStringRepr() const;
TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
MEDCouplingTimeDiscretizationInt *performCopyOrIncrRef(bool deepCopy) const;
+ bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<int> *other, int prec, std::string& reason) const;
+ bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<int> *other, int prec) const;
private:
static const TypeOfTimeDiscretization DISCRETIZATION=ONE_TIME;
MEDCOUPLING_EXPORT static const char REPR[];
MEDCOUPLING_EXPORT void divideEqual(const MEDCouplingTimeDiscretization *other);
MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const;
MEDCOUPLING_EXPORT void powEqual(const MEDCouplingTimeDiscretization *other);
- MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
- MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
+ MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const;
+ MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const;
MEDCOUPLING_EXPORT bool areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const;
MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const;
MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const;
MEDCOUPLING_EXPORT void divideEqual(const MEDCouplingTimeDiscretization *other);
MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const;
MEDCOUPLING_EXPORT void powEqual(const MEDCouplingTimeDiscretization *other);
- MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
- MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
+ MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const;
+ MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const;
MEDCOUPLING_EXPORT bool areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const;
MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const;
MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const;
MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const;
MEDCOUPLING_EXPORT bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const;
MEDCOUPLING_EXPORT bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
- MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
- MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
+ MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const;
+ MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const;
MEDCOUPLING_EXPORT std::vector< const DataArrayDouble *> getArraysForTime(double time) const;
MEDCOUPLING_EXPORT void getValueForTime(double time, const std::vector<double>& vals, double *res) const;
MEDCOUPLING_EXPORT void getValueOnTime(int eltId, double time, double *value) const;
MEDCOUPLING_EXPORT const DataArrayDouble *getEndArray() const;
MEDCOUPLING_EXPORT DataArrayDouble *getEndArray();
MEDCOUPLING_EXPORT void checkConsistencyLight() const;
- MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
- MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
+ MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const;
+ MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const;
MEDCOUPLING_EXPORT void checkNoTimePresence() const;
MEDCOUPLING_EXPORT void checkTimePresence(double time) const;
MEDCOUPLING_EXPORT void getArrays(std::vector<DataArrayDouble *>& arrays) const;
MEDCOUPLING_EXPORT void setEndArray(DataArrayDouble *array, TimeLabel *owner);
- MEDCOUPLING_EXPORT void setStartTime(double time, int iteration, int order) { _start_time=time; _start_iteration=iteration; _start_order=order; }
- MEDCOUPLING_EXPORT void setEndTime(double time, int iteration, int order) { _end_time=time; _end_iteration=iteration; _end_order=order; }
- MEDCOUPLING_EXPORT double getStartTime(int& iteration, int& order) const { iteration=_start_iteration; order=_start_order; return _start_time; }
- MEDCOUPLING_EXPORT double getEndTime(int& iteration, int& order) const { iteration=_end_iteration; order=_end_order; return _end_time; }
- MEDCOUPLING_EXPORT void setStartIteration(int it) { _start_iteration=it; }
- MEDCOUPLING_EXPORT void setEndIteration(int it) { _end_iteration=it; }
- MEDCOUPLING_EXPORT void setStartOrder(int order) { _start_order=order; }
- MEDCOUPLING_EXPORT void setEndOrder(int order) { _end_order=order; }
- MEDCOUPLING_EXPORT void setStartTimeValue(double time) { _start_time=time; }
- MEDCOUPLING_EXPORT void setEndTimeValue(double time) { _end_time=time; }
+ MEDCOUPLING_EXPORT void setStartTime(double time, int iteration, int order) { _start.setAllInfo(time,iteration,order); }
+ MEDCOUPLING_EXPORT void setEndTime(double time, int iteration, int order) { _end.setAllInfo(time,iteration,order); }
+ MEDCOUPLING_EXPORT double getStartTime(int& iteration, int& order) const { return _start.getAllInfo(iteration,order); }
+ MEDCOUPLING_EXPORT double getEndTime(int& iteration, int& order) const { return _end.getAllInfo(iteration,order); }
+ MEDCOUPLING_EXPORT void setStartIteration(int it) { _start.setIteration(it); }
+ MEDCOUPLING_EXPORT void setEndIteration(int it) { _end.setIteration(it); }
+ MEDCOUPLING_EXPORT void setStartOrder(int order) { _start.setOrder(order); }
+ MEDCOUPLING_EXPORT void setEndOrder(int order) { _end.setOrder(order); }
+ MEDCOUPLING_EXPORT void setStartTimeValue(double time) { _start.setTimeValue(time); }
+ MEDCOUPLING_EXPORT void setEndTimeValue(double time) { _end.setTimeValue(time); }
MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
MEDCOUPLING_EXPORT void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
protected:
static const char EXCEPTION_MSG[];
protected:
- double _start_time;
- double _end_time;
- int _start_iteration;
- int _end_iteration;
- int _start_order;
- int _end_order;
+ MEDCouplingTimeKeeper _start;
+ MEDCouplingTimeKeeper _end;
DataArrayDouble *_end_array;
};
if(_array)
_array->decrRef();
}
+
+ template<class T>
+ void MEDCouplingTimeDiscretizationTemplate<T>::setEndArray(typename Traits<T>::ArrayType *array, TimeLabel *owner)
+ {
+ throw INTERP_KERNEL::Exception("setEndArray not available for this type of time discretization !");
+ }
+
+ template<class T>
+ void MEDCouplingTimeDiscretizationTemplate<T>::setArrays(const std::vector<typename Traits<T>::ArrayType *>& arrays, TimeLabel *owner)
+ {
+ if(arrays.size()!=1)
+ throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretization::setArrays : number of arrays must be one.");
+ setArray(arrays.back(),owner);
+ }
+
+ template<class T>
+ const typename Traits<T>::ArrayType *MEDCouplingTimeDiscretizationTemplate<T>::getEndArray() const
+ {
+ throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !");
+ }
+
+ template<class T>
+ typename Traits<T>::ArrayType *MEDCouplingTimeDiscretizationTemplate<T>::getEndArray()
+ {
+ throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !");
+ }
+
+ template<class T>
+ void MEDCouplingTimeDiscretizationTemplate<T>::getArrays(std::vector<typename Traits<T>::ArrayType *>& arrays) const
+ {
+ arrays.resize(1);
+ arrays[0]=_array;
+ }
}
#endif
const char Traits<double>::ArrayTypeName[]="DataArrayDouble";
+const char Traits<double>::FieldTypeName[]="MEDCouplingFieldDouble";
+
const char Traits<int>::ArrayTypeName[]="DataArrayInt";
+const char Traits<int>::FieldTypeName[]="MEDCouplingFieldInt";
+
const char Traits<char>::ArrayTypeName[]="DataArrayChar";
class DataArrayInt;
class DataArrayDouble;
class DataArrayChar;
+ class MEDCouplingFieldDouble;
+ class MEDCouplingFieldInt;
template<>
struct Traits<double>
{
static const char ArrayTypeName[];
+ static const char FieldTypeName[];
typedef DataArrayDouble ArrayType;
+ typedef MEDCouplingFieldDouble FieldType;
};
template<>
struct Traits<int>
{
static const char ArrayTypeName[];
+ static const char FieldTypeName[];
typedef DataArrayInt ArrayType;
+ typedef MEDCouplingFieldInt FieldType;
};
template<>
{
std::ostringstream oss;
oss << "MEDCouplingUMesh::checkConsistency : cell << #" << i<< " with type Type " << cm.getRepr() << " in 'this' whereas meshdim == " << meshDim << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
int nbOfNodesInCell=ptrI[i+1]-ptrI[i]-1;
if(!cm.isDynamic())
std::ostringstream oss;
oss << "MEDCouplingUMesh::checkConsistency : cell #" << i << " with static Type '" << cm.getRepr() << "' has " << cm.getNumberOfNodes();
oss << " nodes whereas in connectivity there is " << nbOfNodesInCell << " nodes ! Looks very bad !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
if(cm.isQuadratic() && cm.isDynamic() && meshDim == 2)
if (nbOfNodesInCell % 2 || nbOfNodesInCell < 4)
std::ostringstream oss;
oss << "MEDCouplingUMesh::checkConsistency : cell #" << i << " with quadratic type '" << cm.getRepr() << "' has " << nbOfNodesInCell;
oss << " nodes. This should be even, and greater or equal than 4!! Looks very bad!";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
for(const int *w=ptr+ptrI[i]+1;w!=ptr+ptrI[i+1];w++)
{
if(nodeId>=nbOfNodes)
{
std::ostringstream oss; oss << "Cell #" << i << " is built with node #" << nodeId << " whereas there are only " << nbOfNodes << " nodes in the mesh !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
else if(nodeId<-1)
{
std::ostringstream oss; oss << "Cell #" << i << " is built with node #" << nodeId << " in connectivity ! sounds bad !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
else
{
if((INTERP_KERNEL::NormalizedCellType)(ptr[ptrI[i]])!=INTERP_KERNEL::NORM_POLYHED)
{
std::ostringstream oss; oss << "Cell #" << i << " is built with node #-1 in connectivity ! sounds bad !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
}
{
std::ostringstream oss; oss << "MEDCouplingUMesh::insertNextCell : Trying to push a " << cm.getRepr() << " cell with a size of " << size;
oss << " ! Expecting " << cm.getNumberOfNodes() << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
int idx=_nodal_connec_index->back();
int val=idx+size+1;
std::ostringstream oss; oss << "MEDCouplingUMesh::insertNextCell : cell type " << cm.getRepr() << " has a dimension " << cm.getDimension();
oss << " whereas Mesh Dimension of current UMesh instance is set to " << _mesh_dim << " ! Please invoke \"setMeshDimension\" method before or invoke ";
oss << "\"MEDCouplingUMesh::New\" static method with 2 parameters name and meshDimension !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
{
std::ostringstream oss; oss << "MEDCouplingUMesh::convertToPolyTypes : On rank #" << std::distance(cellIdsToConvertBg,iter) << " value is " << *iter << " which is not";
oss << " in range [0," << nbOfCells << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
}
{
std::ostringstream oss; oss << "MEDCouplingUMesh::convertToPolyTypes : On rank #" << std::distance(cellIdsToConvertBg,iter) << " value is " << *iter << " which is not";
oss << " in range [0," << nbOfCells << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
for(int cellId=0;cellId<nbOfCells;cellId++)
if(std::count(c+ci[i]+1,c+ci[i+1],-1)!=0)
{
std::ostringstream oss; oss << "MEDCouplingUMesh::convertExtrudedPolyhedra : cell # " << i << " is a polhedron BUT it has NOT exactly 1 face !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
std::size_t n2=std::distance(c+ci[i]+1,c+ci[i+1]);
if(n2%2!=0)
{
std::ostringstream oss; oss << "MEDCouplingUMesh::convertExtrudedPolyhedra : cell # " << i << " is a polhedron with 1 face but there is a mismatch of number of nodes in face should be even !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
int n1=(int)(n2/2);
newci[i+1]=7*n1+2+newci[i];//6*n1 (nodal length) + n1+2 (number of faces) - 1 (number of '-1' separator is equal to number of faces -1) + 1 (for cell type)
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::computeNodeIdsAlg : In cell #" << i << " presence of node id " << conn[j] << " not in [0," << nbOfNodes << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
}
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::getNodeIdsInUse : In cell #" << i << " presence of node id " << conn[j] << " not in [0," << nbOfNodes << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
nbrOfNodesInUse=(int)std::count(traducer,traducer+nbOfNodes,1);
std::ostringstream oss; oss << "MEDCouplingUMesh::areCellsIncludedIn : only following policies are possible : ";
std::copy(possibleCompType,possibleCompType+sizeof(possibleCompType)/sizeof(int),std::ostream_iterator<int>(oss," "));
oss << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
MCAuto<DataArrayInt> o2n=mesh->zipConnectivityTraducer(compType,nbOfCells);
arr=o2n->subArray(nbOfCells);
{
std::ostringstream oss; oss << "MEDCouplingUMesh::setPartOfMySelf : Mismatch of meshdimensions ! this is equal to " << getMeshDimension();
oss << ", whereas other mesh dimension is set equal to " << otherOnSameCoordsThanThis.getMeshDimension() << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
int nbOfCellsToModify=(int)std::distance(cellIdsBg,cellIdsEnd);
if(nbOfCellsToModify!=otherOnSameCoordsThanThis.getNumberOfCells())
{
std::ostringstream oss; oss << "MEDCouplingUMesh::setPartOfMySelf : cells ids length (" << nbOfCellsToModify << ") do not match the number of cells of other mesh (" << otherOnSameCoordsThanThis.getNumberOfCells() << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
int nbOfCells=getNumberOfCells();
bool easyAssign=true;
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::setPartOfMySelf : On pos #" << std::distance(cellIdsBg,it) << " id is equal to " << *it << " which is not in [0," << nbOfCells << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
if(easyAssign)
{
std::ostringstream oss; oss << "MEDCouplingUMesh::setPartOfMySelfSlice : Mismatch of meshdimensions ! this is equal to " << getMeshDimension();
oss << ", whereas other mesh dimension is set equal to " << otherOnSameCoordsThanThis.getMeshDimension() << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
int nbOfCellsToModify=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCouplingUMesh::setPartOfMySelfSlice : ");
if(nbOfCellsToModify!=otherOnSameCoordsThanThis.getNumberOfCells())
{
std::ostringstream oss; oss << "MEDCouplingUMesh::setPartOfMySelfSlice : cells ids length (" << nbOfCellsToModify << ") do not match the number of cells of other mesh (" << otherOnSameCoordsThanThis.getNumberOfCells() << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
int nbOfCells=getNumberOfCells();
bool easyAssign=true;
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::setPartOfMySelfSlice : On pos #" << i << " id is equal to " << it << " which is not in [0," << nbOfCells << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
if(easyAssign)
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::renumberNodesInConn(map) : presence in connectivity for cell #" << i << " of node #" << node << " : Not in map !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
}
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::getTypeOfCell : Requesting type of cell #" << cellId << " but it should be in [0," << _nodal_connec_index->getNbOfElems()-1 << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::buildPartOfMySelfKeepCoordsSlice : On pos #" << i << " input cell id =" << work << " should be in [0," << ncell << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
MCAuto<DataArrayInt> newConn=DataArrayInt::New(); newConn->alloc(newConnIPtr[0],1);
{
free(connIndexRet);
std::ostringstream oss; oss << "MEDCouplingUMesh::buildPartOfMySelfKeepCoords : On pos #" << std::distance(begin,work) << " input cell id =" << *work << " should be in [0," << ncell << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
int *connRet=(int *)malloc(connIndexRet[nbOfElemsRet]*sizeof(int));
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::distanceToPoint : only mesh dimension 2 and 1 are implemented !");
checkFullyDefined();
if((int)std::distance(ptBg,ptEnd)!=spaceDim)
- { std::ostringstream oss; oss << "MEDCouplingUMesh::distanceToPoint : input point has to have dimension equal to the space dimension of this (" << spaceDim << ") !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); }
+ { std::ostringstream oss; oss << "MEDCouplingUMesh::distanceToPoint : input point has to have dimension equal to the space dimension of this (" << spaceDim << ") !"; throw INTERP_KERNEL::Exception(oss.str()); }
DataArrayInt *ret1=0;
MCAuto<DataArrayDouble> pts=DataArrayDouble::New(); pts->useArray(ptBg,false,C_DEALLOC,1,spaceDim);
MCAuto<DataArrayDouble> ret0=distanceToPoints(pts,ret1);
if(pts->getNumberOfComponents()!=spaceDim)
{
std::ostringstream oss; oss << "MEDCouplingUMesh::distanceToPoints : input pts DataArrayDouble has " << pts->getNumberOfComponents() << " components whereas it should be equal to " << spaceDim << " (mesh spaceDimension) !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
checkFullyDefined();
int nbCells=getNumberOfCells();
if(typ2==INTERP_KERNEL::NORM_ERROR)
{
std::ostringstream oss; oss << "MEDCouplingUMesh::convertLinearCellsToQuadratic3D1 : On cell #" << i << " the linear cell type does not support advanced quadratization !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
types.insert(typ2); newConn->pushBackSilent(typ2);
newConn->pushBackValsSilent(cPtr+icPtr[0]+1,cPtr+icPtr[1]);
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::subDivide2DMesh : On polygon #" << i << " edgeid #" << j << " subedges mismatch : end subedge k!=start subedge k+1 !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
else
catch(INTERP_KERNEL::Exception& e)
{
std::ostringstream oss; oss << "Something wrong in polyhedron #" << i << " : " << e.what();
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
}
if(kk==0)
{
std::ostringstream oss; oss << "MEDCouplingUMesh::getBoundingBoxForBBTree : cell #" << i << " contains no valid nodeId !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
return ret.retn();
{
std::ostringstream oss; oss << "MEDCouplingUMesh::getDistributionOfTypes : Type " << INTERP_KERNEL::CellModel::GetCellModel(typ).getRepr();
oss << " is not contiguous !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
types.insert(typ);
ret[3*i]=typ;
{
std::ostringstream oss; oss << "MEDCouplingUMesh::checkTypeConsistencyAndContig : the section " << kk << " points to the profile #" << idInIdsPerType;
oss << ", and this profile contains a value " << *k << " should be in [0," << nbOfCellsOfCurType << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
}
{
std::ostringstream oss; oss << "MEDCouplingUMesh::checkTypeConsistencyAndContig : at section " << kk << " of code it points to the array #" << idInIdsPerType;
oss << " should be in [0," << idsPerType.size() << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
i=j;
ret->getMaxValue(tmp2);
ret->decrRef();
std::ostringstream oss; oss << "MEDCouplingUMesh::emulateMEDMEMBDC : input N-1 mesh present a cell not in descending mesh ... Id of cell is " << tmp2 << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
nM1LevMeshIds=ret;
//
const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[*i]);
std::ostringstream oss; oss << "MEDCouplingUMesh::getLevArrPerCellTypes : Cell #" << std::distance(connI,i);
oss << " has a type " << cm.getRepr() << " not in input array of type !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
nbPerType=tmpb.retn();
{
std::ostringstream oss; oss << "MEDCouplingUMesh::convertNodalConnectivityToStaticGeoTypeMesh : this contains a single geo type (" << cm.getRepr() << ") but ";
oss << "this type is dynamic ! Only static geometric type is possible for that type ! call convertNodalConnectivityToDynamicGeoTypeMesh instead !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
int nbCells=getNumberOfCells();
int typi=(int)typ;
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::convertNodalConnectivityToStaticGeoTypeMesh : there something wrong in cell #" << i << " ! The type of cell is not those expected, or the length of nodal connectivity is not those expected (" << nbNodesPerCell-1 << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
return connOut.retn();
{
std::ostringstream oss; oss << "MEDCouplingUMesh::keepSpecifiedCells : Request on type " << type << " at place #" << std::distance(idsPerGeoTypeBg,work) << " value " << *work;
oss << ". It should be in [0," << szOfType << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
MCAuto<DataArrayInt> idsTokeep=DataArrayInt::New(); idsTokeep->alloc(sz+(int)std::distance(idsPerGeoTypeBg,idsPerGeoTypeEnd),1);
int *idsPtr=idsTokeep->getPointer();
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell : on cell #" << i << " presence of nodeId #" << *conn << " should be in [0," << nbOfNodes << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
int nbOfNodesInCell=nodalI[i+1]-nodalI[i]-1;
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell : on cell #" << i << " presence of cell with no nodes !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
else
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell : on cell polyhedron cell #" << i << " presence of nodeId #" << *it << " should be in [0," << nbOfNodes << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
if(!s.empty())
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell : on polyhedron cell #" << i << " there are no nodes !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
}
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::computePlaneEquationOf3DFaces : invalid 2D cell #" << i << " ! This cell points to an invalid nodeId : " << nodeId << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
}
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::computePlaneEquationOf3DFaces : invalid 2D cell #" << i << " ! Must be constitued by more than 3 nodes !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
INTERP_KERNEL::inverseMatrix(matrix,4,matrix2);
retPtr[0]=matrix2[3]; retPtr[1]=matrix2[7]; retPtr[2]=matrix2[11]; retPtr[3]=matrix2[15];
if(!a[ii])
{
std::ostringstream oss; oss << "MEDCouplingUMesh::MergeUMeshes : item #" << ii << " in input array of size "<< sz << " is empty !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
std::vector< MCAuto<MEDCouplingUMesh> > bb(sz);
std::vector< const MEDCouplingUMesh * > aa(sz);
if(!meshes[ii])
{
std::ostringstream oss; oss << "MEDCouplingUMesh::MergeUMeshesOnSameCoords : item #" << ii << " in input array of size "<< meshes.size() << " is empty !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
const DataArrayDouble *coords=meshes.front()->getCoords();
int meshDim=meshes.front()->getMeshDimension();
{
std::ostringstream oss; oss << " MEDCouplingUMesh::PutUMeshesOnSameAggregatedCoords : Item #" << std::distance(meshes.begin(),it) << " inside the vector of length " << meshes.size();
oss << " has no coordinate array defined !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
else
{
std::ostringstream oss; oss << " MEDCouplingUMesh::PutUMeshesOnSameAggregatedCoords : Item #" << std::distance(meshes.begin(),it) << " inside the vector of length " << meshes.size();
oss << " is null !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
MCAuto<DataArrayDouble> res=DataArrayDouble::Aggregate(coords);
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::MergeNodesOnUMeshesSharingSameCoords : In input vector of unstructured meshes of size " << meshes.size() << " the element #" << std::distance(meshes.begin(),it) << " is null !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
if(s.size()!=1)
{
std::ostringstream oss; oss << "MEDCouplingUMesh::MergeNodesOnUMeshesSharingSameCoords : In input vector of unstructured meshes of size " << meshes.size() << ", it appears that they do not share the same instance of DataArrayDouble for coordiantes ! tryToShareSameCoordsPermute method can help to reach that !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
const DataArrayDouble *coo=*(s.begin());
if(!coo)
std::pair<int,int> p1(bgFace[j],bgFace[(j+1)%nbOfEdgesInFace]);
std::pair<int,int> p2(p1.second,p1.first);
if(std::find(edgesOK.begin(),edgesOK.end(),p1)!=edgesOK.end())
- { std::ostringstream oss; oss << "Face #" << j << " of polyhedron looks bad !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); }
+ { std::ostringstream oss; oss << "Face #" << j << " of polyhedron looks bad !"; throw INTERP_KERNEL::Exception(oss.str()); }
if(std::find(edgesFinished.begin(),edgesFinished.end(),p1)!=edgesFinished.end() || std::find(edgesFinished.begin(),edgesFinished.end(),p2)!=edgesFinished.end())
- { std::ostringstream oss; oss << "Face #" << j << " of polyhedron looks bad !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); }
+ { std::ostringstream oss; oss << "Face #" << j << " of polyhedron looks bad !"; throw INTERP_KERNEL::Exception(oss.str()); }
std::list< std::pair<int,int> >::iterator it=std::find(edgesOK.begin(),edgesOK.end(),p2);
if(it!=edgesOK.end())
{
catch(INTERP_KERNEL::Exception& e)
{
std::ostringstream oss; oss << "Error when computing residual of cell #" << i << " in source/m1 mesh ! Maybe the neighbours of this cell in mesh are not well connected !\n" << "The deep reason is the following : " << e.what();
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
for(std::map<int,INTERP_KERNEL::Node *>::const_iterator it=mappRev.begin();it!=mappRev.end();it++)
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArrays : id located on pos #" << i << " value is " << *idsIt << " ! Must be in [0," << nbOfGrps << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
if(lgth>=work[-1])
*work=lgth;
{
std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArrays : id located on pos #" << i << " value is " << *idsIt << " and at this pos arrIndxIn[" << *idsIt;
oss << "+1]-arrIndxIn[" << *idsIt << "] < 0 ! The input index array is bugged !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
arro->alloc(lgth,1);
{
std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArrays : id located on pos #" << i << " value is " << *idsIt << " arrIndx[" << *idsIt << "] must be >= 0 and arrIndx[";
oss << *idsIt << "+1] <= " << maxSizeOfArr << " (the size of arrIn)!";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
arrOut=arro.retn();
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArraysSlice : id located on pos #" << i << " value is " << idsIt << " ! Must be in [0," << nbOfGrps << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
if(lgth>=work[-1])
*work=lgth;
{
std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArraysSlice : id located on pos #" << i << " value is " << idsIt << " and at this pos arrIndxIn[" << idsIt;
oss << "+1]-arrIndxIn[" << idsIt << "] < 0 ! The input index array is bugged !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
arro->alloc(lgth,1);
{
std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArraysSlice : id located on pos #" << i << " value is " << idsIt << " arrIndx[" << idsIt << "] must be >= 0 and arrIndx[";
oss << idsIt << "+1] <= " << maxSizeOfArr << " (the size of arrIn)!";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
arrOut=arro.retn();
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::SetPartOfIndexedArrays : On pos #" << std::distance(idsOfSelectBg,it) << " value is " << *it << " not in [0," << nbOfTuples << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
srcArrIndexPtr=srcArrIndex->getConstPointer();
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx : On pos #" << std::distance(idsOfSelectBg,it) << " id (idsOfSelectBg[" << std::distance(idsOfSelectBg,it)<< "]) is " << *it << " arrIndxIn[id+1]-arrIndxIn[id]!=srcArrIndex[pos+1]-srcArrIndex[pos] !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx : On pos #" << std::distance(idsOfSelectBg,it) << " value is " << *it << " not in [0," << nbOfTuples << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
}
if(*seedElt>=0 && *seedElt<nbOfTuples)
{ fetched[*seedElt]=true; fetched2[*seedElt]=true; }
else
- { std::ostringstream oss; oss << "MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeedAlg : At pos #" << i << " of seeds value is " << *seedElt << "! Should be in [0," << nbOfTuples << ") !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); }
+ { std::ostringstream oss; oss << "MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeedAlg : At pos #" << i << " of seeds value is " << *seedElt << "! Should be in [0," << nbOfTuples << ") !"; throw INTERP_KERNEL::Exception(oss.str()); }
}
const int *arrInPtr=arrIn->getConstPointer();
const int *arrIndxPtr=arrIndxIn->getConstPointer();
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::SetPartOfIndexedArraysSlice : On pos #" << i << " value is " << it << " not in [0," << nbOfTuples << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
srcArrIndexPtr=srcArrIndex->getConstPointer();
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::SetPartOfIndexedArraysSameIdxSlice : On pos #" << i << " id (idsOfSelectBg[" << i << "]) is " << it << " arrIndxIn[id+1]-arrIndxIn[id]!=srcArrIndex[pos+1]-srcArrIndex[pos] !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
else
{
std::ostringstream oss; oss << "MEDCouplingUMesh::SetPartOfIndexedArraysSameIdxSlice : On pos #" << i << " value is " << it << " not in [0," << nbOfTuples << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
}
self.assertTrue(rd.isEqual(DataArrayInt([0,4,0,3,0,2,0,2,0,0,1,2,1,2,1,6,1,5,1,1,2,8,2,7,3,3,4,4,5,5,6,6,7,7,8,8])))
self.assertTrue(rdi.isEqual(DataArrayInt([0,2,4,6,8,9,10,12,14,16,18,19,20,22,24,25,27,28,29,31,33,35,36])))
pass
-
+
+ def testFieldIntIsOnStage2(self):
+ """ Very important test to check that isEqual of MEDCouplingFieldInt is OK !"""
+ m1=MEDCouplingCMesh() ; m1.setCoords(DataArrayDouble([0,1,2,3]),DataArrayDouble([0,1,2,3,4]))
+ m1=m1.buildUnstructured() ; m1.setName("mesh")
+ f1=MEDCouplingFieldInt(ON_CELLS) ; f1.setMesh(m1)
+ arr1=DataArrayInt([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr1.setInfoOnComponents(["aa","bbb"])
+ f1.setArray(arr1) ; f1.setName("f1") ; f1.setTime(2.,3,4)
+ #
+ m2=MEDCouplingCMesh() ; m2.setCoords(DataArrayDouble([0,1,2,3]),DataArrayDouble([0,1,2,3,4]))
+ m2=m2.buildUnstructured() ; m2.setName("mesh")
+ f2=MEDCouplingFieldInt(ON_CELLS) ; f2.setMesh(m2)
+ arr2=DataArrayInt([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr2.setInfoOnComponents(["aa","bbb"])
+ f2.setArray(arr2) ; f2.setName("f1") ; f2.setTime(2.,3,4)
+ #
+ self.assertTrue(f1.isEqual(f2,1e-12,0.))
+ f1.getArray()[:]*=2
+ self.assertTrue(not f1.isEqual(f2,1e-12,0.))
+ self.assertTrue(not f1.isEqualWithoutConsideringStr(f2,1e-12,0.))
+ f1.getArray()[:]/=2
+ self.assertTrue(f1.isEqual(f2,1e-12,0.))
+ #
+ f1.setName("F1")
+ self.assertTrue(not f1.isEqual(f2,1e-12,0.))
+ f1.setName("f1")
+ self.assertTrue(f1.isEqual(f2,1e-12,0.))
+ #
+ f1.getArray().setInfoOnComponents(["aa","bbbb"])
+ self.assertTrue(not f1.isEqual(f2,1e-12,0.))
+ self.assertTrue(f1.isEqualWithoutConsideringStr(f2,1e-12,0.))
+ f1.getArray().setInfoOnComponents(["aa","bbb"])
+ self.assertTrue(f1.isEqual(f2,1e-12,0.))
+ #
+ f3=f2.deepCopy()
+ self.assertTrue(f1.isEqual(f3,1e-12,0.))
+ #
+ for fd,expected in ((ON_NODES,False),(ON_CELLS,True)):
+ f4=MEDCouplingFieldInt(fd) ; f4.setMesh(m2) ; f4.setTime(2.,3,4)
+ arr4=DataArrayInt([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr4.setInfoOnComponents(["aa","bbb"])
+ f4.setArray(arr4) ; f4.setName("f1")
+ self.assertEqual(f1.isEqual(f4,1e-12,0.),expected)
+ pass
+ pass
+
pass
if __name__ == '__main__':
%newobject MEDCoupling::MEDCouplingFieldDouble::getEndArray;
%newobject MEDCoupling::MEDCouplingFieldDouble::MergeFields;
%newobject MEDCoupling::MEDCouplingFieldDouble::MeldFields;
+%newobject MEDCoupling::MEDCouplingFieldDouble::convertToIntField;
%newobject MEDCoupling::MEDCouplingFieldDouble::doublyContractedProduct;
%newobject MEDCoupling::MEDCouplingFieldDouble::determinant;
%newobject MEDCoupling::MEDCouplingFieldDouble::eigenValues;
%newobject MEDCoupling::MEDCouplingFieldDouble::cellToNodeDiscretization;
%newobject MEDCoupling::MEDCouplingFieldDouble::getValueOnMulti;
%newobject MEDCoupling::MEDCouplingFieldInt::New;
+%newobject MEDCoupling::MEDCouplingFieldInt::convertToDblField;
%newobject MEDCoupling::MEDCouplingFieldInt::getArray;
+%newobject MEDCoupling::MEDCouplingFieldInt::deepCopy;
+%newobject MEDCoupling::MEDCouplingFieldInt::clone;
+%newobject MEDCoupling::MEDCouplingFieldInt::cloneWithMesh;
%newobject MEDCoupling::MEDCouplingFieldTemplate::New;
%newobject MEDCoupling::MEDCouplingMesh::deepCopy;
%newobject MEDCoupling::MEDCouplingMesh::clone;
}
};
+ class MEDCouplingFieldInt;
+
class MEDCouplingFieldDouble : public MEDCoupling::MEDCouplingField
{
public:
std::string simpleRepr() const throw(INTERP_KERNEL::Exception);
std::string advancedRepr() const throw(INTERP_KERNEL::Exception);
std::string writeVTK(const std::string& fileName, bool isBinary=true) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *convertToIntField() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *clone(bool recDeepCpy) const;
MEDCouplingFieldDouble *cloneWithMesh(bool recDeepCpy) const;
MEDCouplingFieldDouble *deepCopy() const;
std::string getTimeUnit() const throw(INTERP_KERNEL::Exception);
void setTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception);
void setArray(DataArrayInt *array) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *deepCopy() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *clone(bool recDeepCpy) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *cloneWithMesh(bool recDeepCpy) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *convertToDblField() const throw(INTERP_KERNEL::Exception);
%extend {
MEDCouplingFieldInt(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME)
{
#include "MEDFileFieldOverView.hxx"
#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingFieldTemplate.hxx"
#include "MEDCouplingFieldDiscretization.hxx"
#include "InterpKernelAutoPtr.hxx"
throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
if(_type!=ON_GAUSS_PT)
{
- locIds->setName(oss.str().c_str());
+ locIds->setName(oss.str());
glob.appendProfile(locIds);
_profile=oss.str();
}
if(locIds)
{
MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
- da5->setName(oss.str().c_str());
+ da5->setName(oss.str());
glob.appendProfile(da5);
_profile=oss.str();
}
{
if(!da3->isIota(nbOfEltsInWholeMesh))
{
- da3->setName(oss.str().c_str());
+ da3->setName(oss.str());
glob.appendProfile(da3);
_profile=oss.str();
}
if(_end-_start!=nbValsInFile*nbi)
{
std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : The number of tuples to read is " << nbValsInFile << "*" << nbi << " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
}
if(_start<0 || _start>=arr->getNumberOfTuples())
{
std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
if(_end<0 || _end>arr->getNumberOfTuples())
{
std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
int nbOfCompo(arr->getNumberOfComponents());
DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
{
const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
int *work=ptToFill;
if(_profile.empty())
const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
*work++=ii;
oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
oss << _nval;
oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
int offset2=codeOfMesh[3*found+2];
for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
{
- const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
- int curDim=(int)cm.getDimension();
+ const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
+ int curDim((int)cm.getDimension());
dim=std::max(dim,curDim);
}
+bool MEDFileFieldPerMeshPerType::isUniqueLevel(int& dim) const
+{
+ const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
+ int curDim((int)cm.getDimension());
+ if(dim!=std::numeric_limits<int>::max())
+ {
+ if(dim!=curDim)
+ return false;
+ }
+ else
+ dim=curDim;
+ return true;
+}
+
void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
{
for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
{
const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
return _field_pm_pt_pd[locId];
{
const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
return _field_pm_pt_pd[locId];
(*it)->getDimension(dim);
}
+bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
+{
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ if(!(*it)->isUniqueLevel(dim))
+ return false;
+ return true;
+}
+
void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
{
for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
if(code.empty())
{
std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
//
std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
{
std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
oss << " nodes in mesh !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
}
if(code.empty())
{
std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
{
std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
oss << " nodes in mesh !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
oss << "\"" << cm2.getRepr() << "\", ";
}
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
oss << "\"" << cm2.getRepr() << "\", ";
}
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
return 0;
}
if(!(*it)->isEqual(*_pfls[id]))
{
std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
}
if(!(*it)->isEqual(*_locs[id],eps))
{
std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
}
std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
for(it=_locs.begin();it!=_locs.end();it++)
oss << "\"" << (*it)->getName() << "\", ";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
return std::distance(_locs.begin(),it);
}
std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
for(it=_pfls.begin();it!=_pfls.end();it++)
oss << "\"" << (*it)->getName() << "\", ";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
return *it;
}
std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
for(it=_pfls.begin();it!=_pfls.end();it++)
oss << "\"" << (*it)->getName() << "\", ";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
return *it;
}
if(!pfl->isEqual(*(*it)))
{
std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
pfl->incrRef();
if(!(*it)->isEqual(*obj,1e-12))
{
std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
_locs.push_back(obj);
oss << "Possible meshes are : ";
for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
oss << "\"" << (*it2) << "\" ";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
{
std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
// end of check
int start=copyTinyInfoFrom(field,arrOfVals);
if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
{
std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
int start=copyTinyInfoFrom(field,arrOfVals);
int pos=addNewEntryIfNecessary(m);
return false;
}
+MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
+{
+ static const char MSG0[]="MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is too complex to be able to extract a field ! Call getFieldOnMeshAtLevel method instead to deal with complexity !";
+ if(_field_per_mesh.empty())
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
+ if(_field_per_mesh.size()>1)
+ throw INTERP_KERNEL::Exception(MSG0);
+ if(_field_per_mesh[0].isNull())
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
+ const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
+ std::set<TypeOfField> types;
+ pm->fillTypesOfFieldAvailable(types);
+ if(types.size()!=1)
+ throw INTERP_KERNEL::Exception(MSG0);
+ TypeOfField type(*types.begin());
+ int meshDimRelToMax(0);
+ if(type==ON_NODES)
+ meshDimRelToMax=0;
+ else
+ {
+ int myDim(std::numeric_limits<int>::max());
+ bool isUnique(pm->isUniqueLevel(myDim));
+ if(!isUnique)
+ throw INTERP_KERNEL::Exception(MSG0);
+ meshDimRelToMax=myDim-mesh->getMeshDimension();
+ if(meshDimRelToMax>0)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
+ }
+ return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
+}
+
/*!
* Returns a new MEDCouplingFieldDouble of given type lying on a given support.
* \param [in] type - a spatial discretization of the new field.
MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
{
MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
- const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
- const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
+ const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
if(meshDimRelToMax==1)
(static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
{
std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
{
std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
default:
{
std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
ret->setDtUnit(dtunit.c_str());
default:
{
std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
ret->setDtUnit(dtunit.c_str());
if(nbSteps<1)
{
std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
//
med_int numdt,numit;
default:
{
std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName,fieldName,iteration,order) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
ret->setDtUnit(dtunit.c_str());
std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
oss << "(" << (*iter).first << "," << (*iter).second << "), ";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
if(loadAll)
ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
if(fieldIdCFormat>=nbFields)
{
std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
oss << "\"" << *it << "\" ";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
return nbOfStep2;
}
else
{
std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
else
{
std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
{
if(!f)
throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
- if(!((DataArray*)arr))
+ if(arr.isNull())
throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
- DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
+ DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
if(!arrOutC)
throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
f->setArray(arrOutC);
DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
{
- if(!((DataArray*)arr))
+ if(arr.isNull())
throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
- DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
+ DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
if(!arrOutC)
throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
arrOutC->incrRef();
_content=new MEDFileField1TSWithoutSDA;
}
+/*!
+ * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
+ * method should be called (getFieldOnMeshAtLevel for example).
+ * But for normal usage of field in MED file world this method is the most efficient to fetch data.
+ *
+ * \param [in] mesh - the mesh the field is lying on
+ * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * caller is to delete this field using decrRef() as it is no more needed.
+ */
+MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
+{
+ MCAuto<DataArray> arrOut;
+ MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
+ MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
+ return ret.retn();
+}
+
/*!
* Returns a new MEDCouplingFieldDouble of a given type lying on
* mesh entities of a given dimension of the first mesh in MED file. If \a this field
if(getFileName().empty())
throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
MCAuto<DataArray> arrOut;
- MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull());
+ MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
return ret.retn();
}
if(getFileName().empty())
throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
MCAuto<DataArray> arrOut;
- MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull());
+ MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
return ret.retn();
}
MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
{
MCAuto<DataArray> arrOut;
- MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
+ MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
return ret.retn();
}
MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
{
MCAuto<DataArray> arrOut;
- MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
+ MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
return ret.retn();
}
if(getFileName().empty())
throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
MCAuto<DataArray> arrOut;
- MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
+ MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
return ret.retn();
}
}
/*!
- * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
+ * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
* checked if its elements are sorted suitable for writing to MED file ("STB" stands for
* "Sort By Type"), if not, an exception is thrown.
* For more info, see \ref AdvMEDLoaderAPIFieldRW
- * \param [in] field - the field to add to \a this. The field double values are ignored.
- * \param [in] arrOfVals - the values of the field \a field used.
+ * \param [in] field - the field to add to \a this.
* \throw If the name of \a field is empty.
* \throw If the data array of \a field is not set.
* \throw If the data array is already allocated but has different number of components
* \throw If the underlying mesh of \a field has no name.
* \throw If elements in the mesh are not in the order suitable for writing to the MED file.
*/
-void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
+void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
{
+ MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
setFileName("");
- contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
+ contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
}
/*!
- * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
+ * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
* can be an aggregation of several MEDCouplingFieldDouble instances.
* The mesh support of input parameter \a field is ignored here, it can be NULL.
* The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
* This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
* A new profile is added only if no equal profile is missing.
* For more info, see \ref AdvMEDLoaderAPIFieldRW
- * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
- * \param [in] arrOfVals - the values of the field \a field used.
+ * \param [in] field - the field to add to \a this.
* \param [in] mesh - the supporting mesh of \a field.
* \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
* \param [in] profile - ids of mesh entities on which corresponding field values lie.
* \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
* \sa setFieldNoProfileSBT()
*/
-void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
+void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
{
+ MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
setFileName("");
- contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
+ contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
}
const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
return ret;
}
-MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
+MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
{
if(getFileName().empty())
throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
- MCAuto<DataArray> arrOut2;
- MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut2,*contentNotNull());
- DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
- if(!arrOutC)
- throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
- arrOut=arrOutC;
- arrOut->incrRef(); // arrOut2 dies at the end of the func
- return ret.retn();
+ MCAuto<DataArray> arrOut;
+ MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
+ MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
+ return ret2.retn();
}
DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
{
- if(!((DataArray *)arr))
+ if(arr.isNull())
throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
- DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
+ DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
if(!arrC)
throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
arrC->incrRef();
return arrC;
}
+MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
+{
+ int t1,t2;
+ double t0(f->getTime(t1,t2));
+ MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
+ MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
+ MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
+ ret->setTime(t0,t1,t2); ret->setArray(arr2);
+ return ret.retn();
+}
+
+MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
+{
+ if(!f)
+ throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
+ int t1,t2;
+ double t0(f->getTime(t1,t2));
+ MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
+ MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
+ ret->setTime(t0,t1,t2);
+ return ret;
+}
+
MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
{
throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
}
/*!
- * Returns a new MEDCouplingFieldDouble of a given type lying on
+ * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
+ * method should be called (getFieldOnMeshAtLevel for example).
+ * But for normal usage of field in MED file world this method is the most efficient to fetch data.
+ *
+ * \param [in] mesh - the mesh the field is lying on
+ * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
+ * caller is to delete this field using decrRef() as it is no more needed.
+ */
+MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
+{
+ MCAuto<DataArray> arrOut;
+ MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
+ MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
+ return ret2.retn();
+}
+
+/*!
+ * Returns a new MEDCouplingFieldInt of a given type lying on
* the top level cells of the first mesh in MED file. If \a this field
* has not been constructed via file reading, an exception is thrown.
* For more info, see \ref AdvMEDLoaderAPIFieldRW
* \param [in] type - a spatial discretization of interest.
- * \param [out] arrOut - the DataArrayInt containing values of field.
* \param [in] renumPol - specifies how to permute values of the result field according to
* the optional numbers of cells and nodes, if any. The valid values are
* - 0 - do not permute.
* - 2 - permute nodes.
* - 3 - permute cells and nodes.
*
- * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
* caller is to delete this field using decrRef() as it is no more needed.
* \throw If \a this field has not been constructed via file reading.
* \throw If the MED file is not readable.
* \throw If no field values lying on the top level support.
* \sa getFieldAtLevel()
*/
-MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const
+MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
{
if(getFileName().empty())
throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
- MCAuto<DataArray> arr;
- MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNull());
- arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
- return ret.retn();
+ MCAuto<DataArray> arrOut;
+ MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
+ MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
+ return ret2.retn();
}
/*!
- * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
+ * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
* For more info, see \ref AdvMEDLoaderAPIFieldRW
* \param [in] type - a spatial discretization of the new field.
* \param [in] mesh - the supporting mesh.
- * \param [out] arrOut - the DataArrayInt containing values of field.
* \param [in] renumPol - specifies how to permute values of the result field according to
* the optional numbers of cells and nodes, if any. The valid values are
* - 0 - do not permute.
* - 2 - permute nodes.
* - 3 - permute cells and nodes.
*
- * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
* caller is to delete this field using decrRef() as it is no more needed.
* \throw If no field of \a this is lying on \a mesh.
* \throw If the mesh is empty.
* \sa getFieldAtLevel()
* \sa getFieldOnMeshAtLevel()
*/
-MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
+MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
{
- MCAuto<DataArray> arr;
- MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
- arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
- return ret.retn();
+ MCAuto<DataArray> arrOut;
+ MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
+ MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
+ return ret2.retn();
}
/*!
- * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
+ * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
* For more info, see \ref AdvMEDLoaderAPIFieldRW
* \param [in] type - a spatial discretization of interest.
* \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
- * \param [out] arrOut - the DataArrayInt containing values of field.
* \param [in] mesh - the supporting mesh.
* \param [in] renumPol - specifies how to permute values of the result field according to
* the optional numbers of cells and nodes, if any. The valid values are
* - 2 - permute nodes.
* - 3 - permute cells and nodes.
*
- * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
* caller is to delete this field using decrRef() as it is no more needed.
* \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
* \throw If no field of \a this is lying on \a mesh.
* \sa getFieldAtLevel()
* \sa getFieldOnMeshAtLevel()
*/
-MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
+MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
{
- MCAuto<DataArray> arr;
- MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
- arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
- return ret.retn();
+ MCAuto<DataArray> arrOut;
+ MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
+ MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
+ return ret2.retn();
}
/*!
* \param [in] type - a spatial discretization of interest.
* \param [in] mName - a name of the supporting mesh.
* \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
- * \param [out] arrOut - the DataArrayInt containing values of field.
* \param [in] renumPol - specifies how to permute values of the result field according to
* the optional numbers of cells and nodes, if any. The valid values are
* - 0 - do not permute.
* - 2 - permute nodes.
* - 3 - permute cells and nodes.
*
- * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
* caller is to delete this field using decrRef() as it is no more needed.
* \throw If the MED file is not readable.
* \throw If there is no mesh named \a mName in the MED file.
* \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
* \sa getFieldAtLevel()
*/
-MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
+MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
{
if(getFileName().empty())
- throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
- MCAuto<DataArray> arr;
- MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
- arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
- return ret.retn();
+ throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
+ MCAuto<DataArray> arrOut;
+ MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
+ MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
+ return ret2.retn();
}
/*!
{
std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
oss << " ! Should be in [0," << sz << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
if(ret->getNumberOfTS()>0)
{
std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
oss << " ! Should be in [0," << sz << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
if(ret->getNumberOfTS()>0)
std::vector< std::pair<int,int> > vp=getIterations();
for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
oss << "(" << (*it2).first << "," << (*it2).second << ") ";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
else
{
std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
return ret;
{
std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
cur->copyNameScope(*this);
}
else
{
std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
for(int iii=0;iii<maxId;iii++)
oss << "(" << it2 << "," << ord << "), ";
}
}
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
oss << ti << ", ";
}
}
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
if(pos<0 || pos>=(int)_time_steps.size())
{
std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
if(item==0)
{
std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
oss << "\nTry to use following method eraseEmptyTS !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
return item;
}
if(pos<0 || pos>=(int)_time_steps.size())
{
std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
if(item==0)
{
std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
oss << "\nTry to use following method eraseEmptyTS !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
return item;
}
if(ret1.size()!=sz)
{
std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
ts[i]=ret1;
}
if(!timeStep)
{
std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
items[i]=timeStep->splitDiscretizations();
}
if(!timeStep)
{
std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
items[i]=timeStep->splitMultiDiscrPerGeoTypes();
if(szOut==std::numeric_limits<std::size_t>::max())
{
std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
if(!arr)
throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
{
std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
oss << " number of components of element to append (" << compos.size() << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
if(_infos!=compos)
{
oss << " But compo in input fields are : ";
std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
oss << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
{
std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
}
if(i<0 || i>=sz)
{
std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
if(tsPtr)
if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
{
std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
_time_steps[i]=ts;
default:
{
std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
ret->setDtUnit(dtunit.c_str());
default:
{
std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
ret->setDtUnit(dtunit.c_str());
if(f0->getMeshName()!=mesh->getName())
{
std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
if(f1->getMeshName()!=mesh->getName())
{
std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
int nts=f0->getNumberOfTS();
if(nts!=f1->getNumberOfTS())
if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
{
std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh time step (" << f0cur->getMeshIteration() << ","<< f0cur->getMeshOrder() << ") whereas input mesh points to time step (" << mesh->getIteration() << "," << mesh->getOrder() << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
{
std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh time step (" << f1cur->getMeshIteration() << ","<< f1cur->getMeshOrder() << ") whereas input mesh points to time step (" << mesh->getIteration() << "," << mesh->getOrder() << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
{
std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : all the time steps must be the same ! it is not the case (" << f0cur->getIteration() << "," << f0cur->getOrder() << ")!=(" << f1cur->getIteration() << "," << f1cur->getOrder() << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
return nts;
if(!item)
{
std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
if(itemC)
return ret.retn();
}
std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
/*!
return ret.retn();
}
+/*!
+ * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
+ * method should be called (getFieldOnMeshAtLevel for example).
+ * But for normal usage of field in MED file world this method is the most efficient to fetch data.
+ *
+ * \param [in] iteration - the iteration number of a required time step.
+ * \param [in] order - the iteration order number of required time step.
+ * \param [in] mesh - the mesh the field is lying on
+ * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * caller is to delete this field using decrRef() as it is no more needed.
+ */
+MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
+{
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
+ MCAuto<DataArray> arrOut;
+ MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
+ MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
+ return ret.retn();
+}
+
/*!
* Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
* a given support.
*/
MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
{
- const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
if(!myF1TSC)
throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
}
/*!
- * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
+ * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
+ * method should be called (getFieldOnMeshAtLevel for example).
+ * But for normal usage of field in MED file world this method is the most efficient to fetch data.
+ *
+ * \param [in] iteration - the iteration number of a required time step.
+ * \param [in] order - the iteration order number of required time step.
+ * \param [in] mesh - the mesh the field is lying on
+ * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
+ * caller is to delete this field using decrRef() as it is no more needed.
+ */
+MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
+{
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
+ const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
+ if(!myF1TSC)
+ throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
+ MCAuto<DataArray> arrOut;
+ MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
+ MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
+ return ret2.retn();
+}
+
+/*!
+ * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
* mesh entities of a given dimension of the first mesh in MED file.
* For more info, see \ref AdvMEDLoaderAPIFieldRW
* \param [in] type - a spatial discretization of interest.
* \param [in] iteration - the iteration number of a required time step.
* \param [in] order - the iteration order number of required time step.
* \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
- * \param [out] arrOut - the DataArrayInt containing values of field.
* \param [in] renumPol - specifies how to permute values of the result field according to
* the optional numbers of cells and nodes, if any. The valid values are
* - 0 - do not permute.
* - 2 - permute nodes.
* - 3 - permute cells and nodes.
*
- * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
* caller is to delete this field using decrRef() as it is no more needed.
* \throw If the MED file is not readable.
* \throw If there is no mesh in the MED file.
* \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
* \throw If no field values of the required parameters are available.
*/
-MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
+MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
{
- const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
- const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
+ const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
if(!myF1TSC)
throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
MCAuto<DataArray> arr;
- MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase());
- arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
- return ret.retn();
+ MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
+ MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
+ return ret2.retn();
}
/*!
- * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
+ * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
* the top level cells of the first mesh in MED file.
* For more info, see \ref AdvMEDLoaderAPIFieldRW
* \param [in] type - a spatial discretization of interest.
* \param [in] iteration - the iteration number of a required time step.
* \param [in] order - the iteration order number of required time step.
- * \param [out] arrOut - the DataArrayInt containing values of field.
* \param [in] renumPol - specifies how to permute values of the result field according to
* the optional numbers of cells and nodes, if any. The valid values are
* - 0 - do not permute.
* - 2 - permute nodes.
* - 3 - permute cells and nodes.
*
- * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
* caller is to delete this field using decrRef() as it is no more needed.
* \throw If the MED file is not readable.
* \throw If there is no mesh in the MED file.
* \throw If no field values of the required parameters are available.
*/
-MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const
+MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
{
- const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
- const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
+ const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
if(!myF1TSC)
throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
MCAuto<DataArray> arr;
- MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase());
- arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
- return ret.retn();
+ MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
+ MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
+ return ret2.retn();
}
/*!
- * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
+ * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
* a given support.
* For more info, see \ref AdvMEDLoaderAPIFieldRW
* \param [in] type - a spatial discretization of interest.
* \param [in] iteration - the iteration number of a required time step.
* \param [in] order - the iteration order number of required time step.
- * \param [out] arrOut - the DataArrayInt containing values of field.
* \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
* \param [in] mesh - the supporting mesh.
* \param [in] renumPol - specifies how to permute values of the result field according to
* - 2 - permute nodes.
* - 3 - permute cells and nodes.
*
- * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
* caller is to delete this field using decrRef() as it is no more needed.
* \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
* \throw If no field of \a this is lying on \a mesh.
* \throw If no field values of the required parameters are available.
*/
-MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
+MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
{
- const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
- const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
+ const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
if(!myF1TSC)
- throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
+ throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
MCAuto<DataArray> arr;
- MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
- arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
- return ret.retn();
+ MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
+ MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
+ return ret2.retn();
}
/*!
- * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
+ * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
* given support.
* For more info, see \ref AdvMEDLoaderAPIFieldRW
* \param [in] type - a spatial discretization of the new field.
* - 2 - permute nodes.
* - 3 - permute cells and nodes.
*
- * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
* caller is to delete this field using decrRef() as it is no more needed.
* \throw If no field of \a this is lying on \a mesh.
* \throw If no field values of the required parameters are available.
*/
-MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
+MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
{
- const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
- const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
+ const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
if(!myF1TSC)
throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
MCAuto<DataArray> arr;
- MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
- arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
- return ret.retn();
+ MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
+ MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
+ return ret2.retn();
}
/*!
* This method is called 'old' because the user should give the mesh name he wants to use for it's field.
* This method is useful for MED2 file format when field on different mesh was autorized.
*/
-MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
+MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
{
- const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
- const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
+ const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
if(!myF1TSC)
throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
MCAuto<DataArray> arr;
- MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
- arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
- return ret.retn();
+ MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
+ MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
+ return ret2.retn();
}
/*!
if(!item)
{
std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
if(itemC)
return ret.retn();
}
std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
/*!
- * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
+ * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
* the given field is checked if its elements are sorted suitable for writing to MED file
* ("STB" stands for "Sort By Type"), if not, an exception is thrown.
* For more info, see \ref AdvMEDLoaderAPIFieldRW
* \throw If the underlying mesh of \a field has no name.
* \throw If elements in the mesh are not in the order suitable for writing to the MED file.
*/
-void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
+void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
{
- contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
+ MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
+ contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
}
/*!
* \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
* \sa setFieldNoProfileSBT()
*/
-void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
+void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
{
- contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
+ MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
+ contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
}
const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
else
{
std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
return ret;
default:
{
std::ostringstream oss; oss << "constructor MEDFileFields(fileName) : file \'" << fileName << "\' at pos #" << i << " field has name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
}
}
if(!elt)
{
std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
elt->writeLL(fid,*this);
}
if(*i<0 || *i>=(int)_fields.size())
{
std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
b[*i]=false;
}
if(k<0 || k>=(int)_fields.size())
{
std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
b[k]=false;
}
if(!fmts)
{
std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
fsOut->pushField(fmtsOut);
if(i<0 || i>=(int)_fields.size())
{
std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
if(!fmts)
else
{
std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
ret->shallowCpyGlobs(*this);
return ret.retn();
if(*i<0 || *i>=(int)_fields.size())
{
std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
fields[j]=_fields[*i];
}
std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
oss << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ throw INTERP_KERNEL::Exception(oss.str());
}
MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
#include "MCAuto.hxx"
#include "MEDCouplingRefCountObject.hxx"
+#include "MEDCouplingFieldInt.hxx"
#include "MEDCouplingMemArray.hxx"
#include "NormalizedUnstructuredMesh.hxx"
void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc);
void writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const;
void getDimension(int& dim) const;
+ bool isUniqueLevel(int& dim) const;
void fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const;
void fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const;
int getIteration() const;
void fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const;
std::vector< std::vector< std::pair<int,int> > > getFieldSplitedByType(std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
void getDimension(int& dim) const;
+ bool isUniqueLevel(int& dim) const;
double getTime() const;
int getIteration() const;
int getOrder() const;
MEDLOADER_EXPORT virtual DataArray *getOrCreateAndGetArray() = 0;
MEDLOADER_EXPORT virtual const DataArray *getOrCreateAndGetArray() const = 0;
public:
+ MEDLOADER_EXPORT MEDCouplingFieldDouble *fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
MEDLOADER_EXPORT static MEDFileField1TS *New();
MEDLOADER_EXPORT MEDFileIntField1TS *convertToInt(bool isDeepCpyGlobs=true) const;
//
+ MEDLOADER_EXPORT MEDCouplingFieldDouble *field(const MEDFileMesh *mesh) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const;
MEDLOADER_EXPORT MEDFileField1TS *convertToDouble(bool isDeepCpyGlobs=true) const;
MEDLOADER_EXPORT MEDFileAnyTypeField1TS *shallowCpy() const;
//
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const;
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol=0) const;
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const;
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const;
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const;
+ MEDLOADER_EXPORT MEDCouplingFieldInt *field(const MEDFileMesh *mesh) const;
+ MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const;
+ MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const;
+ MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const;
+ MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const;
+ MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const;
MEDLOADER_EXPORT DataArrayInt *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const;
//
- MEDLOADER_EXPORT void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals);
- MEDLOADER_EXPORT void setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile);
+ MEDLOADER_EXPORT void setFieldNoProfileSBT(const MEDCouplingFieldInt *field);
+ MEDLOADER_EXPORT void setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile);
MEDLOADER_EXPORT DataArrayInt *getUndergroundDataArray() const;
public:
MEDLOADER_EXPORT static DataArrayInt *ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr);
+ MEDLOADER_EXPORT static MCAuto<MEDCouplingFieldInt> SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr);
+ MEDLOADER_EXPORT static MCAuto<MEDCouplingFieldDouble> ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f);
public:
MEDLOADER_EXPORT MEDFileIntField1TS *extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const;
private:
MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStep(int iteration, int order) const;
MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const;
//
+ MEDLOADER_EXPORT MEDCouplingFieldDouble *field(int iteration, int order, const MEDFileMesh *mesh) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const;
MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStepAtPos(int pos) const;
MEDLOADER_EXPORT MEDFileFieldMultiTS *convertToDouble(bool isDeepCpyGlobs=true) const;
//
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const;
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol=0) const;
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const;
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const;
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const;
+ MEDLOADER_EXPORT MEDCouplingFieldInt *field(int iteration, int order, const MEDFileMesh *mesh) const;
+ MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const;
+ MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const;
+ MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const;
+ MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const;
+ MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol=0) const;
MEDLOADER_EXPORT DataArrayInt *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const;
//
- MEDLOADER_EXPORT void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals);
- MEDLOADER_EXPORT void appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile);
+ MEDLOADER_EXPORT void appendFieldNoProfileSBT(const MEDCouplingFieldInt *field);
+ MEDLOADER_EXPORT void appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile);
//
MEDLOADER_EXPORT DataArrayInt *getUndergroundDataArray(int iteration, int order) const;
public:
%newobject MEDCoupling::MEDFileAnyTypeFieldMultiTS::buildNewEmpty;
%newobject MEDCoupling::MEDFileFieldMultiTS::New;
%newobject MEDCoupling::MEDFileFieldMultiTS::LoadSpecificEntities;
+%newobject MEDCoupling::MEDFileFieldMultiTS::field;
%newobject MEDCoupling::MEDFileFieldMultiTS::getFieldAtLevel;
%newobject MEDCoupling::MEDFileFieldMultiTS::getFieldAtTopLevel;
%newobject MEDCoupling::MEDFileFieldMultiTS::getFieldOnMeshAtLevel;
%newobject MEDCoupling::MEDFileFieldMultiTS::getUndergroundDataArray;
%newobject MEDCoupling::MEDFileFieldMultiTS::convertToInt;
%newobject MEDCoupling::MEDFileIntFieldMultiTS::New;
+%newobject MEDCoupling::MEDFileIntFieldMultiTS::field;
%newobject MEDCoupling::MEDFileIntFieldMultiTS::LoadSpecificEntities;
%newobject MEDCoupling::MEDFileIntFieldMultiTS::getUndergroundDataArray;
%newobject MEDCoupling::MEDFileIntFieldMultiTS::convertToDouble;
+%newobject MEDCoupling::MEDFileIntFieldMultiTS::getFieldAtLevel;
+%newobject MEDCoupling::MEDFileIntFieldMultiTS::getFieldAtTopLevel;
+%newobject MEDCoupling::MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel;
+%newobject MEDCoupling::MEDFileIntFieldMultiTS::getFieldAtLevelOld;
%newobject MEDCoupling::MEDFileAnyTypeField1TS::New;
%newobject MEDCoupling::MEDFileAnyTypeField1TS::shallowCpy;
%newobject MEDCoupling::MEDFileAnyTypeField1TS::deepCopy;
%newobject MEDCoupling::MEDFileAnyTypeField1TS::extractPart;
%newobject MEDCoupling::MEDFileField1TS::New;
+%newobject MEDCoupling::MEDFileField1TS::field;
%newobject MEDCoupling::MEDFileField1TS::getFieldAtLevel;
%newobject MEDCoupling::MEDFileField1TS::getFieldAtTopLevel;
%newobject MEDCoupling::MEDFileField1TS::getFieldOnMeshAtLevel;
%newobject MEDCoupling::MEDFileField1TS::convertToInt;
%newobject MEDCoupling::MEDFileIntField1TS::New;
+%newobject MEDCoupling::MEDFileIntField1TS::field;
+%newobject MEDCoupling::MEDFileIntField1TS::getFieldAtLevel;
+%newobject MEDCoupling::MEDFileIntField1TS::getFieldAtTopLevel;
+%newobject MEDCoupling::MEDFileIntField1TS::getFieldOnMeshAtLevel;
+%newobject MEDCoupling::MEDFileIntField1TS::getFieldAtLevelOld;
%newobject MEDCoupling::MEDFileIntField1TS::getUndergroundDataArray;
%newobject MEDCoupling::MEDFileIntField1TS::convertToDouble;
static MEDFileField1TS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
static MEDFileField1TS *New();
MEDCoupling::MEDFileIntField1TS *convertToInt(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *field(const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
static MEDFileIntField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception);
MEDCoupling::MEDFileField1TS *convertToDouble(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception);
//
- void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception);
- void setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+ void setFieldNoProfileSBT(const MEDCouplingFieldInt *field) throw(INTERP_KERNEL::Exception);
+ void setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *field(const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
%extend
{
MEDFileIntField1TS() throw(INTERP_KERNEL::Exception)
return self->simpleRepr();
}
- PyObject *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *ret1=0;
- MEDCouplingFieldDouble *ret0=self->getFieldAtLevel(type,meshDimRelToMax,ret1,renumPol);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- PyObject *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *ret1=0;
- MEDCouplingFieldDouble *ret0=self->getFieldAtTopLevel(type,ret1,renumPol);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- PyObject *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *ret1=0;
- MEDCouplingFieldDouble *ret0=self->getFieldOnMeshAtLevel(type,meshDimRelToMax,mesh,ret1,renumPol);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- PyObject *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *ret1=0;
- MEDCouplingFieldDouble *ret0=self->getFieldOnMeshAtLevel(type,mesh,ret1,renumPol);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- PyObject *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *ret1=0;
- MEDCouplingFieldDouble *ret0=self->getFieldAtLevelOld(type,mname,meshDimRelToMax,ret1,renumPol);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
PyObject *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
{
DataArrayInt *ret1=0;
static MEDFileFieldMultiTS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
static MEDFileFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
//
+ MEDCouplingFieldDouble *field(int iteration, int order, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
static MEDFileIntFieldMultiTS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
static MEDFileIntFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
//
- void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception);
- void appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+ void appendFieldNoProfileSBT(const MEDCouplingFieldInt *field) throw(INTERP_KERNEL::Exception);
+ void appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
MEDCoupling::MEDFileFieldMultiTS *convertToDouble(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *field(int iteration, int order, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
%extend
{
MEDFileIntFieldMultiTS()
return self->simpleRepr();
}
- PyObject *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *ret1=0;
- MEDCouplingFieldDouble *ret0=self->getFieldAtLevel(type,iteration,order,meshDimRelToMax,ret1,renumPol);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- PyObject *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *ret1=0;
- MEDCouplingFieldDouble *ret0=self->getFieldAtTopLevel(type,iteration,order,ret1,renumPol);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- PyObject *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *ret1=0;
- MEDCouplingFieldDouble *ret0=self->getFieldOnMeshAtLevel(type,iteration,order,meshDimRelToMax,mesh,ret1,renumPol);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- PyObject *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *ret1=0;
- MEDCouplingFieldDouble *ret0=self->getFieldOnMeshAtLevel(type,iteration,order,mesh,ret1,renumPol);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- PyObject *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *ret1=0;
- MEDCouplingFieldDouble *ret0=self->getFieldAtLevelOld(type,iteration,order,mname,meshDimRelToMax,ret1,renumPol);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
PyObject *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
{
DataArrayInt *ret1=0;
def testInt32InMEDFileFieldStar1(self):
fname="Pyfile63.med"
f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
- arr=f1.getArray().convertToIntArr()
- f1.setArray(None)
+ f1=f1.convertToIntField()
m1=f1.getMesh()
mm1=MEDFileUMesh.New()
mm1.setCoords(m1.getCoords())
mm1.setName(m1.getName())
mm1.write(fname,2)
ff1=MEDFileIntField1TS()
- ff1.setFieldNoProfileSBT(f1,arr)
- a,b=ff1.getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
- self.assertEqual(b.getInfoOnComponents(),['power [MW/m^3]','density [g/cm^3]','temperature [K]'])
- self.assertTrue(b.isEqual(arr))
+ ff1.setFieldNoProfileSBT(f1)
+ a=ff1.getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
+ self.assertEqual(a.getArray().getInfoOnComponents(),['power [MW/m^3]','density [g/cm^3]','temperature [K]'])
self.assertTrue(a.isEqual(f1,1e-12,1e-12))
ff1.write(fname,0)
ff2=MEDFileAnyTypeField1TS.New(fname)
self.assertEqual(ff2.getName(),"VectorFieldOnCells")
self.assertEqual(ff2.getTime(),[0,1,2.0])
self.assertTrue(isinstance(ff2,MEDFileIntField1TS))
- a,b=ff1.getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
- self.assertEqual(b.getInfoOnComponents(),['power [MW/m^3]','density [g/cm^3]','temperature [K]'])
- self.assertTrue(b.isEqual(arr))
+ a=ff1.getFieldOnMeshAtLevel(ON_CELLS,0,mm1)
+ self.assertEqual(a.getArray().getInfoOnComponents(),['power [MW/m^3]','density [g/cm^3]','temperature [K]'])
self.assertTrue(a.isEqual(f1,1e-12,1e-12))
ff2.setTime(1,2,3.)
c=ff2.getUndergroundDataArray() ; c*=2
self.assertEqual(ffs1.getTimeSteps(),[(0, 1, 2.0), (1, 2, 3.0)])
self.assertEqual(len(ffs1),2)
self.assertTrue(isinstance(ffs1,MEDFileIntFieldMultiTS))
- a,b=ffs1[2.].getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
- self.assertTrue(b.isEqual(arr))
+ a=ffs1[2.].getFieldOnMeshAtLevel(ON_CELLS,0,mm1)
self.assertTrue(a.isEqual(f1,1e-12,1e-12))
- a,b=ffs1[2.].getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
- self.assertTrue(b.isEqual(arr))
+ a=ffs1.getFieldOnMeshAtLevel(ON_CELLS,0,1,0,mm1)
self.assertTrue(a.isEqual(f1,1e-12,1e-12))
it=ffs1.__iter__() ; it.next() ; ff2bis=it.next()
- a,b=ff2bis.getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
- self.assertTrue(b.isEqual(2*arr))
- f1.setTime(3.,1,2)
- self.assertTrue(a.isEqual(f1,1e-12,1e-12))
+ a=ff2bis.getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
+ self.assertTrue(a.getArray().isEqual(2*f1.getArray()))
+ f1.setTime(3.,1,2) ; f1.getArray()[:]*=2
+ self.assertTrue(a.isEqual(f1,1e-12,1e-12)) ; f1.getArray()[:]/=2
bc=DataArrayInt(6,3) ; bc[:]=0 ; bc.setInfoOnComponents(['power [MW/m^3]','density [g/cm^3]','temperature [K]'])
for it in ffs1:
- a,b=it.getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
- bc+=b
+ a=it.getFieldOnMeshAtLevel(ON_CELLS,0,mm1)
+ bc+=a.getArray()
pass
- self.assertTrue(bc.isEqual(3*arr))
- nf1=MEDCouplingFieldDouble(ON_NODES)
+ self.assertTrue(bc.isEqual(3*f1.getArray()))
+ nf1=MEDCouplingFieldInt(ON_NODES)
nf1.setTime(9.,10,-1)
nf1.setMesh(f1.getMesh())
narr=DataArrayInt(12,2) ; narr.setInfoOnComponents(["aa [u1]","bbbvv [ppp]"]) ; narr[:,0]=range(12) ; narr[:,1]=2*narr[:,0]
- nf1.setName("VectorFieldOnNodes")
+ nf1.setName("VectorFieldOnNodes") ; nf1.setArray(narr)
nff1=MEDFileIntField1TS.New()
- nff1.setFieldNoProfileSBT(nf1,narr)
+ nff1.setFieldNoProfileSBT(nf1)
self.assertEqual(nff1.getInfo(),('aa [u1]','bbbvv [ppp]'))
self.assertEqual(nff1.getTime(),[10,-1,9.0])
nff1.write(fname,0)
#
- nf2=MEDCouplingFieldDouble(ON_NODES)
+ nf2=MEDCouplingFieldInt(ON_NODES)
nf2.setTime(19.,20,-11)
nf2.setMesh(f1.getMesh())
narr2=DataArrayInt(8,2) ; narr.setInfoOnComponents(["aapfl [u1]","bbbvvpfl [ppp]"]) ; narr2[:,0]=range(8) ; narr2[:,0]+=10 ; narr2[:,1]=3*narr2[:,0]
- nf2.setName("VectorFieldOnNodesPfl") ; narr2.setName(nf2.getName())
+ nf2.setName("VectorFieldOnNodesPfl") ; narr2.setName(nf2.getName()) ; nf2.setArray(narr2)
nff2=MEDFileIntField1TS.New()
npfl=DataArrayInt([1,2,4,5,6,7,10,11]) ; npfl.setName("npfl")
- nff2.setFieldProfile(nf2,narr2,mm1,0,npfl)
+ nff2.setFieldProfile(nf2,mm1,0,npfl)
nff2.getFieldWithProfile(ON_NODES,0,mm1)
a,b=nff2.getFieldWithProfile(ON_NODES,0,mm1) ; b.setName(npfl.getName())
self.assertTrue(b.isEqual(npfl))
self.assertTrue(isinstance(ffs[2],MEDFileFieldMultiTS))
self.assertTrue(isinstance(ffs[3],MEDFileIntFieldMultiTS))
#
- self.assertTrue(fs["VectorFieldOnCells"][0].getUndergroundDataArray().isEqualWithoutConsideringStr(arr))
- self.assertTrue(fs["VectorFieldOnCells"][1,2].getUndergroundDataArray().isEqualWithoutConsideringStr(2*arr))
+ self.assertTrue(fs["VectorFieldOnCells"][0].getUndergroundDataArray().isEqualWithoutConsideringStr(f1.getArray()))
+ self.assertTrue(fs["VectorFieldOnCells"][1,2].getUndergroundDataArray().isEqualWithoutConsideringStr(2*f1.getArray()))
self.assertTrue(fs["VectorFieldOnNodesPfl"][0].getUndergroundDataArray().isEqualWithoutConsideringStr(narr2))
self.assertTrue(fs["VectorFieldOnNodes"][9.].getUndergroundDataArray().isEqualWithoutConsideringStr(narr))
self.assertTrue(fs["VectorFieldOnNodesDouble"][29.].getUndergroundDataArray().isEqualWithoutConsideringStr(f1.getMesh().getCoords(),1e-12))
fmts=MEDFileIntFieldMultiTS()
pflName="PFL"
pfl=DataArrayInt([1,3,5]) ; pfl.setName(pflName)
- f=MEDCouplingFieldDouble(ON_CELLS) ; f.setMesh(mesh)
+ f=MEDCouplingFieldInt(ON_CELLS) ; f.setMesh(mesh)
fieldName="FieldOnCell"
f.setTime(1.2,1,1) ; f.setName(fieldName)
- arr=DataArrayInt([101,102,103])
- fmts.appendFieldProfile(f,arr,mm,0,pfl)
+ arr=DataArrayInt([101,102,103]) ; f.setArray(arr)
+ fmts.appendFieldProfile(f,mm,0,pfl)
#
mm.write(fname,2)
fmts.write(fname,0)
self.assertEqual(pfltest.getName(),pflName)
self.assertEqual(ftest.getName(),fieldName)
self.assertTrue(ftest.isEqualWithoutConsideringStr(arr))
- ftest2,vals=f1ts.getFieldOnMeshAtLevel(ON_CELLS,0,mm)
- self.assertTrue(vals.isEqualWithoutConsideringStr(arr))
+ ftest2=f1ts.getFieldOnMeshAtLevel(ON_CELLS,0,mm)
+ self.assertTrue(ftest2.getArray().isEqualWithoutConsideringStr(arr))
self.assertEqual(ftest2.getTime(),f.getTime())
self.assertEqual(ftest2.getMesh().getNumberOfCells(),len(arr))
pass
+ def testMEDFileFieldEasyField1(self):
+ """Check for all spatial discretization of field (cells,nodes,elno,gauss) for double field that all is OK. Here no profile and only top level is considered."""
+ ## Basic test on cells on top level
+ fname="Pyfile101.med"
+ fieldName="field1"
+ mm=MEDFileUMesh()
+ coo=DataArrayDouble([(3,2,1),(8,7,6),(5,9,10)])
+ m=MEDCouplingUMesh("mesh",2) ; m.setCoords(coo)
+ m.allocateCells()
+ m.insertNextCell(NORM_TRI3,[0,1,2])
+ m.insertNextCell(NORM_TRI3,[3,4,5])
+ m.insertNextCell(NORM_TRI3,[6,7,8])
+ m.insertNextCell(NORM_TRI3,[9,10,11])
+ m.insertNextCell(NORM_QUAD4,[100,101,102,103])
+ m.insertNextCell(NORM_QUAD4,[104,105,106,107])
+ mm[0]=m
+ mm.write(fname,2)
+ arr0=DataArrayDouble([10,11,12,13,100,101])
+ f=MEDCouplingFieldDouble(ON_CELLS) ; f.setArray(arr0) ; f.setMesh(m)
+ f.setName(fieldName) ; f.setTime(2.,6,7)
+ f0=f.deepCopy()
+ ff=MEDFileFieldMultiTS() ; ff.appendFieldNoProfileSBT(f)
+ ff.write(fname,0)
+ arr2=arr0+1000 ; f.setArray(arr2)
+ f.setTime(3.,8,9) ; ff=MEDFileField1TS() ; ff.setFieldNoProfileSBT(f)
+ ff.write(fname,0)
+ f1=f.deepCopy()
+ ##
+ mm=MEDFileMesh.New(fname)
+ f1ts=MEDFileField1TS(fname,fieldName,6,7)
+ ftst0=f1ts.field(mm)
+ self.assertTrue(f0.isEqual(ftst0,1e-12,1e-12))
+ f1ts=MEDFileField1TS(fname,fieldName,8,9)
+ ftst1=f1ts.field(mm)
+ self.assertTrue(f1.isEqual(ftst1,1e-12,1e-12))
+ fmts=MEDFileFieldMultiTS(fname,fieldName)
+ self.assertTrue(f1.isEqual(fmts.field(8,9,mm),1e-12,1e-12))
+ ## Basic test on nodes on top level
+ f2=MEDCouplingFieldDouble(ON_NODES) ; arr2=DataArrayDouble([200,201,202]) ; arr2.setInfoOnComponent(0,"tutu") ; f2.setArray(arr2) ; f2.setMesh(m) ; f2.setTime(22.,23,24)
+ f2.setName(fieldName)
+ mm.write(fname,2)
+ ff=MEDFileField1TS() ; ff.setFieldNoProfileSBT(f2) ; ff.write(fname,0)
+ #
+ mm=MEDFileMesh.New(fname)
+ f1ts=MEDFileField1TS(fname,fieldName,23,24)
+ self.assertTrue(f2.isEqual(f1ts.field(mm),1e-12,1e-12))
+ fmts=MEDFileFieldMultiTS(fname,fieldName)
+ self.assertTrue(f2.isEqual(fmts.field(23,24,mm),1e-12,1e-12))
+ ## Node on elements
+ f3=MEDCouplingFieldDouble(ON_GAUSS_NE) ; f3.setMesh(m) ; arr3=DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]) ; f3.setArray(arr3) ; f3.setTime(0.5,2,3)
+ f3.setName(fieldName) ; f3.checkConsistencyLight()
+ mm.write(fname,2) ; ff=MEDFileField1TS() ; ff.setFieldNoProfileSBT(f3) ; ff.write(fname,0)
+ #
+ mm=MEDFileMesh.New(fname)
+ f1ts=MEDFileField1TS(fname,fieldName,2,3)
+ self.assertTrue(f3.isEqual(f1ts.field(mm),1e-12,1e-12))
+ ## Gauss
+ f4=MEDCouplingFieldDouble(ON_GAUSS_PT) ; f4.setMesh(m) ; f4.setName(fieldName)
+ f4.setGaussLocalizationOnType(NORM_TRI3,[0.,0.,1.,0.,1.,1.],[0.1,0.1, 0.2,0.2, 0.3,0.3, 0.4,0.4, 0.5,0.5],[0.2,0.3,0.1,0.05,0.35])
+ f4.setGaussLocalizationOnType(NORM_QUAD4,[0.,0.,1.,0.,1.,1.,0.,1.],[0.3,0.4, 0.6,0.7],[0.7,0.3]) ; f4.setTime(0.25,4,5)
+ arr4=DataArrayDouble([0,1,2,3,4 ,10,11,12,13,14, 20,21,22,23,24, 30,31,32,33,34, 45,46, 55,56]) ; arr4.setInfoOnComponent(0,"abc") ; f4.setArray(arr4)
+ f4.checkConsistencyLight()
+ mm.write(fname,2) ; ff=MEDFileField1TS() ; ff.setFieldNoProfileSBT(f4) ; ff.write(fname,0)
+ #
+ mm=MEDFileMesh.New(fname)
+ f1ts=MEDFileField1TS(fname,fieldName,4,5)
+ self.assertTrue(f4.isEqual(f1ts.field(mm),1e-12,1e-12))
+ pass
+
+ def testMEDFileFieldEasyField2(self):
+ """Same thantestMEDFileFieldEasyField1 except that here intfields are considered.
+ Check for all spatial discretization of field (cells,nodes,elno,gauss) for int field that all is OK. Here no profile and only top level is considered."""
+ ## Basic test on cells on top level
+ fname="Pyfile102.med"
+ fieldName="field1"
+ mm=MEDFileUMesh()
+ coo=DataArrayDouble([(3,2,1),(8,7,6),(5,9,10)])
+ m=MEDCouplingUMesh("mesh",2) ; m.setCoords(coo)
+ m.allocateCells()
+ m.insertNextCell(NORM_TRI3,[0,1,2])
+ m.insertNextCell(NORM_TRI3,[3,4,5])
+ m.insertNextCell(NORM_TRI3,[6,7,8])
+ m.insertNextCell(NORM_TRI3,[9,10,11])
+ m.insertNextCell(NORM_QUAD4,[100,101,102,103])
+ m.insertNextCell(NORM_QUAD4,[104,105,106,107])
+ mm[0]=m
+ mm.write(fname,2)
+ arr0=DataArrayInt([10,11,12,13,100,101])
+ f=MEDCouplingFieldInt(ON_CELLS) ; f.setArray(arr0) ; f.setMesh(m)
+ f.setName(fieldName) ; f.setTime(2.,6,7)
+ f0=f.deepCopy()
+ ff=MEDFileIntFieldMultiTS() ; ff.appendFieldNoProfileSBT(f)
+ ff.write(fname,0)
+ arr2=arr0+1000 ; f.setArray(arr2)
+ f.setTime(3.,8,9) ; ff=MEDFileIntField1TS() ; ff.setFieldNoProfileSBT(f)
+ ff.write(fname,0)
+ f1=f.deepCopy()
+ ##
+ mm=MEDFileMesh.New(fname)
+ f1ts=MEDFileIntField1TS(fname,fieldName,6,7)
+ ftst0=f1ts.field(mm)
+ self.assertTrue(f0.isEqual(ftst0,1e-12,1e-12))
+ f1ts=MEDFileIntField1TS(fname,fieldName,8,9)
+ ftst1=f1ts.field(mm)
+ self.assertTrue(f1.isEqual(ftst1,1e-12,1e-12))
+ fmts=MEDFileIntFieldMultiTS(fname,fieldName)
+ self.assertTrue(f1.isEqual(fmts.field(8,9,mm),1e-12,1e-12))
+ ## Basic test on nodes on top level
+ f2=MEDCouplingFieldInt(ON_NODES) ; arr2=DataArrayInt([200,201,202]) ; arr2.setInfoOnComponent(0,"tutu") ; f2.setArray(arr2) ; f2.setMesh(m) ; f2.setTime(22.,23,24)
+ f2.setName(fieldName)
+ mm.write(fname,2)
+ ff=MEDFileIntField1TS() ; ff.setFieldNoProfileSBT(f2) ; ff.write(fname,0)
+ #
+ mm=MEDFileMesh.New(fname)
+ f1ts=MEDFileIntField1TS(fname,fieldName,23,24)
+ self.assertTrue(f2.isEqual(f1ts.field(mm),1e-12,1e-12))
+ fmts=MEDFileIntFieldMultiTS(fname,fieldName)
+ self.assertTrue(f2.isEqual(fmts.field(23,24,mm),1e-12,1e-12))
+ ## Node on elements
+ f3=MEDCouplingFieldInt(ON_GAUSS_NE) ; f3.setMesh(m) ; arr3=DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]) ; f3.setArray(arr3) ; f3.setTime(0.5,2,3)
+ f3.setName(fieldName) ; f3.checkConsistencyLight()
+ mm.write(fname,2) ; ff=MEDFileIntField1TS() ; ff.setFieldNoProfileSBT(f3) ; ff.write(fname,0)
+ #
+ mm=MEDFileMesh.New(fname)
+ f1ts=MEDFileIntField1TS(fname,fieldName,2,3)
+ self.assertTrue(f3.isEqual(f1ts.field(mm),1e-12,1e-12))
+ ## Gauss
+ f4=MEDCouplingFieldInt(ON_GAUSS_PT) ; f4.setMesh(m) ; f4.setName(fieldName)
+ f4.setGaussLocalizationOnType(NORM_TRI3,[0.,0.,1.,0.,1.,1.],[0.1,0.1, 0.2,0.2, 0.3,0.3, 0.4,0.4, 0.5,0.5],[0.2,0.3,0.1,0.05,0.35])
+ f4.setGaussLocalizationOnType(NORM_QUAD4,[0.,0.,1.,0.,1.,1.,0.,1.],[0.3,0.4, 0.6,0.7],[0.7,0.3]) ; f4.setTime(0.25,4,5)
+ arr4=DataArrayInt([0,1,2,3,4 ,10,11,12,13,14, 20,21,22,23,24, 30,31,32,33,34, 45,46, 55,56]) ; arr4.setInfoOnComponent(0,"abc") ; f4.setArray(arr4)
+ f4.checkConsistencyLight()
+ mm.write(fname,2) ; ff=MEDFileIntField1TS() ; ff.setFieldNoProfileSBT(f4) ; ff.write(fname,0)
+ #
+ mm=MEDFileMesh.New(fname)
+ f1ts=MEDFileIntField1TS(fname,fieldName,4,5)
+ self.assertTrue(f4.isEqual(f1ts.field(mm),1e-12,1e-12))
+ pass
+
+ def testMEDFileFieldEasyField3(self):
+ """Here a multi level mesh. And field on cells lying on different level of this mesh. Show how "field" method deal with that. Here on field double are considered."""
+ fname="Pyfile103.med"
+ fieldName="field1"
+ mm=MEDFileUMesh()
+ coo=DataArrayDouble([(3,2,1),(8,7,6),(5,9,10)])
+ m=MEDCouplingUMesh("mesh",2) ; m.setCoords(coo)
+ m.allocateCells()
+ m.insertNextCell(NORM_TRI3,[0,1,2])
+ m.insertNextCell(NORM_TRI3,[3,4,5])
+ m.insertNextCell(NORM_TRI3,[6,7,8])
+ m.insertNextCell(NORM_TRI3,[9,10,11])
+ m.insertNextCell(NORM_QUAD4,[100,101,102,103])
+ m.insertNextCell(NORM_QUAD4,[104,105,106,107])
+ mm[-1]=m
+ m0=MEDCouplingUMesh("mesh",3) ; m0.setCoords(coo)
+ m0.allocateCells()
+ m0.insertNextCell(NORM_TETRA4,[3,2,5,0])
+ m0.insertNextCell(NORM_TETRA4,[7,6,3,2])
+ mm[0]=m0
+ mm.write(fname,2)
+ # start slowly
+ f1=MEDCouplingFieldDouble(ON_CELLS) ; f1.setName(fieldName) ; f1.setArray(DataArrayDouble([(0,100),(1,101)])) ; f1.setMesh(mm[0]) ; f1.setTime(4.,1,2)
+ f1ts=MEDFileField1TS() ; f1ts.setFieldNoProfileSBT(f1) ; f1ts.write(fname,0)
+ #
+ mm=MEDFileMesh.New(fname) ; f1ts=MEDFileField1TS(fname,fieldName,1,2)
+ self.assertTrue(f1.isEqual(f1ts.field(mm),1e-12,1e-12))
+ # here f1 lying on level -1 not 0 check if "field" method detect it !
+ f1=MEDCouplingFieldDouble(ON_CELLS) ; f1.setName(fieldName) ; f1.setArray(DataArrayDouble([(0,100),(1,101),(0,100),(1,101),(0,100),(1,101)]))
+ f1.setMesh(mm[-1]) # -1 is very important
+ f1.setTime(16.,3,4)
+ f1.checkConsistencyLight()
+ mm.write(fname,2)
+ f1ts=MEDFileField1TS() ; f1ts.setFieldNoProfileSBT(f1) ; f1ts.write(fname,0)
+ #
+ mm=MEDFileMesh.New(fname) ; f1ts=MEDFileField1TS(fname,fieldName,3,4)
+ self.assertTrue(f1.isEqual(f1ts.field(mm),1e-12,1e-12))
+ # nodes on elements
+ f3=MEDCouplingFieldDouble(ON_GAUSS_NE)
+ f3.setMesh(mm[-1]) # this line is important
+ arr3=DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]) ; f3.setArray(arr3) ; f3.setTime(0.5,2,3)
+ f3.setName(fieldName) ; f3.checkConsistencyLight()
+ mm.write(fname,2) ; ff=MEDFileField1TS() ; ff.setFieldNoProfileSBT(f3) ; ff.write(fname,0)
+ #
+ mm=MEDFileMesh.New(fname) ; f1ts=MEDFileField1TS(fname,fieldName,2,3)
+ self.assertTrue(f3.isEqual(f1ts.field(mm),1e-12,1e-12))
+ # gauss
+ f4=MEDCouplingFieldDouble(ON_GAUSS_PT)
+ f4.setMesh(mm[-1]) # this line is important
+ f4.setName(fieldName)
+ f4.setGaussLocalizationOnType(NORM_TRI3,[0.,0.,1.,0.,1.,1.],[0.1,0.1, 0.2,0.2, 0.3,0.3, 0.4,0.4, 0.5,0.5],[0.2,0.3,0.1,0.05,0.35])
+ f4.setGaussLocalizationOnType(NORM_QUAD4,[0.,0.,1.,0.,1.,1.,0.,1.],[0.3,0.4, 0.6,0.7],[0.7,0.3]) ; f4.setTime(0.25,4,5)
+ arr4=DataArrayDouble([0,1,2,3,4 ,10,11,12,13,14, 20,21,22,23,24, 30,31,32,33,34, 45,46, 55,56]) ; arr4.setInfoOnComponent(0,"abc") ; f4.setArray(arr4)
+ f4.checkConsistencyLight()
+ mm.write(fname,2) ; ff=MEDFileField1TS() ; ff.setFieldNoProfileSBT(f4) ; ff.write(fname,0)
+ mm=MEDFileMesh.New(fname) ; f1ts=MEDFileField1TS(fname,fieldName,4,5)
+ self.assertTrue(f4.isEqual(f1ts.field(mm),1e-12,1e-12))
+ pass
+
+ def testMEDFileFieldEasyField4(self):
+ """ Same than testMEDFileFieldEasyField3 but with integers"""
+ fname="Pyfile104.med"
+ fieldName="field1"
+ mm=MEDFileUMesh()
+ coo=DataArrayDouble([(3,2,1),(8,7,6),(5,9,10)])
+ m=MEDCouplingUMesh("mesh",2) ; m.setCoords(coo)
+ m.allocateCells()
+ m.insertNextCell(NORM_TRI3,[0,1,2])
+ m.insertNextCell(NORM_TRI3,[3,4,5])
+ m.insertNextCell(NORM_TRI3,[6,7,8])
+ m.insertNextCell(NORM_TRI3,[9,10,11])
+ m.insertNextCell(NORM_QUAD4,[100,101,102,103])
+ m.insertNextCell(NORM_QUAD4,[104,105,106,107])
+ mm[-1]=m
+ m0=MEDCouplingUMesh("mesh",3) ; m0.setCoords(coo)
+ m0.allocateCells()
+ m0.insertNextCell(NORM_TETRA4,[3,2,5,0])
+ m0.insertNextCell(NORM_TETRA4,[7,6,3,2])
+ mm[0]=m0
+ mm.write(fname,2)
+ # start slowly
+ f1=MEDCouplingFieldInt(ON_CELLS) ; f1.setName(fieldName) ; f1.setArray(DataArrayInt([(0,100),(1,101)])) ; f1.setMesh(mm[0]) ; f1.setTime(4.,1,2)
+ f1ts=MEDFileIntField1TS() ; f1ts.setFieldNoProfileSBT(f1) ; f1ts.write(fname,0)
+ #
+ mm=MEDFileMesh.New(fname) ; f1ts=MEDFileIntField1TS(fname,fieldName,1,2)
+ self.assertTrue(f1.isEqual(f1ts.field(mm),1e-12,1e-12))
+ # here f1 lying on level -1 not 0 check if "field" method detect it !
+ f1=MEDCouplingFieldInt(ON_CELLS) ; f1.setName(fieldName) ; f1.setArray(DataArrayInt([(0,100),(1,101),(0,100),(1,101),(0,100),(1,101)]))
+ f1.setMesh(mm[-1]) # -1 is very important
+ f1.setTime(16.,3,4)
+ f1.checkConsistencyLight()
+ mm.write(fname,2)
+ f1ts=MEDFileIntField1TS() ; f1ts.setFieldNoProfileSBT(f1) ; f1ts.write(fname,0)
+ #
+ mm=MEDFileMesh.New(fname) ; f1ts=MEDFileIntField1TS(fname,fieldName,3,4)
+ self.assertTrue(f1.isEqual(f1ts.field(mm),1e-12,1e-12))
+ # nodes on elements
+ f3=MEDCouplingFieldInt(ON_GAUSS_NE)
+ f3.setMesh(mm[-1]) # this line is important
+ arr3=DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]) ; f3.setArray(arr3) ; f3.setTime(0.5,2,3)
+ f3.setName(fieldName) ; f3.checkConsistencyLight()
+ mm.write(fname,2) ; ff=MEDFileIntField1TS() ; ff.setFieldNoProfileSBT(f3) ; ff.write(fname,0)
+ #
+ mm=MEDFileMesh.New(fname) ; f1ts=MEDFileIntField1TS(fname,fieldName,2,3)
+ self.assertTrue(f3.isEqual(f1ts.field(mm),1e-12,1e-12))
+ # gauss
+ f4=MEDCouplingFieldInt(ON_GAUSS_PT)
+ f4.setMesh(mm[-1]) # this line is important
+ f4.setName(fieldName)
+ f4.setGaussLocalizationOnType(NORM_TRI3,[0.,0.,1.,0.,1.,1.],[0.1,0.1, 0.2,0.2, 0.3,0.3, 0.4,0.4, 0.5,0.5],[0.2,0.3,0.1,0.05,0.35])
+ f4.setGaussLocalizationOnType(NORM_QUAD4,[0.,0.,1.,0.,1.,1.,0.,1.],[0.3,0.4, 0.6,0.7],[0.7,0.3]) ; f4.setTime(0.25,4,5)
+ arr4=DataArrayInt([0,1,2,3,4 ,10,11,12,13,14, 20,21,22,23,24, 30,31,32,33,34, 45,46, 55,56]) ; arr4.setInfoOnComponent(0,"abc") ; f4.setArray(arr4)
+ f4.checkConsistencyLight()
+ mm.write(fname,2) ; ff=MEDFileIntField1TS() ; ff.setFieldNoProfileSBT(f4) ; ff.write(fname,0)
+ mm=MEDFileMesh.New(fname) ; f1ts=MEDFileIntField1TS(fname,fieldName,4,5)
+ self.assertTrue(f4.isEqual(f1ts.field(mm),1e-12,1e-12))
+ pass
+
+ def testMEDFileFieldEasyField5(self):
+ """More and more difficult now look at how profiles are managed by "field" method."""
+ fname="Pyfile105.med"
+ fieldName="field1"
+ mm=MEDFileUMesh()
+ coo=DataArrayDouble([(3,2,1),(8,7,6),(5,9,10)])
+ m=MEDCouplingUMesh("mesh",2) ; m.setCoords(coo)
+ m.allocateCells()
+ m.insertNextCell(NORM_TRI3,[0,1,2])
+ m.insertNextCell(NORM_TRI3,[3,4,5])
+ m.insertNextCell(NORM_TRI3,[6,7,8])
+ m.insertNextCell(NORM_TRI3,[9,10,11])
+ m.insertNextCell(NORM_QUAD4,[100,101,102,103])
+ m.insertNextCell(NORM_QUAD4,[104,105,106,107])
+ mm[0]=m
+ mm.write(fname,2)
+ pfl=DataArrayInt([0,2,3,5]) ; pfl.setName("pfl")
+ m2=m.deepCopy()[pfl] ; m2.setName(m.getName())
+ #
+ arr0=DataArrayDouble([10,11,12,13])
+ f=MEDCouplingFieldDouble(ON_CELLS) ; f.setArray(arr0) ; f.setMesh(m2)
+ f.setName(fieldName) ; f.setTime(2.,6,7) ; f.checkConsistencyLight()
+ ff=MEDFileFieldMultiTS() ; ff.appendFieldProfile(f,mm,0,pfl) # ff is a field on profile
+ ff.write(fname,0)
+ #
+ mm=MEDFileMesh.New(fname) ; f1ts=MEDFileField1TS(fname,fieldName,6,7)
+ self.assertTrue(f.isEqual(f1ts.field(mm),1e-12,1e-12))
+ # more complicated -> multi level
+ m0=MEDCouplingUMesh("mesh",3) ; m0.setCoords(coo)
+ m0.allocateCells()
+ m0.insertNextCell(NORM_TETRA4,[3,2,5,0])
+ m0.insertNextCell(NORM_TETRA4,[7,6,3,2])
+ mm2=MEDFileUMesh()
+ mm2[0]=m0 ; mm2[-1]=m
+ #
+ ff=MEDFileField1TS() ; ff.setFieldProfile(f,mm2,-1,pfl)
+ #
+ mm=MEDFileMesh.New(fname) ; f1ts=MEDFileField1TS(fname,fieldName,6,7)
+ self.assertTrue(f.isEqual(f1ts.field(mm),1e-12,1e-12))
+ pass
+
pass
if __name__ == "__main__":
- unittest.main()
+ unittest.main()