//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// Author : Anthony Geay (CEA/DEN)
+// Author : Anthony Geay (EDF R&D)
#include "MEDFileField.txx"
#include "MEDFileMesh.hxx"
catch(INTERP_KERNEL::Exception& e)
{ throw e; }
-/*!
- * 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()));
- MCAuto<MEDCouplingFieldDouble> ret2(MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut));
- return ret2.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
- * 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 [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
- * \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.
- * - 1 - permute cells.
- * - 2 - permute nodes.
- * - 3 - permute cells and nodes.
- *
- * \return MEDCouplingFieldDouble * - 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 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 given \a type or given \a meshDimRelToMax are available.
- * \sa getFieldOnMeshAtLevel()
- */
-MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
-{
- 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> ret2(MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut));
- return ret2.retn();
-}
-
-/*!
- * Returns a new MEDCouplingFieldDouble 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 [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.
- * - 1 - permute cells.
- * - 2 - permute nodes.
- * - 3 - permute cells and nodes.
- *
- * \return MEDCouplingFieldDouble * - 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 there is no mesh in the MED file.
- * \throw If no field values of the given \a type.
- * \throw If no field values lying on the top level support.
- * \sa getFieldAtLevel()
- */
-MEDCouplingFieldDouble *MEDFileField1TS::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> arrOut;
- MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
- MCAuto<MEDCouplingFieldDouble> ret2(MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut));
- return ret2.retn();
-}
-
-/*!
- * Returns a new MEDCouplingFieldDouble 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 [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.
- * - 1 - permute cells.
- * - 2 - permute nodes.
- * - 3 - permute cells and nodes.
- *
- * \return MEDCouplingFieldDouble * - 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.
- * \throw If no field values of the given \a type are available.
- * \sa getFieldAtLevel()
- * \sa getFieldOnMeshAtLevel()
- */
-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> ret2(MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut));
- return ret2.retn();
-}
-
-/*!
- * Returns a new MEDCouplingFieldDouble 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 [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
- * - 0 - do not permute.
- * - 1 - permute cells.
- * - 2 - permute nodes.
- * - 3 - permute cells and nodes.
- *
- * \return MEDCouplingFieldDouble * - 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 given \a type or given \a meshDimRelToMax are available.
- * \sa getFieldAtLevel()
- * \sa getFieldOnMeshAtLevel()
- */
-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> ret2(MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut));
- return ret2.retn();
-}
-
-/*!
- * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
- * This method is called "Old" because in MED3 norm a field has only one meshName
- * attached, so this method is for readers of MED2 files. 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 [in] mName - a name of the supporting mesh.
- * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
- * \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.
- * - 1 - permute cells.
- * - 2 - permute nodes.
- * - 3 - permute cells and nodes.
- *
- * \return MEDCouplingFieldDouble * - 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 there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
- * \throw If \a this field has not been constructed via file reading.
- * \throw If no field of \a this is lying on the mesh named \a mName.
- * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
- * \sa getFieldAtLevel()
- */
-MEDCouplingFieldDouble *MEDFileField1TS::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> arrOut;
- MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
- MCAuto<MEDCouplingFieldDouble> ret2(MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut));
- return ret2.retn();
-}
-
-/*!
- * Adds a MEDCouplingFieldDouble 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.
- * \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
- * than \a field.
- * \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 MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
-{
- setFileName("");
- MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*field));
- contentNotNull()->setFieldNoProfileSBT(field->timeDiscrSafe(),ft,field->getArray(),*this,*contentNotNull());
-}
-
-/*!
- * Adds a MEDCouplingFieldDouble 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,
- * and \a profile.
- *
- * 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 mesh support of field is ignored.
- * \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 either \a field or \a mesh or \a profile has an empty name.
- * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
- * \throw If the data array of \a field is not set.
- * \throw If the data array of \a this is already allocated but has different number of
- * components than \a field.
- * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
- * \sa setFieldNoProfileSBT()
- */
-void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
-{
- setFileName("");
- MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::NewWithoutCheck(*field));
- contentNotNull()->setFieldProfile(field->timeDiscrSafe(),ft,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
-}
-
MEDFileField1TS *MEDFileField1TS::shallowCpy() const
{
return new MEDFileField1TS(*this);
return ret.retn();
}
-/*!
- * 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.
- * \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
- * than \a field.
- * \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 MEDCouplingFieldInt *field)
-{
- setFileName("");
- MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*field));
- contentNotNull()->setFieldNoProfileSBT(field->timeDiscrSafe(),ft,field->getArray(),*this,*contentNotNull());
-}
-
-/*!
- * 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,
- * and \a profile.
- *
- * 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.
- * \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 either \a field or \a mesh or \a profile has an empty name.
- * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
- * \throw If the data array of \a field is not set.
- * \throw If the data array of \a this is already allocated but has different number of
- * components than \a field.
- * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
- * \sa setFieldNoProfileSBT()
- */
-void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
-{
- setFileName("");
- MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::NewWithoutCheck(*field));
- contentNotNull()->setFieldProfile(field->timeDiscrSafe(),ft,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
-}
-
-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> arrOut;
- MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
- MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInField(ret,arrOut));
- return ret2.retn();
-}
-
MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
{
if(!f)
throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
}
-/*!
- * 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(SetDataArrayDoubleInField(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 [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.
- * - 1 - permute cells.
- * - 2 - permute nodes.
- * - 3 - permute cells and nodes.
- *
- * \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 there is no mesh in the MED file.
- * \throw If no field values of the given \a type.
- * \throw If no field values lying on the top level support.
- * \sa getFieldAtLevel()
- */
-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> arrOut;
- MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
- MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInField(ret,arrOut));
- return ret2.retn();
-}
-
-/*!
- * 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 [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.
- * - 1 - permute cells.
- * - 2 - permute nodes.
- * - 3 - permute cells and nodes.
- *
- * \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.
- * \throw If no field values of the given \a type are available.
- * \sa getFieldAtLevel()
- * \sa getFieldOnMeshAtLevel()
- */
-MEDCouplingFieldInt *MEDFileIntField1TS::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<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInField(ret,arrOut));
- return ret2.retn();
-}
-
-/*!
- * 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 [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
- * - 0 - do not permute.
- * - 1 - permute cells.
- * - 2 - permute nodes.
- * - 3 - permute cells and nodes.
- *
- * \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 given \a type or given \a meshDimRelToMax are available.
- * \sa getFieldAtLevel()
- * \sa getFieldOnMeshAtLevel()
- */
-MEDCouplingFieldInt *MEDFileIntField1TS::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<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInField(ret,arrOut));
- return ret2.retn();
-}
-
-/*!
- * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
- * This method is called "Old" because in MED3 norm a field has only one meshName
- * attached, so this method is for readers of MED2 files. 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 [in] mName - a name of the supporting mesh.
- * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
- * \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.
- * - 1 - permute cells.
- * - 2 - permute nodes.
- * - 3 - permute cells and nodes.
- *
- * \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 there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
- * \throw If \a this field has not been constructed via file reading.
- * \throw If no field of \a this is lying on the mesh named \a mName.
- * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
- * \sa getFieldAtLevel()
- */
-MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
-{
- if(getFileName().empty())
- 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(SetDataArrayDoubleInField(ret,arrOut));
- return ret2.retn();
-}
-
//= MEDFileFloatField1TS
MEDFileFloatField1TS::MEDFileFloatField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
MCAuto<typename Traits<T>::FieldType> MEDFileTemplateField1TS<T>::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
{
if(!f)
- throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
+ throw INTERP_KERNEL::Exception("MEDFileTemplateField1TS<T>::SetDataArrayDoubleInField : input field is NULL !");
if(arr.isNull())
- throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
+ throw INTERP_KERNEL::Exception("MEDFileTemplateField1TS<T>::SetDataArrayDoubleInField : no array !");
int t1,t2;
double t0(f->getTime(t1,t2));
std::string tu(f->getTimeUnit());
ret->setTime(t0,t1,t2); ret->setArray(arr2); ret->setTimeUnit(tu);
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] mesh - the mesh the field is lying on
+ * \return typename Traits<T>::FieldType * - a new instance of typename Traits<T>::FieldType. The
+ * caller is to delete this field using decrRef() as it is no more needed.
+ */
+ template<class T>
+ typename Traits<T>::FieldType *MEDFileTemplateField1TS<T>::field(const MEDFileMesh *mesh) const
+ {
+ MCAuto<DataArray> arrOut;
+ MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
+ MCAuto<typename Traits<T>::FieldType> ret2(MEDFileTemplateField1TS<T>::SetDataArrayDoubleInField(ret,arrOut));
+ return ret2.retn();
+ }
+
+ /*!
+ * Returns a new typename Traits<T>::FieldType of a given type lying on
+ * mesh entities of a given dimension 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 [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
+ * \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.
+ * - 1 - permute cells.
+ * - 2 - permute nodes.
+ * - 3 - permute cells and nodes.
+ *
+ * \return typename Traits<T>::FieldType * - a new instance of typename Traits<T>::FieldType. 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 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 given \a type or given \a meshDimRelToMax are available.
+ * \sa getFieldOnMeshAtLevel()
+ */
+ template<class T>
+ typename Traits<T>::FieldType *MEDFileTemplateField1TS<T>::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
+ {
+ if(getFileName().empty())
+ throw INTERP_KERNEL::Exception("MEDFileTemplateField1TS<T>::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<typename Traits<T>::FieldType> ret2(MEDFileTemplateField1TS<T>::SetDataArrayDoubleInField(ret,arrOut));
+ return ret2.retn();
+ }
+
+ /*!
+ * Returns a new typename Traits<T>::FieldType 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 [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.
+ * - 1 - permute cells.
+ * - 2 - permute nodes.
+ * - 3 - permute cells and nodes.
+ *
+ * \return typename Traits<T>::FieldType * - a new instance of typename Traits<T>::FieldType. 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 there is no mesh in the MED file.
+ * \throw If no field values of the given \a type.
+ * \throw If no field values lying on the top level support.
+ * \sa getFieldAtLevel()
+ */
+ template<class T>
+ typename Traits<T>::FieldType *MEDFileTemplateField1TS<T>::getFieldAtTopLevel(TypeOfField type, int renumPol) const
+ {
+ if(getFileName().empty())
+ throw INTERP_KERNEL::Exception("MEDFileTemplateField1TS<T>::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<typename Traits<T>::FieldType> ret2(MEDFileTemplateField1TS<T>::SetDataArrayDoubleInField(ret,arrOut));
+ return ret2.retn();
+ }
+
+ /*!
+ * Returns a new typename Traits<T>::FieldType 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 [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.
+ * - 1 - permute cells.
+ * - 2 - permute nodes.
+ * - 3 - permute cells and nodes.
+ *
+ * \return typename Traits<T>::FieldType * - a new instance of typename Traits<T>::FieldType. 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.
+ * \throw If no field values of the given \a type are available.
+ * \sa getFieldAtLevel()
+ * \sa getFieldOnMeshAtLevel()
+ */
+ template<class T>
+ typename Traits<T>::FieldType *MEDFileTemplateField1TS<T>::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<typename Traits<T>::FieldType> ret2(MEDFileTemplateField1TS<T>::SetDataArrayDoubleInField(ret,arrOut));
+ return ret2.retn();
+ }
+
+ /*!
+ * Returns a new typename Traits<T>::FieldType 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 [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
+ * - 0 - do not permute.
+ * - 1 - permute cells.
+ * - 2 - permute nodes.
+ * - 3 - permute cells and nodes.
+ *
+ * \return typename Traits<T>::FieldType * - a new instance of typename Traits<T>::FieldType. 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 given \a type or given \a meshDimRelToMax are available.
+ * \sa getFieldAtLevel()
+ * \sa getFieldOnMeshAtLevel()
+ */
+ template<class T>
+ typename Traits<T>::FieldType *MEDFileTemplateField1TS<T>::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<typename Traits<T>::FieldType> ret2(MEDFileTemplateField1TS<T>::SetDataArrayDoubleInField(ret,arrOut));
+ return ret2.retn();
+ }
+
+ /*!
+ * Returns a new typename Traits<T>::FieldType of a given type lying on a given support.
+ * This method is called "Old" because in MED3 norm a field has only one meshName
+ * attached, so this method is for readers of MED2 files. 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 [in] mName - a name of the supporting mesh.
+ * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
+ * \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.
+ * - 1 - permute cells.
+ * - 2 - permute nodes.
+ * - 3 - permute cells and nodes.
+ *
+ * \return typename Traits<T>::FieldType * - a new instance of typename Traits<T>::FieldType. 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 there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
+ * \throw If \a this field has not been constructed via file reading.
+ * \throw If no field of \a this is lying on the mesh named \a mName.
+ * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
+ * \sa getFieldAtLevel()
+ */
+ template<class T>
+ typename Traits<T>::FieldType *MEDFileTemplateField1TS<T>::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
+ {
+ if(getFileName().empty())
+ throw INTERP_KERNEL::Exception("MEDFileTemplateField1TS<T>::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<typename Traits<T>::FieldType> ret2(MEDFileTemplateField1TS<T>::SetDataArrayDoubleInField(ret,arrOut));
+ return ret2.retn();
+ }
+
+ /*!
+ * Adds a MEDCouplingFieldDouble 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.
+ * \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
+ * than \a field.
+ * \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.
+ */
+ template<class T>
+ void MEDFileTemplateField1TS<T>::setFieldNoProfileSBT(const typename Traits<T>::FieldType *field)
+ {
+ setFileName("");
+ MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*field));
+ contentNotNull()->setFieldNoProfileSBT(field->timeDiscrSafe(),ft,field->getArray(),*this,*contentNotNull());
+ }
+
+ /*!
+ * Adds a MEDCouplingFieldDouble 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,
+ * and \a profile.
+ *
+ * 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 mesh support of field is ignored.
+ * \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 either \a field or \a mesh or \a profile has an empty name.
+ * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
+ * \throw If the data array of \a field is not set.
+ * \throw If the data array of \a this is already allocated but has different number of
+ * components than \a field.
+ * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
+ * \sa setFieldNoProfileSBT()
+ */
+ template<class T>
+ void MEDFileTemplateField1TS<T>::setFieldProfile(const typename Traits<T>::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
+ {
+ setFileName("");
+ MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::NewWithoutCheck(*field));
+ contentNotNull()->setFieldProfile(field->timeDiscrSafe(),ft,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
+ }
}
#endif