-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2013 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
}
if(_nature!=other->_nature)
{
- oss << "Field nature differ : this nature = \"" << MEDCouplingNatureOfField::getRepr(_nature) << "\" and other nature = \"" << MEDCouplingNatureOfField::getRepr(other->_nature) << "\" !";
+ oss << "Field nature differ : this nature = \"" << MEDCouplingNatureOfField::GetRepr(_nature) << "\" and other nature = \"" << MEDCouplingNatureOfField::GetRepr(other->_nature) << "\" !";
reason=oss.str();
return false;
}
bool MEDCouplingField::isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const
{
+ if(!other)
+ throw INTERP_KERNEL::Exception("MEDCouplingField::isEqualWithoutConsideringStr : input field is NULL !");
+ if(!_type)
+ throw INTERP_KERNEL::Exception("MEDCouplingField::isEqualWithoutConsideringStr : spatial discretization of this is NULL !");
if(!_type->isEqualWithoutConsideringStr(other->_type,valsPrec))
return false;
if(_nature!=other->_nature)
*/
bool MEDCouplingField::areCompatibleForMerge(const MEDCouplingField *other) const
{
+ if(!other)
+ throw INTERP_KERNEL::Exception("MEDCouplingField::areCompatibleForMerge : input field is NULL !");
if(!_type->isEqual(other->_type,1.))
return false;
if(_nature!=other->_nature)
*/
bool MEDCouplingField::areStrictlyCompatible(const MEDCouplingField *other) const
{
+ if(!other)
+ throw INTERP_KERNEL::Exception("MEDCouplingField::areStrictlyCompatible : input field is NULL !");
if(!_type->isEqual(other->_type,1.e-12))
return false;
if(_nature!=other->_nature)
*/
void MEDCouplingField::setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception)
{
+ MEDCouplingNatureOfField::GetRepr(nat);//generate a throw if nat not recognized
_nature=nat;
}
{
if(!_mesh)
throw INTERP_KERNEL::Exception("MEDCouplingField::getLocalizationOfDiscr : No mesh set !");
+ if(!((const MEDCouplingFieldDiscretization *)_type))
+ throw INTERP_KERNEL::Exception("MEDCouplingField::getLocalizationOfDiscr : No spatial discretization set !");
return _type->getLocalizationOfDiscValues(_mesh);
}
*/
MEDCouplingFieldDouble *MEDCouplingField::buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception)
{
- if(_mesh==0)
- throw INTERP_KERNEL::Exception("MEDCouplingField::getMeasureField : no mesh defined !!!");
+ if(!_mesh)
+ throw INTERP_KERNEL::Exception("MEDCouplingField::buildMeasureField : no mesh defined !");
+ if(!((const MEDCouplingFieldDiscretization *)_type))
+ throw INTERP_KERNEL::Exception("MEDCouplingField::buildMeasureField : No spatial discretization set !");
return _type->getMeasureField(_mesh,isAbs);
}
if(_mesh)
_mesh->decrRef();
_mesh=mesh;
+ declareAsNew();
if(_mesh)
{
_mesh->incrRef();
{
if(!_mesh)
throw INTERP_KERNEL::Exception("Mesh has to be set before calling setGaussLocalizationOnType method !");
+ if(!((const MEDCouplingFieldDiscretization *)_type))
+ throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call setGaussLocalizationOnType method !");
_type->setGaussLocalizationOnType(_mesh,type,refCoo,gsCoo,wg);
}
{
if(!_mesh)
throw INTERP_KERNEL::Exception("Mesh has to be set before calling setGaussLocalizationOnCells method !");
+ if(!((const MEDCouplingFieldDiscretization *)_type))
+ throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call setGaussLocalizationOnCells method !");
_type->setGaussLocalizationOnCells(_mesh,begin,end,refCoo,gsCoo,wg);
}
{
if(!_mesh)
throw INTERP_KERNEL::Exception("Mesh has to be set before calling clearGaussLocalizations method !");
+ if(!((const MEDCouplingFieldDiscretization *)_type))
+ throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call clearGaussLocalizations method !");
_type->clearGaussLocalizations();
}
{
if(!_mesh)
throw INTERP_KERNEL::Exception("Mesh has to be set before calling getGaussLocalization method !");
+ if(!((const MEDCouplingFieldDiscretization *)_type))
+ throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call getGaussLocalization method !");
return _type->getGaussLocalization(locId);
}
{
if(!_mesh)
throw INTERP_KERNEL::Exception("Mesh has to be set before calling getGaussLocalizationIdOfOneType method !");
+ if(!((const MEDCouplingFieldDiscretization *)_type))
+ throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call getGaussLocalizationIdOfOneType method !");
return _type->getGaussLocalizationIdOfOneType(type);
}
{
if(!_mesh)
throw INTERP_KERNEL::Exception("Mesh has to be set before calling getGaussLocalizationIdsOfOneType method !");
+ if(!((const MEDCouplingFieldDiscretization *)_type))
+ throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call getGaussLocalizationIdsOfOneType method !");
return _type->getGaussLocalizationIdsOfOneType(type);
}
{
if(!_mesh)
throw INTERP_KERNEL::Exception("Mesh has to be set before calling getNbOfGaussLocalization method !");
+ if(!((const MEDCouplingFieldDiscretization *)_type))
+ throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call getNbOfGaussLocalization method !");
return _type->getNbOfGaussLocalization();
}
{
if(!_mesh)
throw INTERP_KERNEL::Exception("Mesh has to be set before calling getGaussLocalizationIdOfOneCell method !");
+ if(!((const MEDCouplingFieldDiscretization *)_type))
+ throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call getGaussLocalizationIdOfOneCell method !");
return _type->getGaussLocalizationIdOfOneCell(cellId);
}
cellIds.clear();
if(!_mesh)
throw INTERP_KERNEL::Exception("Mesh has to be set before calling getGaussLocalizationIdOfOneCell method !");
+ if(!((const MEDCouplingFieldDiscretization *)_type))
+ throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call getCellIdsHavingGaussLocalization method !");
_type->getCellIdsHavingGaussLocalization(locId,cellIds);
}
{
if(!_mesh)
throw INTERP_KERNEL::Exception("Mesh has to be set before calling getGaussLocalization method !");
+ if(!((const MEDCouplingFieldDiscretization *)_type))
+ throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call getGaussLocalization method !");
return _type->getGaussLocalization(locId);
}
{
}
-MEDCouplingField::MEDCouplingField(const MEDCouplingField& other):RefCountObject(other),_name(other._name),_desc(other._desc),_nature(other._nature),
- _mesh(0),_type(other._type->clone())
+MEDCouplingField::MEDCouplingField(const MEDCouplingField& other, bool deepCopy):RefCountObject(other),_name(other._name),_desc(other._desc),_nature(other._nature),
+ _mesh(0),_type(0)
{
if(other._mesh)
{
_mesh=other._mesh;
_mesh->incrRef();
}
+ if(deepCopy)
+ _type=other._type->clone();
+ else
+ _type=other._type;
}
/*!
* This method returns a submesh of 'mesh' instance constituting cell ids contained in array defined as an interval [start;end).
- * @param di is an array returned that specifies entity ids (nodes, cells ids...) in mesh 'mesh' of entity in returned submesh.
+ * @param di is an array returned that specifies entity ids (nodes, cells, Gauss points... ) in array.
+ *
+ * \sa MEDCouplingField::buildSubMeshDataRange
*/
MEDCouplingMesh *MEDCouplingField::buildSubMeshData(const int *start, const int *end, DataArrayInt *&di) const
{
+ if(!((const MEDCouplingFieldDiscretization *)_type))
+ throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call buildSubMeshData method !");
return _type->buildSubMeshData(_mesh,start,end,di);
}
+/*!
+ * This method returns a submesh of 'mesh' instance constituting cell ids defined by a range given by the 3 following inputs \a begin, \a end and \a step.
+ *
+ * \param [out] beginOut Valid only if \a di is NULL
+ * \param [out] endOut Valid only if \a di is NULL
+ * \param [out] stepOut Valid only if \a di is NULL
+ * \param [out] di is an array returned that specifies entity ids (nodes, cells, Gauss points... ) in array if no output range is foundable.
+ *
+ * \sa MEDCouplingField::buildSubMeshData
+ */
+MEDCouplingMesh *MEDCouplingField::buildSubMeshDataRange(int begin, int end, int step, int& beginOut, int& endOut, int& stepOut, DataArrayInt *&di) const
+{
+ if(!((const MEDCouplingFieldDiscretization *)_type))
+ throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call buildSubMeshDataRange method !");
+ return _type->buildSubMeshDataRange(_mesh,begin,end,step,beginOut,endOut,stepOut,di);
+}
+
/*!
* This method returns tuples ids implied by the mesh selection of the cell ids contained in array defined as an interval [start;end).
* \return a newly allocated DataArrayInt instance containing tuples ids.
*/
DataArrayInt *MEDCouplingField::computeTupleIdsToSelectFromCellIds(const int *startCellIds, const int *endCellIds) const
{
+ if(!((const MEDCouplingFieldDiscretization *)_type))
+ throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call computeTupleIdsToSelectFromCellIds method !");
return _type->computeTupleIdsToSelectFromCellIds(_mesh,startCellIds,endCellIds);
}
*/
int MEDCouplingField::getNumberOfTuplesExpected() const throw(INTERP_KERNEL::Exception)
{
+ if(!((const MEDCouplingFieldDiscretization *)_type))
+ throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call getNumberOfTuplesExpected method !");
if(_mesh)
return _type->getNumberOfTuples(_mesh);
else
throw INTERP_KERNEL::Exception("MEDCouplingField::getNumberOfTuplesExpected : Empty mesh !");
}
+void MEDCouplingField::setDiscretization(MEDCouplingFieldDiscretization *newDisc)
+{
+ bool needUpdate=(const MEDCouplingFieldDiscretization *)_type!=newDisc;
+ _type=newDisc;
+ if(newDisc)
+ newDisc->incrRef();
+ if(needUpdate)
+ declareAsNew();
+}
+
/*!
* This method returns number of mesh placed expected regarding its discretization and its _mesh attribute.
* This method expected a not null _mesh instance. If null, an exception will be thrown.
*/
int MEDCouplingField::getNumberOfMeshPlacesExpected() const throw(INTERP_KERNEL::Exception)
{
+ if(!((const MEDCouplingFieldDiscretization *)_type))
+ throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call getNumberOfMeshPlacesExpected method !");
if(_mesh)
return _type->getNumberOfMeshPlaces(_mesh);
else
throw INTERP_KERNEL::Exception("MEDCouplingField::getNumberOfMeshPlacesExpected : Empty mesh !");
}
+
+/*!
+ * Copy tiny info (component names, name, description) but warning the underlying mesh is not renamed (for safety reason).
+ */
+void MEDCouplingField::copyTinyStringsFrom(const MEDCouplingField *other) throw(INTERP_KERNEL::Exception)
+{
+ if(other)
+ {
+ setName(other->_name.c_str());
+ setDescription(other->_desc.c_str());
+ }
+}