-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D
+// Copyright (C) 2007-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
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingFieldTemplate.hxx"
+#include "MEDCouplingFieldT.txx"
+#include "MEDCouplingFieldInt.hxx"
#include "MEDCouplingUMesh.hxx"
#include "MEDCouplingTimeDiscretization.hxx"
#include "MEDCouplingFieldDiscretization.hxx"
-#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "MCAuto.hxx"
#include "MEDCouplingNatureOfField.hxx"
#include "InterpKernelAutoPtr.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);
}
/*!
* \c clone(false) is rather dedicated for advanced users that want to limit the amount
* of memory. It allows the user to perform methods like operator+(), operator*()
* etc. with \a this and the returned field. If the user wants to duplicate deeply the
- * underlying mesh he should call cloneWithMesh() method or deepCpy() instead.
+ * underlying mesh he should call cloneWithMesh() method or deepCopy() instead.
* \warning The underlying \b mesh of the returned field is **always the same**
* (pointer) as \a this one **whatever the value** of \a recDeepCpy parameter.
* \param [in] recDeepCpy - if \c true, the copy of the underlying data arrays is
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 deepCpy().
- * 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
-{
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=clone(recDeepCpy);
- if(_mesh)
- {
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mCpy=_mesh->deepCpy();
- ret->setMesh(mCpy);
- }
- return ret.retn();
-}
-
/*!
* Returns a new MEDCouplingFieldDouble which is a deep copy of \a this one **including
* the mesh**.
* caller is to delete this field using decrRef() as it is no more needed.
* \sa cloneWithMesh()
*/
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::deepCpy() const
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::deepCopy() const
{
return cloneWithMesh(true);
}
*/
MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCopy) const
{
- MEDCouplingTimeDiscretization *tdo=_time_discr->buildNewTimeReprFromThis(td,deepCopy);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDiscretization> disc;
+ MEDCouplingTimeDiscretization *tdo=timeDiscr()->buildNewTimeReprFromThis(td,deepCopy);
+ MCAuto<MEDCouplingFieldDiscretization> disc;
if(_type)
disc=_type->clone();
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),tdo,disc.retn());
+ MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),tdo,disc.retn());
ret->setMesh(getMesh());
ret->setName(getName());
ret->setDescription(getDescription());
* \return MEDCouplingFieldDouble* - a new instance of MEDCouplingFieldDouble. The
* caller is to delete this field using decrRef() as it is no more needed. The returned field will share the same mesh object object than those in \a this.
* \throw If \a this spatial discretization is empty or not ON_NODES.
- * \throw If \a this is not coherent (see MEDCouplingFieldDouble::checkCoherency).
+ * \throw If \a this is not coherent (see MEDCouplingFieldDouble::checkConsistencyLight).
*
* \warning This method is a \b non \b conservative method of remapping from node spatial discretization to cell spatial discretization.
* If a conservative method of interpolation is required MEDCoupling::MEDCouplingRemapper class should be used instead with "P1P0" method.
*/
MEDCouplingFieldDouble *MEDCouplingFieldDouble::nodeToCellDiscretization() const
{
- checkCoherency();
+ checkConsistencyLight();
TypeOfField tf(getTypeOfField());
if(tf!=ON_NODES)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::nodeToCellDiscretization : this field is expected to be on ON_NODES !");
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret(clone(false));
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDiscretizationP0> nsp(new MEDCouplingFieldDiscretizationP0);
+ MCAuto<MEDCouplingFieldDouble> ret(clone(false));
+ MCAuto<MEDCouplingFieldDiscretizationP0> nsp(new MEDCouplingFieldDiscretizationP0);
ret->setDiscretization(nsp);
- const MEDCouplingMesh *m(getMesh());//m is non empty thanks to checkCoherency call
+ const MEDCouplingMesh *m(getMesh());//m is non empty thanks to checkConsistencyLight call
int nbCells(m->getNumberOfCells());
std::vector<DataArrayDouble *> arrs(getArrays());
std::size_t sz(arrs.size());
- std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > outArrsSafe(sz); std::vector<DataArrayDouble *> outArrs(sz);
+ std::vector< MCAuto<DataArrayDouble> > outArrsSafe(sz); std::vector<DataArrayDouble *> outArrs(sz);
for(std::size_t j=0;j<sz;j++)
{
int nbCompo(arrs[j]->getNumberOfComponents());
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 MEDCouplingFieldDouble* - a new instance of MEDCouplingFieldDouble. The
* caller is to delete this field using decrRef() as it is no more needed. The returned field will share the same mesh object object than those in \a this.
* \throw If \a this spatial discretization is empty or not ON_CELLS.
- * \throw If \a this is not coherent (see MEDCouplingFieldDouble::checkCoherency).
+ * \throw If \a this is not coherent (see MEDCouplingFieldDouble::checkConsistencyLight).
*
* \warning This method is a \b non \b conservative method of remapping from cell spatial discretization to node spatial discretization.
* If a conservative method of interpolation is required MEDCoupling::MEDCouplingRemapper class should be used instead with "P0P1" method.
*/
MEDCouplingFieldDouble *MEDCouplingFieldDouble::cellToNodeDiscretization() const
{
- checkCoherency();
+ checkConsistencyLight();
TypeOfField tf(getTypeOfField());
if(tf!=ON_CELLS)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::cellToNodeDiscretization : this field is expected to be on ON_CELLS !");
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret(clone(false));
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDiscretizationP1> nsp(new MEDCouplingFieldDiscretizationP1);
+ MCAuto<MEDCouplingFieldDouble> ret(clone(false));
+ MCAuto<MEDCouplingFieldDiscretizationP1> nsp(new MEDCouplingFieldDiscretizationP1);
ret->setDiscretization(nsp);
- const MEDCouplingMesh *m(getMesh());//m is non empty thanks to checkCoherency call
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rn(DataArrayInt::New()),rni(DataArrayInt::New());
+ const MEDCouplingMesh *m(getMesh());//m is non empty thanks to checkConsistencyLight call
+ MCAuto<DataArrayInt> rn(DataArrayInt::New()),rni(DataArrayInt::New());
m->getReverseNodalConnectivity(rn,rni);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rni2(rni->deltaShiftIndex());
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> rni3(rni2->convertToDblArr()); rni2=0;
+ MCAuto<DataArrayInt> rni2(rni->deltaShiftIndex());
+ MCAuto<DataArrayDouble> rni3(rni2->convertToDblArr()); rni2=0;
std::vector<DataArrayDouble *> arrs(getArrays());
std::size_t sz(arrs.size());
- std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > outArrsSafe(sz); std::vector<DataArrayDouble *> outArrs(sz);
+ std::vector< MCAuto<DataArrayDouble> > outArrsSafe(sz); std::vector<DataArrayDouble *> outArrs(sz);
for(std::size_t j=0;j<sz;j++)
{
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp(arrs[j]->selectByTupleIdSafe(rn->begin(),rn->end()));
+ MCAuto<DataArrayDouble> tmp(arrs[j]->selectByTupleIdSafe(rn->begin(),rn->end()));
outArrsSafe[j]=(tmp->accumulatePerChunck(rni->begin(),rni->end())); tmp=0;
outArrsSafe[j]->divideEqual(rni3);
outArrsSafe[j]->copyStringInfoFrom(*arrs[j]);
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);
- 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);
+ 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;
}
void MEDCouplingFieldDouble::renumberCells(const int *old2NewBg, bool check)
{
renumberCellsWithoutMesh(old2NewBg,check);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=_mesh->deepCpy();
+ MCAuto<MEDCouplingMesh> m=_mesh->deepCopy();
m->renumberCells(old2NewBg,check);
setMesh(m);
updateTime();
//
_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(!meshC)
throw INTERP_KERNEL::Exception("Invalid mesh to apply renumberNodes on it !");
int nbOfNodes=meshC->getNumberOfNodes();
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> meshC2((MEDCouplingPointSet *)meshC->deepCpy());
+ MCAuto<MEDCouplingPointSet> meshC2((MEDCouplingPointSet *)meshC->deepCopy());
int newNbOfNodes=*std::max_element(old2NewBg,old2NewBg+nbOfNodes)+1;
renumberNodesWithoutMesh(old2NewBg,newNbOfNodes,eps);
meshC2->renumberNodes(old2NewBg,newNbOfNodes);
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);
/*!
* Returns all tuple ids of \a this scalar field that fit the range [\a vmin,
- * \a vmax]. This method calls DataArrayDouble::getIdsInRange().
+ * \a vmax]. This method calls DataArrayDouble::findIdsInRange().
* \param [in] vmin - a lower boundary of the range. Tuples with values less than \a
* vmin are not included in the result array.
* \param [in] vmax - an upper boundary of the range. Tuples with values more than \a
* \throw If the data array is not set.
* \throw If \a this->getNumberOfComponents() != 1.
*/
-DataArrayInt *MEDCouplingFieldDouble::getIdsInRange(double vmin, double vmax) const
+DataArrayInt *MEDCouplingFieldDouble::findIdsInRange(double vmin, double vmax) const
{
if(getArray()==0)
- throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getIdsInRange : no default array set !");
- return getArray()->getIdsInRange(vmin,vmax);
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::findIdsInRange : no default array set !");
+ return getArray()->findIdsInRange(vmin,vmax);
}
/*!
/*!
* Builds a newly created field, that the caller will have the responsability to deal with.
- * \n This method makes the assumption that \a this field is correctly defined when this method is called (\a this->checkCoherency() returns without any exception thrown), **no check of this will be done**.
+ * \n This method makes the assumption that \a this field is correctly defined when this method is called (\a this->checkConsistencyLight() returns without any exception thrown), **no check of this will be done**.
* \n This method returns a restriction of \a this so that only tuple ids specified in [ \a partBg , \a partEnd ) will be contained in the returned field.
* \n Parameter [\a partBg, \a partEnd ) specifies **cell ids whatever the spatial discretization** of \a this (
* \ref MEDCoupling::ON_CELLS "ON_CELLS",
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::buildSubPart : Expecting a not NULL spatial discretization !");
DataArrayInt *arrSelect;
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=_type->buildSubMeshData(_mesh,partBg,partEnd,arrSelect);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arrSelect2(arrSelect);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=clone(false);//quick shallow copy.
+ MCAuto<MEDCouplingMesh> m=_type->buildSubMeshData(_mesh,partBg,partEnd,arrSelect);
+ MCAuto<DataArrayInt> arrSelect2(arrSelect);
+ MCAuto<MEDCouplingFieldDouble> ret=clone(false);//quick shallow copy.
const MEDCouplingFieldDiscretization *disc=getDiscretization();
if(disc)
- ret->setDiscretization(MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDiscretization>(disc->clonePart(partBg,partEnd)));
+ 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< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrsSafe;
+ std::vector< MCAuto<DataArrayDouble> > arrsSafe;
const int *arrSelBg=arrSelect->begin();
const int *arrSelEnd=arrSelect->end();
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
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();
}
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::buildSubPart : Expecting a not NULL spatial discretization !");
DataArrayInt *arrSelect;
int beginOut,endOut,stepOut;
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=_type->buildSubMeshDataRange(_mesh,begin,end,step,beginOut,endOut,stepOut,arrSelect);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arrSelect2(arrSelect);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=clone(false);//quick shallow copy.
+ MCAuto<MEDCouplingMesh> m=_type->buildSubMeshDataRange(_mesh,begin,end,step,beginOut,endOut,stepOut,arrSelect);
+ MCAuto<DataArrayInt> arrSelect2(arrSelect);
+ MCAuto<MEDCouplingFieldDouble> ret=clone(false);//quick shallow copy.
const MEDCouplingFieldDiscretization *disc=getDiscretization();
if(disc)
- ret->setDiscretization(MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDiscretization>(disc->clonePartRange(begin,end,step)));
+ 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< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrsSafe;
+ std::vector< MCAuto<DataArrayDouble> > arrsSafe;
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
{
DataArrayDouble *arr=0;
arr=(*iter)->selectByTupleIdSafe(arrSelBg,arrSelEnd);
}
else
- arr=(*iter)->selectByTupleId2(beginOut,endOut,stepOut);
+ arr=(*iter)->selectByTupleIdSafeSlice(beginOut,endOut,stepOut);
}
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(other._time_discr->performCpy(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::checkCoherency() const
-{
- if(!_mesh)
- throw INTERP_KERNEL::Exception("Field invalid because no mesh specified !");
- if(!((const MEDCouplingFieldDiscretization *)_type))
- throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::checkCoherency : no spatial discretization !");
- _time_discr->checkCoherency();
- _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;
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret1;
+ MCAuto<DataArrayInt> ret1;
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
{
if(*iter)
isExistingArr=true;
DataArrayInt *tmp;
ret=std::max(ret,(*iter)->getMaxValue2(tmp));
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmpSafe(tmp);
+ MCAuto<DataArrayInt> tmpSafe(tmp);
if(!((const DataArrayInt *)ret1))
ret1=tmpSafe;
}
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;
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret1;
+ MCAuto<DataArrayInt> ret1;
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
{
if(*iter)
isExistingArr=true;
DataArrayInt *tmp;
ret=std::max(ret,(*iter)->getMinValue2(tmp));
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmpSafe(tmp);
+ MCAuto<DataArrayInt> tmpSafe(tmp);
if(!((const DataArrayInt *)ret1))
ret1=tmpSafe;
}
{
if(getArray()==0)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getWeightedAverageValue : no default array defined !");
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> w=buildMeasureField(isWAbs);
+ MCAuto<MEDCouplingFieldDouble> w=buildMeasureField(isWAbs);
double deno=w->getArray()->accumulate(0);
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=getArray()->deepCpy();
+ MCAuto<DataArrayDouble> arr=getArray()->deepCopy();
arr->multiplyEqual(w->getArray());
arr->accumulate(res);
int nCompo = getArray()->getNumberOfComponents();
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;
}
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalytic : no mesh defined !");
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform fillFromAnalytic !");
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> loc=_type->getLocalizationOfDiscValues(_mesh);
- _time_discr->fillFromAnalytic(loc,nbOfComp,func);
+ MCAuto<DataArrayDouble> loc=_type->getLocalizationOfDiscValues(_mesh);
+ timeDiscr()->fillFromAnalytic(loc,nbOfComp,func);
}
/*!
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalytic : no mesh defined !");
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform fillFromAnalytic !");
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> loc=_type->getLocalizationOfDiscValues(_mesh);
- _time_discr->fillFromAnalytic(loc,nbOfComp,func);
+ MCAuto<DataArrayDouble> loc=_type->getLocalizationOfDiscValues(_mesh);
+ timeDiscr()->fillFromAnalytic(loc,nbOfComp,func);
}
/*!
* \ref py_mcfielddouble_fillFromAnalytic2 "Here is a Python example".
* \endif
*/
-void MEDCouplingFieldDouble::fillFromAnalytic2(int nbOfComp, const std::string& func)
+void MEDCouplingFieldDouble::fillFromAnalyticCompo(int nbOfComp, const std::string& func)
{
if(!_mesh)
- throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalytic2 : no mesh defined !");
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalyticCompo : no mesh defined !");
if(!((const MEDCouplingFieldDiscretization *)_type))
- throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform fillFromAnalytic2 !");
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> loc=_type->getLocalizationOfDiscValues(_mesh);
- _time_discr->fillFromAnalytic2(loc,nbOfComp,func);
+ throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform fillFromAnalyticCompo !");
+ MCAuto<DataArrayDouble> loc=_type->getLocalizationOfDiscValues(_mesh);
+ timeDiscr()->fillFromAnalyticCompo(loc,nbOfComp,func);
}
/*!
* \ref py_mcfielddouble_fillFromAnalytic3 "Here is a Python example".
* \endif
*/
-void MEDCouplingFieldDouble::fillFromAnalytic3(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func)
+void MEDCouplingFieldDouble::fillFromAnalyticNamedCompo(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func)
{
if(!_mesh)
- throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalytic2 : no mesh defined !");
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalyticCompo : no mesh defined !");
if(!((const MEDCouplingFieldDiscretization *)_type))
- throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform fillFromAnalytic3 !");
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> loc=_type->getLocalizationOfDiscValues(_mesh);
- _time_discr->fillFromAnalytic3(loc,nbOfComp,varsOrder,func);
+ throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform fillFromAnalyticNamedCompo !");
+ MCAuto<DataArrayDouble> loc=_type->getLocalizationOfDiscValues(_mesh);
+ 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);
}
* \ref py_mcfielddouble_applyFunc2 "Here is a Python example".
* \endif
*/
-void MEDCouplingFieldDouble::applyFunc2(int nbOfComp, const std::string& func)
+void MEDCouplingFieldDouble::applyFuncCompo(int nbOfComp, const std::string& func)
{
- _time_discr->applyFunc2(nbOfComp,func);
+ timeDiscr()->applyFuncCompo(nbOfComp,func);
}
/*!
* \ref py_mcfielddouble_applyFunc3 "Here is a Python example".
* \endif
*/
-void MEDCouplingFieldDouble::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func)
+void MEDCouplingFieldDouble::applyFuncNamedCompo(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func)
{
- _time_discr->applyFunc3(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);
}
/*!
* data array (Sorry, it is confusing !).
* So \b this \b method \b behaves \b exactly \b as MEDCouplingField::getNumberOfTuplesExpected \b method.
*
- * \warning No checkCoherency() is done here.
+ * \warning No checkConsistencyLight() is done here.
* For more info on the data arrays, see \ref arrays.
* \return int - the number of tuples.
* \throw If the mesh is not set.
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);
}
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::changeUnderlyingMesh : is expected to operate on not null meshes !");
DataArrayInt *cellCor=0,*nodeCor=0;
other->checkGeoEquivalWith(_mesh,levOfCheck,precOnMesh,cellCor,nodeCor);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellCor2(cellCor),nodeCor2(nodeCor);
+ MCAuto<DataArrayInt> cellCor2(cellCor),nodeCor2(nodeCor);
if(cellCor)
renumberCellsWithoutMesh(cellCor->getConstPointer(),false);
if(nodeCor)
* The job of this method consists in calling
* \a this->changeUnderlyingMesh() with \a f->getMesh() as the first parameter, and then
* \a this -= \a f.<br>
- * This method requires that \a f and \a this are coherent (checkCoherency()) and that \a f
+ * This method requires that \a f and \a this are coherent (checkConsistencyLight()) and that \a f
* and \a this are coherent for a merge.<br>
* "DM" in the method name stands for "different meshes".
* \param [in] f - the field to subtract from this.
*/
void MEDCouplingFieldDouble::substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double precOnMesh, double eps)
{
- checkCoherency();
+ checkConsistencyLight();
if(!f)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::substractInPlaceDM : input field is NULL !");
- f->checkCoherency();
+ f->checkConsistencyLight();
if(!areCompatibleForMerge(f))
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::substractInPlaceDM : Fields are not compatible ; unable to apply mergeFields on them !");
changeUnderlyingMesh(f->getMesh(),levOfCheck,precOnMesh,eps);
throw INTERP_KERNEL::Exception("Invalid support mesh to apply mergeNodes on it : must be a MEDCouplingPointSet one !");
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform mergeNodes !");
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> meshC2((MEDCouplingPointSet *)meshC->deepCpy());
+ MCAuto<MEDCouplingPointSet> meshC2((MEDCouplingPointSet *)meshC->deepCopy());
bool ret;
int ret2;
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=meshC2->mergeNodes(eps,ret,ret2);
+ MCAuto<DataArrayInt> arr=meshC2->mergeNodes(eps,ret,ret2);
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);
* \throw If the data array is not set.
* \throw If field values at merged nodes (if any) deffer more than \a epsOnVals.
*/
-bool MEDCouplingFieldDouble::mergeNodes2(double eps, double epsOnVals)
+bool MEDCouplingFieldDouble::mergeNodesCenter(double eps, double epsOnVals)
{
const MEDCouplingPointSet *meshC=dynamic_cast<const MEDCouplingPointSet *>(_mesh);
if(!meshC)
throw INTERP_KERNEL::Exception("Invalid support mesh to apply mergeNodes on it : must be a MEDCouplingPointSet one !");
if(!((const MEDCouplingFieldDiscretization *)_type))
- throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform mergeNodes2 !");
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> meshC2((MEDCouplingPointSet *)meshC->deepCpy());
+ throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform mergeNodesCenter !");
+ MCAuto<MEDCouplingPointSet> meshC2((MEDCouplingPointSet *)meshC->deepCopy());
bool ret;
int ret2;
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=meshC2->mergeNodes2(eps,ret,ret2);
+ MCAuto<DataArrayInt> arr=meshC2->mergeNodesCenter(eps,ret,ret2);
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);
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::zipCoords : Invalid support mesh to apply zipCoords on it : must be a MEDCouplingPointSet one !");
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform zipCoords !");
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> meshC2((MEDCouplingPointSet *)meshC->deepCpy());
+ MCAuto<MEDCouplingPointSet> meshC2((MEDCouplingPointSet *)meshC->deepCopy());
int oldNbOfNodes=meshC2->getNumberOfNodes();
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=meshC2->zipCoordsTraducer();
+ MCAuto<DataArrayInt> arr=meshC2->zipCoordsTraducer();
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);
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::zipConnectivity : Invalid support mesh to apply zipCoords on it : must be a MEDCouplingPointSet one !");
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform zipConnectivity !");
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> meshC2((MEDCouplingUMesh *)meshC->deepCpy());
+ MCAuto<MEDCouplingUMesh> meshC2((MEDCouplingUMesh *)meshC->deepCopy());
int oldNbOfCells=meshC2->getNumberOfCells();
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=meshC2->zipConnectivityTraducer(compType);
+ MCAuto<DataArrayInt> arr=meshC2->zipConnectivityTraducer(compType);
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);
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::extractSlice3D : underlying mesh is null !");
if(getTypeOfField()!=ON_CELLS)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::extractSlice3D : only implemented for fields on cells !");
- const MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> umesh(mesh->buildUnstructured());
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=clone(false);
+ const MCAuto<MEDCouplingUMesh> umesh(mesh->buildUnstructured());
+ MCAuto<MEDCouplingFieldDouble> ret=clone(false);
ret->setMesh(umesh);
DataArrayInt *cellIds=0;
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh2=umesh->buildSlice3D(origin,vec,eps,cellIds);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds2=cellIds;
+ MCAuto<MEDCouplingUMesh> mesh2=umesh->buildSlice3D(origin,vec,eps,cellIds);
+ MCAuto<DataArrayInt> cellIds2=cellIds;
ret->setMesh(mesh2);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tupleIds=computeTupleIdsToSelectFromCellIds(cellIds->begin(),cellIds->end());
+ 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< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > newArr2(arrays.size());
+ std::vector< MCAuto<DataArrayDouble> > newArr2(arrays.size());
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++,i++)
{
if(*iter)
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform simplexize !");
int oldNbOfCells=_mesh->getNumberOfCells();
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> meshC2(_mesh->deepCpy());
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=meshC2->simplexize(policy);
+ MCAuto<MEDCouplingMesh> meshC2(_mesh->deepCopy());
+ MCAuto<DataArrayInt> arr=meshC2->simplexize(policy);
int newNbOfCells=meshC2->getNumberOfCells();
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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
+ MEDCouplingTimeDiscretization *td=timeDiscr()->doublyContractedProduct();
+ td->copyTinyAttrFrom(*timeDiscr());
+ MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
ret->setName("DoublyContractedProduct");
ret->setMesh(getMesh());
return ret.retn();
{
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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
+ MEDCouplingTimeDiscretization *td=timeDiscr()->determinant();
+ td->copyTinyAttrFrom(*timeDiscr());
+ MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
ret->setName("Determinant");
ret->setMesh(getMesh());
return ret.retn();
{
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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
+ MEDCouplingTimeDiscretization *td=timeDiscr()->eigenValues();
+ td->copyTinyAttrFrom(*timeDiscr());
+ MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
ret->setName("EigenValues");
ret->setMesh(getMesh());
return ret.retn();
{
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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
+ MEDCouplingTimeDiscretization *td=timeDiscr()->eigenVectors();
+ td->copyTinyAttrFrom(*timeDiscr());
+ MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
ret->setName("EigenVectors");
ret->setMesh(getMesh());
return ret.retn();
{
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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
+ MEDCouplingTimeDiscretization *td=timeDiscr()->inverse();
+ td->copyTinyAttrFrom(*timeDiscr());
+ MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
ret->setName("Inversion");
ret->setMesh(getMesh());
return ret.retn();
{
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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
+ MEDCouplingTimeDiscretization *td=timeDiscr()->trace();
+ td->copyTinyAttrFrom(*timeDiscr());
+ MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
ret->setName("Trace");
ret->setMesh(getMesh());
return ret.retn();
{
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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
+ MEDCouplingTimeDiscretization *td=timeDiscr()->deviator();
+ td->copyTinyAttrFrom(*timeDiscr());
+ MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
ret->setName("Deviator");
ret->setMesh(getMesh());
return ret.retn();
{
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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
+ MEDCouplingTimeDiscretization *td=timeDiscr()->magnitude();
+ td->copyTinyAttrFrom(*timeDiscr());
+ MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
ret->setName("Magnitude");
ret->setMesh(getMesh());
return ret.retn();
{
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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
+ MEDCouplingTimeDiscretization *td=timeDiscr()->maxPerTuple();
+ td->copyTinyAttrFrom(*timeDiscr());
+ MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
std::ostringstream oss;
oss << "Max_" << getName();
ret->setName(oss.str());
*/
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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
+ MEDCouplingTimeDiscretization *td=timeDiscr()->keepSelectedComponents(compoIds);
+ td->copyTinyAttrFrom(*timeDiscr());
+ MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
ret->setName(getName());
ret->setMesh(getMesh());
return ret.retn();
*/
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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
+ MEDCouplingTimeDiscretization *td=f1->timeDiscr()->aggregate(f2->timeDiscr());
+ td->copyTinyAttrFrom(*f1->timeDiscr());
+ MCAuto<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
ret->setName(f1->getName());
ret->setDescription(f1->getDescription());
if(m1)
{
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=m1->mergeMyselfWith(m2);
+ MCAuto<MEDCouplingMesh> m=m1->mergeMyselfWith(m2);
ret->setMesh(m);
}
return ret.retn();
{
if(a.size()<1)
throw INTERP_KERNEL::Exception("FieldDouble::MergeFields : size of array must be >= 1 !");
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> > ms(a.size());
+ std::vector< MCAuto<MEDCouplingUMesh> > ms(a.size());
std::vector< const MEDCouplingUMesh *> ms2(a.size());
std::vector< const MEDCouplingTimeDiscretization *> tds(a.size());
std::vector<const MEDCouplingFieldDouble *>::const_iterator it=a.begin();
{ 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));
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(a[0]->getNature(),td,a[0]->_type->clone());
+ 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(ms2[0])
{
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=MEDCouplingUMesh::MergeUMeshes(ms2);
+ MCAuto<MEDCouplingUMesh> m=MEDCouplingUMesh::MergeUMeshes(ms2);
m->copyTinyInfoFrom(ms2[0]);
ret->setMesh(m);
}
{
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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
+ 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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(NoNature,td,f1->_type->clone());
+ 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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
+ 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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
+ 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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
+ 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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
+ 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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
+ 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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(NoNature,td,f1->_type->clone());
+ 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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(NoNature,td,f1->_type->clone());
+ 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);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(NoNature,td,f1->_type->clone());
+ 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(!m)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::WriteVTK : Fields are lying on a same mesh but it is empty !");
std::string ret(m->getVTKFileNameOf(fileName));
- MEDCouplingAutoRefCountObjectPtr<DataArrayByte> byteArr;
+ MCAuto<DataArrayByte> byteArr;
if(isBinary)
{ byteArr=DataArrayByte::New(); byteArr->alloc(0,1); }
std::ostringstream coss,noss;
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;
}