SET(VERSION_DEV "1")
SET(WITH_MEDMEMGUI "0")
+#Defining all options first
+option(SALOME_USE_MPI "Use MPI containers" OFF)
+
SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR})
IF(KERNEL_ROOT_DIR)
FILE(TO_CMAKE_PATH $ENV{KERNEL_ROOT_DIR} KERNEL_ROOT_DIR)
SET(SALOME_MACROS_DIR ${KERNEL_ROOT_DIR}/salome_adm/cmake_files)
- INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPLATFORM.cmake)
- INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPYTHON.cmake)
- INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindMPI.cmake)
- INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindOMNIORB.cmake)
- INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindPTHREADS.cmake)
- INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindHDF5.cmake)
- INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindBOOST.cmake)
- INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindLIBXML2.cmake)
- INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindSWIG.cmake)
+ INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/deprecated/FindPLATFORM.cmake)
+ INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/deprecated/FindPYTHON.cmake)
+ if(SALOME_USE_MPI)
+ INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/deprecated/FindMPI.cmake)
+ endif(SALOME_USE_MPI)
+ INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/deprecated/FindOMNIORB.cmake)
+ INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/deprecated/FindPTHREADS.cmake)
+ INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/deprecated/FindHDF5.cmake)
+ INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/deprecated/FindBOOST.cmake)
+ INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/deprecated/FindLIBXML2.cmake)
+ INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/deprecated/FindSWIG.cmake)
INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindCPPUNIT.cmake)
- INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindDOXYGEN.cmake)
+ INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/deprecated/FindDOXYGEN.cmake)
INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindSPHINX.cmake)
- INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindLIBBATCH.cmake)
- INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindKERNEL.cmake)
+ INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindSalomeLIBBATCH.cmake)
+ INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/deprecated/FindKERNEL.cmake)
SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR})
FILE(TO_CMAKE_PATH $ENV{GUI_ROOT_DIR} GUI_ROOT_DIR)
IF(GUI_ROOT_DIR)
SET(MED_ENABLE_GUI ON)
- INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindCAS.cmake)
- INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindQT4.cmake)
- INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindOPENGL.cmake)
- INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindVTK.cmake)
- INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindQWT.cmake)
- INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindSIPPYQT.cmake)
- INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindGUI.cmake)
+ INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/deprecated/FindCAS.cmake)
+ INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/deprecated/FindQT4.cmake)
+ INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/deprecated/FindOPENGL.cmake)
+ INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/deprecated/FindVTK.cmake)
+ INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/deprecated/FindQWT.cmake)
+ INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/deprecated/FindSIPPYQT.cmake)
+ INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/deprecated/FindGUI.cmake)
ENDIF(GUI_ROOT_DIR)
ELSE(KERNEL_ROOT_DIR)
SET(SALOME_MACROS_DIR ${CMAKE_SOURCE_DIR}/adm_local_without_kernel/cmake_files)
INCLUDE(${CMAKE_SOURCE_DIR}/adm_local_without_kernel/cmake_files/FindPLATFORM.cmake)
- INCLUDE(${CMAKE_SOURCE_DIR}/adm_local_without_kernel/cmake_files/FindMPI.cmake)
+ if(SALOME_USE_MPI)
+ INCLUDE(${CMAKE_SOURCE_DIR}/adm_local_without_kernel/cmake_files/FindMPI.cmake)
+ endif(SALOME_USE_MPI)
INCLUDE(${CMAKE_SOURCE_DIR}/adm_local_without_kernel/cmake_files/FindBOOST.cmake)
INCLUDE(${CMAKE_SOURCE_DIR}/adm_local_without_kernel/cmake_files/FindCPPUNIT.cmake)
INCLUDE(${CMAKE_SOURCE_DIR}/adm_local_without_kernel/cmake_files/FindHDF5.cmake)
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-ADD_SUBDIRECTORY(MEDMEM)
ADD_SUBDIRECTORY(salome)
ADD_SUBDIRECTORY(doxygen)
#
# Author : Anthony Geay (CEA/DEN)
-INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/UseOMNIORB.cmake)
+INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/deprecated/UseOMNIORB.cmake)
INCLUDE_DIRECTORIES(
${OMNIORB_INCLUDE_DIRS}
ENDIF(MPI_IS_OK)
IF(MED_ENABLE_SPLITTER)
- SET(COMMON_SUBDIRS ${COMMON_SUBDIRS} MEDPartitioner)
- SET(OLD_COMMON_SUBDIRS ${OLD_COMMON_SUBDIRS} MEDSPLITTER)
- IF(SWIG_STATUS)
- SET(OLD_COMMON_SUBDIRS ${OLD_COMMON_SUBDIRS} MEDSPLITTER_Swig)
- ENDIF(SWIG_STATUS)
+ IF(MED_ENABLE_MED3)
+ SET(COMMON_SUBDIRS ${COMMON_SUBDIRS} MEDPartitioner)
+ SET(OLD_COMMON_SUBDIRS ${OLD_COMMON_SUBDIRS} MEDSPLITTER)
+ IF(SWIG_STATUS)
+ SET(OLD_COMMON_SUBDIRS ${OLD_COMMON_SUBDIRS} MEDSPLITTER_Swig)
+ ENDIF(SWIG_STATUS)
+ ENDIF(MED_ENABLE_MED3)
ENDIF(MED_ENABLE_SPLITTER)
IF(MED_ENABLE_RENUMBER)
- SET(OLD_COMMON_SUBDIRS ${OLD_COMMON_SUBDIRS} RENUMBER)
+ IF(MED_ENABLE_MED3)
+ SET(OLD_COMMON_SUBDIRS ${OLD_COMMON_SUBDIRS} RENUMBER)
+ ENDIF(MED_ENABLE_MED3)
ENDIF(MED_ENABLE_RENUMBER)
IF(MED_ENABLE_KERNEL)
_quadratic=false;
_dyn=false;
_extruded_type=NORM_ERROR;
+ _reverse_extruded_type=NORM_ERROR;
_linear_type=NORM_ERROR;
_quadratic_type=NORM_ERROR;
switch(type)
break;
case NORM_SEG2:
{
- _nb_of_pts=2; _nb_of_sons=2; _dim=1; _extruded_type=NORM_QUAD4; _quadratic_type=NORM_SEG3; _is_simplex=true; _is_extruded=true;
+ _nb_of_pts=2; _nb_of_sons=2; _dim=1; _extruded_type=NORM_QUAD4; _quadratic_type=NORM_SEG3; _is_simplex=true; _is_extruded=true; _reverse_extruded_type=NORM_POINT1;
_sons_type[0]=NORM_POINT1; _sons_type[1]=NORM_POINT1;
_sons_con[0][0]=0; _nb_of_sons_con[0]=1;
_sons_con[1][0]=1; _nb_of_sons_con[1]=1;
break;
case NORM_HEXA8:
{
- _nb_of_pts=8; _nb_of_sons=6; _dim=3; _quadratic_type=NORM_HEXA20; _is_simplex=false; _is_extruded=true;
+ _nb_of_pts=8; _nb_of_sons=6; _dim=3; _quadratic_type=NORM_HEXA20; _is_simplex=false; _is_extruded=true; _reverse_extruded_type=NORM_QUAD4;
_sons_type[0]=NORM_QUAD4; _sons_type[1]=NORM_QUAD4; _sons_type[2]=NORM_QUAD4; _sons_type[3]=NORM_QUAD4; _sons_type[4]=NORM_QUAD4; _sons_type[5]=NORM_QUAD4;
_sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=3; _nb_of_sons_con[0]=4;
_sons_con[1][0]=4; _sons_con[1][1]=7; _sons_con[1][2]=6; _sons_con[1][3]=5; _nb_of_sons_con[1]=4;
break;
case NORM_PENTA6:
{
- _nb_of_pts=6; _nb_of_sons=5; _dim=3; _quadratic_type=NORM_PENTA15; _is_simplex=false; _is_extruded=true;
+ _nb_of_pts=6; _nb_of_sons=5; _dim=3; _quadratic_type=NORM_PENTA15; _is_simplex=false; _is_extruded=true; _reverse_extruded_type=NORM_TRI3;
_sons_type[0]=NORM_TRI3; _sons_type[1]=NORM_TRI3; _sons_type[2]=NORM_QUAD4; _sons_type[3]=NORM_QUAD4; _sons_type[4]=NORM_QUAD4;
_sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _nb_of_sons_con[0]=3;
_sons_con[1][0]=3; _sons_con[1][1]=5; _sons_con[1][2]=4; _nb_of_sons_con[1]=3;
INTERPKERNEL_EXPORT unsigned getNumberOfNodesConstituentTheSon(unsigned sonId) const { return _nb_of_sons_con[sonId]; }
INTERPKERNEL_EXPORT unsigned getNumberOfNodesConstituentTheSon2(unsigned sonId, const int *nodalConn, int lgth) const;
INTERPKERNEL_EXPORT NormalizedCellType getExtrudedType() const { return _extruded_type; }
+ INTERPKERNEL_EXPORT NormalizedCellType getReverseExtrudedType() const { return _reverse_extruded_type; }
INTERPKERNEL_EXPORT NormalizedCellType getLinearType() const { return _linear_type; }
INTERPKERNEL_EXPORT NormalizedCellType getQuadraticType() const { return _quadratic_type; }
INTERPKERNEL_EXPORT NormalizedCellType getSonType(unsigned sonId) const { return _sons_type[sonId]; }
unsigned _nb_of_sons;
NormalizedCellType _type;
NormalizedCellType _extruded_type;
+ NormalizedCellType _reverse_extruded_type;
NormalizedCellType _linear_type;
NormalizedCellType _quadratic_type;
unsigned _sons_con[MAX_NB_OF_SONS][MAX_NB_OF_NODES_PER_ELEM];
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#ifndef __INTERPKERNELGAUSS_HXX__
-#define __INTERPKERNELGAUSS_HXX__
+#ifndef __INTERPKERNELGAUSSCOORDS_HXX__
+#define __INTERPKERNELGAUSSCOORDS_HXX__
#include "INTERPKERNELDefines.hxx"
#include "NormalizedUnstructuredMesh.hxx"
GaussInfoVector _my_gauss_info;
};
}
-#endif //INTERPKERNELGAUSS
+#endif //INTERPKERNELGAUSSCOORDS
return ret;
}
+DataArrayInt *MEDCouplingExtrudedMesh::giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception)
+{
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
+ INTERP_KERNEL::NormalizedCellType revExtTyp=cm.getReverseExtrudedType();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+ if(revExtTyp==INTERP_KERNEL::NORM_ERROR)
+ {
+ ret->alloc(0,1);
+ return ret.retn();
+ }
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=_mesh2D->giveCellsWithType(revExtTyp);
+ int nbOfLevs=_mesh1D->getNumberOfCells();
+ int nbOfCells2D=_mesh2D->getNumberOfCells();
+ int nbOfTuples=tmp->getNumberOfTuples();
+ ret->alloc(nbOfLevs*nbOfTuples,1);
+ int *pt=ret->getPointer();
+ for(int i=0;i<nbOfLevs;i++,pt+=nbOfTuples)
+ std::transform(tmp->begin(),tmp->end(),pt,std::bind2nd(std::plus<double>(),i*nbOfCells2D));
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret2=ret->renumberR(_mesh3D_ids->begin());
+ ret2->sort();
+ return ret2.retn();
+}
+
+DataArrayInt *MEDCouplingExtrudedMesh::computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret2D=_mesh2D->computeNbOfNodesPerCell();
+ int nbOfLevs=_mesh1D->getNumberOfCells();
+ int nbOfCells2D=_mesh2D->getNumberOfCells();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret3D=DataArrayInt::New(); ret3D->alloc(nbOfLevs*nbOfCells2D,1);
+ int *pt=ret3D->getPointer();
+ for(int i=0;i<nbOfLevs;i++,pt+=nbOfCells2D)
+ std::copy(ret2D->begin(),ret2D->end(),pt);
+ return ret3D->renumberR(_mesh3D_ids->begin());
+}
+
int MEDCouplingExtrudedMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const
{
int ret=0;
DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception);
INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const;
std::set<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
+ DataArrayInt *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
void getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const throw(INTERP_KERNEL::Exception);
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());
+ }
+}
virtual bool isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec, std::string& reason) const throw(INTERP_KERNEL::Exception);
virtual bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
virtual bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
+ virtual void copyTinyStringsFrom(const MEDCouplingField *other) throw(INTERP_KERNEL::Exception);
void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh);
const ParaMEDMEM::MEDCouplingMesh *getMesh() const { return _mesh; }
void setName(const char *name) { _name=name; }
#include <list>
#include <limits>
#include <sstream>
+#include <numeric>
#include <algorithm>
#include <functional>
const TypeOfField MEDCouplingFieldDiscretizationKriging::TYPE=ON_NODES_KR;
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_SEG2[2]={1.,1.};
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_SEG3[3]={0.5555555555555556,0.5555555555555556,0.8888888888888888};
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_SEG4[4]={0.347854845137454,0.347854845137454,0.652145154862546,0.652145154862546};
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_TRI3[3]={0.16666666666666666,0.16666666666666666,0.16666666666666666};
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_TRI6[6]={0.0549758718227661,0.0549758718227661,0.0549758718227661,0.11169079483905,0.11169079483905,0.11169079483905};
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_TRI7[7]={0.062969590272413,0.062969590272413,0.062969590272413,0.066197076394253,0.066197076394253,0.066197076394253,0.1125};
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_QUAD4[4]={1.,1.,1.,1.};
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_QUAD9[9]={0.30864197530864196,0.30864197530864196,0.30864197530864196,0.30864197530864196,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.7901234567901234};
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_TETRA4[4]={0.041666666666666664,0.041666666666666664,0.041666666666666664,0.041666666666666664};
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_PENTA6[6]={0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666};
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_HEXA8[8]={1.,1.,1.,1.,1.,1.,1.,1.};
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_HEXA27[27]={0.1714677640603567,0.1714677640603567,0.1714677640603567,0.1714677640603567,0.1714677640603567,0.1714677640603567,0.1714677640603567,0.1714677640603567,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.43895747599451296,0.43895747599451296,0.43895747599451296,0.43895747599451296,0.43895747599451296,0.43895747599451296,0.7023319615912208};
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_PYRA5[5]={0.13333333333333333,0.13333333333333333,0.13333333333333333,0.13333333333333333,0.13333333333333333};
+
MEDCouplingFieldDiscretization::MEDCouplingFieldDiscretization():_precision(DFLT_PRECISION)
{
}
*/
void MEDCouplingFieldDiscretization::normL1(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception)
{
- MEDCouplingFieldDouble *vol=getMeasureField(mesh,true);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> vol=getMeasureField(mesh,true);
int nbOfCompo=arr->getNumberOfComponents();
int nbOfElems=getNumberOfTuples(mesh);
std::fill(res,res+nbOfCompo,0.);
deno+=v;
}
std::transform(res,res+nbOfCompo,res,std::bind2nd(std::multiplies<double>(),1./deno));
- vol->decrRef();
}
/*!
*/
void MEDCouplingFieldDiscretization::normL2(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception)
{
- MEDCouplingFieldDouble *vol=getMeasureField(mesh,true);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> vol=getMeasureField(mesh,true);
int nbOfCompo=arr->getNumberOfComponents();
int nbOfElems=getNumberOfTuples(mesh);
std::fill(res,res+nbOfCompo,0.);
}
std::transform(res,res+nbOfCompo,res,std::bind2nd(std::multiplies<double>(),1./deno));
std::transform(res,res+nbOfCompo,res,std::ptr_fun<double,double>(std::sqrt));
- vol->decrRef();
}
/*!
*/
void MEDCouplingFieldDiscretization::integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs, double *res) const throw(INTERP_KERNEL::Exception)
{
- MEDCouplingFieldDouble *vol=getMeasureField(mesh,isWAbs);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> vol=getMeasureField(mesh,isWAbs);
int nbOfCompo=arr->getNumberOfComponents();
int nbOfElems=getNumberOfTuples(mesh);
std::fill(res,res+nbOfCompo,0.);
std::transform(tmp,tmp+nbOfCompo,res,res,std::plus<double>());
}
delete [] tmp;
- vol->decrRef();
}
void MEDCouplingFieldDiscretization::getSerializationIntArray(DataArrayInt *& arr) const
int oldNbOfElems=arr->getNumberOfTuples();
int nbOfComp=arr->getNumberOfComponents();
int newNbOfTuples=newNbOfEntity;
- DataArrayDouble *arrCpy=arr->deepCpy();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrCpy=arr->deepCpy();
const double *ptSrc=arrCpy->getConstPointer();
arr->reAlloc(newNbOfTuples);
double *ptToFill=arr->getPointer();
//if(!std::equal(ptSrc+i*nbOfComp,ptSrc+(i+1)*nbOfComp,ptToFill+newNb*nbOfComp))
if(*std::max_element((double *)tmp,((double *)tmp)+nbOfComp)>eps)
{
- arrCpy->decrRef();
std::ostringstream oss;
oss << msg << " " << i << " and " << std::find(old2NewPtr,old2NewPtr+i,newNb)-old2NewPtr
<< " have been merged and " << msg << " field on them are different !";
}
}
}
- arrCpy->decrRef();
}
void MEDCouplingFieldDiscretization::RenumberEntitiesFromN2OArr(const int *new2OldPtr, int new2OldSz, DataArrayDouble *arr, const char *msg)
{
int nbOfComp=arr->getNumberOfComponents();
- DataArrayDouble *arrCpy=arr->deepCpy();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrCpy=arr->deepCpy();
const double *ptSrc=arrCpy->getConstPointer();
arr->reAlloc(new2OldSz);
double *ptToFill=arr->getPointer();
int oldNb=new2OldPtr[i];
std::copy(ptSrc+oldNb*nbOfComp,ptSrc+(oldNb+1)*nbOfComp,ptToFill+i*nbOfComp);
}
- arrCpy->decrRef();
}
MEDCouplingFieldDiscretization::~MEDCouplingFieldDiscretization()
throw INTERP_KERNEL::Exception("Not implemented yet !");
}
+void MEDCouplingFieldDiscretizationGaussNE::integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs, double *res) const throw(INTERP_KERNEL::Exception)
+{
+ if(!mesh || !arr)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGaussNE::integral : input mesh or array is null !");
+ int nbOfCompo=arr->getNumberOfComponents();
+ std::fill(res,res+nbOfCompo,0.);
+ //
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> vol=getMeasureField(mesh,isWAbs);
+ std::set<INTERP_KERNEL::NormalizedCellType> types=mesh->getAllGeoTypes();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nbOfNodesPerCell=mesh->computeNbOfNodesPerCell();
+ nbOfNodesPerCell->computeOffsets2();
+ const double *arrPtr=arr->begin(),*volPtr=vol->getArray()->begin();
+ for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=types.begin();it!=types.end();it++)
+ {
+ std::size_t wArrSz=-1;
+ const double *wArr=GetWeightArrayFromGeometricType(*it,wArrSz);
+ INTERP_KERNEL::AutoPtr<double> wArr2=new double[wArrSz];
+ double sum=std::accumulate(wArr,wArr+wArrSz,0.);
+ std::transform(wArr,wArr+wArrSz,(double *)wArr2,std::bind2nd(std::multiplies<double>(),1./sum));
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=mesh->giveCellsWithType(*it);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids2=ids->buildExplicitArrByRanges(nbOfNodesPerCell);
+ const int *ptIds2=ids2->begin(),*ptIds=ids->begin();
+ int nbOfCellsWithCurGeoType=ids->getNumberOfTuples();
+ for(int i=0;i<nbOfCellsWithCurGeoType;i++,ptIds++,ptIds2+=wArrSz)
+ {
+ for(int k=0;k<nbOfCompo;k++)
+ {
+ double tmp=0.;
+ for(std::size_t j=0;j<wArrSz;j++)
+ tmp+=arrPtr[nbOfCompo*ptIds2[j]+k]*wArr2[j];
+ res[k]+=tmp*volPtr[*ptIds];
+ }
+ }
+ }
+}
+
+const double *MEDCouplingFieldDiscretizationGaussNE::GetWeightArrayFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType, std::size_t& lgth) throw(INTERP_KERNEL::Exception)
+{
+ switch(geoType)
+ {
+ case INTERP_KERNEL::NORM_SEG2:
+ lgth=(int)sizeof(FGP_SEG2)/sizeof(double);
+ return FGP_SEG2;
+ case INTERP_KERNEL::NORM_SEG3:
+ lgth=(int)sizeof(FGP_SEG3)/sizeof(double);
+ return FGP_SEG3;
+ case INTERP_KERNEL::NORM_SEG4:
+ lgth=(int)sizeof(FGP_SEG4)/sizeof(double);
+ return FGP_SEG4;
+ case INTERP_KERNEL::NORM_TRI3:
+ lgth=(int)sizeof(FGP_TRI3)/sizeof(double);
+ return FGP_TRI3;
+ case INTERP_KERNEL::NORM_TRI6:
+ lgth=(int)sizeof(FGP_TRI6)/sizeof(double);
+ return FGP_TRI6;
+ case INTERP_KERNEL::NORM_TRI7:
+ lgth=(int)sizeof(FGP_TRI7)/sizeof(double);
+ return FGP_TRI7;
+ case INTERP_KERNEL::NORM_QUAD4:
+ lgth=(int)sizeof(FGP_QUAD4)/sizeof(double);
+ return FGP_QUAD4;
+ case INTERP_KERNEL::NORM_QUAD9:
+ lgth=(int)sizeof(FGP_QUAD9)/sizeof(double);
+ return FGP_QUAD9;
+ case INTERP_KERNEL::NORM_TETRA4:
+ lgth=(int)sizeof(FGP_TETRA4)/sizeof(double);
+ return FGP_TETRA4;
+ case INTERP_KERNEL::NORM_PENTA6:
+ lgth=(int)sizeof(FGP_PENTA6)/sizeof(double);
+ return FGP_PENTA6;
+ case INTERP_KERNEL::NORM_HEXA8:
+ lgth=(int)sizeof(FGP_HEXA8)/sizeof(double);
+ return FGP_HEXA8;
+ case INTERP_KERNEL::NORM_HEXA27:
+ lgth=(int)sizeof(FGP_HEXA27)/sizeof(double);
+ return FGP_HEXA27;
+ case INTERP_KERNEL::NORM_PYRA5:
+ lgth=(int)sizeof(FGP_PYRA5)/sizeof(double);
+ return FGP_PYRA5;
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGaussNE::GetWeightArrayFromGeometricType : only SEG[2,3,4], TRI[3,6,7], QUAD[4,9], TETRA4, PENTA6, HEXA[8,27], PYRA5 supported !");
+ }
+}
+
void MEDCouplingFieldDiscretizationGaussNE::computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd,
DataArrayInt *&cellRest)
{
{
if(!mesh)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGaussNE::computeTupleIdsToSelectFromCellIds : null mesh !");
- const MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> umesh=mesh->buildUnstructured();
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nbOfNodesPerCell=umesh->computeNbOfNodesPerCell();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nbOfNodesPerCell=mesh->computeNbOfNodesPerCell();
nbOfNodesPerCell->computeOffsets2();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> sel=DataArrayInt::New(); sel->useArray(startCellIds,false,CPP_DEALLOC,(int)std::distance(startCellIds,endCellIds),1);
return sel->buildExplicitArrByRanges(nbOfNodesPerCell);
void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
+ void integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs, double *res) const throw(INTERP_KERNEL::Exception);
void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd,
DataArrayInt *&cellRest);
void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
void renumberValuesOnNodes(double epsOnVals, const int *old2New, int newNbOfNodes, DataArrayDouble *arr) const;
void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, int newSz, DataArrayDouble *arr) const;
void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
+ static const double *GetWeightArrayFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType, std::size_t& lgth) throw(INTERP_KERNEL::Exception);
protected:
MEDCouplingFieldDiscretizationGaussNE(const MEDCouplingFieldDiscretizationGaussNE& other);
public:
static const char REPR[];
static const TypeOfField TYPE;
+ static const double FGP_SEG2[2];
+ static const double FGP_SEG3[3];
+ static const double FGP_SEG4[4];
+ static const double FGP_TRI3[3];
+ static const double FGP_TRI6[6];
+ static const double FGP_TRI7[7];
+ static const double FGP_QUAD4[4];
+ //static const double FGP_QUAD8[8];
+ static const double FGP_QUAD9[9];
+ static const double FGP_TETRA4[4];
+ //static const double FGP_TETRA10[10];
+ static const double FGP_PENTA6[6];
+ //static const double FGP_PENTA15[15];
+ static const double FGP_HEXA8[8];
+ static const double FGP_HEXA27[27];
+ static const double FGP_PYRA5[5];
+ //static const double FGP_PYRA13[13];
};
class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationKriging : public MEDCouplingFieldDiscretizationOnNodes
/*!
* Copy tiny info (component names, name, description) but warning the underlying mesh is not renamed (for safety reason).
*/
-void MEDCouplingFieldDouble::copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception)
+void MEDCouplingFieldDouble::copyTinyStringsFrom(const MEDCouplingField *other) throw(INTERP_KERNEL::Exception)
{
- if(other)
+ MEDCouplingField::copyTinyStringsFrom(other);
+ const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
+ if(otherC)
{
- setName(other->_name.c_str());
- setDescription(other->_desc.c_str());
- _time_discr->copyTinyStringsFrom(*other->_time_discr);
+ _time_discr->copyTinyStringsFrom(*otherC->_time_discr);
}
}
{
_time_discr->copyTinyAttrFrom(*other->_time_discr);
}
+
+}
+
+void MEDCouplingFieldDouble::copyAllTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception)
+{
+ copyTinyStringsFrom(other);
+ copyTinyAttrFrom(other);
}
std::string MEDCouplingFieldDouble::simpleRepr() const
void setTimeUnit(const char *unit);
const char *getTimeUnit() const;
void synchronizeTimeWithSupport() throw(INTERP_KERNEL::Exception);
- void copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
+ void copyTinyStringsFrom(const MEDCouplingField *other) throw(INTERP_KERNEL::Exception);
void copyTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
+ void copyAllTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
std::string simpleRepr() const;
std::string advancedRepr() const;
void writeVTK(const char *fileName) const throw(INTERP_KERNEL::Exception);
{
if(value!=start || end!=start)
{
- std::ostringstream oss; oss << "DataArray::CheckValueInRange : " << msg << " ! Expected start " << start << " of range in [0," << value << "[ !";
+ std::ostringstream oss; oss << "DataArray::CheckValueInRangeEx : " << msg << " ! Expected start " << start << " of input range, in [0," << value << "[ !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
if(end<0 || end>value)
{
- std::ostringstream oss; oss << "DataArray::CheckClosingParInRange : " << msg << " ! Expected start " << end << " of range in [0," << value << "[ !";
+ std::ostringstream oss; oss << "DataArray::CheckValueInRangeEx : " << msg << " ! Expected end " << end << " of input range, in [0," << value << "] !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
{
if(value<0 || value>ref)
{
- std::ostringstream oss; oss << "DataArray::CheckClosingParInRange : " << msg << " ! Expected a range in [0," << ref << "] having closing open parenthesis " << value << " !";
+ std::ostringstream oss; oss << "DataArray::CheckClosingParInRange : " << msg << " ! Expected input range in [0," << ref << "] having closing open parenthesis " << value << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
throw INTERP_KERNEL::Exception("DataArrayDouble::pushBackSilent : not available for DataArrayDouble with number of components different than 1 !");
}
+void DataArrayDouble::pushBackValsSilent(const double *valsBg, const double *valsEnd) throw(INTERP_KERNEL::Exception)
+{
+ int nbCompo=getNumberOfComponents();
+ if(nbCompo==1)
+ _mem.insertAtTheEnd(valsBg,valsEnd);
+ else if(nbCompo==0)
+ {
+ _info_on_compo.resize(1);
+ _mem.insertAtTheEnd(valsBg,valsEnd);
+ }
+ else
+ throw INTERP_KERNEL::Exception("DataArrayDouble::pushBackValsSilent : not available for DataArrayDouble with number of components different than 1 !");
+}
+
double DataArrayDouble::popBackSilent() throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()==1)
return _mem.popBack();
else
- throw INTERP_KERNEL::Exception("DataArrayDouble::pushBackSilent : not available for DataArrayDouble with number of components different than 1 !");
+ throw INTERP_KERNEL::Exception("DataArrayDouble::popBackSilent : not available for DataArrayDouble with number of components different than 1 !");
}
void DataArrayDouble::pack() const throw(INTERP_KERNEL::Exception)
DataArrayDouble *DataArrayDouble::toNoInterlace() const throw(INTERP_KERNEL::Exception)
{
if(_mem.isNull())
- throw INTERP_KERNEL::Exception("DataArrayDouble::fromNoInterlace : Not defined array !");
+ throw INTERP_KERNEL::Exception("DataArrayDouble::toNoInterlace : Not defined array !");
double *tab=_mem.toNoInterlace(getNumberOfComponents());
DataArrayDouble *ret=DataArrayDouble::New();
ret->useArray(tab,true,CPP_DEALLOC,getNumberOfTuples(),getNumberOfComponents());
*/
void DataArrayDouble::renumberInPlace(const int *old2New)
{
+ checkAllocated();
int nbTuples=getNumberOfTuples();
int nbOfCompo=getNumberOfComponents();
double *tmp=new double[nbTuples*nbOfCompo];
*/
void DataArrayDouble::renumberInPlaceR(const int *new2Old)
{
+ checkAllocated();
int nbTuples=getNumberOfTuples();
int nbOfCompo=getNumberOfComponents();
double *tmp=new double[nbTuples*nbOfCompo];
*/
DataArrayDouble *DataArrayDouble::renumber(const int *old2New) const
{
+ checkAllocated();
int nbTuples=getNumberOfTuples();
int nbOfCompo=getNumberOfComponents();
DataArrayDouble *ret=DataArrayDouble::New();
*/
DataArrayDouble *DataArrayDouble::renumberR(const int *new2Old) const
{
+ checkAllocated();
int nbTuples=getNumberOfTuples();
int nbOfCompo=getNumberOfComponents();
DataArrayDouble *ret=DataArrayDouble::New();
*/
DataArrayDouble *DataArrayDouble::renumberAndReduce(const int *old2New, int newNbOfTuple) const
{
+ checkAllocated();
int nbTuples=getNumberOfTuples();
int nbOfCompo=getNumberOfComponents();
DataArrayDouble *ret=DataArrayDouble::New();
*/
DataArrayDouble *DataArrayDouble::selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const
{
- DataArrayDouble *ret=DataArrayDouble::New();
+ checkAllocated();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
int nbComp=getNumberOfComponents();
ret->alloc((int)std::distance(new2OldBg,new2OldEnd),nbComp);
ret->copyStringInfoFrom(*this);
for(const int *w=new2OldBg;w!=new2OldEnd;w++,i++)
std::copy(srcPt+(*w)*nbComp,srcPt+((*w)+1)*nbComp,pt+i*nbComp);
ret->copyStringInfoFrom(*this);
- return ret;
+ return ret.retn();
}
/*!
*/
DataArrayDouble *DataArrayDouble::selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
int nbComp=getNumberOfComponents();
int oldNbOfTuples=getNumberOfTuples();
*/
DataArrayDouble *DataArrayDouble::selectByTupleId2(int bg, int end2, int step) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
int nbComp=getNumberOfComponents();
int newNbOfTuples=GetNumberOfItemGivenBES(bg,end2,step,"DataArrayDouble::selectByTupleId2 : ");
*/
DataArrayDouble *DataArrayDouble::substr(int tupleIdBg, int tupleIdEnd) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
int nbt=getNumberOfTuples();
if(tupleIdBg<0)
throw INTERP_KERNEL::Exception("DataArrayDouble::substr : The tupleIdBg parameter must be greater than 0 !");
*/
DataArrayDouble *DataArrayDouble::getDifferentValues(double prec, int limitTupleId) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
DataArrayInt *c0=0,*cI0=0;
findCommonTuples(prec,limitTupleId,c0,cI0);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c(c0),cI(cI0);
{
if(!a)
throw INTERP_KERNEL::Exception("DataArrayDouble::setSelectedComponents : input DataArrayDouble is NULL !");
+ checkAllocated();
copyPartOfStringInfoFrom2(compoIds,*a);
std::size_t partOfCompoSz=compoIds.size();
int nbOfCompo=getNumberOfComponents();
- int nbOfTuples=getNumberOfTuples();
+ int nbOfTuples=std::min(getNumberOfTuples(),a->getNumberOfTuples());
const double *ac=a->getConstPointer();
double *nc=getPointer();
for(int i=0;i<nbOfTuples;i++)
int nbOfTuples=getNumberOfTuples();
DataArray::CheckValueInRangeEx(nbOfTuples,bgTuples,endTuples,"invalid tuple value");
DataArray::CheckValueInRangeEx(nbComp,bgComp,endComp,"invalid component value");
- a->checkNbOfElems(newNbOfTuples*newNbOfComp,msg);
- if(strictCompoCompare)
- a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
- double *pt=getPointer()+bgTuples*nbComp+bgComp;
+ bool assignTech=true;
+ if(a->getNbOfElems()==newNbOfTuples*newNbOfComp)
+ {
+ if(strictCompoCompare)
+ a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ }
+ else
+ {
+ a->checkNbOfTuplesAndComp(1,newNbOfComp,msg);
+ assignTech=false;
+ }
const double *srcPt=a->getConstPointer();
- for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
- for(int j=0;j<newNbOfComp;j++,srcPt++)
- pt[j*stepComp]=*srcPt;
+ double *pt=getPointer()+bgTuples*nbComp+bgComp;
+ if(assignTech)
+ {
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ for(int j=0;j<newNbOfComp;j++,srcPt++)
+ pt[j*stepComp]=*srcPt;
+ }
+ else
+ {
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ {
+ const double *srcPt2=srcPt;
+ for(int j=0;j<newNbOfComp;j++,srcPt2++)
+ pt[j*stepComp]=*srcPt2;
+ }
+ }
}
/*!
}
}
+void DataArrayDouble::setPartOfValues4(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception)
+{
+ if(!a)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::setPartOfValues4 : input DataArrayDouble is NULL !");
+ const char msg[]="DataArrayDouble::setPartOfValues4";
+ checkAllocated();
+ a->checkAllocated();
+ int newNbOfTuples=DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg);
+ int newNbOfComp=(int)std::distance(bgComp,endComp);
+ int nbComp=getNumberOfComponents();
+ for(const int *z=bgComp;z!=endComp;z++)
+ DataArray::CheckValueInRange(nbComp,*z,"invalid component id");
+ int nbOfTuples=getNumberOfTuples();
+ DataArray::CheckValueInRangeEx(nbOfTuples,bgTuples,endTuples,"invalid tuple value");
+ bool assignTech=true;
+ if(a->getNbOfElems()==newNbOfTuples*newNbOfComp)
+ {
+ if(strictCompoCompare)
+ a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ }
+ else
+ {
+ a->checkNbOfTuplesAndComp(1,newNbOfComp,msg);
+ assignTech=false;
+ }
+ const double *srcPt=a->getConstPointer();
+ double *pt=getPointer()+bgTuples*nbComp;
+ if(assignTech)
+ {
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ for(const int *z=bgComp;z!=endComp;z++,srcPt++)
+ pt[*z]=*srcPt;
+ }
+ else
+ {
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ {
+ const double *srcPt2=srcPt;
+ for(const int *z=bgComp;z!=endComp;z++,srcPt2++)
+ pt[*z]=*srcPt2;
+ }
+ }
+}
+
+void DataArrayDouble::setPartOfValuesSimple4(double a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception)
+{
+ const char msg[]="DataArrayDouble::setPartOfValuesSimple4";
+ checkAllocated();
+ int newNbOfTuples=DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg);
+ int nbComp=getNumberOfComponents();
+ for(const int *z=bgComp;z!=endComp;z++)
+ DataArray::CheckValueInRange(nbComp,*z,"invalid component id");
+ int nbOfTuples=getNumberOfTuples();
+ DataArray::CheckValueInRangeEx(nbOfTuples,bgTuples,endTuples,"invalid tuple value");
+ double *pt=getPointer()+bgTuples*nbComp;
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ for(const int *z=bgComp;z!=endComp;z++)
+ pt[*z]=a;
+}
+
/*!
* 'this', 'a' and 'tuplesSelec' are expected to be defined. If not an exception will be thrown.
* @param a is an array having exactly the same number of components than 'this'
*/
void DataArrayDouble::setPartOfValuesAdv(const DataArrayDouble *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception)
{
- if(!a)
+ if(!a || !tuplesSelec)
throw INTERP_KERNEL::Exception("DataArrayDouble::setPartOfValuesAdv : input DataArrayDouble is NULL !");
checkAllocated();
a->checkAllocated();
{
if(!other)
throw INTERP_KERNEL::Exception("DataArrayDouble::computeTupleIdsNearTuples : input pointer other is null !");
+ checkAllocated();
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> bbox=computeBBoxPerTuple(eps);
other->checkAllocated();
int nbOfCompo=getNumberOfComponents();
double DataArrayDouble::getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before or call 'getMaxValueInArray' method !");
int nbOfTuples=getNumberOfTuples();
double DataArrayDouble::getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayDouble::getMinValue : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before call 'getMinValueInArray' method !");
int nbOfTuples=getNumberOfTuples();
const double *ptr=getConstPointer();
int nbTuple=getNumberOfTuples();
int nbComps=getNumberOfComponents();
- if(compId>=nbComps)
+ if(compId<0 || compId>=nbComps)
throw INTERP_KERNEL::Exception("DataArrayDouble::accumulate : Invalid compId specified : No such nb of components !");
double ret=0.;
for(int i=0;i<nbTuple;i++)
DataArrayDouble *DataArrayDouble::fromPolarToCart() const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
int nbOfComp=getNumberOfComponents();
if(nbOfComp!=2)
throw INTERP_KERNEL::Exception("DataArrayDouble::fromPolarToCart : must be an array with exactly 2 components !");
DataArrayDouble *DataArrayDouble::fromCylToCart() const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
int nbOfComp=getNumberOfComponents();
if(nbOfComp!=3)
throw INTERP_KERNEL::Exception("DataArrayDouble::fromCylToCart : must be an array with exactly 3 components !");
DataArrayDouble *DataArrayDouble::fromSpherToCart() const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
int nbOfComp=getNumberOfComponents();
if(nbOfComp!=3)
throw INTERP_KERNEL::Exception("DataArrayDouble::fromSpherToCart : must be an array with exactly 3 components !");
DataArrayDouble *DataArrayDouble::doublyContractedProduct() const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
int nbOfComp=getNumberOfComponents();
if(nbOfComp!=6)
throw INTERP_KERNEL::Exception("DataArrayDouble::doublyContractedProduct : must be an array with exactly 6 components !");
DataArrayDouble *DataArrayDouble::eigenValues() const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
int nbOfComp=getNumberOfComponents();
if(nbOfComp!=6)
throw INTERP_KERNEL::Exception("DataArrayDouble::eigenValues : must be an array with exactly 6 components !");
DataArrayDouble *DataArrayDouble::eigenVectors() const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
int nbOfComp=getNumberOfComponents();
if(nbOfComp!=6)
throw INTERP_KERNEL::Exception("DataArrayDouble::eigenVectors : must be an array with exactly 6 components !");
DataArrayDouble *DataArrayDouble::inverse() const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
int nbOfComp=getNumberOfComponents();
if(nbOfComp!=6 && nbOfComp!=9 && nbOfComp!=4)
throw INTERP_KERNEL::Exception("DataArrayDouble::inversion : must be an array with 4,6 or 9 components !");
DataArrayDouble *DataArrayDouble::trace() const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
int nbOfComp=getNumberOfComponents();
if(nbOfComp!=6 && nbOfComp!=9 && nbOfComp!=4)
throw INTERP_KERNEL::Exception("DataArrayDouble::trace : must be an array with 4,6 or 9 components !");
DataArrayDouble *DataArrayDouble::deviator() const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
int nbOfComp=getNumberOfComponents();
if(nbOfComp!=6)
throw INTERP_KERNEL::Exception("DataArrayDouble::deviator : must be an array with exactly 6 components !");
double *ptr=getPointer();
int nbOfElems=getNbOfElems();
std::transform(ptr,ptr+nbOfElems,ptr,std::ptr_fun<double,double>(fabs));
+ declareAsNew();
}
void DataArrayDouble::applyLin(double a, double b, int compoId) throw(INTERP_KERNEL::Exception)
DataArrayInt *DataArrayDouble::getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayDouble::getIdsInRange : this must have exactly one component !");
const double *cptr=getConstPointer();
if(!other)
throw INTERP_KERNEL::Exception("DataArrayDouble::addEqual : input DataArrayDouble instance is NULL !");
const char *msg="Nb of tuples mismatch for DataArrayDouble::addEqual !";
+ checkAllocated();
+ other->checkAllocated();
int nbOfTuple=getNumberOfTuples();
int nbOfTuple2=other->getNumberOfTuples();
int nbOfComp=getNumberOfComponents();
if(!other)
throw INTERP_KERNEL::Exception("DataArrayDouble::substractEqual : input DataArrayDouble instance is NULL !");
const char *msg="Nb of tuples mismatch for DataArrayDouble::substractEqual !";
+ checkAllocated();
+ other->checkAllocated();
int nbOfTuple=getNumberOfTuples();
int nbOfTuple2=other->getNumberOfTuples();
int nbOfComp=getNumberOfComponents();
if(!other)
throw INTERP_KERNEL::Exception("DataArrayDouble::multiplyEqual : input DataArrayDouble instance is NULL !");
const char *msg="Nb of tuples mismatch for DataArrayDouble::multiplyEqual !";
+ checkAllocated();
+ other->checkAllocated();
int nbOfTuple=getNumberOfTuples();
int nbOfTuple2=other->getNumberOfTuples();
int nbOfComp=getNumberOfComponents();
if(!other)
throw INTERP_KERNEL::Exception("DataArrayDouble::divideEqual : input DataArrayDouble instance is NULL !");
const char *msg="Nb of tuples mismatch for DataArrayDouble::divideEqual !";
+ checkAllocated();
+ other->checkAllocated();
int nbOfTuple=getNumberOfTuples();
int nbOfTuple2=other->getNumberOfTuples();
int nbOfComp=getNumberOfComponents();
throw INTERP_KERNEL::Exception("DataArrayInt::pushBackSilent : not available for DataArrayInt with number of components different than 1 !");
}
+void DataArrayInt::pushBackValsSilent(const int *valsBg, const int *valsEnd) throw(INTERP_KERNEL::Exception)
+{
+ int nbCompo=getNumberOfComponents();
+ if(nbCompo==1)
+ _mem.insertAtTheEnd(valsBg,valsEnd);
+ else if(nbCompo==0)
+ {
+ _info_on_compo.resize(1);
+ _mem.insertAtTheEnd(valsBg,valsEnd);
+ }
+ else
+ throw INTERP_KERNEL::Exception("DataArrayInt::pushBackValsSilent : not available for DataArrayInt with number of components different than 1 !");
+}
+
int DataArrayInt::popBackSilent() throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()==1)
return _mem.popBack();
else
- throw INTERP_KERNEL::Exception("DataArrayInt::pushBackSilent : not available for DataArrayInt with number of components different than 1 !");
+ throw INTERP_KERNEL::Exception("DataArrayInt::popBackSilent : not available for DataArrayInt with number of components different than 1 !");
}
void DataArrayInt::pack() const throw(INTERP_KERNEL::Exception)
void DataArrayInt::writeVTK(std::ostream& ofs, int indent, const char *type, const char *nameInFile) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
std::string idt(indent,' ');
ofs << idt << "<DataArray type=\"" << type << "\" Name=\"" << nameInFile << "\" NumberOfComponents=\"" << getNumberOfComponents() << "\"";
ofs << " format=\"ascii\" RangeMin=\"" << getMinValueInArray() << "\" RangeMax=\"" << getMaxValueInArray() << "\">\n" << idt;
*/
void DataArrayInt::transformWithIndArr(const int *indArrBg, const int *indArrEnd) throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("Call transformWithIndArr method on DataArrayInt with only one component, you can call 'rearrange' method before !");
int nbElemsIn=(int)std::distance(indArrBg,indArrEnd);
void DataArrayInt::splitByValueRange(const int *arrBg, const int *arrEnd,
DataArrayInt *& castArr, DataArrayInt *& rankInsideCast, DataArrayInt *& castsPresent) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("Call splitByValueRange method on DataArrayInt with only one component, you can call 'rearrange' method before !");
int nbOfTuples=getNumberOfTuples();
* This method sweeps all the values (tuples) in 'this' (it should be allocated) and for each value v on place i, place indArr[v] will have
* value i.
* indArr[v] where 'indArr' is defined by ['indArrBg','indArrEnd').
- * This method is half/safe that is to say if there is location i so that indArr[v] is not in [0,this->getNumberOfTuples()) an exception
- * will be thrown.
+ * This method is safe that is to say if there is location i so that indArr[v] is not in [0,this->getNumberOfTuples()) an exception
+ * will be thrown. An exception is also thrown if there is a location i so that \a this[i] not in [0,distance(indArrBg,indArrEnd)) !
*/
DataArrayInt *DataArrayInt::transformWithIndArrR(const int *indArrBg, const int *indArrEnd) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("Call transformWithIndArrR method on DataArrayInt with only one component, you can call 'rearrange' method before !");
int nbElemsIn=(int)std::distance(indArrBg,indArrEnd);
int *tmp=ret->getPointer();
for(int i=0;i<nbOfTuples;i++,pt++)
{
- int pos=indArrBg[*pt];
- if(pos>=0 && pos<nbElemsIn)
- tmp[pos]=i;
+ if(*pt>=0 && *pt<nbElemsIn)
+ {
+ int pos=indArrBg[*pt];
+ if(pos>=0 && pos<nbOfTuples)
+ tmp[pos]=i;
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::transformWithIndArrR : error on tuple #" << i << " value of new pos is " << pos << " ( indArrBg[" << *pt << "]) ! Should be in [0," << nbOfTuples << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
else
{
- std::ostringstream oss; oss << "DataArrayInt::transformWithIndArrR : error on tuple #" << i << " value is " << *pt << " and indirectionnal array as a size equal to " << nbElemsIn;
+ std::ostringstream oss; oss << "DataArrayInt::transformWithIndArrR : error on tuple #" << i << " value is " << *pt << " and indirectionnal array as a size equal to " << nbElemsIn << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
*/
DataArrayInt *DataArrayInt::invertArrayO2N2N2O(int newNbOfElem) const
{
- DataArrayInt *ret=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
ret->alloc(newNbOfElem,1);
int nbOfOldNodes=getNumberOfTuples();
const int *old2New=getConstPointer();
for(int i=0;i!=nbOfOldNodes;i++)
if(old2New[i]!=-1)
pt[old2New[i]]=i;
- return ret;
+ return ret.retn();
}
/*!
*/
DataArrayInt *DataArrayInt::invertArrayO2N2N2OBis(int newNbOfElem) const throw(INTERP_KERNEL::Exception)
{
- DataArrayInt *ret=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
ret->alloc(newNbOfElem,1);
int nbOfOldNodes=getNumberOfTuples();
const int *old2New=getConstPointer();
for(int i=nbOfOldNodes-1;i>=0;i--)
if(old2New[i]!=-1)
pt[old2New[i]]=i;
- return ret;
+ return ret.retn();
}
/*!
*/
DataArrayInt *DataArrayInt::invertArrayN2O2O2N(int oldNbOfElem) const
{
- DataArrayInt *ret=DataArrayInt::New();
+ checkAllocated();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
ret->alloc(oldNbOfElem,1);
const int *new2Old=getConstPointer();
int *pt=ret->getPointer();
int nbOfNewElems=getNumberOfTuples();
for(int i=0;i<nbOfNewElems;i++)
pt[new2Old[i]]=i;
- return ret;
+ return ret.retn();
}
bool DataArrayInt::isEqualIfNotWhy(const DataArrayInt& other, std::string& reason) const
*/
DataArrayInt *DataArrayInt::buildPermutationArr(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
if(getNumberOfComponents()!=1 || other.getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::buildPermutationArr : 'this' and 'other' have to have exactly ONE component !");
int nbTuple=getNumberOfTuples();
+ other.checkAllocated();
if(nbTuple!=other.getNumberOfTuples())
throw INTERP_KERNEL::Exception("DataArrayInt::buildPermutationArr : 'this' and 'other' must have the same number of tuple !");
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
DataArrayInt *DataArrayInt::fromNoInterlace() const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
if(_mem.isNull())
throw INTERP_KERNEL::Exception("DataArrayInt::fromNoInterlace : Not defined array !");
int *tab=_mem.fromNoInterlace(getNumberOfComponents());
DataArrayInt *DataArrayInt::toNoInterlace() const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
if(_mem.isNull())
throw INTERP_KERNEL::Exception("DataArrayInt::toNoInterlace : Not defined array !");
int *tab=_mem.toNoInterlace(getNumberOfComponents());
void DataArrayInt::renumberInPlace(const int *old2New)
{
+ checkAllocated();
int nbTuples=getNumberOfTuples();
int nbOfCompo=getNumberOfComponents();
int *tmp=new int[nbTuples*nbOfCompo];
void DataArrayInt::renumberInPlaceR(const int *new2Old)
{
+ checkAllocated();
int nbTuples=getNumberOfTuples();
int nbOfCompo=getNumberOfComponents();
int *tmp=new int[nbTuples*nbOfCompo];
*/
DataArrayInt *DataArrayInt::renumber(const int *old2New) const
{
+ checkAllocated();
int nbTuples=getNumberOfTuples();
int nbOfCompo=getNumberOfComponents();
DataArrayInt *ret=DataArrayInt::New();
DataArrayInt *DataArrayInt::renumberR(const int *new2Old) const
{
+ checkAllocated();
int nbTuples=getNumberOfTuples();
int nbOfCompo=getNumberOfComponents();
DataArrayInt *ret=DataArrayInt::New();
*/
DataArrayInt *DataArrayInt::renumberAndReduce(const int *old2New, int newNbOfTuple) const
{
+ checkAllocated();
int nbTuples=getNumberOfTuples();
int nbOfCompo=getNumberOfComponents();
DataArrayInt *ret=DataArrayInt::New();
*/
DataArrayInt *DataArrayInt::selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const
{
- DataArrayInt *ret=DataArrayInt::New();
+ checkAllocated();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
int nbComp=getNumberOfComponents();
ret->alloc((int)std::distance(new2OldBg,new2OldEnd),nbComp);
ret->copyStringInfoFrom(*this);
for(const int *w=new2OldBg;w!=new2OldEnd;w++,i++)
std::copy(srcPt+(*w)*nbComp,srcPt+((*w)+1)*nbComp,pt+i*nbComp);
ret->copyStringInfoFrom(*this);
- return ret;
+ return ret.retn();
}
/*!
*/
DataArrayInt *DataArrayInt::selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
int nbComp=getNumberOfComponents();
int oldNbOfTuples=getNumberOfTuples();
*/
DataArrayInt *DataArrayInt::selectByTupleId2(int bg, int end2, int step) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
int nbComp=getNumberOfComponents();
int newNbOfTuples=GetNumberOfItemGivenBES(bg,end2,step,"DataArrayInt::selectByTupleId2 : ");
int nbOfTuplesThis=getNumberOfTuples();
if(ranges.empty())
{
- DataArrayInt *ret=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
ret->alloc(0,nbOfComp);
ret->copyStringInfoFrom(*this);
- return ret;
+ return ret.retn();
}
int ref=ranges.front().first;
int nbOfTuples=0;
for(int i=0;i<nbOfTuples;i++)
{
int tmp2=input[i];
- if(tmp2<targetNb)
+ if(tmp2>=0 && tmp2<targetNb)
tmp[tmp2].push_back(i);
else
{
- std::ostringstream oss; oss << "DataArrayInt::changeSurjectiveFormat : At pos " << i << " presence of element " << tmp2 << " higher than " << targetNb;
+ std::ostringstream oss; oss << "DataArrayInt::changeSurjectiveFormat : At pos " << i << " presence of element " << tmp2 << " ! should be in [0," << targetNb << ") !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
*/
DataArrayInt *DataArrayInt::substr(int tupleIdBg, int tupleIdEnd) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
int nbt=getNumberOfTuples();
if(tupleIdBg<0)
throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter must be greater than 0 !");
void DataArrayInt::setSelectedComponents(const DataArrayInt *a, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception)
{
+ if(!a)
+ throw INTERP_KERNEL::Exception("DataArrayInt::setSelectedComponents : input DataArrayInt is NULL !");
+ checkAllocated();
+ a->checkAllocated();
copyPartOfStringInfoFrom2(compoIds,*a);
std::size_t partOfCompoSz=compoIds.size();
int nbOfCompo=getNumberOfComponents();
- int nbOfTuples=getNumberOfTuples();
+ int nbOfTuples=std::min(getNumberOfTuples(),a->getNumberOfTuples());
const int *ac=a->getConstPointer();
int *nc=getPointer();
for(int i=0;i<nbOfTuples;i++)
int nbOfTuples=getNumberOfTuples();
DataArray::CheckValueInRangeEx(nbOfTuples,bgTuples,endTuples,"invalid tuple value");
DataArray::CheckValueInRangeEx(nbComp,bgComp,endComp,"invalid component value");
- a->checkNbOfElems(newNbOfTuples*newNbOfComp,msg);
- if(strictCompoCompare)
- a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ bool assignTech=true;
+ if(a->getNbOfElems()==newNbOfTuples*newNbOfComp)
+ {
+ if(strictCompoCompare)
+ a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ }
+ else
+ {
+ a->checkNbOfTuplesAndComp(1,newNbOfComp,msg);
+ assignTech=false;
+ }
int *pt=getPointer()+bgTuples*nbComp+bgComp;
const int *srcPt=a->getConstPointer();
- for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
- for(int j=0;j<newNbOfComp;j++,srcPt++)
- pt[j*stepComp]=*srcPt;
+ if(assignTech)
+ {
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ for(int j=0;j<newNbOfComp;j++,srcPt++)
+ pt[j*stepComp]=*srcPt;
+ }
+ else
+ {
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ {
+ const int *srcPt2=srcPt;
+ for(int j=0;j<newNbOfComp;j++,srcPt2++)
+ pt[j*stepComp]=*srcPt2;
+ }
+ }
}
/*!
}
}
+void DataArrayInt::setPartOfValues4(const DataArrayInt *a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception)
+{
+ if(!a)
+ throw INTERP_KERNEL::Exception("DataArrayInt::setPartOfValues4 : input DataArrayInt is NULL !");
+ const char msg[]="DataArrayInt::setPartOfValues4";
+ checkAllocated();
+ a->checkAllocated();
+ int newNbOfTuples=DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg);
+ int newNbOfComp=(int)std::distance(bgComp,endComp);
+ int nbComp=getNumberOfComponents();
+ for(const int *z=bgComp;z!=endComp;z++)
+ DataArray::CheckValueInRange(nbComp,*z,"invalid component id");
+ int nbOfTuples=getNumberOfTuples();
+ DataArray::CheckValueInRangeEx(nbOfTuples,bgTuples,endTuples,"invalid tuple value");
+ bool assignTech=true;
+ if(a->getNbOfElems()==newNbOfTuples*newNbOfComp)
+ {
+ if(strictCompoCompare)
+ a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ }
+ else
+ {
+ a->checkNbOfTuplesAndComp(1,newNbOfComp,msg);
+ assignTech=false;
+ }
+ const int *srcPt=a->getConstPointer();
+ int *pt=getPointer()+bgTuples*nbComp;
+ if(assignTech)
+ {
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ for(const int *z=bgComp;z!=endComp;z++,srcPt++)
+ pt[*z]=*srcPt;
+ }
+ else
+ {
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ {
+ const int *srcPt2=srcPt;
+ for(const int *z=bgComp;z!=endComp;z++,srcPt2++)
+ pt[*z]=*srcPt2;
+ }
+ }
+}
+
+void DataArrayInt::setPartOfValuesSimple4(int a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception)
+{
+ const char msg[]="DataArrayInt::setPartOfValuesSimple4";
+ checkAllocated();
+ int newNbOfTuples=DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg);
+ int nbComp=getNumberOfComponents();
+ for(const int *z=bgComp;z!=endComp;z++)
+ DataArray::CheckValueInRange(nbComp,*z,"invalid component id");
+ int nbOfTuples=getNumberOfTuples();
+ DataArray::CheckValueInRangeEx(nbOfTuples,bgTuples,endTuples,"invalid tuple value");
+ int *pt=getPointer()+bgTuples*nbComp;
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ for(const int *z=bgComp;z!=endComp;z++)
+ pt[*z]=a;
+}
+
/*!
* 'this', 'a' and 'tuplesSelec' are expected to be defined. If not an exception will be thrown.
* @param a is an array having exactly the same number of components than 'this'
*/
void DataArrayInt::setPartOfValuesAdv(const DataArrayInt *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception)
{
- if(!a)
+ if(!a || !tuplesSelec)
throw INTERP_KERNEL::Exception("DataArrayInt::setPartOfValuesAdv : DataArrayInt pointer in input is NULL !");
checkAllocated();
a->checkAllocated();
DataArrayInt *DataArrayInt::getIdsEqual(int val) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::getIdsEqual : the array must have only one component, you can call 'rearrange' method before !");
const int *cptr=getConstPointer();
DataArrayInt *DataArrayInt::getIdsNotEqual(int val) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::getIdsNotEqual : the array must have only one component, you can call 'rearrange' method before !");
const int *cptr=getConstPointer();
*/
int DataArrayInt::changeValue(int oldValue, int newValue) throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::changeValue : the array must have only one component, you can call 'rearrange' method before !");
- checkAllocated();
int *start=getPointer();
int *end2=start+getNbOfElems();
int ret=0;
*/
int DataArrayInt::locateTuple(const std::vector<int>& tupl) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
int nbOfCompo=getNumberOfComponents();
if(nbOfCompo==0)
throw INTERP_KERNEL::Exception("DataArrayInt::locateTuple : 0 components in 'this' !");
*/
int DataArrayInt::search(const std::vector<int>& vals) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
int nbOfCompo=getNumberOfComponents();
if(nbOfCompo!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::search : works only for DataArrayInt instance with one component !");
*/
int DataArrayInt::locateValue(int value) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::presenceOfValue : the array must have only one component, you can call 'rearrange' method before !");
const int *cptr=getConstPointer();
*/
int DataArrayInt::locateValue(const std::vector<int>& vals) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::presenceOfValue : the array must have only one component, you can call 'rearrange' method before !");
std::set<int> vals2(vals.begin(),vals.end());
const int *ptr=getConstPointer();
int nbTuple=getNumberOfTuples();
int nbComps=getNumberOfComponents();
- if(compId>=nbComps)
+ if(compId<0 || compId>=nbComps)
throw INTERP_KERNEL::Exception("DataArrayInt::accumulate : Invalid compId specified : No such nb of components !");
int ret=0;
for(int i=0;i<nbTuple;i++)
int DataArrayInt::getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::getMaxValue : must be applied on DataArrayInt with only one component !");
int nbOfTuples=getNumberOfTuples();
int DataArrayInt::getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::getMaxValue : must be applied on DataArrayInt with only one component !");
int nbOfTuples=getNumberOfTuples();
int *ptr=getPointer();
int nbOfElems=getNbOfElems();
std::transform(ptr,ptr+nbOfElems,ptr,std::ptr_fun<int,int>(std::abs));
+ declareAsNew();
}
void DataArrayInt::applyLin(int a, int b, int compoId) throw(INTERP_KERNEL::Exception)
*/
DataArrayInt *DataArrayInt::getIdsInRange(int vmin, int vmax) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::getIdsInRange : this must have exactly one component !");
const int *cptr=getConstPointer();
{
(*it)->checkAllocated();
if((*it)->getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayInt::BuildUnion : only single component allowed !");
+ throw INTERP_KERNEL::Exception("DataArrayInt::BuildIntersection : only single component allowed !");
int tmp1;
valm=std::min((*it)->getMinValue(tmp1),valm);
}
if(valm<0)
- throw INTERP_KERNEL::Exception("DataArrayInt::BuildUnion : a negative value has been detected !");
+ throw INTERP_KERNEL::Exception("DataArrayInt::BuildIntersection : a negative value has been detected !");
//
std::set<int> r;
for(std::vector<const DataArrayInt *>::const_iterator it=a.begin();it!=a.end();it++)
if(!other)
throw INTERP_KERNEL::Exception("DataArrayInt::addEqual : input DataArrayInt instance is NULL !");
const char *msg="Nb of tuples mismatch for DataArrayInt::addEqual !";
+ checkAllocated(); other->checkAllocated();
int nbOfTuple=getNumberOfTuples();
int nbOfTuple2=other->getNumberOfTuples();
int nbOfComp=getNumberOfComponents();
if(!other)
throw INTERP_KERNEL::Exception("DataArrayInt::substractEqual : input DataArrayInt instance is NULL !");
const char *msg="Nb of tuples mismatch for DataArrayInt::substractEqual !";
+ checkAllocated(); other->checkAllocated();
int nbOfTuple=getNumberOfTuples();
int nbOfTuple2=other->getNumberOfTuples();
int nbOfComp=getNumberOfComponents();
if(!other)
throw INTERP_KERNEL::Exception("DataArrayInt::multiplyEqual : input DataArrayInt instance is NULL !");
const char *msg="Nb of tuples mismatch for DataArrayInt::multiplyEqual !";
+ checkAllocated(); other->checkAllocated();
int nbOfTuple=getNumberOfTuples();
int nbOfTuple2=other->getNumberOfTuples();
int nbOfComp=getNumberOfComponents();
if(!other)
throw INTERP_KERNEL::Exception("DataArrayInt::divideEqual : input DataArrayInt instance is NULL !");
const char *msg="Nb of tuples mismatch for DataArrayInt::divideEqual !";
+ checkAllocated(); other->checkAllocated();
int nbOfTuple=getNumberOfTuples();
int nbOfTuple2=other->getNumberOfTuples();
int nbOfComp=getNumberOfComponents();
if(!other)
throw INTERP_KERNEL::Exception("DataArrayInt::modulusEqual : input DataArrayInt instance is NULL !");
const char *msg="Nb of tuples mismatch for DataArrayInt::modulusEqual !";
+ checkAllocated(); other->checkAllocated();
int nbOfTuple=getNumberOfTuples();
int nbOfTuple2=other->getNumberOfTuples();
int nbOfComp=getNumberOfComponents();
MEDCOUPLING_EXPORT void cpyFrom(const DataArrayDouble& other) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reserve(int nbOfElems) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void pushBackSilent(double val) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void pushBackValsSilent(const double *valsBg, const double *valsEnd) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT double popBackSilent() throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void pack() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getNbOfElemAllocated() const { return _mem.getNbOfElemAllocated(); }
MEDCOUPLING_EXPORT void setPartOfValuesSimple2(double a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValues3(const DataArrayDouble *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValuesSimple3(double a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setPartOfValues4(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setPartOfValuesSimple4(double a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValuesAdv(const DataArrayDouble *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setContigPartOfSelectedValues(int tupleIdStart, const DataArrayDouble *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setContigPartOfSelectedValues2(int tupleIdStart, const DataArrayDouble *a, int bg, int end2, int step) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void cpyFrom(const DataArrayInt& other) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reserve(int nbOfElems) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void pushBackSilent(int val) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void pushBackValsSilent(const int *valsBg, const int *valsEnd) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int popBackSilent() throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void pack() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getNbOfElemAllocated() const { return _mem.getNbOfElemAllocated(); }
MEDCOUPLING_EXPORT void setPartOfValuesSimple2(int a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValues3(const DataArrayInt *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValuesSimple3(int a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setPartOfValues4(const DataArrayInt *a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setPartOfValuesSimple4(int a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValuesAdv(const DataArrayInt *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setContigPartOfSelectedValues(int tupleIdStart, const DataArrayInt*a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setContigPartOfSelectedValues2(int tupleIdStart, const DataArrayInt *a, int bg, int end2, int step) throw(INTERP_KERNEL::Exception);
virtual int getMeshDimension() const = 0;
virtual DataArrayDouble *getCoordinatesAndOwner() const = 0;
virtual DataArrayDouble *getBarycenterAndOwner() const = 0;
+ virtual DataArrayInt *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception) = 0;
virtual int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const = 0;
virtual INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const = 0;
virtual std::set<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const = 0;
if(_src_method!=srcField->getDiscretization()->getStringRepr())
throw INTERP_KERNEL::Exception("Incoherency with prepare call for source field");
MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(MEDCouplingFieldDiscretization::getTypeOfFieldFromStringRepr(_target_method.c_str()),srcField->getTimeDiscretization());
- ret->copyTinyAttrFrom(srcField);
+ ret->copyAllTinyAttrFrom(srcField);
ret->setNature(srcField->getNature());
ret->setMesh(_target_mesh);
transfer(srcField,ret,dftValue);
{
if(_target_method!=targetField->getDiscretization()->getStringRepr())
throw INTERP_KERNEL::Exception("Incoherency with prepare call for target field");
- MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(MEDCouplingFieldDiscretization::getTypeOfFieldFromStringRepr(_target_method.c_str()),targetField->getTimeDiscretization());
- ret->copyTinyAttrFrom(targetField);
+ MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(MEDCouplingFieldDiscretization::getTypeOfFieldFromStringRepr(_src_method.c_str()),targetField->getTimeDiscretization());
+ ret->copyAllTinyAttrFrom(targetField);
ret->setNature(targetField->getNature());
ret->setMesh(_src_mesh);
reverseTransfer(ret,targetField,dftValue);
std::set<INTERP_KERNEL::NormalizedCellType> MEDCouplingStructuredMesh::getAllGeoTypes() const
{
- INTERP_KERNEL::NormalizedCellType ret;
- switch(getMeshDimension())
- {
- case 3:
- ret=INTERP_KERNEL::NORM_HEXA8;
- break;
- case 2:
- ret=INTERP_KERNEL::NORM_QUAD4;
- break;
- case 1:
- ret=INTERP_KERNEL::NORM_SEG2;
- break;
- default:
- throw INTERP_KERNEL::Exception("Unexpected dimension for MEDCouplingStructuredMesh::getAllGeoTypes !");
- }
std::set<INTERP_KERNEL::NormalizedCellType> ret2;
- ret2.insert(ret);
+ ret2.insert(getTypeOfCell(0));
return ret2;
}
int MEDCouplingStructuredMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const
{
int ret=getNumberOfCells();
- int dim=getMeshDimension();
- switch(type)
+ if(type==getTypeOfCell(0))
+ return ret;
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getTypeOfCell(0));
+ std::ostringstream oss; oss << "MEDCouplingStructuredMesh::getNumberOfCellsWithType : no specified type ! Type available is " << cm.getRepr() << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
+DataArrayInt *MEDCouplingStructuredMesh::giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+ if(getTypeOfCell(0)==type)
{
- case INTERP_KERNEL::NORM_HEXA8:
- if(dim==3)
- return ret;
- case INTERP_KERNEL::NORM_QUAD4:
- if(dim==2)
- return ret;
- case INTERP_KERNEL::NORM_SEG2:
- if(dim==1)
- return ret;
- default:
- throw INTERP_KERNEL::Exception("Unexpected dimension for MEDCouplingStructuredMesh::getTypeOfCell !");
+ ret->alloc(getNumberOfCells(),1);
+ ret->iota(0);
}
- return 0;
+ else
+ ret->alloc(0,1);
+ return ret.retn();
+}
+
+DataArrayInt *MEDCouplingStructuredMesh::computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception)
+{
+ int nbCells=getNumberOfCells();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+ ret->alloc(nbCells,1);
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getTypeOfCell(0));
+ ret->fillWithValue((int)cm.getNumberOfNodes());
+ return ret.retn();
}
void MEDCouplingStructuredMesh::getNodeIdsOfCell(int cellId, std::vector<int>& conn) const
INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const;
std::set<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
+ DataArrayInt *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
static void GetPosFromId(int nodeId, int meshDim, const int *split, int *res);
void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
std::size_t getHeapMemorySize() const;
DataArrayInt *revDesc=DataArrayInt::New();
DataArrayInt *revDescIndx=DataArrayInt::New();
//
- MEDCouplingUMesh *meshDM1=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> meshDM1=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx);
revDesc->decrRef();
desc->decrRef();
descIndx->decrRef();
boundaryCells.push_back(i);
revDescIndx->decrRef();
MEDCouplingPointSet *ret=meshDM1->buildPartOfMySelf(&boundaryCells[0],&boundaryCells[0]+boundaryCells.size(),keepCoords);
- meshDM1->decrRef();
return ret;
}
{
// Connectivity
const int *recvBuffer=a1->getConstPointer();
- DataArrayInt* myConnecIndex=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> myConnecIndex=DataArrayInt::New();
myConnecIndex->alloc(tinyInfo[6]+1,1);
std::copy(recvBuffer,recvBuffer+tinyInfo[6]+1,myConnecIndex->getPointer());
- DataArrayInt* myConnec=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> myConnec=DataArrayInt::New();
myConnec->alloc(tinyInfo[7],1);
std::copy(recvBuffer+tinyInfo[6]+1,recvBuffer+tinyInfo[6]+1+tinyInfo[7],myConnec->getPointer());
- setConnectivity(myConnec, myConnecIndex) ;
- myConnec->decrRef();
- myConnecIndex->decrRef();
+ setConnectivity(myConnec, myConnecIndex);
}
}
types.insert((INTERP_KERNEL::NormalizedCellType)conn[connIndex[*work]]);
connRetWork=std::copy(conn+connIndex[*work],conn+connIndex[*work+1],connRetWork);
}
- DataArrayInt *connRetArr=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> connRetArr=DataArrayInt::New();
connRetArr->useArray(connRet,true,CPP_DEALLOC,connIndexRet[nbOfElemsRet],1);
- DataArrayInt *connIndexRetArr=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> connIndexRetArr=DataArrayInt::New();
connIndexRetArr->useArray(connIndexRet,true,CPP_DEALLOC,(int)nbOfElemsRet+1,1);
ret->setConnectivity(connRetArr,connIndexRetArr,false);
ret->_types=types;
- connRetArr->decrRef();
- connIndexRetArr->decrRef();
ret->copyTinyInfoFrom(this);
return ret.retn();
}
std::string name="MeasureOfMesh_";
name+=getName();
int nbelem=getNumberOfCells();
- MEDCouplingFieldDouble *field=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
field->setName(name.c_str());
- DataArrayDouble* array=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> array=DataArrayDouble::New();
array->alloc(nbelem,1);
double *area_vol=array->getPointer();
- field->setArray(array) ;
- array->decrRef();
+ field->setArray(array) ; array=0;
field->setMesh(const_cast<MEDCouplingUMesh *>(this));
field->synchronizeTimeWithMesh();
if(getMeshDimension()!=-1)
{
area_vol[0]=std::numeric_limits<double>::max();
}
- return field;
+ return field.retn();
}
/*!
std::string name="PartMeasureOfMesh_";
name+=getName();
int nbelem=(int)std::distance(begin,end);
- DataArrayDouble* array=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> array=DataArrayDouble::New();
array->setName(name.c_str());
array->alloc(nbelem,1);
double *area_vol=array->getPointer();
{
area_vol[0]=std::numeric_limits<double>::max();
}
- return array;
+ return array.retn();
}
/*!
*/
MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureFieldOnNode(bool isAbs) const
{
- MEDCouplingFieldDouble *tmp=getMeasureField(isAbs);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> tmp=getMeasureField(isAbs);
std::string name="MeasureOnNodeOfMesh_";
name+=getName();
int nbNodes=getNumberOfNodes();
- MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_NODES);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_NODES);
double cst=1./((double)getMeshDimension()+1.);
- DataArrayDouble* array=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> array=DataArrayDouble::New();
array->alloc(nbNodes,1);
double *valsToFill=array->getPointer();
std::fill(valsToFill,valsToFill+nbNodes,0.);
const double *values=tmp->getArray()->getConstPointer();
- DataArrayInt *da=DataArrayInt::New();
- DataArrayInt *daInd=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> daInd=DataArrayInt::New();
getReverseNodalConnectivity(da,daInd);
const int *daPtr=da->getConstPointer();
const int *daIPtr=daInd->getConstPointer();
for(const int *cell=daPtr+daIPtr[i];cell!=daPtr+daIPtr[i+1];cell++)
valsToFill[i]+=cst*values[*cell];
ret->setMesh(this);
- da->decrRef();
- daInd->decrRef();
ret->setArray(array);
- array->decrRef();
- tmp->decrRef();
- return ret;
+ return ret.retn();
}
/*!
{
if((getMeshDimension()!=2) && (getMeshDimension()!=1 || getSpaceDimension()!=2))
throw INTERP_KERNEL::Exception("Expected a umesh with ( meshDim == 2 spaceDim == 2 or 3 ) or ( meshDim == 1 spaceDim == 2 ) !");
- MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
- DataArrayDouble *array=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> array=DataArrayDouble::New();
int nbOfCells=getNumberOfCells();
int nbComp=getMeshDimension()+1;
array->alloc(nbOfCells,nbComp);
{
if(getSpaceDimension()==3)
{
- DataArrayDouble *loc=getBarycenterAndOwner();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> loc=getBarycenterAndOwner();
const double *locPtr=loc->getConstPointer();
for(int i=0;i<nbOfCells;i++,vals+=3)
{
double n=INTERP_KERNEL::norm<3>(vals);
std::transform(vals,vals+3,vals,std::bind2nd(std::multiplies<double>(),1./n));
}
- loc->decrRef();
}
else
{
}
}
ret->setArray(array);
- array->decrRef();
ret->setMesh(this);
ret->synchronizeTimeWithSupport();
- return ret;
+ return ret.retn();
}
/*!
{
if((getMeshDimension()!=2) && (getMeshDimension()!=1 || getSpaceDimension()!=2))
throw INTERP_KERNEL::Exception("Expected a umesh with ( meshDim == 2 spaceDim == 2 or 3 ) or ( meshDim == 1 spaceDim == 2 ) !");
- MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
- DataArrayDouble *array=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> array=DataArrayDouble::New();
std::size_t nbelems=std::distance(begin,end);
int nbComp=getMeshDimension()+1;
array->alloc((int)nbelems,nbComp);
{
if(getSpaceDimension()==3)
{
- DataArrayDouble *loc=getPartBarycenterAndOwner(begin,end);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> loc=getPartBarycenterAndOwner(begin,end);
const double *locPtr=loc->getConstPointer();
for(const int *i=begin;i!=end;i++,vals+=3,locPtr+=3)
{
double n=INTERP_KERNEL::norm<3>(vals);
std::transform(vals,vals+3,vals,std::bind2nd(std::multiplies<double>(),1./n));
}
- loc->decrRef();
}
else
{
}
}
ret->setArray(array);
- array->decrRef();
ret->setMesh(this);
ret->synchronizeTimeWithSupport();
- return ret;
+ return ret.retn();
}
/*!
throw INTERP_KERNEL::Exception("Expected a umesh with meshDim == 1 for buildDirectionVectorField !");
if(_types.size()!=1 || *(_types.begin())!=INTERP_KERNEL::NORM_SEG2)
throw INTERP_KERNEL::Exception("Expected a umesh with only NORM_SEG2 type of elements for buildDirectionVectorField !");
- MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
- DataArrayDouble *array=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> array=DataArrayDouble::New();
int nbOfCells=getNumberOfCells();
int spaceDim=getSpaceDimension();
array->alloc(nbOfCells,spaceDim);
pt=std::transform(coo+conn[1]*spaceDim,coo+(conn[1]+1)*spaceDim,coo+conn[0]*spaceDim,pt,std::minus<double>());
}
ret->setArray(array);
- array->decrRef();
ret->setMesh(this);
ret->synchronizeTimeWithSupport();
- return ret;
+ return ret.retn();
}
/*!
throw INTERP_KERNEL::Exception("Expected a umesh with only NORM_SEG2 type of elements for project1D !");
if(getSpaceDimension()!=3)
throw INTERP_KERNEL::Exception("Expected a umesh with spaceDim==3 for project1D !");
- MEDCouplingFieldDouble *f=buildDirectionVectorField();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f=buildDirectionVectorField();
const double *fPtr=f->getArray()->getConstPointer();
double tmp[3];
for(int i=0;i<getNumberOfCells();i++)
double n1=INTERP_KERNEL::norm<3>(tmp);
n1/=INTERP_KERNEL::norm<3>(tmp1);
if(n1>eps)
- {
- f->decrRef();
- throw INTERP_KERNEL::Exception("UMesh::Projection 1D failed !");
- }
+ throw INTERP_KERNEL::Exception("UMesh::Projection 1D failed !");
}
const double *coo=getCoords()->getConstPointer();
for(int i=0;i<getNumberOfNodes();i++)
std::transform(tmp,tmp+3,v,tmp,std::multiplies<double>());
res[i]=std::accumulate(tmp,tmp+3,0.);
}
- f->decrRef();
}
/*!
}
zipCoords();
int oldNbOfNodes=getNumberOfNodes();
- DataArrayDouble *newCoords=0;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> newCoords;
switch(policy)
{
case 0:
throw INTERP_KERNEL::Exception("Not implemented extrusion policy : must be in (0) !");
}
setCoords(newCoords);
- newCoords->decrRef();
- MEDCouplingUMesh *ret=buildExtrudedMeshFromThisLowLev(oldNbOfNodes,isQuad);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=buildExtrudedMeshFromThisLowLev(oldNbOfNodes,isQuad);
updateTime();
- return ret;
+ return ret.retn();
}
/*!
int nbOf1DCells=mesh1D->getNumberOfCells();
if(nbOf1DCells<2)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D : impossible to detect any angle of rotation ! Change extrusion policy 1->0 !");
- DataArrayDouble *ret=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
int nbOfLevsInVec=nbOf1DCells+1;
ret->alloc(oldNbOfNodes*nbOfLevsInVec,2);
double *retPtr=ret->getPointer();
retPtr=std::copy(getCoords()->getConstPointer(),getCoords()->getConstPointer()+getCoords()->getNbOfElems(),retPtr);
- MEDCouplingUMesh *tmp=MEDCouplingUMesh::New();
- DataArrayDouble *tmp2=getCoords()->deepCpy();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> tmp=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp2=getCoords()->deepCpy();
tmp->setCoords(tmp2);
- tmp2->decrRef();
const double *coo1D=mesh1D->getCoords()->getConstPointer();
const int *conn1D=mesh1D->getNodalConnectivity()->getConstPointer();
const int *connI1D=mesh1D->getNodalConnectivityIndex()->getConstPointer();
tmp->rotate(end,0,angle);
retPtr=std::copy(tmp2->getConstPointer(),tmp2->getConstPointer()+tmp2->getNbOfElems(),retPtr);
}
- tmp->decrRef();
- return ret;
+ return ret.retn();
}
/*!
int nbOf1DCells=mesh1D->getNumberOfCells();
if(nbOf1DCells<2)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D : impossible to detect any angle of rotation ! Change extrusion policy 1->0 !");
- DataArrayDouble *ret=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
int nbOfLevsInVec=nbOf1DCells+1;
ret->alloc(oldNbOfNodes*nbOfLevsInVec,3);
double *retPtr=ret->getPointer();
retPtr=std::copy(getCoords()->getConstPointer(),getCoords()->getConstPointer()+getCoords()->getNbOfElems(),retPtr);
- MEDCouplingUMesh *tmp=MEDCouplingUMesh::New();
- DataArrayDouble *tmp2=getCoords()->deepCpy();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> tmp=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp2=getCoords()->deepCpy();
tmp->setCoords(tmp2);
- tmp2->decrRef();
const double *coo1D=mesh1D->getCoords()->getConstPointer();
const int *conn1D=mesh1D->getNodalConnectivity()->getConstPointer();
const int *connI1D=mesh1D->getNodalConnectivityIndex()->getConstPointer();
}
retPtr=std::copy(tmp2->getConstPointer(),tmp2->getConstPointer()+tmp2->getNbOfElems(),retPtr);
}
- tmp->decrRef();
- return ret;
+ return ret.retn();
}
/*!
MEDCouplingUMesh *ret=MEDCouplingUMesh::New("Extruded",getMeshDimension()+1);
const int *conn=_nodal_connec->getConstPointer();
const int *connI=_nodal_connec_index->getConstPointer();
- DataArrayInt *newConn=DataArrayInt::New();
- DataArrayInt *newConnI=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newConn=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newConnI=DataArrayInt::New();
newConnI->alloc(nbOf3DCells+1,1);
int *newConnIPtr=newConnI->getPointer();
*newConnIPtr++=0;
}
}
ret->setConnectivity(newConn,newConnI,true);
- newConn->decrRef();
- newConnI->decrRef();
ret->setCoords(getCoords());
return ret;
}
_types.clear();
for(int i=0;i<nbOfCells;i++,ociptr++)
{
- INTERP_KERNEL::NormalizedCellType type=getTypeOfCell(i);
+ INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)icptr[iciptr[i]];
const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
if(!cm.isQuadratic())
{
setConnectivity(newConn,newConnI,false);
}
+/*!
+ * This method converts all linear cell in \a this to quadratic one.
+ * Contrary to MEDCouplingUMesh::convertQuadraticCellsToLinear method, here it is needed to specify the target
+ * type of cells expected. For example INTERP_KERNEL::NORM_TRI3 can be converted to INTERP_KERNEL::NORM_TRI6 if \a conversionType is equal to 0 (the default)
+ * or to INTERP_KERNEL::NORM_TRI7 if \a conversionType is equal to 1. All non linear cells and polyhedron in \a this are let untouched.
+ * Contrary to MEDCouplingUMesh::convertQuadraticCellsToLinear method, the coordinates in \a this can be become bigger. All created nodes will be put at the
+ * end of the existing coordinates.
+ *
+ * \param [in] conversionType specifies the type of conversion expected. Only 0 (default) and 1 are supported presently. 0 those that creates the 'most' simple
+ * corresponding quadratic cells. 1 is those creating the 'most' complex.
+ * \return a newly created DataArrayInt instance that the caller should deal with containing cell ids of converted cells.
+ *
+ * \throw if \a this is not fully defined. It throws too if \a conversionType is not in [0,1].
+ *
+ * \sa MEDCouplingUMesh::convertQuadraticCellsToLinear
+ */
+DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic(int conversionType) throw(INTERP_KERNEL::Exception)
+{
+ DataArrayInt *conn=0,*connI=0;
+ DataArrayDouble *coords=0;
+ std::set<INTERP_KERNEL::NormalizedCellType> types;
+ checkFullyDefined();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret,connSafe,connISafe;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsSafe;
+ int meshDim=getMeshDimension();
+ switch(conversionType)
+ {
+ case 0:
+ switch(meshDim)
+ {
+ case 1:
+ ret=convertLinearCellsToQuadratic1D0(conn,connI,coords,types);
+ connSafe=conn; connISafe=connI; coordsSafe=coords;
+ case 2:
+ ret=convertLinearCellsToQuadratic2D0(conn,connI,coords,types);
+ connSafe=conn; connISafe=connI; coordsSafe=coords;
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertLinearCellsToQuadratic : conversion of type 0 mesh dimensions available are [1] !");
+ }
+ //case 1:
+ //return convertLinearCellsToQuadratic1();
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertLinearCellsToQuadratic : conversion type available are 0 (default, the simplest) and 1 (the most complex) !");
+ }
+ setConnectivity(connSafe,connISafe,false);
+ _types=types;
+ setCoords(coordsSafe);
+ return ret.retn();
+}
+
+/*!
+ * Implementes \a conversionType 0 for meshes with meshDim = 1, of MEDCouplingUMesh::convertLinearCellsToQuadratic method.
+ * \return a newly created DataArrayInt instance that the caller should deal with containing cell ids of converted cells.
+ * \sa MEDCouplingUMesh::convertLinearCellsToQuadratic.
+ */
+DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic1D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> bary=getBarycenterAndOwner();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newConn=DataArrayInt::New(); newConn->alloc(0,1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newConnI=DataArrayInt::New(); newConnI->alloc(1,1); newConnI->setIJ(0,0,0);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New(); ret->alloc(0,1);
+ int nbOfCells=getNumberOfCells();
+ int nbOfNodes=getNumberOfNodes();
+ const int *cPtr=_nodal_connec->getConstPointer();
+ const int *icPtr=_nodal_connec_index->getConstPointer();
+ int lastVal=0,offset=nbOfNodes;
+ for(int i=0;i<nbOfCells;i++,icPtr++)
+ {
+ INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)cPtr[*icPtr];
+ if(type==INTERP_KERNEL::NORM_SEG2)
+ {
+ types.insert(INTERP_KERNEL::NORM_SEG3);
+ newConn->pushBackSilent((int)INTERP_KERNEL::NORM_SEG3);
+ newConn->pushBackValsSilent(cPtr+cPtr[0]+1,cPtr+cPtr[0]+3);
+ newConn->pushBackSilent(offset++);
+ newConnI->pushBackSilent(lastVal+4);
+ ret->pushBackSilent(i);
+ lastVal+=4;
+ }
+ else
+ {
+ types.insert(type);
+ int tmp=lastVal+(icPtr[1]-icPtr[0]);
+ newConnI->pushBackSilent(tmp);
+ newConn->pushBackValsSilent(cPtr+cPtr[0],cPtr+cPtr[1]);
+ lastVal=tmp;
+ }
+ }
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp=bary->selectByTupleIdSafe(ret->begin(),ret->end());
+ conn=newConn.retn(); connI=newConnI.retn(); coords=DataArrayDouble::Aggregate(getCoords(),tmp);
+ return ret.retn();
+}
+
+/*!
+ * Implementes \a conversionType 0 for meshes with meshDim = 2, of MEDCouplingUMesh::convertLinearCellsToQuadratic method.
+ * \return a newly created DataArrayInt instance that the caller should deal with containing cell ids of converted cells.
+ * \sa MEDCouplingUMesh::convertLinearCellsToQuadratic.
+ */
+DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic2D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> desc(DataArrayInt::New()),descI(DataArrayInt::New());
+ DataArrayInt *tmp2=DataArrayInt::New(),*tmp3=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m1D=buildDescendingConnectivity2(desc,descI,tmp2,tmp3); tmp2->decrRef(); tmp3->decrRef();
+ DataArrayInt *conn1D=0,*conn1DI=0;
+ std::set<INTERP_KERNEL::NormalizedCellType> types1D;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret1D=m1D->convertLinearCellsToQuadratic1D0(conn1D,conn1DI,coords,types1D); ret1D=0;
+ return 0;//tony
+}
+
/*!
* This method tessallates 'this' so that the number of cells remains the same.
* This method works only for meshes with spaceDim equal to 2 and meshDim equal to 2.
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
ret->setMesh(this);
int nbOfCells=getNumberOfCells();
- DataArrayDouble *arr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::New();
arr->alloc(nbOfCells,1);
double *pt=arr->getPointer();
ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef.
- arr->decrRef();
const int *conn=_nodal_connec->getConstPointer();
const int *connI=_nodal_connec_index->getConstPointer();
const double *coo=_coords->getConstPointer();
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
ret->setMesh(this);
int nbOfCells=getNumberOfCells();
- DataArrayDouble *arr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::New();
arr->alloc(nbOfCells,1);
double *pt=arr->getPointer();
ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef.
- arr->decrRef();
const int *conn=_nodal_connec->getConstPointer();
const int *connI=_nodal_connec_index->getConstPointer();
const double *coo=_coords->getConstPointer();
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
ret->setMesh(this);
int nbOfCells=getNumberOfCells();
- DataArrayDouble *arr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::New();
arr->alloc(nbOfCells,1);
double *pt=arr->getPointer();
ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef.
- arr->decrRef();
const int *conn=_nodal_connec->getConstPointer();
const int *connI=_nodal_connec_index->getConstPointer();
const double *coo=_coords->getConstPointer();
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
ret->setMesh(this);
int nbOfCells=getNumberOfCells();
- DataArrayDouble *arr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::New();
arr->alloc(nbOfCells,1);
double *pt=arr->getPointer();
ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef.
- arr->decrRef();
const int *conn=_nodal_connec->getConstPointer();
const int *connI=_nodal_connec_index->getConstPointer();
const double *coo=_coords->getConstPointer();
}
std::vector<const MEDCouplingPointSet *> aps(a.size());
std::copy(a.begin(),a.end(),aps.begin());
- DataArrayDouble *pts=MergeNodesArray(aps);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> pts=MergeNodesArray(aps);
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New("merge",meshDim);
ret->setCoords(pts);
- pts->decrRef();
- DataArrayInt *c=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c=DataArrayInt::New();
c->alloc(meshLgth,1);
int *cPtr=c->getPointer();
- DataArrayInt *cI=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cI=DataArrayInt::New();
cI->alloc(nbOfCells+1,1);
int *cIPtr=cI->getPointer();
*cIPtr++=0;
}
//
ret->setConnectivity(c,cI,true);
- c->decrRef();
- cI->decrRef();
return ret.retn();
}
meshLgth+=(*iter)->getMeshLength();
meshIndexLgth+=(*iter)->getNumberOfCells();
}
- DataArrayInt *nodal=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodal=DataArrayInt::New();
nodal->alloc(meshLgth,1);
int *nodalPtr=nodal->getPointer();
- DataArrayInt *nodalIndex=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodalIndex=DataArrayInt::New();
nodalIndex->alloc(meshIndexLgth+1,1);
int *nodalIndexPtr=nodalIndex->getPointer();
int offset=0;
ret->setMeshDimension(meshDim);
ret->setConnectivity(nodal,nodalIndex,true);
ret->setCoords(coords);
- nodalIndex->decrRef();
- nodal->decrRef();
return ret;
}
MEDCouplingUMesh *MEDCouplingUMesh::FuseUMeshesOnSameCoords(const std::vector<const MEDCouplingUMesh *>& meshes, int compType, std::vector<DataArrayInt *>& corr)
{
//All checks are delegated to MergeUMeshesOnSameCoords
- MEDCouplingUMesh *ret=MergeUMeshesOnSameCoords(meshes);
- DataArrayInt *o2n=ret->zipConnectivityTraducer(compType);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MergeUMeshesOnSameCoords(meshes);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n=ret->zipConnectivityTraducer(compType);
corr.resize(meshes.size());
std::size_t nbOfMeshes=meshes.size();
int offset=0;
tmp->setName(meshes[i]->getName());
corr[i]=tmp;
}
- o2n->decrRef();
- return ret;
+ return ret.retn();
}
/*!
MEDCOUPLING_EXPORT bool isFullyQuadratic() const;
MEDCOUPLING_EXPORT bool isPresenceOfQuadratic() const;
MEDCOUPLING_EXPORT void convertQuadraticCellsToLinear() throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *convertLinearCellsToQuadratic(int conversionType=0) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void tessellate2D(double eps) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void tessellate2DCurve(double eps) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception);
static bool AreCellsEqualInPool(const std::vector<int>& candidates, int compType, const int *conn, const int *connI, DataArrayInt *result) ;
MEDCouplingUMesh *buildPartOfMySelfKeepCoords(const int *begin, const int *end) const;
MEDCouplingUMesh *buildPartOfMySelfKeepCoords2(int start, int end, int step) const;
+ DataArrayInt *convertLinearCellsToQuadratic1D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *convertLinearCellsToQuadratic2D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const throw(INTERP_KERNEL::Exception);
template<int SPACEDIM>
void getCellsContainingPointsAlg(const double *coords, const double *pos, int nbOfPoints,
double eps, std::vector<int>& elts, std::vector<int>& eltsIndex) const;
return _types;
}
+DataArrayInt *MEDCouplingUMeshDesc::giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception("MEDCouplingUMeshDesc::giveCellsWithType : not implemented yet !");
+}
+
+DataArrayInt *MEDCouplingUMeshDesc::computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception("MEDCouplingUMeshDesc::computeNbOfNodesPerCell : not implemented yet !");
+}
+
int MEDCouplingUMeshDesc::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const
{
const int *desc_connec=_desc_connec->getConstPointer();
MEDCOUPLING_EXPORT int getMeshDimension() const { return _mesh_dim; }
MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const;
MEDCOUPLING_EXPORT std::set<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
+ MEDCOUPLING_EXPORT DataArrayInt *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
MEDCOUPLING_EXPORT void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
MEDCOUPLING_EXPORT std::string simpleRepr() const;
targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+6);
targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+7);
targetMesh->finishInsertingCells();
+ CPPUNIT_ASSERT_THROW(targetMesh->checkCoherency(),INTERP_KERNEL::Exception);
DataArrayDouble *myCoords=DataArrayDouble::New();
myCoords->alloc(9,3);
std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
targetMesh.insertNextCell(NORM_POINT1,1,[7]);
targetMesh.insertNextCell(NORM_POINT1,1,[6]);
targetMesh.finishInsertingCells();
+ self.assertRaises(InterpKernelException,targetMesh.checkCoherency);
myCoords=DataArrayDouble.New();
myCoords.setValues(targetCoords,9,3);
targetMesh.setCoords(myCoords);
pass
pass
- def testSwigCellOrientation1(self):
+ def testSwig2CellOrientation1(self):
coords=DataArrayDouble([-0.21606,-0.10803,0.29999999999999999,-0.21606,-0.10803,0.37700000000000006,0,-0.10803,0.29999999999999999,0,-0.10803,0.37700000000000006,0,0.10803,0.29999999999999999,0,0.10803,0.37700000000000006,-0.21606,0.10803,0.29999999999999999,-0.21606,0.10803,0.37700000000000006,0,0.03601,0.29999999999999999,0,0.03601,0.37700000000000006,0,-0.03601,0.29999999999999999,0,-0.03601,0.37700000000000006],12,3)
conn=[[0,2,10,8,4,6],[1,3,11,9,5,7],[0,1,3,2],[2,3,11,10],[10,11,9,8],[8,9,5,4],[4,5,7,6],[6,7,1,0]]
for i in xrange(256):
pass
pass
- def testSwigCheckConsecutiveCellTypesForMEDFileFrmt1(self):
+ def testSwig2CheckConsecutiveCellTypesForMEDFileFrmt1(self):
m1=MEDCouplingUMesh("",2) ; m1.allocateCells(0)
m1.insertNextCell(NORM_QUAD4,[0,1,2,3])
m1.insertNextCell(NORM_TRI3,[0,1,2])
self.assertTrue(m1.checkConsecutiveCellTypesForMEDFileFrmt())
pass
- def testSwigDAAccumulate1(self):
+ def testSwig2DAAccumulate1(self):
d=DataArrayInt(10) ; d.iota(0)
self.assertEqual([45],d.accumulate())
self.assertEqual(45,d.accumulate(0))
self.assertEqual(155.,d.accumulate(2))
pass
- def testSwigUMeshDistanceToMesh1(self):
+ def testSwig2UMeshDistanceToMesh1(self):
m=MEDCouplingUMesh("toto",2)
coords=DataArrayDouble([2.3,3.4,5.6,6.5,-4.3,3.2,-9.8,7.6,-5.4],3,3)
m.setCoords(coords)
self.assertAlmostEqual(0.07071067811865482,a,14) ; self.assertEqual(1,b) ; self.assertEqual(2,c)
pass
- def testSwigNonRegressionPartitionBySpreadZone1(self):
+ def testSwig2NonRegressionPartitionBySpreadZone1(self):
m=MEDCouplingCMesh()
arr=DataArrayDouble(6) ; arr.iota(0.)
m.setCoords(arr,arr,arr)
self.assertTrue(d2.isEqual(DataArrayInt([0,1,1,1,1,1,1,2,2,2,2,2,2,3])))
pass
- def testSwigCurveLinearMesh2(self):
+ def testSwig2CurveLinearMesh2(self):
c=MEDCouplingCMesh()
#2D
arr1=DataArrayDouble([0,1,3,7])
self.assertTrue(cl.buildUnstructured().getBarycenterAndOwner().isEqual(DataArrayDouble(li4_1,4,2),1e-14))
pass
- def testSwigCurveLinearMeshNonRegression1(self):
+ def testSwig2CurveLinearMeshNonRegression1(self):
coords=DataArrayDouble([0.0, 0.0, 0.10000000149011612, 0.6000000238418579, 0.10000000149011612, 0.30000001192092896, 1.100000023841858, 0.10000000149011612, 0.20000000298023224, 0.10000000149011612, 0.6000000238418579, 0.20000000298023224, 0.699999988079071, 0.6000000238418579, 0.10000000149011612, 1.2000000476837158, 0.6000000238418579, 0.30000001192092896, 0.10000000149011612, 1.100000023841858, 0.30000001192092896, 0.5, 1.100000023841858, 0.20000000298023224, 1.0, 1.2000000476837158, 0.10000000149011612, 0.0, 0.10000000149011612, 0.5, 0.5, 0.10000000149011612, 0.6000000238418579, 1.2000000476837158, 0.10000000149011612, 0.699999988079071, 0.10000000149011612, 0.6000000238418579, 0.699999988079071, 0.6000000238418579, 0.6000000238418579, 0.5, 1.100000023841858, 0.6000000238418579, 0.6000000238418579, 0.10000000149011612, 1.0, 0.6000000238418579, 0.699999988079071, 1.2000000476837158, 0.699999988079071, 0.8999999761581421, 1.0, 0.5, 0.10000000149011612, 0.10000000149011612, 1.2000000476837158, 0.699999988079071, 0.10000000149011612, 1.0, 1.0, 0.10000000149011612, 1.100000023841858, 0.10000000149011612, 0.6000000238418579, 1.100000023841858, 0.6000000238418579, 0.6000000238418579, 1.100000023841858, 1.100000023841858, 0.6000000238418579, 1.2000000476837158, 0.10000000149011612, 1.2000000476837158, 1.0, 0.5, 1.100000023841858, 1.2000000476837158, 1.2000000476837158, 1.100000023841858, 1.0],27,3)
m=MEDCouplingCurveLinearMesh("toto")
m.setCoords(coords)
self.assertTrue(m.getBarycenterAndOwner().isEqual(m.buildUnstructured().getBarycenterAndOwner(),1e-12))
pass
+ def testSwig2NonRegressionDASetSelectedComponents1(self):
+ da=DataArrayDouble.New([1.,2.,3.,4.,5.,6.],3,2)
+ dv=DataArrayDouble.New();
+ dv.alloc(4,4)
+ dv.fillWithZero()
+ # da has less tuples than dv
+ dv.setSelectedComponents(da,[1,0])
+ #
+ self.assertTrue(dv.isEqual(DataArrayDouble([2.,1.,0.,0.,4.,3.,0.,0.,6.,5.,0.,0.,0.,0.,0.,0.],4,4),1e-14))
+ #
+ da=DataArrayInt.New([1,2,3,4,5,6],3,2)
+ dv=DataArrayInt.New();
+ dv.alloc(4,4)
+ dv.fillWithZero()
+ # da has less tuples than dv
+ dv.setSelectedComponents(da,[1,0])
+ #
+ self.assertTrue(dv.isEqual(DataArrayInt([2,1,0,0,4,3,0,0,6,5,0,0,0,0,0,0],4,4)))
+ pass
+
+ def testSwigSetItem3(self):
+ # 1-2
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[3]=[1,2]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,0,0,0,0,0,1,2,0,0,0,0],6,2),1e-14))
+ # 2-2 false
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[[5,3,2]]=[1,2]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,0,0,0,1,2,1,2,0,0,1,2],6,2),1e-14))
+ # 3-2 false
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[:]=[1,2]
+ self.assertTrue(d.isEqual(DataArrayDouble([1,2,1,2,1,2,1,2,1,2,1,2],6,2),1e-14))
+ # 4-2 false
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[DataArrayInt([0,3,4])]=[1,2]
+ self.assertTrue(d.isEqual(DataArrayDouble([1,2,0,0,0,0,1,2,1,2,0,0],6,2),1e-14))
+ # 5-2
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[5,1]=[7]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,7],6,2),1e-14))
+ # 6-2 false
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[[3,5],1]=[7]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,0,0,0,0,0,0,7,0,0,0,7],6,2),1e-14))
+ # 7-2 false
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[:-1:2,1]=[7]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,7,0,0,0,7,0,0,0,7,0,0],6,2),1e-14))
+ # 8-2 false
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[DataArrayInt([0,3,4]),1]=[7]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,7,0,0,0,0,0,7,0,7,0,0],6,2),1e-14))
+ # 9-2
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[3,[1,0]]=[7,8]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,0,0,0,0,0,8,7,0,0,0,0],6,2),1e-14))
+ # 10-2 false
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[[1,3,4],[1,0]]=[7,8]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,0,8,7,0,0,8,7,8,7,0,0],6,2),1e-14))
+ # 11-2 false
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[1::2,[1,0]]=[7,8]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,0,8,7,0,0,8,7,0,0,8,7],6,2),1e-14))
+ # 12-2 false
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[DataArrayInt([1,4]),[1,0]]=[7,8]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,0,8,7,0,0,0,0,8,7,0,0],6,2),1e-14))
+ # 13-2
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[1,:-1]=[9]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,0,9,0,0,0,0,0,0,0,0,0],6,2),1e-14))
+ # 14-2 false
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[[1,4,5],:]=[7,8]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,0,7,8,0,0,0,0,7,8,7,8],6,2),1e-14))
+ # 15-2 false
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[1::2,:]=[3,9]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,0,3,9,0,0,3,9,0,0,3,9],6,2),1e-14))
+ # 1-2
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[3]=[1,2]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,0,0,0,0,1,2,0,0,0,0],6,2)))
+ # 2-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[[5,3,2]]=[1,2]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,0,0,1,2,1,2,0,0,1,2],6,2)))
+ # 3-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[:]=[1,2]
+ self.assertTrue(d.isEqual(DataArrayInt([1,2,1,2,1,2,1,2,1,2,1,2],6,2)))
+ # 4-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[DataArrayInt([0,3,4])]=[1,2]
+ self.assertTrue(d.isEqual(DataArrayInt([1,2,0,0,0,0,1,2,1,2,0,0],6,2)))
+ # 5-2
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[5,1]=[7]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,7],6,2)))
+ # 6-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[[3,5],1]=[7]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,0,0,0,0,0,7,0,0,0,7],6,2)))
+ # 7-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[:-1:2,1]=[7]
+ self.assertTrue(d.isEqual(DataArrayInt([0,7,0,0,0,7,0,0,0,7,0,0],6,2)))
+ # 8-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[DataArrayInt([0,3,4]),1]=[7]
+ self.assertTrue(d.isEqual(DataArrayInt([0,7,0,0,0,0,0,7,0,7,0,0],6,2)))
+ # 9-2
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[3,[1,0]]=[7,8]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,0,0,0,0,8,7,0,0,0,0],6,2)))
+ # 10-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[[1,3,4],[1,0]]=[7,8]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,8,7,0,0,8,7,8,7,0,0],6,2)))
+ # 11-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[1::2,[1,0]]=[7,8]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,8,7,0,0,8,7,0,0,8,7],6,2)))
+ # 12-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[DataArrayInt([1,4]),[1,0]]=[7,8]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,8,7,0,0,0,0,8,7,0,0],6,2)))
+ # 13-2
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[1,:-1]=[9]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,9,0,0,0,0,0,0,0,0,0],6,2)))
+ # 14-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[[1,4,5],:]=[7,8]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,7,8,0,0,0,0,7,8,7,8],6,2)))
+ # 15-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[1::2,:]=[3,9]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,3,9,0,0,3,9,0,0,3,9],6,2)))
+ pass
+
def setUp(self):
pass
pass
%newobject ParaMEDMEM::DataArrayDoubleTuple::buildDADouble;
%newobject ParaMEDMEM::MEDCouplingMesh::deepCpy;
%newobject ParaMEDMEM::MEDCouplingMesh::checkTypeConsistencyAndContig;
+%newobject ParaMEDMEM::MEDCouplingMesh::computeNbOfNodesPerCell;
+%newobject ParaMEDMEM::MEDCouplingMesh::giveCellsWithType;
%newobject ParaMEDMEM::MEDCouplingMesh::getCoordinatesAndOwner;
%newobject ParaMEDMEM::MEDCouplingMesh::getBarycenterAndOwner;
%newobject ParaMEDMEM::MEDCouplingMesh::buildOrthogonalField;
%newobject ParaMEDMEM::MEDCouplingUMesh::__iter__;
%newobject ParaMEDMEM::MEDCouplingUMesh::__getitem__;
%newobject ParaMEDMEM::MEDCouplingUMesh::cellsByType;
-%newobject ParaMEDMEM::MEDCouplingUMesh::giveCellsWithType;
%newobject ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer;
%newobject ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity;
%newobject ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity2;
%newobject ParaMEDMEM::MEDCouplingUMesh::buildExtrudedMesh;
%newobject ParaMEDMEM::MEDCouplingUMesh::buildSpreadZonesWithPoly;
-%newobject ParaMEDMEM::MEDCouplingUMesh::computeNbOfNodesPerCell;
%newobject ParaMEDMEM::MEDCouplingUMesh::MergeUMeshes;
%newobject ParaMEDMEM::MEDCouplingUMesh::MergeUMeshesOnSameCoords;
%newobject ParaMEDMEM::MEDCouplingUMesh::ComputeSpreadZoneGradually;
%newobject ParaMEDMEM::MEDCouplingUMesh::computeFetchedNodeIds;
%newobject ParaMEDMEM::MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec;
%newobject ParaMEDMEM::MEDCouplingUMesh::buildDirectionVectorField;
+%newobject ParaMEDMEM::MEDCouplingUMesh::convertLinearCellsToQuadratic;
%newobject ParaMEDMEM::MEDCouplingUMesh::getEdgeRatioField;
%newobject ParaMEDMEM::MEDCouplingUMesh::getAspectRatioField;
%newobject ParaMEDMEM::MEDCouplingUMesh::getWarpField;
virtual int getMeshDimension() const throw(INTERP_KERNEL::Exception);
virtual DataArrayDouble *getCoordinatesAndOwner() const throw(INTERP_KERNEL::Exception);
virtual DataArrayDouble *getBarycenterAndOwner() const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
virtual int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
virtual INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const throw(INTERP_KERNEL::Exception);
virtual std::string simpleRepr() const;
int getNumberOfNodesInCell(int cellId) const throw(INTERP_KERNEL::Exception);
int getMeshLength() const throw(INTERP_KERNEL::Exception);
void computeTypes() throw(INTERP_KERNEL::Exception);
- DataArrayInt *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
std::string reprConnectivityOfThis() const throw(INTERP_KERNEL::Exception);
MEDCouplingUMesh *buildSetInstanceFromThis(int spaceDim) const throw(INTERP_KERNEL::Exception);
//tools
DataArrayInt *convertCellArrayPerGeoType(const DataArrayInt *da) const throw(INTERP_KERNEL::Exception);
DataArrayInt *computeFetchedNodeIds() const throw(INTERP_KERNEL::Exception);
DataArrayInt *zipConnectivityTraducer(int compType, int startCellId=0) throw(INTERP_KERNEL::Exception);
- DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception);
MEDCouplingUMesh *buildDescendingConnectivity2(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception);
void orientCorrectlyPolyhedrons() throw(INTERP_KERNEL::Exception);
void tessellate2D(double eps) throw(INTERP_KERNEL::Exception);
void tessellate2DCurve(double eps) throw(INTERP_KERNEL::Exception);
void convertQuadraticCellsToLinear() throw(INTERP_KERNEL::Exception);
+ DataArrayInt *convertLinearCellsToQuadratic(int conversionType=0) throw(INTERP_KERNEL::Exception);
void convertDegeneratedCells() throw(INTERP_KERNEL::Exception);
bool areOnlySimplexCells() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getEdgeRatioField() const throw(INTERP_KERNEL::Exception);
return self;
case 2:
tmp=DataArrayDouble::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayDouble::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayDouble::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayDouble::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
return self;
case 3:
}
case 11:
{
- int bb=pt1.first;
- int ee=pt1.second.first;
- int ss=pt1.second.second;
- if(ee<bb || ss<=0)
- throw INTERP_KERNEL::Exception("Invalid slice in tuple selection");
- int nbOfE=(ee-bb)/ss;
- std::vector<int> nv(nbOfE);
- for(int jj=0;jj<nbOfE;jj++)
- nv[jj]=bb+jj*ss;
switch(sw1)
{
case 1:
- self->setPartOfValuesSimple2(i1,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size());
+ self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
return self;
case 2:
tmp=DataArrayDouble::New();
tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
- self->setPartOfValues2(tmp,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size(),false);
+ self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size(),false);
return self;
case 3:
- self->setPartOfValues2(d1,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size());
+ self->setPartOfValues4(d1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
return self;
default:
throw INTERP_KERNEL::Exception(msg);
return self;
case 2:
tmp=DataArrayDouble::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayDouble::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayInt::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayInt::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayInt::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayInt::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
return self;
case 3:
}
case 11:
{
- int bb=pt1.first;
- int ee=pt1.second.first;
- int ss=pt1.second.second;
- if(ee<bb || ss<=0)
- throw INTERP_KERNEL::Exception("Invalid slice in tuple selection");
- int nbOfE=(ee-bb)/ss;
- std::vector<int> nv(nbOfE);
- for(int jj=0;jj<nbOfE;jj++)
- nv[jj]=bb+jj*ss;
switch(sw1)
{
case 1:
- self->setPartOfValuesSimple2(i1,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size());
+ self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
return self;
case 2:
tmp=DataArrayInt::New();
tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
- self->setPartOfValues2(tmp,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size(),false);
+ self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size(),false);
return self;
case 3:
- self->setPartOfValues2(d1,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size());
+ self->setPartOfValues4(d1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
return self;
case 4:
tmp=dd1->buildDAInt(1,self->getNumberOfComponents());
- self->setPartOfValues2(tmp,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size());
+ self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
return self;
default:
throw INTERP_KERNEL::Exception(msg);
return self;
case 2:
tmp=DataArrayInt::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
return self;
case 3:
return self;
case 2:
tmp=DataArrayInt::New();
- tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size());
self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false);
return self;
case 3:
virtual bool areCompatibleForMerge(const MEDCouplingField *other) const throw(INTERP_KERNEL::Exception);
virtual bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const throw(INTERP_KERNEL::Exception);
virtual bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const throw(INTERP_KERNEL::Exception);
+ virtual void copyTinyStringsFrom(const MEDCouplingField *other) throw(INTERP_KERNEL::Exception);
void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
void setName(const char *name) throw(INTERP_KERNEL::Exception);
const char *getDescription() const throw(INTERP_KERNEL::Exception);
void setTimeUnit(const char *unit);
const char *getTimeUnit() const;
void synchronizeTimeWithSupport() throw(INTERP_KERNEL::Exception);
- void copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
void copyTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
+ void copyAllTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
std::string simpleRepr() const;
std::string advancedRepr() const;
void writeVTK(const char *fileName) const throw(INTERP_KERNEL::Exception);
pass
array.setValues(ptr,sourceMesh.getNumberOfCells(),1);
srcField.setArray(array);
+ srcField.setName("abc") ; srcField.setDescription("def")
+ srcField.setTime(7.7,9,10)
trgfield=remapper.transferField(srcField,4.57);
+ self.assertEqual("abc",trgfield.getName())
+ self.assertEqual("def",trgfield.getDescription())
+ a,b,c=trgfield.getTime()
+ self.assertAlmostEqual(7.7,a,14)
+ self.assertEqual(b,9)
+ self.assertEqual(c,10)
values=trgfield.getArray().getValues();
valuesExpected=[7.5 ,7. ,7.,8.,7.5];
for i in xrange(targetMesh.getNumberOfCells()):
self.assertTrue(f11.getArray().isEqual(expected2,1e-13))
self.assertTrue(f22.getArray().isEqual(expected2,1e-13))
pass
+
+ def testCellToNodeReverse3D(self):
+ c=DataArrayDouble([0.,1.,2.5])
+ cc=MEDCouplingCMesh()
+ cc.setCoords(c,c,c)
+ um=cc.buildUnstructured()
+ f=um.getMeasureField(ON_CELLS)
+ #
+ n2o=um.simplexize(PLANAR_FACE_5)
+ f.setArray(f.getArray()[n2o])
+ f.checkCoherency()
+ f.setNature(ConservativeVolumic)
+ f.setTime(5.6,7,8)
+ f.setName("toto") ; f.setDescription("aDescription")
+ p=MEDCouplingRemapper()
+ p.setP1P0BaryMethod(True)
+ p.prepare(um,um,"P1P0")
+ fNode=p.reverseTransferField(f,1e300)
+ self.assertEqual("toto",fNode.getName())
+ self.assertEqual("aDescription",fNode.getDescription())
+ a,b,c=fNode.getTime()
+ self.assertAlmostEqual(5.6,a,14)
+ self.assertEqual(7,b) ; self.assertEqual(8,c)
+ #
+ integExpected=34.328125
+ self.assertAlmostEqual(fNode.integral(False)[0],integExpected,14)
+ self.assertAlmostEqual(f.integral(False)[0],integExpected,14)
+ pass
def build2DSourceMesh_1(self):
sourceCoords=[-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7]
MEDFileBasis.cxx
MEDFileMeshLL.cxx
MEDFileField.cxx
+ MEDFileParameter.cxx
MEDFileData.cxx
SauvMedConvertor.cxx
SauvReader.cxx
MEDCouplingAutoRefCountObjectPtr<MEDFileMeshes> meshes;
if((const MEDFileMeshes *)_meshes)
meshes=_meshes->deepCpy();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileParameters> params;
+ if((const MEDFileParameters *)_params)
+ params=_params->deepCpy();
MEDCouplingAutoRefCountObjectPtr<MEDFileData> ret=MEDFileData::New();
- ret->_fields=fields; ret->_meshes=meshes;
+ ret->_fields=fields; ret->_meshes=meshes; ret->_params=params;
return ret.retn();
}
ret+=_fields->getHeapMemorySize();
if((const MEDFileMeshes *)_meshes)
ret+=_meshes->getHeapMemorySize();
+ if((const MEDFileParameters *)_params)
+ ret+=_params->getHeapMemorySize();
return ret;
}
return const_cast<MEDFileMeshes *>(static_cast<const MEDFileMeshes *>(_meshes));
}
+MEDFileParameters *MEDFileData::getParams() const
+{
+ return const_cast<MEDFileParameters *>(static_cast<const MEDFileParameters *>(_params));
+}
+
void MEDFileData::setFields(MEDFileFields *fields) throw(INTERP_KERNEL::Exception)
{
- if(!fields)
- throw INTERP_KERNEL::Exception("MEDFileData::setFields : input pointer is null !");
- fields->incrRef();
+ if(fields)
+ fields->incrRef();
_fields=fields;
}
void MEDFileData::setMeshes(MEDFileMeshes *meshes) throw(INTERP_KERNEL::Exception)
{
- if(!meshes)
- throw INTERP_KERNEL::Exception("MEDFileData::setMeshes : input pointer is null !");
- meshes->incrRef();
+ if(meshes)
+ meshes->incrRef();
_meshes=meshes;
}
+void MEDFileData::setParams(MEDFileParameters *params) throw(INTERP_KERNEL::Exception)
+{
+ if(params)
+ params->incrRef();
+ _params=params;
+}
+
int MEDFileData::getNumberOfFields() const throw(INTERP_KERNEL::Exception)
{
const MEDFileFields *f=_fields;
return m->getNumberOfMeshes();
}
+int MEDFileData::getNumberOfParams() const throw(INTERP_KERNEL::Exception)
+{
+ const MEDFileParameters *p=_params;
+ if(!p)
+ throw INTERP_KERNEL::Exception("MEDFileData::getNumberOfParams : no params set !");
+ return p->getNumberOfParams();
+}
+
std::string MEDFileData::simpleRepr() const
{
std::ostringstream oss;
tmp2->simpleReprWithoutHeader(oss);
}
else
- oss << "No meshes set !!!\n";
+ oss << "No meshes set !!!\n\n";
+ oss << "Params part :\n*************\n\n";
+ const MEDFileParameters *tmp3=_params;
+ if(tmp3)
+ {
+ tmp3->simpleReprWithoutHeader(oss);
+ }
+ else
+ oss << "params set !!!\n";
return oss.str();
}
{
_fields=MEDFileFields::New(fileName);
_meshes=MEDFileMeshes::New(fileName);
+ _params=MEDFileParameters::New(fileName);
}
catch(INTERP_KERNEL::Exception& e)
{
const MEDFileFields *fs=_fields;
if(fs)
fs->writeLL(fid);
+ const MEDFileParameters *ps=_params;
+ if(ps)
+ ps->writeLL(fid);
}
#define __MEDFILEDATA_HXX__
#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "MEDFileParameter.hxx"
#include "MEDFileField.hxx"
#include "MEDFileMesh.hxx"
std::size_t getHeapMemorySize() const;
MEDFileFields *getFields() const;
MEDFileMeshes *getMeshes() const;
+ MEDFileParameters *getParams() const;
void setFields(MEDFileFields *fields) throw(INTERP_KERNEL::Exception);
void setMeshes(MEDFileMeshes *meshes) throw(INTERP_KERNEL::Exception);
+ void setParams(MEDFileParameters *params) throw(INTERP_KERNEL::Exception);
int getNumberOfFields() const throw(INTERP_KERNEL::Exception);
int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception);
+ int getNumberOfParams() const throw(INTERP_KERNEL::Exception);
std::string simpleRepr() const;
//
bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
private:
MEDCouplingAutoRefCountObjectPtr<MEDFileFields> _fields;
MEDCouplingAutoRefCountObjectPtr<MEDFileMeshes> _meshes;
+ MEDCouplingAutoRefCountObjectPtr<MEDFileParameters> _params;
};
}
int nnodes=mesh2->getNumberOfNodes();
if(nnodes==da->getNbOfElems())
{
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->getConstPointer(),arr2->getConstPointer()+arr2->getNbOfElems());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
ret->getArray()->renumberInPlace(da3->getConstPointer());
mesh2->setName(mesh->getName());
ret->setMesh(mesh2);
return ret.retn();
}
+/*!
+ * \return a new allocated object that the caller should deal with.
+ */
MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
{
const MEDFileField1TSWithoutSDA *item=_content->getTimeStepAtPos2(pos);
return ret.retn();
}
+/*!
+ * \return a new allocated object that the caller should deal with.
+ */
MEDFileField1TS *MEDFileFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
{
int pos=getPosOfTimeStep(iteration,order);
return getTimeStepAtPos(pos);
}
+/*!
+ * \return a new allocated object that the caller should deal with.
+ */
MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
{
int pos=getPosGivenTime(time,eps);
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay (CEA/DEN)
+
+#include "MEDFileParameter.hxx"
+#include "MEDFileUtilities.hxx"
+#include "MEDLoaderBase.hxx"
+
+#include "InterpKernelAutoPtr.hxx"
+
+using namespace ParaMEDMEM;
+
+MEDFileParameter1TS::MEDFileParameter1TS(int iteration, int order, double time):_iteration(iteration),_order(order),_time(time)
+{
+}
+
+MEDFileParameter1TS::MEDFileParameter1TS():_iteration(-1),_order(-1),_time(0.)
+{
+}
+
+bool MEDFileParameter1TS::isEqual(const MEDFileParameter1TS *other, double eps, std::string& what) const
+{
+ std::ostringstream oss;
+ if(!other)
+ { what="Other is null"; return false; }
+ if(_iteration!=other->_iteration)
+ { oss << "iteration number mismatches " << _iteration << " != " << other->_iteration; what=oss.str(); return false; }
+ if(_order!=other->_order)
+ { oss << "order number mismatches " << _iteration << " != " << other->_iteration; what=oss.str(); return false; }
+ if(fabs(_time-other->_time)>eps)
+ { oss << "time mismatches " << _time << " != " << other->_time << " eps=" << eps; what=oss.str(); return false; }
+ return true;
+}
+
+MEDFileParameter1TS *MEDFileParameterDouble1TSWTI::deepCpy() const throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileParameterDouble1TSWTI(*this);
+}
+
+bool MEDFileParameterDouble1TSWTI::isEqual(const MEDFileParameter1TS *other, double eps, std::string& what) const
+{
+ if(!MEDFileParameter1TS::isEqual(other,eps,what))
+ return false;
+ const MEDFileParameterDouble1TSWTI *otherC=dynamic_cast<const MEDFileParameterDouble1TSWTI *>(other);
+ if(!otherC)
+ { what="IsEqual fails because this is double parameter other no !"; return false; }
+ if(fabs(_arr-otherC->_arr)>eps)
+ { std::ostringstream oss; oss << "value differ " << _arr << " != " << otherC->_arr << " (eps=" << eps << ")"; return false; }
+ return true;
+}
+
+std::size_t MEDFileParameterDouble1TSWTI::getHeapMemorySize() const
+{
+ return sizeof(MEDFileParameterDouble1TSWTI);
+}
+
+std::string MEDFileParameterDouble1TSWTI::simpleRepr() const
+{
+ std::ostringstream oss;
+ simpleRepr2(0,oss);
+ return oss.str();
+}
+
+void MEDFileParameterDouble1TSWTI::simpleRepr2(int bkOffset, std::ostream& oss) const
+{
+ std::string startOfLine(bkOffset,' ');
+ oss << startOfLine << "ParameterDoubleItem with (iteration,order) = (" << _iteration << "," << _order << ")" << std::endl;
+ oss << startOfLine << "Time associacited = " << _time << std::endl;
+ oss << startOfLine << "The value is ***** " << _arr << " *****" << std::endl;
+}
+
+MEDFileParameterDouble1TSWTI *MEDFileParameterDouble1TSWTI::New(int iteration, int order, double time)
+{
+ return new MEDFileParameterDouble1TSWTI(iteration,order,time);
+}
+
+MEDFileParameterDouble1TSWTI::MEDFileParameterDouble1TSWTI():_arr(std::numeric_limits<double>::max())
+{
+}
+
+MEDFileParameterDouble1TSWTI::MEDFileParameterDouble1TSWTI(int iteration, int order, double time):MEDFileParameter1TS(iteration,order,time)
+{
+}
+
+void MEDFileParameterDouble1TSWTI::finishLoading(med_idt fid, const std::string& name, int dt, int it, int nbOfSteps) throw(INTERP_KERNEL::Exception)
+{
+ std::ostringstream oss; oss << "MEDFileParameterDouble1TS::finishLoading : no specified time step (" << dt << "," << it << ") ! Time steps available : ";
+ for(int i=0;i<nbOfSteps;i++)
+ {
+ int locDt,locIt;
+ double tim;
+ MEDparameterComputationStepInfo(fid,name.c_str(),i+1,&locDt,&locIt,&tim);
+ if(dt==locDt && it==locIt)
+ {
+ _iteration=locDt; _order=locIt; _time=tim;
+ MEDparameterValueRd(fid,name.c_str(),_iteration,_order,reinterpret_cast<unsigned char *const>(&_arr));
+ return ;
+ }
+ else
+ {
+ oss << "(" << locDt << "," << locIt << ")";
+ if(i!=nbOfSteps-1)
+ oss << ", ";
+ }
+ }
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
+void MEDFileParameterDouble1TSWTI::readValue(med_idt fid, const std::string& name) throw(INTERP_KERNEL::Exception)
+{
+ MEDparameterValueRd(fid,name.c_str(),_iteration,_order,reinterpret_cast<unsigned char *const>(&_arr));
+}
+
+void MEDFileParameterDouble1TSWTI::finishLoading(med_idt fid, const std::string& name, int timeStepId) throw(INTERP_KERNEL::Exception)
+{
+ int locDt,locIt;
+ double dt;
+ MEDparameterComputationStepInfo(fid,name.c_str(),timeStepId+1,&locDt,&locIt,&dt);
+ _iteration=locDt; _order=locIt; _time=dt;
+ MEDparameterValueRd(fid,name.c_str(),_iteration,_order,reinterpret_cast<unsigned char *const>(&_arr));
+}
+
+void MEDFileParameterDouble1TSWTI::writeLL(med_idt fid, const std::string& name, const MEDFileWritable& mw) const throw(INTERP_KERNEL::Exception)
+{
+ char nameW[MED_NAME_SIZE+1];
+ MEDLoaderBase::safeStrCpy(name.c_str(),MED_NAME_SIZE,nameW,mw.getTooLongStrPolicy());
+ MEDparameterValueWr(fid,nameW,_iteration,_order,_time,reinterpret_cast<const unsigned char *>(&_arr));
+}
+
+std::size_t MEDFileParameterTinyInfo::getHeapMemSizeOfStrings() const
+{
+ return _dt_unit.capacity()+_name.capacity()+_desc_name.capacity();
+}
+
+bool MEDFileParameterTinyInfo::isEqualStrings(const MEDFileParameterTinyInfo& other, std::string& what) const
+{
+ std::ostringstream oss;
+ if(_name!=other._name)
+ { oss << "name differ ! this=" << _name << " and other=" << other._name; what=oss.str(); return false; }
+ if(_desc_name!=other._desc_name)
+ { oss << "name differ ! this=" << _desc_name << " and other=" << other._desc_name; what=oss.str(); return false; }
+ if(_dt_unit!=other._dt_unit)
+ { oss << "unit of time differ ! this=" << _dt_unit << " and other=" << other._dt_unit; what=oss.str(); return false; }
+ return true;
+}
+
+void MEDFileParameterTinyInfo::writeLLHeader(med_idt fid, med_parameter_type typ) const throw(INTERP_KERNEL::Exception)
+{
+ char nameW[MED_NAME_SIZE+1],descW[MED_COMMENT_SIZE+1],dtunitW[MED_SNAME_SIZE+1];
+ MEDLoaderBase::safeStrCpy(_name.c_str(),MED_NAME_SIZE,nameW,getTooLongStrPolicy());
+ MEDLoaderBase::safeStrCpy(_desc_name.c_str(),MED_COMMENT_SIZE,descW,getTooLongStrPolicy());
+ MEDLoaderBase::safeStrCpy(_dt_unit.c_str(),MED_SNAME_SIZE,dtunitW,getTooLongStrPolicy());
+ MEDparameterCr(fid,nameW,typ,descW,dtunitW);
+}
+
+void MEDFileParameterTinyInfo::mainRepr(int bkOffset, std::ostream& oss) const
+{
+ std::string startOfLine(bkOffset,' ');
+ oss << startOfLine << "Parameter with name \"" << _name << "\"" << std::endl;
+ oss << startOfLine << "Parameter with description \"" << _desc_name << "\"" << std::endl;
+ oss << startOfLine << "Parameter with unit name \"" << _dt_unit << "\"" << std::endl;
+}
+
+MEDFileParameterDouble1TS *MEDFileParameterDouble1TS::New()
+{
+ return new MEDFileParameterDouble1TS;
+}
+
+MEDFileParameterDouble1TS *MEDFileParameterDouble1TS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileParameterDouble1TS(fileName);
+}
+
+MEDFileParameterDouble1TS *MEDFileParameterDouble1TS::New(const char *fileName, const char *paramName) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileParameterDouble1TS(fileName,paramName);
+}
+
+MEDFileParameterDouble1TS *MEDFileParameterDouble1TS::New(const char *fileName, const char *paramName, int dt, int it) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileParameterDouble1TS(fileName,paramName,dt,it);
+}
+
+MEDFileParameterDouble1TS::MEDFileParameterDouble1TS()
+{
+}
+
+MEDFileParameterDouble1TS::MEDFileParameterDouble1TS(const char *fileName, const char *paramName, int dt, int it) throw(INTERP_KERNEL::Exception)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ int nbPar=MEDnParameter(fid);
+ std::ostringstream oss; oss << "MEDFileParameterDouble1TS : no double param name \"" << paramName << "\" ! Double Parameters available are : ";
+ INTERP_KERNEL::AutoPtr<char> pName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> descName=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE);
+ INTERP_KERNEL::AutoPtr<char> unitName=MEDLoaderBase::buildEmptyString(MED_SNAME_SIZE);
+ med_parameter_type paramType;
+ for(int i=0;i<nbPar;i++)
+ {
+ int nbOfSteps;
+ MEDparameterInfo(fid,i+1,pName,¶mType,descName,unitName,&nbOfSteps);
+ std::string paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE);
+ if(paramNameCpp==paramName && paramType==MED_FLOAT64)
+ {
+ _dt_unit=MEDLoaderBase::buildStringFromFortran(unitName,MED_SNAME_SIZE);
+ _name=paramNameCpp;
+ _desc_name=MEDLoaderBase::buildStringFromFortran(descName,MED_COMMENT_SIZE);
+ finishLoading(fid,_name,dt,it,nbOfSteps);
+ return ;
+ }
+ else
+ {
+ oss << paramNameCpp;
+ if(i!=nbPar-1) oss << ", ";
+ }
+ }
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
+MEDFileParameterDouble1TS::MEDFileParameterDouble1TS(const char *fileName, const char *paramName) throw(INTERP_KERNEL::Exception)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ int nbPar=MEDnParameter(fid);
+ std::ostringstream oss; oss << "MEDFileParameterDouble1TS : no double param name \"" << paramName << "\" ! Double Parameters available are : ";
+ INTERP_KERNEL::AutoPtr<char> pName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> descName=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE);
+ INTERP_KERNEL::AutoPtr<char> unitName=MEDLoaderBase::buildEmptyString(MED_SNAME_SIZE);
+ med_parameter_type paramType;
+ for(int i=0;i<nbPar;i++)
+ {
+ int nbOfSteps;
+ MEDparameterInfo(fid,i+1,pName,¶mType,descName,unitName,&nbOfSteps);
+ std::string paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE);
+ if(paramNameCpp==paramName && paramType==MED_FLOAT64)
+ {
+ if(nbOfSteps>0)
+ {
+ _dt_unit=MEDLoaderBase::buildStringFromFortran(unitName,MED_SNAME_SIZE);
+ _name=paramNameCpp;
+ _desc_name=MEDLoaderBase::buildStringFromFortran(descName,MED_COMMENT_SIZE);
+ finishLoading(fid,_name,0);
+ return ;
+ }
+ else
+ {
+ std::ostringstream oss2; oss2 << "Param name \"" << paramName << "\" exists but no time steps on it !";
+ throw INTERP_KERNEL::Exception(oss2.str().c_str());
+ }
+ }
+ else
+ {
+ oss << paramNameCpp;
+ if(i!=nbPar-1) oss << ", ";
+ }
+ }
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
+MEDFileParameterDouble1TS::MEDFileParameterDouble1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ int nbPar=MEDnParameter(fid);
+ if(nbPar<1)
+ {
+ std::ostringstream oss2; oss2 << "No parameter in file \"" << fileName << "\" !";
+ throw INTERP_KERNEL::Exception(oss2.str().c_str());
+ }
+ INTERP_KERNEL::AutoPtr<char> pName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> descName=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE);
+ INTERP_KERNEL::AutoPtr<char> unitName=MEDLoaderBase::buildEmptyString(MED_SNAME_SIZE);
+ med_parameter_type paramType;
+ int nbOfSteps;
+ MEDparameterInfo(fid,1,pName,¶mType,descName,unitName,&nbOfSteps);
+ std::string paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE);
+ if(paramType==MED_FLOAT64)
+ {
+ if(nbOfSteps>0)
+ {
+ _dt_unit=MEDLoaderBase::buildStringFromFortran(unitName,MED_SNAME_SIZE);
+ _name=paramNameCpp;
+ _desc_name=MEDLoaderBase::buildStringFromFortran(descName,MED_COMMENT_SIZE);
+ finishLoading(fid,_name,0);
+ return ;
+ }
+ else
+ {
+ std::ostringstream oss2; oss2 << "Double param name \"" << paramNameCpp << "\" exists in file \""<< fileName << "\"but no time steps on it !";
+ throw INTERP_KERNEL::Exception(oss2.str().c_str());
+ }
+ }
+ else
+ {
+ std::ostringstream oss2; oss2 << "First parameter in file \"" << fileName << "\" is not double !";
+ throw INTERP_KERNEL::Exception(oss2.str().c_str());
+ }
+}
+
+bool MEDFileParameterDouble1TS::isEqual(const MEDFileParameter1TS *other, double eps, std::string& what) const
+{
+ if(!MEDFileParameterDouble1TSWTI::isEqual(other,eps,what))
+ return false;
+ const MEDFileParameterDouble1TS *otherC=dynamic_cast<const MEDFileParameterDouble1TS *>(other);
+ if(!otherC)
+ { what="Other is not of type MEDFileParameterDouble1TS as this"; return false; }
+ if(!isEqualStrings(*otherC,what))
+ return false;
+ return true;
+}
+
+MEDFileParameter1TS *MEDFileParameterDouble1TS::deepCpy() const throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileParameterDouble1TS(*this);
+}
+
+std::string MEDFileParameterDouble1TS::simpleRepr() const
+{
+ std::ostringstream oss;
+ MEDFileParameterTinyInfo::mainRepr(0,oss);
+ MEDFileParameterDouble1TSWTI::simpleRepr2(0,oss);
+ return oss.str();
+}
+
+std::size_t MEDFileParameterDouble1TS::getHeapMemorySize() const
+{
+ return getHeapMemSizeOfStrings()+sizeof(MEDFileParameterDouble1TS);
+}
+
+void MEDFileParameterDouble1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+{
+ med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ MEDFileParameterTinyInfo::writeLLHeader(fid,MED_FLOAT64);
+ MEDFileParameterDouble1TSWTI::writeLL(fid,_name,*this);
+}
+
+MEDFileParameterMultiTS *MEDFileParameterMultiTS::New()
+{
+ return new MEDFileParameterMultiTS;
+}
+
+MEDFileParameterMultiTS *MEDFileParameterMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileParameterMultiTS(fileName);
+}
+
+MEDFileParameterMultiTS *MEDFileParameterMultiTS::New(const char *fileName, const char *paramName) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileParameterMultiTS(fileName,paramName);
+}
+
+MEDFileParameterMultiTS::MEDFileParameterMultiTS()
+{
+}
+
+MEDFileParameterMultiTS::MEDFileParameterMultiTS(const MEDFileParameterMultiTS& other, bool deepCopy):MEDFileParameterTinyInfo(other),_param_per_ts(other._param_per_ts)
+{
+ if(deepCopy)
+ for(std::size_t i=0;i<_param_per_ts.size();i++)
+ {
+ const MEDFileParameter1TS *elt=_param_per_ts[i];
+ if(elt)
+ _param_per_ts[i]=elt->deepCpy();
+ }
+}
+
+MEDFileParameterMultiTS::MEDFileParameterMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ int nbPar=MEDnParameter(fid);
+ if(nbPar<1)
+ {
+ std::ostringstream oss; oss << "MEDFileParameterMultiTS : no parameter in file \"" << fileName << "\" !" ;
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ INTERP_KERNEL::AutoPtr<char> pName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> descName=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE);
+ INTERP_KERNEL::AutoPtr<char> unitName=MEDLoaderBase::buildEmptyString(MED_SNAME_SIZE);
+ med_parameter_type paramType;
+ int nbOfSteps;
+ MEDparameterInfo(fid,1,pName,¶mType,descName,unitName,&nbOfSteps);
+ std::string paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE);
+ _dt_unit=MEDLoaderBase::buildStringFromFortran(unitName,MED_SNAME_SIZE);
+ _name=paramNameCpp;
+ _desc_name=MEDLoaderBase::buildStringFromFortran(descName,MED_COMMENT_SIZE);
+ finishLoading(fid,paramType,nbOfSteps);
+}
+
+MEDFileParameterMultiTS::MEDFileParameterMultiTS(const char *fileName, const char *paramName) throw(INTERP_KERNEL::Exception)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ int nbPar=MEDnParameter(fid);
+ std::ostringstream oss; oss << "MEDFileParameterDouble1TS : no double param name \"" << paramName << "\" ! Double Parameters available are : ";
+ INTERP_KERNEL::AutoPtr<char> pName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> descName=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE);
+ INTERP_KERNEL::AutoPtr<char> unitName=MEDLoaderBase::buildEmptyString(MED_SNAME_SIZE);
+ med_parameter_type paramType;
+ for(int i=0;i<nbPar;i++)
+ {
+ int nbOfSteps;
+ MEDparameterInfo(fid,i+1,pName,¶mType,descName,unitName,&nbOfSteps);
+ std::string paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE);
+ if(paramNameCpp==paramName)
+ {
+ if(nbOfSteps>0)
+ {
+ _dt_unit=MEDLoaderBase::buildStringFromFortran(unitName,MED_SNAME_SIZE);
+ _name=paramNameCpp;
+ _desc_name=MEDLoaderBase::buildStringFromFortran(descName,MED_COMMENT_SIZE);
+ finishLoading(fid,paramType,nbOfSteps);
+ return ;
+ }
+ else
+ {
+ std::ostringstream oss2; oss2 << "Param name \"" << paramName << "\" exists but no time steps on it !";
+ throw INTERP_KERNEL::Exception(oss2.str().c_str());
+ }
+ }
+ else
+ {
+ oss << paramNameCpp;
+ if(i!=nbPar-1) oss << ", ";
+ }
+ }
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
+void MEDFileParameterMultiTS::finishLoading(med_idt fid, med_parameter_type typ, int nbOfSteps) throw(INTERP_KERNEL::Exception)
+{
+ _param_per_ts.resize(nbOfSteps);
+ for(int i=0;i<nbOfSteps;i++)
+ {
+ int dt,it;
+ double tim;
+ MEDparameterComputationStepInfo(fid,_name.c_str(),i+1,&dt,&it,&tim);
+ switch(typ)
+ {
+ case MED_FLOAT64:
+ _param_per_ts[i]=MEDFileParameterDouble1TSWTI::New(dt,it,tim);
+ _param_per_ts[i]->readValue(fid,_name.c_str());
+ break;
+ /*case MED_INT32;
+ _param_per_ts[i]=;
+ break;*/
+ default:
+ throw INTERP_KERNEL::Exception("MEDFileParameterMultiTS::finishLoading : supporting only FLOAT64 !");
+ }
+ }
+}
+
+std::size_t MEDFileParameterMultiTS::getHeapMemorySize() const
+{
+ std::size_t ret=sizeof(MEDFileParameterMultiTS);
+ std::size_t ret2=sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS>)*_param_per_ts.capacity();
+ for(std::size_t i=0;i<_param_per_ts.size();i++)
+ {
+ const MEDFileParameter1TS *pt(_param_per_ts[i]);
+ if(pt)
+ ret2+=pt->getHeapMemorySize();
+ }
+ return ret2+ret;
+}
+
+MEDFileParameterMultiTS *MEDFileParameterMultiTS::deepCpy() const throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileParameterMultiTS(*this,true);
+}
+
+bool MEDFileParameterMultiTS::isEqual(const MEDFileParameterMultiTS *other, double eps, std::string& what) const
+{
+ if(!other)
+ { what="other is null !"; return false; }
+ if(_param_per_ts.size()!=other->_param_per_ts.size())
+ { what="number of time steps differs !"; return false; }
+ std::ostringstream oss;
+ for(std::size_t i=0;i<_param_per_ts.size();i++)
+ {
+ const MEDFileParameter1TS *a(_param_per_ts[i]),*b(other->_param_per_ts[i]);
+ if((a && !b) || (!a && b))
+ { oss << "At time step id #" << i << " pointer is defined on one side not in the other !"; what=oss.str(); return false; }
+ if(a)
+ if(!a->isEqual(b,eps,what))
+ { oss << " At time step id #" << i << " non equality !"; what+=oss.str(); return false; }
+ }
+ return true;
+}
+
+void MEDFileParameterMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+{
+ med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ writeLL(fid,*this);
+}
+
+void MEDFileParameterMultiTS::writeLL(med_idt fid, const MEDFileWritable& mw) const throw(INTERP_KERNEL::Exception)
+{
+ std::set<med_parameter_type> diffType;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++)
+ {
+ const MEDFileParameter1TS *elt(*it);
+ if(dynamic_cast<const MEDFileParameterDouble1TSWTI *>(elt))
+ diffType.insert(MED_FLOAT64);
+ }
+ if(diffType.size()>1)
+ throw INTERP_KERNEL::Exception("MEDFileParameterMultiTS::writeLL : impossible to mix type of data in parameters in MED file ! Only float64 or only int32 ...");
+ if(diffType.empty())
+ return;
+ med_parameter_type typ=*diffType.begin();
+ MEDFileParameterTinyInfo::writeLLHeader(fid,typ);
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++)
+ {
+ const MEDFileParameter1TS *elt(*it);
+ if(elt)
+ elt->writeLL(fid,_name,mw);
+ }
+}
+
+std::string MEDFileParameterMultiTS::simpleRepr() const
+{
+ std::ostringstream oss;
+ simpleRepr2(0,oss);
+ return oss.str();
+}
+
+void MEDFileParameterMultiTS::simpleRepr2(int bkOffset, std::ostream& oss) const
+{
+ MEDFileParameterTinyInfo::mainRepr(bkOffset,oss);
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++)
+ {
+ const MEDFileParameter1TS *elt(*it);
+ if(elt)
+ elt->simpleRepr2(bkOffset+2,oss);
+ }
+}
+
+void MEDFileParameterMultiTS::appendValue(int dt, int it, double time, double val) throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileParameterDouble1TSWTI> elt=MEDFileParameterDouble1TSWTI::New(dt,it,time);
+ elt->setValue(val);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> elt2((MEDFileParameterDouble1TSWTI*)elt); elt2->incrRef();
+ _param_per_ts.push_back(elt2);
+}
+
+double MEDFileParameterMultiTS::getDoubleValue(int iteration, int order) const throw(INTERP_KERNEL::Exception)
+{
+ int pos=getPosOfTimeStep(iteration,order);
+ const MEDFileParameter1TS *elt=_param_per_ts[pos];
+ if(!elt)
+ {
+ std::ostringstream oss; oss << "MEDFileParameterMultiTS::getDoubleValue : time iteration it=" << iteration << " order=" << order;
+ oss << " exists but elt is empty !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ const MEDFileParameterDouble1TSWTI *eltC=dynamic_cast<const MEDFileParameterDouble1TSWTI *>(elt);
+ if(!eltC)
+ {
+ std::ostringstream oss; oss << "MEDFileParameterMultiTS::getDoubleValue : time iteration it=" << iteration << " order=" << order;
+ oss << " exists but not double !";
+ }
+ return eltC->getValue();
+}
+
+int MEDFileParameterMultiTS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
+{
+ int ret=0;
+ std::ostringstream oss; oss << "MEDFileParameterMultiTS::getPosOfTimeStep : no such iteration=" << iteration << " order=" << order << " ! Possibilities are :";
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++,ret++)
+ {
+ const MEDFileParameter1TS *elt(*it);
+ if(elt)
+ {
+ if(elt->getIteration()==iteration && elt->getOrder())
+ return ret;
+ else
+ oss << "(" << elt->getIteration() << "," << elt->getOrder() << "), ";
+ }
+ }
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
+int MEDFileParameterMultiTS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
+{
+ int ret=0;
+ std::ostringstream oss; oss << "MEDFileParameterMultiTS::getPosGivenTime : no such time=" << time << " ! Possibilities are :";
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++,ret++)
+ {
+ const MEDFileParameter1TS *elt(*it);
+ if(elt)
+ {
+ if(fabs(elt->getTimeValue()-time)<=eps)
+ return ret;
+ else
+ oss << elt->getTimeValue() << ", ";
+ }
+ }
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
+/*!
+ * \return an internal pointer that can be null. Warning the caller is \b not responsible of the returned pointer.
+ */
+MEDFileParameter1TS *MEDFileParameterMultiTS::getTimeStepAtPos(int posId) const throw(INTERP_KERNEL::Exception)
+{
+ if(posId<0 || posId>=(int)_param_per_ts.size())
+ {
+ std::ostringstream oss; oss << "MEDFileParameterMultiTS::getTimeStepAtPos : invalid pos ! Should be in [0," << _param_per_ts.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return const_cast<MEDFileParameter1TS *>(static_cast<const MEDFileParameter1TS *>(_param_per_ts[posId]));
+}
+
+void MEDFileParameterMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
+{
+ std::vector<bool> b(_param_per_ts.size(),true);
+ int len=(int)_param_per_ts.size();
+ for(const int *w=startIds;w!=endIds;w++)
+ if(*w>=0 && *w<len)
+ b[*w]=false;
+ else
+ {
+ std::ostringstream oss; oss << "MEDFileParameterMultiTS::eraseTimeStepIds : At pos #" << std::distance(startIds,w) << " value is " << *w << " should be in [0," << len << ") !"; throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ std::size_t newNb=std::count(b.begin(),b.end(),true);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> > paramPerTs(newNb);
+ std::size_t j=0;
+ for(std::size_t i=0;i<_param_per_ts.size();i++)
+ if(b[i])
+ paramPerTs[j++]=_param_per_ts[i];
+ _param_per_ts=paramPerTs;
+}
+
+std::vector< std::pair<int,int> > MEDFileParameterMultiTS::getIterations() const throw(INTERP_KERNEL::Exception)
+{
+ std::vector< std::pair<int,int> > ret;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++)
+ {
+ const MEDFileParameter1TS *elt(*it);
+ if(elt)
+ ret.push_back(std::pair<int,int>(elt->getIteration(),elt->getOrder()));
+ }
+ return ret;
+}
+
+/*!
+ * \param [out] ret1
+ */
+std::vector< std::pair<int,int> > MEDFileParameterMultiTS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector< std::pair<int,int> > ret0;
+ ret1.clear();
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++)
+ {
+ const MEDFileParameter1TS *elt(*it);
+ if(elt)
+ {
+ ret0.push_back(std::pair<int,int>(elt->getIteration(),elt->getOrder()));
+ ret1.push_back(elt->getTimeValue());
+ }
+ }
+ return ret0;
+}
+
+MEDFileParameters *MEDFileParameters::New()
+{
+ return new MEDFileParameters;
+}
+
+MEDFileParameters *MEDFileParameters::New(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileParameters(fileName);
+}
+
+MEDFileParameters::MEDFileParameters(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ int nbPar=MEDnParameter(fid);
+ _params.resize(nbPar);
+ INTERP_KERNEL::AutoPtr<char> pName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> descName=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE);
+ INTERP_KERNEL::AutoPtr<char> unitName=MEDLoaderBase::buildEmptyString(MED_SNAME_SIZE);
+ med_parameter_type paramType;
+ for(int i=0;i<nbPar;i++)
+ {
+ int nbOfSteps;
+ MEDparameterInfo(fid,i+1,pName,¶mType,descName,unitName,&nbOfSteps);
+ std::string paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE);
+ _params[i]=MEDFileParameterMultiTS::New(fileName,paramNameCpp.c_str());
+ }
+}
+
+MEDFileParameters::MEDFileParameters()
+{
+}
+
+std::size_t MEDFileParameters::getHeapMemorySize() const
+{
+ std::size_t ret=sizeof(MEDFileParameters);
+ std::size_t ret2=sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS>)*_params.capacity();
+ for(std::size_t i=0;i<_params.size();i++)
+ {
+ const MEDFileParameterMultiTS *pt(_params[i]);
+ if(pt)
+ ret2+=pt->getHeapMemorySize();
+ }
+ return ret2+ret;
+}
+
+MEDFileParameters *MEDFileParameters::deepCpy() const throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileParameters(*this,true);
+}
+
+bool MEDFileParameters::isEqual(const MEDFileParameters *other, double eps, std::string& what) const
+{
+ if(!other)
+ { what="other is null !"; return false; }
+ if(_params.size()!=other->_params.size())
+ { what="number of parameters differs !"; return false; }
+ std::ostringstream oss;
+ for(std::size_t i=0;i<_params.size();i++)
+ {
+ const MEDFileParameterMultiTS *a(_params[i]),*b(other->_params[i]);
+ if((a && !b) || (!a && b))
+ { oss << "At param with id #" << i << " pointer is defined on one side not in the other !"; what=oss.str(); return false; }
+ if(a)
+ if(!a->isEqual(b,eps,what))
+ { oss << " At param with id #" << i << " non equality !"; what+=oss.str(); return false; }
+ }
+ return true;
+}
+
+MEDFileParameters::MEDFileParameters(const MEDFileParameters& other, bool deepCopy):MEDFileWritable(other),_params(other._params)
+{
+ if(deepCopy)
+ for(std::size_t i=0;i<_params.size();i++)
+ {
+ const MEDFileParameterMultiTS *elt=_params[i];
+ if(elt)
+ _params[i]=elt->deepCpy();
+ }
+}
+
+void MEDFileParameters::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+{
+ med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ writeLL(fid);
+}
+
+void MEDFileParameters::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS> >::const_iterator it=_params.begin();it!=_params.end();it++)
+ {
+ const MEDFileParameterMultiTS *elt(*it);
+ if(elt)
+ elt->writeLL(fid,*this);
+ }
+}
+
+std::vector<std::string> MEDFileParameters::getParamsNames() const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> ret(_params.size());
+ int i=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS> >::const_iterator it=_params.begin();it!=_params.end();it++,i++)
+ {
+ const MEDFileParameterMultiTS *p=(*it);
+ if(p)
+ {
+ ret[i]=p->getName();
+ }
+ else
+ {
+ std::ostringstream oss; oss << "MEDFileParameters::getParamsNames : At rank #" << i << " param is not defined !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ return ret;
+}
+
+std::string MEDFileParameters::simpleRepr() const
+{
+ std::ostringstream oss;
+ simpleReprWithoutHeader(oss);
+ return oss.str();
+}
+
+void MEDFileParameters::simpleReprWithoutHeader(std::ostream& oss) const
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS> >::const_iterator it=_params.begin();it!=_params.end();it++)
+ {
+ const MEDFileParameterMultiTS *elt(*it);
+ if(elt)
+ elt->simpleRepr2(2,oss);
+ }
+}
+
+void MEDFileParameters::resize(int newSize) throw(INTERP_KERNEL::Exception)
+{
+ if(newSize<0)
+ throw INTERP_KERNEL::Exception("MEDFileParameters::resize : should be positive !");
+ _params.resize(newSize);
+}
+
+void MEDFileParameters::pushParam(MEDFileParameterMultiTS *param) throw(INTERP_KERNEL::Exception)
+{
+ if(param)
+ param->incrRef();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS> elt(param);
+ _params.push_back(elt);
+}
+
+void MEDFileParameters::setParamAtPos(int i, MEDFileParameterMultiTS *param) throw(INTERP_KERNEL::Exception)
+{
+ if(i<0)
+ throw INTERP_KERNEL::Exception("MEDFileParameters::setParamAtPos : should be positive !");
+ if(i>=(int)_params.size())
+ _params.resize(i+1);
+ if(param)
+ param->incrRef();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS> elt(param);
+ _params[i]=elt;
+}
+
+/*!
+ * \return an internal pointer that can be null. Warning the caller is \b not responsible of the returned pointer.
+ */
+MEDFileParameterMultiTS *MEDFileParameters::getParamAtPos(int i) const throw(INTERP_KERNEL::Exception)
+{
+ if(i<0 || i>=(int)_params.size())
+ {
+ std::ostringstream oss; oss << "MEDFileParameters::getParamAtPos : should be in [0," << _params.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ const MEDFileParameterMultiTS *elt=_params[i];
+ return const_cast<MEDFileParameterMultiTS *>(elt);
+}
+
+/*!
+ * \return an internal pointer that can be null. Warning the caller is \b not responsible of the returned pointer.
+ */
+MEDFileParameterMultiTS *MEDFileParameters::getParamWithName(const char *paramName) const throw(INTERP_KERNEL::Exception)
+{
+ int pos=getPosFromParamName(paramName);
+ return getParamAtPos(pos);
+}
+
+void MEDFileParameters::destroyParamAtPos(int i) throw(INTERP_KERNEL::Exception)
+{
+ if(i<0 || i>=(int)_params.size())
+ {
+ std::ostringstream oss; oss << "MEDFileParameters::destroyParamAtPos : should be in [0," << _params.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ _params[i]=MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS>(0);
+}
+
+int MEDFileParameters::getPosFromParamName(const char *paramName) const throw(INTERP_KERNEL::Exception)
+{
+ std::ostringstream oss; oss << "MEDFileParameters::getPosFromParamName : no such name=" << paramName << " ! Possibilities are :";
+ int ret=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS> >::const_iterator it=_params.begin();it!=_params.end();it++,ret++)
+ {
+ const MEDFileParameterMultiTS *elt(*it);
+ if(elt)
+ {
+ if(std::string(elt->getName())==paramName)
+ return ret;
+ else
+ oss << elt->getName() << ", ";
+ }
+ }
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
+int MEDFileParameters::getNumberOfParams() const throw(INTERP_KERNEL::Exception)
+{
+ return (int)_params.size();
+}
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay (CEA/DEN)
+
+#ifndef __MEDFILEPARAMETER_HXX__
+#define __MEDFILEPARAMETER_HXX__
+
+#include "MEDLoaderDefines.hxx"
+#include "MEDFileUtilities.hxx"
+#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+
+namespace ParaMEDMEM
+{
+ class MEDLOADER_EXPORT MEDFileParameter1TS : public RefCountObject
+ {
+ public:
+ virtual MEDFileParameter1TS *deepCpy() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual bool isEqual(const MEDFileParameter1TS *other, double eps, std::string& what) const;
+ virtual void simpleRepr2(int bkOffset, std::ostream& oss) const = 0;
+ virtual void readValue(med_idt fid, const std::string& name) throw(INTERP_KERNEL::Exception) = 0;
+ virtual void writeLL(med_idt fid, const std::string& name, const MEDFileWritable& mw) const throw(INTERP_KERNEL::Exception) = 0;
+ public:
+ void setIteration(int it) { _iteration=it; }
+ int getIteration() const { return _iteration; }
+ void setOrder(int order) { _order=order; }
+ int getOrder() const { return _order; }
+ void setTimeValue(double time) { _time=time; }
+ void setTime(int dt, int it, double time) { _time=time; _iteration=dt; _order=it; }
+ double getTime(int& dt, int& it) { dt=_iteration; it=_order; return _time; }
+ double getTimeValue() const { return _time; }
+ protected:
+ MEDFileParameter1TS(int iteration, int order, double time);
+ MEDFileParameter1TS();
+ protected:
+ int _iteration;
+ int _order;
+ double _time;
+ };
+
+ class MEDLOADER_EXPORT MEDFileParameterDouble1TSWTI : public MEDFileParameter1TS
+ {
+ public:
+ static MEDFileParameterDouble1TSWTI *New(int iteration, int order, double time);
+ MEDFileParameter1TS *deepCpy() const throw(INTERP_KERNEL::Exception);
+ void setValue(double val) throw(INTERP_KERNEL::Exception) { _arr=val; }
+ double getValue() const throw(INTERP_KERNEL::Exception) { return _arr; }
+ bool isEqual(const MEDFileParameter1TS *other, double eps, std::string& what) const;
+ std::size_t getHeapMemorySize() const;
+ void readValue(med_idt fid, const std::string& name) throw(INTERP_KERNEL::Exception);
+ std::string simpleRepr() const;
+ protected:
+ MEDFileParameterDouble1TSWTI();
+ MEDFileParameterDouble1TSWTI(int iteration, int order, double time);
+ void simpleRepr2(int bkOffset, std::ostream& oss) const;
+ void finishLoading(med_idt fid, const std::string& name, int dt, int it, int nbOfSteps) throw(INTERP_KERNEL::Exception);
+ void finishLoading(med_idt fid, const std::string& name, int timeStepId) throw(INTERP_KERNEL::Exception);
+ void writeLL(med_idt fid, const std::string& name, const MEDFileWritable& mw) const throw(INTERP_KERNEL::Exception);
+ protected:
+ double _arr;
+ };
+
+ class MEDLOADER_EXPORT MEDFileParameterTinyInfo : public MEDFileWritable
+ {
+ public:
+ void setDescription(const char *name) { _desc_name=name; }
+ const char *getDescription() const { return _desc_name.c_str(); }
+ void setTimeUnit(const char *unit) { _dt_unit=unit; }
+ const char *getTimeUnit() const { return _dt_unit.c_str(); }
+ std::size_t getHeapMemSizeOfStrings() const;
+ bool isEqualStrings(const MEDFileParameterTinyInfo& other, std::string& what) const;
+ protected:
+ void writeLLHeader(med_idt fid, med_parameter_type typ) const throw(INTERP_KERNEL::Exception);
+ void mainRepr(int bkOffset, std::ostream& oss) const;
+ protected:
+ std::string _dt_unit;
+ std::string _name;
+ std::string _desc_name;
+ };
+
+ class MEDLOADER_EXPORT MEDFileParameterDouble1TS : public MEDFileParameterDouble1TSWTI, public MEDFileParameterTinyInfo
+ {
+ public:
+ static MEDFileParameterDouble1TS *New();
+ static MEDFileParameterDouble1TS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileParameterDouble1TS *New(const char *fileName, const char *paramName) throw(INTERP_KERNEL::Exception);
+ static MEDFileParameterDouble1TS *New(const char *fileName, const char *paramName, int dt, int it) throw(INTERP_KERNEL::Exception);
+ virtual MEDFileParameter1TS *deepCpy() const throw(INTERP_KERNEL::Exception);
+ virtual bool isEqual(const MEDFileParameter1TS *other, double eps, std::string& what) const;
+ virtual std::string simpleRepr() const;
+ std::size_t getHeapMemorySize() const;
+ void setName(const char *name) throw(INTERP_KERNEL::Exception) { _name=name; }
+ const char *getName() const throw(INTERP_KERNEL::Exception) { return _name.c_str(); }
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ private:
+ MEDFileParameterDouble1TS();
+ MEDFileParameterDouble1TS(const char *fileName) throw(INTERP_KERNEL::Exception);
+ MEDFileParameterDouble1TS(const char *fileName, const char *paramName) throw(INTERP_KERNEL::Exception);
+ MEDFileParameterDouble1TS(const char *fileName, const char *paramName, int dt, int it) throw(INTERP_KERNEL::Exception);
+ };
+
+ class MEDLOADER_EXPORT MEDFileParameterMultiTS : public RefCountObject, public MEDFileParameterTinyInfo
+ {
+ public:
+ static MEDFileParameterMultiTS *New();
+ static MEDFileParameterMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileParameterMultiTS *New(const char *fileName, const char *paramName) throw(INTERP_KERNEL::Exception);
+ const char *getName() const { return _name.c_str(); }
+ void setName(const char *name) { _name=name; }
+ std::size_t getHeapMemorySize() const;
+ MEDFileParameterMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception);
+ bool isEqual(const MEDFileParameterMultiTS *other, double eps, std::string& what) const;
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ void writeLL(med_idt fid, const MEDFileWritable& mw) const throw(INTERP_KERNEL::Exception);
+ std::string simpleRepr() const;
+ void appendValue(int dt, int it, double time, double val) throw(INTERP_KERNEL::Exception);
+ double getDoubleValue(int iteration, int order) const throw(INTERP_KERNEL::Exception);
+ int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
+ int getPosGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
+ MEDFileParameter1TS *getTimeStepAtPos(int posId) const throw(INTERP_KERNEL::Exception);
+ void eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception);
+ std::vector< std::pair<int,int> > getIterations() const throw(INTERP_KERNEL::Exception);
+ std::vector< std::pair<int,int> > getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception);
+ void simpleRepr2(int bkOffset, std::ostream& oss) const;
+ protected:
+ MEDFileParameterMultiTS();
+ MEDFileParameterMultiTS(const MEDFileParameterMultiTS& other, bool deepCopy);
+ MEDFileParameterMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception);
+ MEDFileParameterMultiTS(const char *fileName, const char *paramName) throw(INTERP_KERNEL::Exception);
+ void finishLoading(med_idt fid, med_parameter_type typ, int nbOfSteps) throw(INTERP_KERNEL::Exception);
+ protected:
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> > _param_per_ts;
+ };
+
+ class MEDLOADER_EXPORT MEDFileParameters : public RefCountObject, public MEDFileWritable
+ {
+ public:
+ static MEDFileParameters *New();
+ static MEDFileParameters *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ std::size_t getHeapMemorySize() const;
+ MEDFileParameters *deepCpy() const throw(INTERP_KERNEL::Exception);
+ bool isEqual(const MEDFileParameters *other, double eps, std::string& what) const;
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getParamsNames() const throw(INTERP_KERNEL::Exception);
+ std::string simpleRepr() const;
+ void simpleReprWithoutHeader(std::ostream& oss) const;
+ void resize(int newSize) throw(INTERP_KERNEL::Exception);
+ void pushParam(MEDFileParameterMultiTS *param) throw(INTERP_KERNEL::Exception);
+ void setParamAtPos(int i, MEDFileParameterMultiTS *param) throw(INTERP_KERNEL::Exception);
+ MEDFileParameterMultiTS *getParamAtPos(int i) const throw(INTERP_KERNEL::Exception);
+ MEDFileParameterMultiTS *getParamWithName(const char *paramName) const throw(INTERP_KERNEL::Exception);
+ void destroyParamAtPos(int i) throw(INTERP_KERNEL::Exception);
+ int getPosFromParamName(const char *paramName) const throw(INTERP_KERNEL::Exception);
+ int getNumberOfParams() const throw(INTERP_KERNEL::Exception);
+ protected:
+ void simpleRepr2(int bkOffset, std::ostream& oss) const;
+ MEDFileParameters(const char *fileName) throw(INTERP_KERNEL::Exception);
+ MEDFileParameters(const MEDFileParameters& other, bool deepCopy);
+ MEDFileParameters();
+ protected:
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS> > _params;
+ };
+}
+
+#endif
salomeinclude_HEADERS= \
MEDLoaderDefines.hxx \
-MEDLoader.hxx MEDLoaderBase.hxx MEDFileUtilities.hxx MEDFileMesh.hxx MEDFileMeshLL.hxx \
-MEDFileMeshElt.hxx MEDFileBasis.hxx MEDFileField.hxx MEDFileData.hxx \
+MEDLoader.hxx MEDLoaderBase.hxx MEDFileUtilities.hxx MEDFileMesh.hxx MEDFileMeshLL.hxx \
+MEDFileMeshElt.hxx MEDFileBasis.hxx MEDFileField.hxx MEDFileData.hxx MEDFileParameter.hxx \
SauvMedConvertor.hxx SauvReader.hxx SauvWriter.hxx SauvUtilities.hxx
dist_libmedloader_la_SOURCES= \
MEDLoader.cxx MEDLoaderBase.cxx MEDFileUtilities.cxx \
MEDFileMesh.cxx MEDFileMeshElt.cxx MEDFileBasis.cxx \
-MEDFileMeshLL.cxx MEDFileField.cxx MEDFileData.cxx \
-SauvMedConvertor.cxx SauvReader.cxx SauvWriter.cxx
+MEDFileMeshLL.cxx MEDFileField.cxx MEDFileData.cxx \
+SauvMedConvertor.cxx SauvReader.cxx SauvWriter.cxx \
+MEDFileParameter.cxx
libmedloader_la_CPPFLAGS= $(MED3_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \
-I$(srcdir)/../INTERP_KERNEL \
{
static vector<const int*> conn;
static const int hexa20 [] = {0,6,4,2, 12,18,16,14, 7,5,3,1, 19,17,15,13, 8,11,10,9};
- static const int penta15[] = {0,2,4, 9,11,13, 1,3,5, 10,12,14, 6,7,3};
+ static const int penta15[] = {0,2,4, 9,11,13, 1,3,5, 10,12,14, 6,8,7};
static const int pyra13 [] = {0,2,4,6, 12, 1,3,5,7, 8,9,10,11};
static const int tetra10[] = {0,2,4, 9, 1,3,5, 6,7,8};
static const int quad8 [] = {0,2,4,6, 1,3,5,7};
#include "MEDLoader.hxx"
#include "MEDFileMesh.hxx"
#include "MEDFileField.hxx"
+#include "MEDFileParameter.hxx"
#include "MEDFileData.hxx"
#include "MEDLoaderTypemaps.i"
#include "SauvReader.hxx"
$result=convertMEDFileMesh($1,$owner);
}
+%typemap(out) ParaMEDMEM::MEDFileParameter1TS*
+{
+ $result=convertMEDFileParameter1TS($1,$owner);
+}
+
%newobject MEDLoader::ReadUMeshFromFamilies;
%newobject MEDLoader::ReadUMeshFromGroups;
%newobject MEDLoader::ReadUMeshFromFile;
%newobject ParaMEDMEM::MEDFileData::deepCpy;
%newobject ParaMEDMEM::MEDFileData::getMeshes;
%newobject ParaMEDMEM::MEDFileData::getFields;
+%newobject ParaMEDMEM::MEDFileData::getParams;
+
+%newobject ParaMEDMEM::MEDFileParameterDouble1TS::New;
+%newobject ParaMEDMEM::MEDFileParameterDouble1TS::deepCpy;
+%newobject ParaMEDMEM::MEDFileParameterMultiTS::New;
+%newobject ParaMEDMEM::MEDFileParameterMultiTS::deepCpy;
+%newobject ParaMEDMEM::MEDFileParameterMultiTS::getTimeStepAtPos;
+%newobject ParaMEDMEM::MEDFileParameterMultiTS::__getitem__;
+%newobject ParaMEDMEM::MEDFileParameters::New;
+%newobject ParaMEDMEM::MEDFileParameters::deepCpy;
+%newobject ParaMEDMEM::MEDFileParameters::getParamAtPos;
+%newobject ParaMEDMEM::MEDFileParameters::getParamWithName;
+%newobject ParaMEDMEM::MEDFileParameters::__getitem__;
%newobject ParaMEDMEM::SauvWriter::New;
%newobject ParaMEDMEM::SauvReader::New;
%feature("unref") MEDFileField1TS "$this->decrRef();"
%feature("unref") MEDFileFieldMultiTS "$this->decrRef();"
%feature("unref") MEDFileFields "$this->decrRef();"
+%feature("unref") MEDFileParameter1TS "$this->decrRef();"
+%feature("unref") MEDFileParameterDouble1TSWTI "$this->decrRef();"
+%feature("unref") MEDFileParameterDouble1TS "$this->decrRef();"
+%feature("unref") MEDFileParameterMultiTS "$this->decrRef();"
+%feature("unref") MEDFileParameters "$this->decrRef();"
%feature("unref") MEDFileData "$this->decrRef();"
%feature("unref") SauvReader "$this->decrRef();"
%feature("unref") SauvWriter "$this->decrRef();"
{
public:
static MEDFileMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
- static MEDFileMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1);
+ static MEDFileMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception);
virtual MEDFileMesh *deepCpy() const throw(INTERP_KERNEL::Exception);
virtual MEDFileMesh *shallowCpy() const throw(INTERP_KERNEL::Exception);
virtual void clearNonDiscrAttributes() const;
void setTimeUnit(const char *unit);
const char *getTimeUnit() const;
virtual int getNumberOfNodes() const throw(INTERP_KERNEL::Exception);
- std::vector<int> getNonEmptyLevels() const;
- std::vector<int> getNonEmptyLevelsExt() const;
+ std::vector<int> getNonEmptyLevels() const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception);
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
int getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
//
return MEDFileMesh::New(fileName);
}
- MEDFileMesh(const char *fileName, const char *mName, int dt=-1, int it=-1)
+ MEDFileMesh(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception)
{
return MEDFileMesh::New(fileName,mName,dt,it);
}
}
};
+ class MEDFileParameter1TS : public RefCountObject
+ {
+ public:
+ void setIteration(int it);
+ int getIteration() const;
+ void setOrder(int order);
+ int getOrder() const;
+ void setTimeValue(double time);
+ void setTime(int dt, int it, double time);
+ double getTime(int& dt, int& it);
+ double getTimeValue() const;
+ };
+
+ class MEDFileParameterDouble1TSWTI : public MEDFileParameter1TS
+ {
+ public:
+ void setValue(double val) throw(INTERP_KERNEL::Exception);
+ double getValue() const throw(INTERP_KERNEL::Exception);
+ std::string simpleRepr() const;
+ %extend
+ {
+ std::string __str__() const throw(INTERP_KERNEL::Exception)
+ {
+ return self->simpleRepr();
+ }
+ }
+ };
+
+ class MEDFileParameterTinyInfo : public MEDFileWritable
+ {
+ public:
+ void setDescription(const char *name);
+ const char *getDescription() const;
+ void setTimeUnit(const char *unit);
+ const char *getTimeUnit() const;
+ };
+
+ class MEDFileParameterDouble1TS : public MEDFileParameterDouble1TSWTI, public MEDFileParameterTinyInfo
+ {
+ public:
+ static MEDFileParameterDouble1TS *New();
+ static MEDFileParameterDouble1TS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileParameterDouble1TS *New(const char *fileName, const char *paramName) throw(INTERP_KERNEL::Exception);
+ static MEDFileParameterDouble1TS *New(const char *fileName, const char *paramName, int dt, int it) throw(INTERP_KERNEL::Exception);
+ virtual MEDFileParameter1TS *deepCpy() const throw(INTERP_KERNEL::Exception);
+ virtual std::string simpleRepr() const;
+ void setName(const char *name) throw(INTERP_KERNEL::Exception);
+ const char *getName() const throw(INTERP_KERNEL::Exception);
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ MEDFileParameterDouble1TS()
+ {
+ return MEDFileParameterDouble1TS::New();
+ }
+
+ MEDFileParameterDouble1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
+ {
+ return MEDFileParameterDouble1TS::New(fileName);
+ }
+
+ MEDFileParameterDouble1TS(const char *fileName, const char *paramName) throw(INTERP_KERNEL::Exception)
+ {
+ return MEDFileParameterDouble1TS::New(fileName,paramName);
+ }
+
+ MEDFileParameterDouble1TS(const char *fileName, const char *paramName, int dt, int it) throw(INTERP_KERNEL::Exception)
+ {
+ return MEDFileParameterDouble1TS::New(fileName,paramName,dt,it);
+ }
+
+ std::string __str__() const throw(INTERP_KERNEL::Exception)
+ {
+ return self->simpleRepr();
+ }
+
+ PyObject *isEqual(const MEDFileParameter1TS *other, double eps) const
+ {
+ std::string what;
+ bool ret0=self->isEqual(other,eps,what);
+ PyObject *res=PyList_New(2);
+ PyObject *ret0Py=ret0?Py_True:Py_False;
+ Py_XINCREF(ret0Py);
+ PyList_SetItem(res,0,ret0Py);
+ PyList_SetItem(res,1,PyString_FromString(what.c_str()));
+ return res;
+ }
+ }
+ };
+
+ class MEDFileParameterMultiTS : public RefCountObject, public MEDFileParameterTinyInfo
+ {
+ public:
+ static MEDFileParameterMultiTS *New();
+ static MEDFileParameterMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileParameterMultiTS *New(const char *fileName, const char *paramName) throw(INTERP_KERNEL::Exception);
+ const char *getName() const;
+ void setName(const char *name);
+ MEDFileParameterMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception);
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ std::string simpleRepr() const;
+ void appendValue(int dt, int it, double time, double val) throw(INTERP_KERNEL::Exception);
+ double getDoubleValue(int iteration, int order) const throw(INTERP_KERNEL::Exception);
+ int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
+ int getPosGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ MEDFileParameterMultiTS()
+ {
+ return MEDFileParameterMultiTS::New();
+ }
+
+ MEDFileParameterMultiTS(const char *fileName)
+ {
+ return MEDFileParameterMultiTS::New(fileName);
+ }
+
+ MEDFileParameterMultiTS(const char *fileName, const char *paramName)
+ {
+ return MEDFileParameterMultiTS::New(fileName,paramName);
+ }
+
+ std::string __str__() const throw(INTERP_KERNEL::Exception)
+ {
+ return self->simpleRepr();
+ }
+
+ PyObject *isEqual(const MEDFileParameterMultiTS *other, double eps) const
+ {
+ std::string what;
+ bool ret0=self->isEqual(other,eps,what);
+ PyObject *res=PyList_New(2);
+ PyObject *ret0Py=ret0?Py_True:Py_False;
+ Py_XINCREF(ret0Py);
+ PyList_SetItem(res,0,ret0Py);
+ PyList_SetItem(res,1,PyString_FromString(what.c_str()));
+ return res;
+ }
+
+ void eraseTimeStepIds(PyObject *ids) throw(INTERP_KERNEL::Exception)
+ {
+ int sw;
+ int pos1;
+ std::vector<int> pos2;
+ DataArrayInt *pos3=0;
+ DataArrayIntTuple *pos4=0;
+ convertObjToPossibleCpp1(ids,sw,pos1,pos2,pos3,pos4);
+ switch(sw)
+ {
+ case 1:
+ {
+ self->eraseTimeStepIds(&pos1,&pos1+1);
+ return;
+ }
+ case 2:
+ {
+ if(pos2.empty())
+ return;
+ self->eraseTimeStepIds(&pos2[0],&pos2[0]+pos2.size());
+ return ;
+ }
+ case 3:
+ {
+ self->eraseTimeStepIds(pos3->begin(),pos3->end());
+ return ;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDFileParameterMultiTS::eraseTimeStepIds : unexpected input array type recognized !");
+ }
+ }
+
+ int getTimeStepId(PyObject *elt0) const throw(INTERP_KERNEL::Exception)
+ {
+ if(elt0 && PyInt_Check(elt0))
+ {//fmts[3]
+ int pos=PyInt_AS_LONG(elt0);
+ return pos;
+ }
+ else if(elt0 && PyTuple_Check(elt0))
+ {
+ if(PyTuple_Size(elt0)==2)
+ {
+ PyObject *o0=PyTuple_GetItem(elt0,0);
+ PyObject *o1=PyTuple_GetItem(elt0,1);
+ if(PyInt_Check(o0) && PyInt_Check(o1))
+ {//fmts(1,-1)
+ int iter=PyInt_AS_LONG(o0);
+ int order=PyInt_AS_LONG(o1);
+ return self->getPosOfTimeStep(iter,order);
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileParameterMultiTS::getTimeStepId : invalid input param ! input is a tuple of size 2 but two integers are expected in this tuple to request a time steps !");
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileParameterMultiTS::getTimeStepId : invalid input param ! input is a tuple of size != 2 ! two integers are expected in this tuple to request a time steps !");
+ }
+ else if(elt0 && PyFloat_Check(elt0))
+ {
+ double val=PyFloat_AS_DOUBLE(elt0);
+ return self->getPosGivenTime(val);
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileParameterMultiTS::getTimeStepId : invalid input params ! expected fmts[int], fmts[int,int] or fmts[double] to request time step !");
+ }
+
+ MEDFileParameter1TS *__getitem__(PyObject *elt0) const throw(INTERP_KERNEL::Exception)
+ {
+ MEDFileParameter1TS *ret=self->getTimeStepAtPos(ParaMEDMEM_MEDFileParameterMultiTS_getTimeStepId(self,elt0));
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+
+ std::vector<int> getTimeStepIds(PyObject *elts) const throw(INTERP_KERNEL::Exception)
+ {
+ if(PyList_Check(elts))
+ {
+ int sz=PyList_Size(elts);
+ std::vector<int> ret(sz);
+ for(int i=0;i<sz;i++)
+ {
+ PyObject *elt=PyList_GetItem(elts,i);
+ ret[i]=ParaMEDMEM_MEDFileParameterMultiTS_getTimeStepId(self,elt);
+ }
+ return ret;
+ }
+ else
+ {
+ std::vector<int> ret(1);
+ ret[0]=ParaMEDMEM_MEDFileParameterMultiTS_getTimeStepId(self,elts);
+ return ret;
+ }
+ }
+
+ void __delitem__(PyObject *elts) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> idsToRemove=ParaMEDMEM_MEDFileParameterMultiTS_getTimeStepIds(self,elts);
+ if(!idsToRemove.empty())
+ self->eraseTimeStepIds(&idsToRemove[0],&idsToRemove[0]+idsToRemove.size());
+ }
+
+ MEDFileParameter1TS *getTimeStepAtPos(int posId) const throw(INTERP_KERNEL::Exception)
+ {
+ MEDFileParameter1TS *ret=self->getTimeStepAtPos(posId);
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+
+ PyObject *getIterations() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair<int,int> > res=self->getIterations();
+ PyObject *ret=PyList_New(res.size());
+ int rk=0;
+ for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
+ {
+ PyObject *elt=PyTuple_New(2);
+ PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
+ PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
+ PyList_SetItem(ret,rk,elt);
+ }
+ return ret;
+ }
+
+ PyObject *getTimeSteps() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<double> res2;
+ std::vector< std::pair<int,int> > res=self->getTimeSteps(res2);
+ PyObject *ret=PyList_New(res.size());
+ int rk=0;
+ for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
+ {
+ PyObject *elt=PyTuple_New(3);
+ PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
+ PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
+ PyTuple_SetItem(elt,2,SWIG_From_double(res2[rk]));
+ PyList_SetItem(ret,rk,elt);
+ }
+ return ret;
+ }
+ }
+ };
+
+ class MEDFileParameters : public RefCountObject, public MEDFileWritable
+ {
+ public:
+ static MEDFileParameters *New();
+ static MEDFileParameters *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ MEDFileParameters *deepCpy() const throw(INTERP_KERNEL::Exception);
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getParamsNames() const throw(INTERP_KERNEL::Exception);
+ std::string simpleRepr() const;
+ void resize(int newSize) throw(INTERP_KERNEL::Exception);
+ void pushParam(MEDFileParameterMultiTS *param) throw(INTERP_KERNEL::Exception);
+ void setParamAtPos(int i, MEDFileParameterMultiTS *param) throw(INTERP_KERNEL::Exception);
+ void destroyParamAtPos(int i) throw(INTERP_KERNEL::Exception);
+ int getPosFromParamName(const char *paramName) const throw(INTERP_KERNEL::Exception);
+ int getNumberOfParams() const throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ MEDFileParameters()
+ {
+ return MEDFileParameters::New();
+ }
+
+ MEDFileParameters(const char *fileName)
+ {
+ return MEDFileParameters::New(fileName);
+ }
+
+ std::string __str__() const throw(INTERP_KERNEL::Exception)
+ {
+ return self->simpleRepr();
+ }
+
+ MEDFileParameterMultiTS *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ if(PyInt_Check(obj))
+ {
+ MEDFileParameterMultiTS *ret=self->getParamAtPos((int)PyInt_AS_LONG(obj));
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+ else if(PyString_Check(obj))
+ {
+ MEDFileParameterMultiTS *ret=self->getParamWithName(PyString_AsString(obj));
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileParameters::__getitem__ : only integer or string with meshname supported !");
+ }
+
+ MEDFileParameterMultiTS *getParamAtPos(int i) const throw(INTERP_KERNEL::Exception)
+ {
+ MEDFileParameterMultiTS *ret=self->getParamAtPos(i);
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+
+ MEDFileParameterMultiTS *getParamWithName(const char *paramName) const throw(INTERP_KERNEL::Exception)
+ {
+ MEDFileParameterMultiTS *ret=self->getParamWithName(paramName);
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+
+ PyObject *isEqual(const MEDFileParameters *other, double eps) const
+ {
+ std::string what;
+ bool ret0=self->isEqual(other,eps,what);
+ PyObject *res=PyList_New(2);
+ PyObject *ret0Py=ret0?Py_True:Py_False;
+ Py_XINCREF(ret0Py);
+ PyList_SetItem(res,0,ret0Py);
+ PyList_SetItem(res,1,PyString_FromString(what.c_str()));
+ return res;
+ }
+ }
+ };
+
class MEDFileData : public RefCountObject, public MEDFileWritable
{
public:
MEDFileData *deepCpy() const throw(INTERP_KERNEL::Exception);
void setFields(MEDFileFields *fields) throw(INTERP_KERNEL::Exception);
void setMeshes(MEDFileMeshes *meshes) throw(INTERP_KERNEL::Exception);
+ void setParams(MEDFileParameters *params) throw(INTERP_KERNEL::Exception);
int getNumberOfFields() const throw(INTERP_KERNEL::Exception);
int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception);
+ int getNumberOfParams() const throw(INTERP_KERNEL::Exception);
//
bool changeMeshName(const char *oldMeshName, const char *newMeshName) throw(INTERP_KERNEL::Exception);
bool unPolyzeMeshes() throw(INTERP_KERNEL::Exception);
return ret;
}
+ MEDFileParameters *getParams() const throw(INTERP_KERNEL::Exception)
+ {
+ MEDFileParameters *ret=self->getParams();
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+
MEDFileFields *getFields() const throw(INTERP_KERNEL::Exception)
{
MEDFileFields *ret=self->getFields();
fileName="Pyfile18.med"
mname="ExampleOfMultiDimW"
medmesh=MEDFileMesh.New(fileName,mname)
+ self.assertRaises(InterpKernelException,MEDFileMesh.New,fileName,"")
self.assertEqual((0,-1),medmesh.getNonEmptyLevels())
m1_0=medmesh.getLevel0Mesh(True)
m1_1=MEDLoader.ReadUMeshFromFile(fileName,mname,0)
self.assertTrue(m1.getMesh().isEqual(mesh,1e-12))
pass
+ def testParameters1(self):
+ fname="Pyfile56.med"
+ m=MEDCouplingCMesh() ; arr=DataArrayDouble([0.,1.2,3.5]) ; m.setCoords(arr,arr) ; m.setName("mesh")
+ mm=MEDFileCMesh() ; mm.setMesh(m)
+ ms=MEDFileMeshes() ; ms.pushMesh(mm)
+ data=MEDFileData()
+ p=MEDFileParameters()
+ data.setParams(p) ; data.setMeshes(ms)
+ pts=MEDFileParameterMultiTS()
+ pts.setName("A") ; pts.setDescription("An example of parameter") ; pts.setTimeUnit("ms")
+ pts.appendValue(1,2,3.4,567.89)
+ pts.appendValue(2,3,5.6,999.123)
+ pts2=pts.deepCpy() ; pts2.setName("B") ; pts2.setDescription("A second example")
+ p.pushParam(pts) ; p.pushParam(pts2)
+ data.write(fname,2)
+ p2=MEDFileParameters(fname)
+ self.assertTrue(p.isEqual(p2,1e-14)[0])
+ self.assertAlmostEqual(p[1][1,2].getValue(),567.89,13)
+ p3=p.deepCpy()
+ pts4=pts2.deepCpy()
+ pts3=pts2.deepCpy()
+ self.assertTrue(pts3.isEqual(pts2,1e-14)[0])
+ pts2.eraseTimeStepIds([0])
+ self.assertTrue(not pts3.isEqual(pts2,1e-14)[0])
+ del pts3[[3.4]]
+ self.assertTrue(pts3.isEqual(pts2,1e-14)[0])
+ self.assertRaises(InterpKernelException,p[1].__getitem__,(1,2))
+ self.assertRaises(InterpKernelException,p["B"].__getitem__,(1,2))
+ self.assertAlmostEqual(p[0][1,2].getValue(),567.89,13)
+ self.assertAlmostEqual(p["A"][1,2].getValue(),567.89,13)
+ p=p3
+ self.assertTrue(p.isEqual(p2,1e-14)[0])
+ self.assertTrue(p2["B"].isEqual(pts,1e-14)[0])
+ self.assertTrue(not p2["B"].isEqual(pts2,1e-14)[0])
+ self.assertAlmostEqual(p2[0][1,2].getValue(),567.89,13)
+ self.assertEqual(p.getParamsNames(),('A','B'))
+ ptsr=MEDFileParameterMultiTS(fname,"B")
+ self.assertTrue(ptsr.isEqual(pts4,1e-14)[0])
+ ptsr=MEDFileParameterMultiTS(fname)
+ self.assertTrue(ptsr.isEqual(pts,1e-14)[0])
+ p1tsr=MEDFileParameterDouble1TS(fname)
+ self.assertEqual(p1tsr.getName(),"A")
+ self.assertAlmostEqual(p1tsr.getValue(),567.89,13)
+ p1tsr=MEDFileParameterDouble1TS(fname,"B")
+ self.assertEqual(p1tsr.getName(),"B")
+ self.assertAlmostEqual(p1tsr.getValue(),567.89,13)
+ p1tsr=MEDFileParameterDouble1TS(fname,"B",2,3)
+ self.assertEqual(p1tsr.getName(),"B")
+ self.assertAlmostEqual(p1tsr.getValue(),999.123,13)
+ data2=MEDFileData(fname)
+ self.assertEqual(2,data2.getNumberOfParams())
+ self.assertAlmostEqual(data2.getParams()["B"][1,2].getValue(),567.89,13)
+ pass
pass
unittest.main()
return ret;
}
+static PyObject* convertMEDFileParameter1TS(ParaMEDMEM::MEDFileParameter1TS* p1ts, int owner) throw(INTERP_KERNEL::Exception)
+{
+ PyObject *ret=0;
+ if(dynamic_cast<MEDFileParameterDouble1TS *>(p1ts))
+ ret=SWIG_NewPointerObj((void*)p1ts,SWIGTYPE_p_ParaMEDMEM__MEDFileParameterDouble1TS,owner);
+ if(dynamic_cast<MEDFileParameterDouble1TSWTI *>(p1ts))
+ ret=SWIG_NewPointerObj((void*)p1ts,SWIGTYPE_p_ParaMEDMEM__MEDFileParameterDouble1TSWTI,owner);
+ if(!ret)
+ throw INTERP_KERNEL::Exception("Not recognized type of MEDFileParameter1TS on downcast !");
+ return ret;
+}
+
static std::vector<std::pair<int,int> > convertTimePairIdsFromPy(PyObject *pyLi) throw(INTERP_KERNEL::Exception)
{
std::vector<std::pair<int,int> > ret;
medpartitioner_CXXFLAGS = @CXXTMPDPTHFLAGS@
if MED_ENABLE_PARMETIS
- bin_PROGRAMS=medpartitioner_para
+ bin_PROGRAMS+=medpartitioner_para
dist_medpartitioner_para_SOURCES= medpartitioner_para.cxx
medpartitioner_para_CPPFLAGS= $(libmedpartitioner_la_CPPFLAGS)
medpartitioner_para_LDADD= $(libmedpartitioner_la_LDFLAGS) -lm libmedpartitioner.la